Beispiel #1
0
def upload_exam(request):
    msg = init_msg(request)
    msg['state'] = 'fail'
    try:
        file_key = 'exam_excel'
        if request.method == "POST":
            for x in request.POST:
                print x, request.POST[x]

        if request.FILES.has_key(file_key):
            postfix = (request.FILES[file_key].name).split('.')[-1]
            path = EXAM_EXCEL_FOLD + getRandomStr() + "." + postfix
            print path
            handle_uploaded_photo(path, request.FILES[file_key])

            single_Q, multi_Q = excel_analyze(path)

            groups = Group.objects.all()
            msg['groups'] = groups
            msg['single_Q'] = set_Q(single_Q, "single")
            msg['single_num'] = getLen(single_Q)
            msg['single_score'] = 50
            msg['multi_Q'] = set_Q(multi_Q, "multi")
            msg['multi_num'] = getLen(multi_Q)
            msg['multi_score'] = 50

            msg['max_retry_num'] = 2

            msg['exam_excel_file'] = path

    except Exception, e:
        print "create_exam_upload_excel: ", str(e)
Beispiel #2
0
def get_single_multi_Q_given_exam(exam):
    try:
        path = exam.exam_excel_file
        single_Q, multi_Q = excel_analyze(path)
    except Exception, e:
        print "get_single_multi_Q_given_exam:", str(e)
        return None, None
Beispiel #3
0
def update_exam(request):
    msg = init_msg(request)
    msg['state'] = 'fail'
    try:
        exam_id = int(request.GET['exam_id'])
        msg['exam_id'] = exam_id
        exam = Exam.objects.filter(id=exam_id)[0]

        path = exam.exam_excel_file
        single_Q, multi_Q = excel_analyze(path)

        groups = Group.objects.all()
        msg['groups'] = groups
        msg['exam'] = exam

        msg['single_Q'] = set_Q(single_Q, "single")
        msg['single_num'] = getLen(single_Q)
        msg['single_score'] = int(exam.single_score)
        msg['multi_Q'] = set_Q(multi_Q, "multi")
        msg['multi_num'] = getLen(multi_Q)
        msg['multi_score'] = int(exam.multi_score)
        msg['max_retry_num'] = int(exam.max_retry_num)
        msg['detail_intro'] = exam.detail_intro

        msg['exam_excel_file'] = path

    except Exception, e:
        print "create_exam_update_excel: ", str(e)