From: Guillaume Pellerin Date: Thu, 10 Dec 2015 12:06:53 +0000 (+0100) Subject: update quiz behavior X-Git-Tag: 2.8.1-pro~264 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=28cd3d2d535224080f64d18694fd2fdf1cae16b0;p=teleforma.git update quiz behavior --- diff --git a/teleforma/templates/quiz/base.html b/teleforma/templates/quiz/base.html index 69e00c84..2e091326 100644 --- a/teleforma/templates/quiz/base.html +++ b/teleforma/templates/quiz/base.html @@ -10,6 +10,4 @@ {% block course_content %} {% endblock course_content %} -{% block progress %} -{% endblock progress %} diff --git a/teleforma/templates/quiz/correct_answer.html b/teleforma/templates/quiz/correct_answer.html index d98a10d9..de6ad590 100644 --- a/teleforma/templates/quiz/correct_answer.html +++ b/teleforma/templates/quiz/correct_answer.html @@ -15,7 +15,7 @@ {{ answer.content }} {% trans "This is the correct answer" %} {% else %} - + {{ answer.content }} {% if previous.question_type.MCQuestion %} diff --git a/teleforma/templates/quiz/question.html b/teleforma/templates/quiz/question.html index 14b209c1..11015526 100644 --- a/teleforma/templates/quiz/question.html +++ b/teleforma/templates/quiz/question.html @@ -3,8 +3,10 @@ {% load quiz_tags %} +{% comment %} {% block title %} {{ quiz.title }} {% endblock %} {% block description %} {{ quiz.title }} - {{ quiz.description }} {% endblock %} +{% endcomment %} {% block course_content %} @@ -14,26 +16,29 @@

{{ previous.previous_question }}

{% if previous.previous_outcome %} -
+
{% else %} -
+
{% endif %}

{% trans "Your answer was" %} - {{ previous.previous_outcome|yesno:"correct,incorrect" }} + {{ previous.previous_outcome|yesno:"correcte,incorrecte" }}

- +
{% include 'correct_answer.html' %} + +
+ {% if previous.previous_question.explanation %}

{% trans "Explanation" %}:

{{ previous.previous_question.explanation }}

- + {% endif %}
{% endif %} @@ -43,15 +48,18 @@ {% if question %} {% if progress %} -
+
{% trans "Question" %} {{ progress.0|add:1 }} {% trans "of" %} {{ progress.1 }}
+
{% endif %} +{% comment %}

{% trans "Question category" %}: {{ question.category }}

+{% endcomment %}

{{ question.content }}

@@ -73,10 +81,12 @@ - +
{% endif %}
+{% block result %} +{% endblock result %} {% endblock %} diff --git a/teleforma/templates/quiz/result.html b/teleforma/templates/quiz/result.html index 4617db10..fed90e25 100644 --- a/teleforma/templates/quiz/result.html +++ b/teleforma/templates/quiz/result.html @@ -1,30 +1,14 @@ -{% extends "quiz/base.html" %} +{% extends "quiz/question.html" %} {% load i18n %} {% load quiz_tags %} +{% comment %} {% block title %} {{ quiz.title}} {% endblock %} {% block description %} {% trans "Exam Results for" %} {{ quiz.title }} {% endblock %} +{% endcomment %} -{% block course_content %} - - {% if previous.answers %} - -

{% trans "The previous question" %}:

-

{{ previous.previous_question }}

-

Your answer was - - {{ previous.previous_outcome|yesno:"correct,incorrect" }} - -

- {% include 'correct_answer.html' %} -

{% trans "Explanation" %}:

-
-

{{ previous.previous_question.explanation }}

-
-
- - {% endif %} +{% block result %} {% if max_score %} @@ -35,16 +19,25 @@ {{ quiz.title }}

- {% trans "You answered" %} {{ score }} {% trans "questions correctly out of" %} {{ max_score }}, {% trans "giving you" %} {{ percent }} {% trans "percent correct" %} + {% trans "You answered" %} {{ score }} {% trans "questions correctly out of" %} {{ max_score }}, {% trans "giving you" %} {{ percent }} {% trans "percent correct" %}.

{% if quiz.pass_mark %} -
-

{{ sitting.result_message }}

-
- + {% if sitting.result_message %} +
+

{{ sitting.result_message }}

+
+ {% endif %} + {% if percent >= quiz.pass_mark %} + Votre quiz est validé.

+  {% trans "Back" %} au séminaire + {% else %} + Vous devez recommencer le quiz.

+  {% trans "Recommencer" %} + {% endif %} {% endif %} +{% comment %}

{% trans "Review the questions below and try the exam again in the future"%}.

{% if user.is_authenticated %} @@ -52,14 +45,12 @@

{% trans "The result of this exam will be stored in your progress section so you can review and monitor your progression" %}.

{% endif %} -
- +{% endcomment %} +
{% endif %} -
- {% if possible %}

@@ -95,5 +86,4 @@ {% endif %} - -{% endblock %} +{% endblock result %} diff --git a/teleforma/templates/teleforma/inc/quiz_list.html b/teleforma/templates/teleforma/inc/quiz_list.html index ba1357ee..5511c86a 100644 --- a/teleforma/templates/teleforma/inc/quiz_list.html +++ b/teleforma/templates/teleforma/inc/quiz_list.html @@ -9,24 +9,6 @@ {{ seminar.quiz.title }} {% endif %} - - {% if question|submitted:user and not question|validated:user %} - {% trans "submitted on" %} {{ question|submitted:user }} - {% elif question|saved:user and not question|submitted:user %} - {% trans "saved on" %} {{ question|saved:user }} - {% elif question|submitted:user and question|validated:user %} - {% trans "validated on" %} {{ question|validated:user }} - {% endif %} - - - {% if question|submitted:user and not question|validated:user %} - - {% elif question|saved:user and not question|submitted:user %} - - {% elif question|submitted:user and question|validated:user %} - - {% endif %} - diff --git a/teleforma/views/pro.py b/teleforma/views/pro.py index f230ff96..75b3cffb 100644 --- a/teleforma/views/pro.py +++ b/teleforma/views/pro.py @@ -782,7 +782,33 @@ class QuizQuestionView(SeminarAccessMixin, SeminarRevisionMixin, QuizTake): def get_context_data(self, **kwargs): context = super(QuizQuestionView, self).get_context_data(**kwargs) user = self.get_user() - seminar = Seminar.objects.get(pk=self.kwargs['pk']) - context['seminar'] = seminar - context['seminar_progress'] = seminar_progress(user, seminar) + self.seminar = Seminar.objects.get(pk=self.kwargs['pk']) + context['seminar'] = self.seminar + context['seminar_progress'] = seminar_progress(user, self.seminar) return context + + def final_result_user(self): + self.seminar = self.quiz.seminar.all()[0] + results = { + 'quiz': self.quiz, + 'score': self.sitting.get_current_score, + 'max_score': self.sitting.get_max_score, + 'percent': self.sitting.get_percent_correct, + 'sitting': self.sitting, + 'previous': self.previous, + 'seminar': self.seminar, + } + + self.sitting.mark_quiz_complete() + + if self.quiz.answers_at_end: + results['questions'] =\ + self.sitting.get_questions(with_answers=True) + results['incorrect_questions'] =\ + self.sitting.get_incorrect_questions + + if self.quiz.exam_paper is False: + self.sitting.delete() + + return render(self.request, 'quiz/result.html', results) +