From c77f0ca5616faa4e9426d610e38da1b6231346dc Mon Sep 17 00:00:00 2001 From: adityacp Date: Fri, 28 Aug 2020 08:24:54 +0530 Subject: Multiple changes - Fix a bug where user cannot submit zero as answer - Fix UI in question statistics - Fix a bug where the trial question paper was not updated --- yaksh/models.py | 20 +++++++++----------- yaksh/templates/yaksh/add_quiz.html | 12 ++++++------ yaksh/templates/yaksh/question.html | 4 ++-- yaksh/templates/yaksh/statistics_question.html | 24 ++++++++++++++---------- yaksh/views.py | 2 +- 5 files changed, 32 insertions(+), 30 deletions(-) (limited to 'yaksh') diff --git a/yaksh/models.py b/yaksh/models.py index 6542daa..32632dd 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -1695,17 +1695,15 @@ class QuestionPaperManager(models.Manager): def create_trial_paper_to_test_quiz(self, trial_quiz, original_quiz_id): """Creates a trial question paper to test quiz.""" - if self.filter(quiz=trial_quiz).exists(): - trial_questionpaper = self.get(quiz=trial_quiz) - else: - trial_questionpaper, trial_questions = \ - self._create_trial_from_questionpaper(original_quiz_id) - trial_questionpaper.quiz = trial_quiz - trial_questionpaper.fixed_questions\ - .add(*trial_questions["fixed_questions"]) - trial_questionpaper.random_questions\ - .add(*trial_questions["random_questions"]) - trial_questionpaper.save() + trial_quiz.questionpaper_set.all().delete() + trial_questionpaper, trial_questions = \ + self._create_trial_from_questionpaper(original_quiz_id) + trial_questionpaper.quiz = trial_quiz + trial_questionpaper.fixed_questions\ + .add(*trial_questions["fixed_questions"]) + trial_questionpaper.random_questions\ + .add(*trial_questions["random_questions"]) + trial_questionpaper.save() return trial_questionpaper diff --git a/yaksh/templates/yaksh/add_quiz.html b/yaksh/templates/yaksh/add_quiz.html index 55e3bd6..9b80e0d 100644 --- a/yaksh/templates/yaksh/add_quiz.html +++ b/yaksh/templates/yaksh/add_quiz.html @@ -55,7 +55,7 @@ {% if quiz and course_id %} {% if quiz.questionpaper_set.get.id %}
- User Mode: Attempt quiz the way normal users will attempt i.e. - + Try as student: Attempt quiz the way students will attempt i.e. -
Total number of participants: {{ total }}
-Question | Type | Total | Answered Correctly |
---|
Question | Type | Total | Answered Correctly | ||
---|---|---|---|---|---|
{{ question.summary }} - + | {{ question.summary }}
-
+
+
Summary:
@@ -38,7 +37,7 @@
Description:
- {{ question.description }} + {{ question.description|safe }} Points: @@ -50,7 +49,7 @@ Type:- {{ question.type }} + {{ question.get_type_display }} {% if question.type in 'mcq mcc' %} @@ -72,6 +71,11 @@ |
+ + + | {{ question.type }} | {{value.1}} | {{ value.0 }} ({% widthratio value.0 value.1 100 %}%) | diff --git a/yaksh/views.py b/yaksh/views.py index 15ebd03..c1798b5 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -821,7 +821,7 @@ def check(request, q_id, attempt_num=None, questionpaper_id=None, previous_question=current_question) else: user_answer = request.POST.get('answer') - if not user_answer: + if not str(user_answer): msg = "Please submit a valid answer." return show_question( request, current_question, paper, notification=msg, -- cgit