예제 #1
0
파일: course.py 프로젝트: freshman88/aedu
def findById(req, id):
    if not is_login(req):
        return HttpResponseNotAllowed()
    service=CourseService()
    data={'code': 200}
    data['data'] = dict(service.findById(id))
    return HttpResponse(json.dumps(data))
예제 #2
0
파일: question.py 프로젝트: freshman88/aedu
def exam(req):
    if not is_login(req):
        return HttpResponseNotAllowed()

    if 'stu' != req.session['utype']:
        return HttpResponseNotAllowed()

    max_len = 5
    service=QuestionService()
    courseId = req.GET.get('courseId')
    all_list = list(service.findByCourseId(courseId))
    if len(all_list) <= max_len:
        examData = all_list
    else:
        examData = list()
        i=0
        indeMap = dict()
        while i<max_len:
            randomIndex = int(random.random()*len(all_list))
            if indeMap.get(randomIndex) is None:
                examData.append(all_list[randomIndex])
                indeMap[randomIndex] = True
                i=i+1
    data={'code': 200}
    data['data'] = examData
    return HttpResponse(json.dumps(data))
예제 #3
0
파일: teacher.py 프로젝트: freshman88/aedu
def all(req):
    if not is_login(req):
        return HttpResponseNotAllowed()
    service=TechService()
    data={'code': 200}
    data['data'] = list(service.list())
    return HttpResponse(json.dumps(data))
예제 #4
0
파일: grade.py 프로젝트: freshman88/aedu
def findById(req, id):
    if not is_login(req):
        return HttpResponseNotAllowed()
    service = GradeService()
    data = {"code": 200}
    data["data"] = dict(service.findById(id))
    return HttpResponse(json.dumps(data))
예제 #5
0
파일: teacher.py 프로젝트: freshman88/aedu
def query(req):
    if not is_login(req):
        return HttpResponseNotAllowed()
    name=req.GET.get('name')
    value=req.GET.get('value')
    service=TechService()
    data={'code': 200}
    data['data'] = list(service.query(name, value))
    return HttpResponse(json.dumps(data))
예제 #6
0
파일: grade.py 프로젝트: freshman88/aedu
def delete(req):
    if req.method != "POST":
        return HttpResponseNotFound()

    if not is_login(req):
        return HttpResponseNotAllowed()
    id = req.POST.get("id")
    service = GradeService()
    service.delete(id)
    return HttpResponse(json.dumps({"code": 200}))
예제 #7
0
def delete(req):
    if req.method != 'POST':
        return HttpResponseNotFound()

    if not is_login(req):
        return HttpResponseNotAllowed()
    id = req.POST.get('id')
    service=ResourceService()
    service.delete(id)
    return HttpResponse(json.dumps({'code': 200}))
예제 #8
0
파일: course.py 프로젝트: freshman88/aedu
def all(req):
    if not is_login(req):
        return HttpResponseNotAllowed()
    techerId=None
    if 'tech' == req.session['utype']:
        techerId = req.session['id']
    service=CourseService()
    data={'code': 200}
    data['data'] = list(service.list(techerId))
    return HttpResponse(json.dumps(data))
예제 #9
0
파일: course.py 프로젝트: freshman88/aedu
def delete(req):
    if req.method != 'POST':
        return HttpResponseNotFound()

    if not is_login(req):
        return HttpResponseNotAllowed()
    id = req.POST.get('id')
    service=CourseService()
    service.delete(id)
    return HttpResponse(json.dumps({'code': 200}))
예제 #10
0
파일: student.py 프로젝트: freshman88/aedu
def all(req):
    if not is_login(req):
        return HttpResponseNotAllowed()
    techerId = None
    if 'tech' == req.session['utype']:
        techerId = req.session['id']
    service = StuService()
    data = {'code': 200}

    data['data'] = list(service.list(techerId))
    return HttpResponse(json.dumps(data))
예제 #11
0
파일: views.py 프로젝트: freshman88/aedu
def manage(request):
    if not is_login(request):
        return HttpResponseNotAllowed()
    utype = request.session['utype']
    if utype == 'admin':
        return render_to_response('manage.html', {'name': request.session.get('name')})
    elif utype == 'tech':
        return render_to_response('manage2.html', {'name': request.session.get('name')})
    elif utype == 'stu':
        return render_to_response('manage3.html', {'name': request.session.get('name')})
    else:
        return HttpResponseNotAllowed()
예제 #12
0
파일: grade.py 프로젝트: freshman88/aedu
def all(req):
    if not is_login(req):
        return HttpResponseNotAllowed()
    service = GradeService()
    data = {"code": 200}
    if "tech" == req.session["utype"]:
        data["data"] = list(service.findByTechId(req.session["id"]))
    elif "stu" == req.session["utype"]:
        data["data"] = list(service.findByStuId(req.session["id"]))
    else:
        data["data"] = list(service.list())
    return HttpResponse(json.dumps(data))
