summaryrefslogtreecommitdiff
path: root/yaksh/views.py
diff options
context:
space:
mode:
authorprathamesh2016-08-25 16:48:29 +0530
committerprathamesh2016-08-25 16:48:29 +0530
commitc0909251ecffcdc0df34bb9ad4a90994708c3a5c (patch)
tree1f68e7b63d6b817d56a0fb34af29b78c8003a7d5 /yaksh/views.py
parente1e299b671a19b65705fb256d282e1e802a4c051 (diff)
downloadonline_test-c0909251ecffcdc0df34bb9ad4a90994708c3a5c.tar.gz
online_test-c0909251ecffcdc0df34bb9ad4a90994708c3a5c.tar.bz2
online_test-c0909251ecffcdc0df34bb9ad4a90994708c3a5c.zip
Students can view their submission i.e. answer paper
A simple interface for students to view their answerpaper. Moderator has an option where he can allow to students to view their answerpaper.
Diffstat (limited to 'yaksh/views.py')
-rw-r--r--yaksh/views.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/yaksh/views.py b/yaksh/views.py
index e1ec44e..9e0edac 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -530,7 +530,7 @@ def check(request, q_id, attempt_num=None, questionpaper_id=None):
msg = "Please submit a valid option or code"
return show_question(request, question, paper, msg)
elif question.type == 'code' and user_answer:
- msg = "Correct Output"
+ msg = 'Correct Output'
paper.completed_question(question.id)
return show_question(request, question, paper, msg)
else:
@@ -558,12 +558,14 @@ def validate_answer(user, user_answer, question, json_data=None):
expected_answer = question.get_test_case(correct=True).options
if user_answer.strip() == expected_answer.strip():
correct = True
+ result['error'] = 'Correct Answer'
elif question.type == 'mcc':
expected_answers = []
for opt in question.get_test_cases(correct=True):
expected_answers.append(opt.options)
if set(user_answer) == set(expected_answers):
correct = True
+ result['error'] = 'Correct Answer'
elif question.type == 'code':
user_dir = get_user_dir(user)
json_result = code_server.run_code(question.language, question.test_case_type, json_data, user_dir)
@@ -1271,3 +1273,15 @@ def test_quiz(request, mode, quiz_id):
trial_questionpaper = test_mode(current_user, godmode, None, quiz_id)
return my_redirect("/exam/start/{0}".format(trial_questionpaper.id))
+
+
+@login_required
+def view_answerpaper(request, questionpaper_id):
+ user = request.user
+ quiz = get_object_or_404(QuestionPaper, pk=questionpaper_id).quiz
+ if quiz.view_answerpaper:
+ data = AnswerPaper.objects.get_user_data(user, questionpaper_id)
+ context = {'data': data, 'quiz': quiz}
+ return my_render_to_response('yaksh/view_answerpaper.html', context)
+ else:
+ return my_redirect('/exam/quizzes/')