diff options
author | adityacp | 2016-02-19 16:19:14 +0530 |
---|---|---|
committer | adityacp | 2016-03-11 15:31:51 +0530 |
commit | 1ddc29e1cb703557ab43d14318c279fce8fc609e (patch) | |
tree | 630405785e5ede4a3adf267fa4e0825fc2001312 /yaksh/views.py | |
parent | ef3cd39ebdf9d9fc9011ba4bc470ec5018bb8077 (diff) | |
download | online_test-1ddc29e1cb703557ab43d14318c279fce8fc609e.tar.gz online_test-1ddc29e1cb703557ab43d14318c279fce8fc609e.tar.bz2 online_test-1ddc29e1cb703557ab43d14318c279fce8fc609e.zip |
Frontend design changes
remove older change
Remove further changes
interface changes
interface changes
small views.py change
change in code evaluator
code evaluator changes
python code evaluator change
exception changes in code evaluator and test cases for python
Update test_python_evaluation.py
changed variable name in test case
Views.py conflict resolve
Diffstat (limited to 'yaksh/views.py')
-rw-r--r-- | yaksh/views.py | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/yaksh/views.py b/yaksh/views.py index 9cd6fdb..25057d7 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -867,7 +867,8 @@ def get_questions(paper): q_unanswered = paper.get_unanswered_questions() q_unanswered.sort() to_attempt = q_unanswered - for index, value in enumerate(all_questions, 1): + question = Question.objects.filter(id__in=all_questions) + for index, value in enumerate(question, 1): questions[value] = index questions = collections.OrderedDict(sorted(questions.items(), key=lambda x:x[1])) return questions, to_attempt, submitted @@ -927,6 +928,7 @@ def show_question(request, q_id, attempt_num, questionpaper_id, success_msg=None return complete(request, msg, attempt_num, questionpaper_id) else: return question(request, q_id, attempt_num, questionpaper_id, success_msg) + def _save_skipped_answer(old_skipped, user_answer, paper, question): @@ -1041,25 +1043,38 @@ def check(request, q_id, attempt_num=None, questionpaper_id=None): if time_left <= 0: reason = 'Your time is up!' return complete(request, reason, attempt_num, questionpaper_id) - # Display the same question if user_answer is None elif not user_answer: msg = "Please submit a valid option or code" time_left = paper.time_left() questions, to_attempt, submitted = get_questions(paper) - context = {'question': question, 'error_message': msg, - 'paper': paper, 'quiz_name': paper.question_paper.quiz.description, - 'time_left': time_left, 'questions': questions, - 'to_attempt': to_attempt, 'submitted': submitted} + context = {'question': question, 'paper': paper, + 'quiz_name': paper.question_paper.quiz.description, + 'time_left': time_left, 'questions': questions, + 'to_attempt': to_attempt, 'submitted': submitted, + 'error_message': msg} ci = RequestContext(request) - - return my_render_to_response('yaksh/question.html', context, - context_instance=ci) + + elif question.type == 'code' and user_answer: + msg = "Correct Output" + success = "True" + next_q = paper.completed_question(question.id) + time_left = paper.time_left() + questions, to_attempt, submitted = get_questions(paper) + context = {'question': question, 'paper': paper, + 'quiz_name': paper.question_paper.quiz.description, + 'time_left': time_left, 'questions': questions, + 'to_attempt': to_attempt, 'submitted': submitted, + 'error_message': msg, 'success': success} + ci = RequestContext(request) + else: next_q = paper.completed_question(question.id) return show_question(request, next_q, attempt_num, questionpaper_id, success_msg) - + + return my_render_to_response('yaksh/question.html', context, + context_instance=ci) def validate_answer(user, user_answer, question, json_data=None): """ @@ -1090,7 +1105,6 @@ def validate_answer(user, user_answer, question, json_data=None): result = json.loads(json_result) if result.get('success'): correct = True - return correct, result def get_question_labels(request, attempt_num=None, questionpaper_id=None): @@ -1535,7 +1549,6 @@ def show_all_questions(request): return my_render_to_response('yaksh/showquestions.html', context, context_instance=ci) - @login_required def user_data(request, username, questionpaper_id=None): """Render user data.""" |