예제 #13
0
파일: grade.py 프로젝트: freshman88/aedu
def all(req):
    if not is_login(req):
        return HttpResponseNotAllowed()
    service = GradeService()
    data = {'code': 200}
    if 'tech' == req.session['utype']:
        data['data'] = list(service.findByTechId(req.session['id']))
    elif 'stu' == req.session['utype']:
        data['data'] = list(service.findByStuId(req.session['id']))
    else:
        data['data'] = list(service.list())
    return HttpResponse(json.dumps(data))
예제 #14
0
def query(req):
    if not is_login(req):
        return HttpResponseNotAllowed()
    techerId=None
    if 'tech' == req.session['utype']:
        techerId = req.session['id']
    name=req.GET.get('name')
    value=req.GET.get('value')
    service=CourseService()
    data={'code': 200}
    data['data'] = list(service.query(name, value, techerId))
    return HttpResponse(json.dumps(data))
예제 #15
0
파일: grade.py 프로젝트: freshman88/aedu
def query(req):
    if not is_login(req):
        return HttpResponseNotAllowed()
    name = req.GET.get('name')
    value = req.GET.get('value')
    service = GradeService()
    data = {'code': 200}
    if 'tech' == req.session['utype']:
        data['data'] = list(service.queryByTechId(req.session['id']))
    elif 'stu' == req.session['utype']:
        data['data'] = list(service.queryByStuId(req.session['id']))
    else:
        data['data'] = list(service.query(name, value))
    return HttpResponse(json.dumps(data))
예제 #16
0
def save(req):
    if req.method != 'POST':
        return HttpResponseNotFound()

    if not is_login(req):
        return HttpResponseNotAllowed()
    service=ResourceService()
    service.save(
        content=req.POST.get('content'), 
        url=req.POST.get('url'), 
        courseId=req.POST.get('courseId'),
        courseName=req.POST.get('courseName')
    )
    return HttpResponse(json.dumps({'code': 200}))
예제 #17
0
파일: grade.py 프로젝트: freshman88/aedu
def query(req):
    if not is_login(req):
        return HttpResponseNotAllowed()
    name = req.GET.get("name")
    value = req.GET.get("value")
    service = GradeService()
    data = {"code": 200}
    if "tech" == req.session["utype"]:
        data["data"] = list(service.queryByTechId(req.session["id"]))
    elif "stu" == req.session["utype"]:
        data["data"] = list(service.queryByStuId(req.session["id"]))
    else:
        data["data"] = list(service.query(name, value))
    return HttpResponse(json.dumps(data))
예제 #18
0
파일: teacher.py 프로젝트: freshman88/aedu
def save(req):
    if req.method != 'POST':
        return HttpResponseNotFound()

    if not is_login(req):
        return HttpResponseNotAllowed()
    service=TechService()
    service.save(
        name=req.POST.get('name'), 
        sex=req.POST.get('sex'), 
        age=req.POST.get('age'), 
        techAge=req.POST.get('techAge'), 
        baseUnit=req.POST.get('baseUnit')
    )
    return HttpResponse(json.dumps({'code': 200}))
예제 #19
0
파일: views.py 프로젝트: freshman88/aedu
def manage(request):
    if not is_login(request):
        return HttpResponseNotAllowed()
    utype = request.session['utype']
    if utype == 'admin':
        return render_to_response('manage.html',
                                  {'name': request.session.get('name')})
    elif utype == 'tech':
        return render_to_response('manage2.html',
                                  {'name': request.session.get('name')})
    elif utype == 'stu':
        return render_to_response('manage3.html',
                                  {'name': request.session.get('name')})
    else:
        return HttpResponseNotAllowed()
예제 #20
0
파일: student.py 프로젝트: freshman88/aedu
def save(req):
    if req.method != 'POST':
        return HttpResponseNotFound()

    if not is_login(req):
        return HttpResponseNotAllowed()
    service = StuService()
    service.save(name=req.POST.get('name'),
                 sex=req.POST.get('sex'),
                 age=req.POST.get('age'),
                 register=req.POST.get('register'),
                 baseUnit=req.POST.get('baseUnit'),
                 techerId=req.POST.get('techerId'),
                 techerNumber=req.POST.get('techerNumber'),
                 techerName=req.POST.get('techerName'))
    return HttpResponse(json.dumps({'code': 200}))
예제 #21
0
파일: question.py 프로젝트: freshman88/aedu
def save(req):
    if req.method != 'POST':
        return HttpResponseNotFound()

    if not is_login(req):
        return HttpResponseNotAllowed()
    service = QuestionService()
    service.save(content=req.POST.get('content'),
                 answerA=req.POST.get('answerA'),
                 answerB=req.POST.get('answerB'),
                 answerC=req.POST.get('answerC'),
                 answerD=req.POST.get('answerD'),
                 rightAnswer=req.POST.get('rightAnswer'),
                 point=req.POST.get('point'),
                 courseId=req.POST.get('courseId'),
                 courseName=req.POST.get('courseName'))
    return HttpResponse(json.dumps({'code': 200}))
