diff options
-rw-r--r-- | yaksh/models.py | 3 | ||||
-rw-r--r-- | yaksh/templates/exam.html | 4 | ||||
-rw-r--r-- | yaksh/templates/yaksh/user_data.html | 4 | ||||
-rw-r--r-- | yaksh/views.py | 21 |
4 files changed, 18 insertions, 14 deletions
diff --git a/yaksh/models.py b/yaksh/models.py index 2d84622..61c9059 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -988,7 +988,8 @@ class AnswerPaper(models.Model): questions and returns the next question. """ next_question = self.next_question(question_id) - self.questions_answered.add(question_id) + if question_id not in self.questions_answered.all(): + self.questions_answered.add(question_id) self.questions_unanswered.remove(question_id) if next_question.id == int(question_id): return None diff --git a/yaksh/templates/exam.html b/yaksh/templates/exam.html index b497cc0..02ff70a 100644 --- a/yaksh/templates/exam.html +++ b/yaksh/templates/exam.html @@ -52,7 +52,9 @@ {% endif %} {% endif %} {% if qid in paper.get_questions_answered %} - <li class="disabled"><a style="background-color:#B4B8BA; width:25%" href="#" data-toggle="tooltip" title="{{ qid.description }}" >{{ forloop.counter }}</a></li> + <li><a style="background-color:#B4B8BA; width:25%" href="#" data-toggle="tooltip" + onclick="call_skip('{{ URL_ROOT }}/exam/{{ question.id }}/skip/{{ qid.id }}/{{ paper.attempt_number }}/{{ paper.question_paper.id }}/')" + title="{{ qid.description }}">{{ forloop.counter }}</a></li> {% endif %} {% else %} {% if qid.id == question.id %} diff --git a/yaksh/templates/yaksh/user_data.html b/yaksh/templates/yaksh/user_data.html index 9be28fb..16707b2 100644 --- a/yaksh/templates/yaksh/user_data.html +++ b/yaksh/templates/yaksh/user_data.html @@ -100,7 +100,7 @@ User IP address: {{ paper.user_ip }} {% else %} <h5>Student answer: </h5> {% for answer in answers %} - {% if not answer.skipped %} + {% if answer.answer.correct %} <div class="panel panel-success"> <div class="panel-heading">Correct answer @@ -116,7 +116,7 @@ User IP address: {{ paper.user_ip }} </div> <div class="panel-body"><pre><code>{{ answer.answer.answer.strip }}</code></pre></div> </div> - {% endif %} + {% endfor %} {% endif %} <hr> 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()) |