예제 #1
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))
예제 #2
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))
예제 #3
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}))
예제 #4
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}))
예제 #5
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))
예제 #6
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))
예제 #7
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))
예제 #8
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))
예제 #9
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}))
예제 #10
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}))