From 9484e8bebcd4363fa3aa1c2fc842de1bdcc25a10 Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Thu, 23 Feb 2017 17:33:07 +0530 Subject: Allow revisiting all types of question to resubmit answer --- yaksh/views.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'yaksh/views.py') diff --git a/yaksh/views.py b/yaksh/views.py index 74c409c..6bd9d67 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -432,9 +432,10 @@ def skip(request, q_id, next_q=None, attempt_num=None, questionpaper_id=None): paper = get_object_or_404(AnswerPaper, user=request.user, attempt_number=attempt_num, question_paper=questionpaper_id) question = get_object_or_404(Question, pk=q_id) - if question in paper.questions_answered.all(): - next_q = paper.next_question(q_id) - return show_question(request, next_q, paper) + print ">>>>>>> Qt", q_id, next_q + # if question in paper.questions_answered.all(): #@@@ + # next_q = paper.next_question(q_id) + # return show_question(request, next_q, paper) if request.method == 'POST' and question.type == 'code': user_code = request.POST.get('answer') @@ -443,10 +444,10 @@ def skip(request, q_id, next_q=None, attempt_num=None, questionpaper_id=None): error=json.dumps([])) new_answer.save() paper.answers.add(new_answer) - if next_q is not None: + if next_q is not None: #@@@ next_q = get_object_or_404(Question, pk=next_q) - if next_q not in paper.questions_unanswered.all(): - return show_question(request, question, paper) + # if next_q not in paper.questions_unanswered.all(): + # return show_question(request, question, paper) else: next_q = paper.next_question(q_id) return show_question(request, next_q, paper) @@ -459,9 +460,9 @@ def check(request, q_id, attempt_num=None, questionpaper_id=None): paper = get_object_or_404(AnswerPaper, user=request.user, attempt_number=attempt_num, question_paper=questionpaper_id) current_question = get_object_or_404(Question, pk=q_id) - if current_question in paper.questions_answered.all(): - next_q = paper.next_question(q_id) - return show_question(request, next_q, paper) + # if current_question in paper.questions_answered.all(): #@@@ + # next_q = paper.next_question(q_id) + # return show_question(request, next_q, paper) if request.method == 'POST': snippet_code = request.POST.get('snippet') @@ -513,7 +514,7 @@ def check(request, q_id, attempt_num=None, questionpaper_id=None): error_message = result.get('error') new_answer.error = json.dumps(result.get('error')) next_question = current_question if current_question.type == 'code' \ - else paper.completed_question(current_question.id) + else paper.completed_question(current_question.id) ##@@ new_answer.save() paper.update_marks('inprogress') paper.set_end_time(timezone.now()) -- cgit From 0f730a5adc35e06f22f89fbbaa2d810e57074561 Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Thu, 23 Feb 2017 17:44:51 +0530 Subject: Remove commented code --- yaksh/views.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'yaksh/views.py') diff --git a/yaksh/views.py b/yaksh/views.py index 6bd9d67..16299a8 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -432,10 +432,6 @@ def skip(request, q_id, next_q=None, attempt_num=None, questionpaper_id=None): paper = get_object_or_404(AnswerPaper, user=request.user, attempt_number=attempt_num, question_paper=questionpaper_id) question = get_object_or_404(Question, pk=q_id) - print ">>>>>>> Qt", q_id, next_q - # if question in paper.questions_answered.all(): #@@@ - # next_q = paper.next_question(q_id) - # return show_question(request, next_q, paper) if request.method == 'POST' and question.type == 'code': user_code = request.POST.get('answer') @@ -444,10 +440,8 @@ def skip(request, q_id, next_q=None, attempt_num=None, questionpaper_id=None): error=json.dumps([])) new_answer.save() paper.answers.add(new_answer) - if next_q is not None: #@@@ + if next_q is not None: next_q = get_object_or_404(Question, pk=next_q) - # if next_q not in paper.questions_unanswered.all(): - # return show_question(request, question, paper) else: next_q = paper.next_question(q_id) return show_question(request, next_q, paper) @@ -460,9 +454,6 @@ def check(request, q_id, attempt_num=None, questionpaper_id=None): paper = get_object_or_404(AnswerPaper, user=request.user, attempt_number=attempt_num, question_paper=questionpaper_id) current_question = get_object_or_404(Question, pk=q_id) - # if current_question in paper.questions_answered.all(): #@@@ - # next_q = paper.next_question(q_id) - # return show_question(request, next_q, paper) if request.method == 'POST': snippet_code = request.POST.get('snippet') @@ -514,7 +505,7 @@ def check(request, q_id, attempt_num=None, questionpaper_id=None): error_message = result.get('error') new_answer.error = json.dumps(result.get('error')) next_question = current_question if current_question.type == 'code' \ - else paper.completed_question(current_question.id) ##@@ + else paper.completed_question(current_question.id) new_answer.save() paper.update_marks('inprogress') paper.set_end_time(timezone.now()) -- cgit From d0d4c9ab3a409c68766bc044825bf22b0519f6a3 Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Fri, 3 Mar 2017 16:35:18 +0530 Subject: Multiple changes: - Fix movement from one question to another in next_question - Fix random display of errors from MCQs - Add Notification display if question has been attempted - Fix test cases for changes made --- yaksh/views.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'yaksh/views.py') diff --git a/yaksh/views.py b/yaksh/views.py index 16299a8..163c12f 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -400,7 +400,7 @@ def start(request, questionpaper_id=None, attempt_num=None): @login_required -def show_question(request, question, paper, error_message=None): +def show_question(request, question, paper, error_message=None, notification=None): """Show a question if possible.""" user = request.user if not question: @@ -412,10 +412,12 @@ def show_question(request, question, paper, error_message=None): if paper.time_left() <= 0: reason='Your time is up!' return complete(request, reason, paper.attempt_number, paper.question_paper.id) + if question in paper.questions_answered.all(): + notification = 'You have already attempted this question' test_cases = question.get_test_cases() files = FileUpload.objects.filter(question_id=question.id, hide=False) context = {'question': question, 'paper': paper, 'error_message': error_message, - 'test_cases': test_cases, 'files': files, + 'test_cases': test_cases, 'files': files, 'notification': notification, 'last_attempt': question.snippet.encode('unicode-escape')} answers = paper.get_previous_answers(question) if answers: @@ -472,14 +474,14 @@ def check(request, q_id, attempt_num=None, questionpaper_id=None): assign.assignmentFile = request.FILES['assignment'] assign.save() user_answer = 'ASSIGNMENT UPLOADED' - next_q = paper.completed_question(current_question.id) + next_q = paper.add_completed_question(current_question.id) return show_question(request, next_q, paper) else: user_code = request.POST.get('answer') user_answer = snippet_code + "\n" + user_code if snippet_code else user_code if not user_answer: msg = ["Please submit a valid option or code"] - return show_question(request, current_question, paper, msg) + return show_question(request, current_question, paper, notification=msg) new_answer = Answer(question=current_question, answer=user_answer, correct=False, error=json.dumps([])) new_answer.save() @@ -497,15 +499,16 @@ def check(request, q_id, attempt_num=None, questionpaper_id=None): new_answer.correct = result.get('success') error_message = None new_answer.error = json.dumps(result.get('error')) - next_question = paper.completed_question(current_question.id) + next_question = paper.add_completed_question(current_question.id) else: new_answer.marks = (current_question.points * result['weight'] / current_question.get_maximum_test_case_weight()) \ if current_question.partial_grading and current_question.type == 'code' else 0 - error_message = result.get('error') + error_message = result.get('error') if current_question.type == 'code' \ + else None new_answer.error = json.dumps(result.get('error')) next_question = current_question if current_question.type == 'code' \ - else paper.completed_question(current_question.id) + else paper.add_completed_question(current_question.id) new_answer.save() paper.update_marks('inprogress') paper.set_end_time(timezone.now()) -- cgit From c118c7eff7abaeba18f7c375828d2e022d21cb9f Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Fri, 3 Mar 2017 19:16:46 +0530 Subject: Modify UI for notifications in submitted code questions --- yaksh/views.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'yaksh/views.py') diff --git a/yaksh/views.py b/yaksh/views.py index 163c12f..1089067 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -413,7 +413,9 @@ def show_question(request, question, paper, error_message=None, notification=Non reason='Your time is up!' return complete(request, reason, paper.attempt_number, paper.question_paper.id) if question in paper.questions_answered.all(): - notification = 'You have already attempted this question' + notification = 'You have already attempted this question successfully' \ + if question.type == "code" else \ + 'You have already attempted this question' test_cases = question.get_test_cases() files = FileUpload.objects.filter(question_id=question.id, hide=False) context = {'question': question, 'paper': paper, 'error_message': error_message, -- cgit