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 %}
- + Edit Question Paper @@ -65,11 +65,11 @@

You can check the quiz by attempting it in the following modes:

- User Mode + Try as student - - God Mode + + Try as teacher Help @@ -88,13 +88,13 @@ diff --git a/yaksh/templates/yaksh/question.html b/yaksh/templates/yaksh/question.html index ae2f9f4..6489b38 100644 --- a/yaksh/templates/yaksh/question.html +++ b/yaksh/templates/yaksh/question.html @@ -127,14 +127,14 @@ question_type = "{{ question.type }}"; - Note: {{ notification }} + {{ notification }} {% else %} {% endif %} {% else %} diff --git a/yaksh/templates/yaksh/statistics_question.html b/yaksh/templates/yaksh/statistics_question.html index 9a54501..52c29d3 100644 --- a/yaksh/templates/yaksh/statistics_question.html +++ b/yaksh/templates/yaksh/statistics_question.html @@ -1,9 +1,10 @@ {% extends "manage.html" %} +{% block title %} Question Statistics {% endblock %} {% block pagetitle %} Statistics for {{ quiz.description }}{% endblock pagetitle %} {% block content %} -
+
    @@ -18,16 +19,14 @@
    {% if question_stats %}

    Total number of participants: {{ total }}

    - - +
    QuestionTypeTotalAnswered Correctly
    + {% for question, value in question_stats.items %} - + 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
    QuestionTypeTotalAnswered 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 %}%)