예제 #22
0
파일: question.py 프로젝트: freshman88/aedu
def grade(req):
    if req.method != 'POST':
        return HttpResponseNotFound()

    if not is_login(req):
        return HttpResponseNotAllowed()

    if 'stu' != req.session['utype']:
        return HttpResponseNotAllowed()

    answer_list = req.POST.get('answers').split(',')
    # print(req.POST.get('answers'))
    service=QuestionService()
    totalPoint = 0
    point = 0
    i = 0
    for idStr in req.POST.get('ids').split(','):
        q = service.findById(int(idStr))
        if q.rightAnswer == answer_list[i]:
            point = point + q.point
        totalPoint = totalPoint + q.point
        i = i+1
    
    c_service=CourseService()
    courseId = req.POST.get('courseId')
    course=c_service.findById(courseId)

    s_service=StuService()
    stuId = req.session['id']
    stu = s_service.findById(stuId)

    g_service=GradeService()
    g_service.save(
        totalPoint=totalPoint,
        point=point, 
        courseId=courseId, 
        courseName=course.name, 
        techerId=course.techerId, 
        techerNumber=course.techerNumber, 
        techerName=course.techerName,
        stuId=stuId, 
        stuNumber=stu.number,
        stuName=stu.name
    )
    return HttpResponse(json.dumps({'code': 200}))
예제 #23
0
파일: question.py 프로젝트: freshman88/aedu
def save(req):
    if req.method != 'POST':
        return HttpResponseNotFound()

    if not is_login(req):
        return HttpResponseNotAllowed()
    service=QuestionService()
    service.save(
        content=req.POST.get('content'), 
        answerA=req.POST.get('answerA'),
        answerB=req.POST.get('answerB'),
        answerC=req.POST.get('answerC'),
        answerD=req.POST.get('answerD'),
        rightAnswer=req.POST.get('rightAnswer'),
        point=req.POST.get('point'),
        courseId=req.POST.get('courseId'),
        courseName=req.POST.get('courseName')
    )
    return HttpResponse(json.dumps({'code': 200}))
예제 #24
0
파일: question.py 프로젝트: freshman88/aedu
def grade(req):
    if req.method != 'POST':
        return HttpResponseNotFound()

    if not is_login(req):
        return HttpResponseNotAllowed()

    if 'stu' != req.session['utype']:
        return HttpResponseNotAllowed()

    answer_list = req.POST.get('answers').split(',')
    # print(req.POST.get('answers'))
    service = QuestionService()
    totalPoint = 0
    point = 0
    i = 0
    for idStr in req.POST.get('ids').split(','):
        q = service.findById(int(idStr))
        if q.rightAnswer == answer_list[i]:
            point = point + q.point
        totalPoint = totalPoint + q.point
        i = i + 1

    c_service = CourseService()
    courseId = req.POST.get('courseId')
    course = c_service.findById(courseId)

    s_service = StuService()
    stuId = req.session['id']
    stu = s_service.findById(stuId)

    g_service = GradeService()
    g_service.save(totalPoint=totalPoint,
                   point=point,
                   courseId=courseId,
                   courseName=course.name,
                   techerId=course.techerId,
                   techerNumber=course.techerNumber,
                   techerName=course.techerName,
                   stuId=stuId,
                   stuNumber=stu.number,
                   stuName=stu.name)
    return HttpResponse(json.dumps({'code': 200}))
예제 #25
0
파일: student.py 프로젝트: freshman88/aedu
def update(req):
    if req.method != 'POST':
        return HttpResponseNotFound()

    if not is_login(req):
        return HttpResponseNotAllowed()
    id = req.POST.get('id')
    service=StuService()
    service.update(
        id,
        name=req.POST.get('name'), 
        sex=req.POST.get('sex'), 
        age=req.POST.get('age'), 
        register=req.POST.get('register'), 
        baseUnit=req.POST.get('baseUnit'),
        techerId=req.POST.get('techerId'),
        techerNumber=req.POST.get('techerNumber'),
        techerName=req.POST.get('techerName')
    )
    return HttpResponse(json.dumps({'code': 200}))
예제 #26
0
def save(req):
    if req.method != 'POST':
        return HttpResponseNotFound()

    if not is_login(req):
        return HttpResponseNotAllowed()
    techerId=None
    if 'tech' == req.session['utype']:
        techerId = req.session['id']
        techer=TechService().findById(techerId)
        service=CourseService()
        service.save(
            name=req.POST.get('name'), 
            purpose=req.POST.get('purpose'), 
            techerId=techerId,
            techerNumber=techer['number'],
            techerName=techer['name']
        )
        return HttpResponse(json.dumps({'code': 200}))
    else:
        return HttpResponseNotAllowed()
예제 #27
0
파일: views.py 프로젝트: freshman88/aedu
def index(request):
    if is_login(request):
        return HttpResponseRedirect('/manage')
    return render_to_response('index.html')
예제 #28
0
파일: views.py 프로젝트: freshman88/aedu
def index(request):
    if is_login(request):
        return HttpResponseRedirect('/manage')
    return render_to_response('index.html')