diff options
author | prathamesh | 2015-01-20 17:05:41 +0530 |
---|---|---|
committer | prathamesh | 2015-01-20 17:05:41 +0530 |
commit | f2e09edeb2e5b884f0e75ad3747b51e7603d70e1 (patch) | |
tree | fac9c70feeff6e1c470097623fd54a6244f786c0 /testapp/exam/views.py | |
parent | cbdeb90a756832c71c80bac4dbe9ba1a3aceacb2 (diff) | |
download | online_test-f2e09edeb2e5b884f0e75ad3747b51e7603d70e1.tar.gz online_test-f2e09edeb2e5b884f0e75ad3747b51e7603d70e1.tar.bz2 online_test-f2e09edeb2e5b884f0e75ad3747b51e7603d70e1.zip |
Assignment upload interface implementation
Diffstat (limited to 'testapp/exam/views.py')
-rw-r--r-- | testapp/exam/views.py | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/testapp/exam/views.py b/testapp/exam/views.py index 9902b74..ce1c62e 100644 --- a/testapp/exam/views.py +++ b/testapp/exam/views.py @@ -21,7 +21,7 @@ from testapp.exam.forms import UserRegisterForm, UserLoginForm, QuizForm,\ QuestionForm, RandomQuestionForm from testapp.exam.xmlrpc_clients import code_server from settings import URL_ROOT - +from testapp.exam.models import AssignmentUpload # The directory where user data can be saved. OUTPUT_DIR = abspath(join(dirname(__file__), 'output')) @@ -760,6 +760,13 @@ def check(request, q_id, attempt_no=None, questionpaper_id=None): user_answer = request.POST.get('answer') elif question.type == 'mcc': user_answer = request.POST.getlist('answer') + elif question.type == 'basgn': + assign = AssignmentUpload() + assign.user = user.profile + assign.assignmentQuestion = question + assign.assignmentFile = request.FILES['assignment'] + assign.save() + user_answer = 'ASSIGNMENT UPLOADED' else: user_code = request.POST.get('answer') user_answer = snippet_code + "\n" + user_code @@ -772,15 +779,16 @@ def check(request, q_id, attempt_no=None, questionpaper_id=None): # If we were not skipped, we were asked to check. For any non-mcq # questions, we obtain the results via XML-RPC with the code executed # safely in a separate process (the code_server.py) running as nobody. - correct, success, err_msg = validate_answer(user, user_answer, question) - if correct: - new_answer.correct = correct - new_answer.marks = question.points - new_answer.error = err_msg - success_msg = True - else: - new_answer.error = err_msg - new_answer.save() + if not question.type == 'basgn': + correct, success, err_msg = validate_answer(user, user_answer, question) + if correct: + new_answer.correct = correct + new_answer.marks = question.points + new_answer.error = err_msg + success_msg = True + else: + new_answer.error = err_msg + new_answer.save() time_left = paper.time_left() if not success: # Should only happen for non-mcq questions. @@ -1204,4 +1212,4 @@ def submit_assignment(request, question_id=None): #next question ke liye code idhar else: #code for skipping the question - + pass |