]> git.parisson.com Git - teleforma.git/commitdiff
update quiz behavior
authorGuillaume Pellerin <yomguy@parisson.com>
Thu, 10 Dec 2015 12:06:53 +0000 (13:06 +0100)
committerGuillaume Pellerin <yomguy@parisson.com>
Thu, 10 Dec 2015 12:06:53 +0000 (13:06 +0100)
teleforma/templates/quiz/base.html
teleforma/templates/quiz/correct_answer.html
teleforma/templates/quiz/question.html
teleforma/templates/quiz/result.html
teleforma/templates/teleforma/inc/quiz_list.html
teleforma/views/pro.py

index 69e00c841f4642743c66d9bf7e70031a0a145f96..2e091326b4d69a238393a1b871ccb9454c354eab 100644 (file)
@@ -10,6 +10,4 @@
 {% block course_content %}
 {% endblock course_content %}
 
-{% block progress %}
-{% endblock progress %}
 
index d98a10d96d9c2b41a03f958f7ef080c50e86a933..de6ad590a523e5dc049c0357032d1e92fb72ab57 100644 (file)
@@ -15,7 +15,7 @@
                  <td>{{ answer.content }}</td>
                  <td><strong>{% trans "This is the correct answer" %}</strong></td>
         {% else %}
-               <tr>
+          <tr>
          <td>{{ answer.content }}</td>
                  <td>
                        {% if previous.question_type.MCQuestion %}
index 14b209c1f5e5414ca14b2b169c21f25bb0570707..110155268352f55a0f87f307b02a18326730fa8d 100644 (file)
@@ -3,8 +3,10 @@
 
 {% load quiz_tags %}
 
+{% comment %}
 {% block title %} {{ quiz.title }} {% endblock %}
 {% block description %} {{ quiz.title }} - {{ quiz.description }} {% endblock %}
+{% endcomment %}
 
 {% block course_content %}
 
   <p>{{ previous.previous_question }}</p>
 
   {% if previous.previous_outcome %}
-       <div class="alert alert-success">
+       <div class="alert success">
   {% else %}
-       <div class="alert alert-warning">
+       <div class="alert error">
   {% endif %}
          <p><small>
                {% trans "Your answer was" %} </small>
                <strong>
-                 {{ previous.previous_outcome|yesno:"correct,incorrect" }}
+                 {{ previous.previous_outcome|yesno:"correcte,incorrecte" }}
                </strong>
          </p>
 
        </div>
-
+  <br>
        {% include 'correct_answer.html' %}
+  <br>
 
+  {% if previous.previous_question.explanation %}
        <p><strong>{% trans "Explanation" %}:</strong></p>
        <div class="well " style="background-color: #fcf8e3;">
          <p>{{ previous.previous_question.explanation }}</p>
        </div>
-
+  {% endif %}
        <hr>
 
 {% endif %}
 {% if question %}
 
 {% if progress %}
-<div style="float: right;">
+<div style="float: left;">
 {% trans "Question" %} {{ progress.0|add:1 }} {% trans "of" %} {{ progress.1 }}
 </div>
+<br>
 {% endif %}
 
+{% comment %}
 <p>
   <small class="muted">{% trans "Question category" %}:</small>
   <strong>{{ question.category }}</strong>
 </p>
+{% endcomment %}
 
 <p class="lead">{{ question.content }}</p>
 
   </ul>
   <input type="submit" value={% trans "Check" %} class="btn btn-large btn-block btn-warning" >
 </form>
-
+<br>
 {% endif %}
 
 <hr>
 
+{% block result %}
+{% endblock result %}
 
 {% endblock %}
index 4617db1054df82aec47ac089a5cbf4150a128ec4..fed90e25e9cbd3f10a0524372c57cd81700ff235 100644 (file)
@@ -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 %}
-
-  <p class="muted"><small>{% trans "The previous question" %}:</small></p>
-  <p>{{ previous.previous_question }}</p>
-  <p>Your answer was
-       <strong>
-         {{ previous.previous_outcome|yesno:"correct,incorrect" }}
-       </strong>
-  </p>
-  {% include 'correct_answer.html' %}
-  <p><strong>{% trans "Explanation" %}:</strong></p>
-  <div class="well " style="background-color: #fcf8e3;">
-    <p>{{ previous.previous_question.explanation }}</p>
-  </div>
-  <hr>
-
-  {% endif %}
+{% block result %}
 
   {% if max_score %}
 
          <strong>{{ quiz.title }}</strong></p>
 
        <p class="lead">
-         {% 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" %}.
        </p>
 
        {% if quiz.pass_mark %}
-       <hr>
-        <p class="lead">{{ sitting.result_message }}</p>
-       <hr>
-
+         {% if sitting.result_message %}
+          <hr>
+          <p class="lead">{{ sitting.result_message }}</p>
+          <hr>
+         {% endif %}
+         {% if percent >= quiz.pass_mark %}
+          <span>Votre quiz est validé.</span><br><br>
+          <a href="{% url teleforma-seminar-detail seminar.id %}" class="component_icon button icon_next">&nbsp;{% trans "Back" %} au séminaire</a>
+         {% else %}
+          <span>Vous devez recommencer le quiz.</span><br><br>
+          <a href="{% url teleforma-quiz seminar.id  seminar.quiz.url %}" class="component_icon button icon_previous">&nbsp;{% trans "Recommencer" %}</a>
+         {% endif %}
        {% endif %}
 
+{% comment %}
        <p>{% trans "Review the questions below and try the exam again in the future"%}.</p>
 
        {% if user.is_authenticated %}
          <p>{% trans "The result of this exam will be stored in your progress section so you can review and monitor your progression" %}.</p>
 
        {% endif %}
-  </div>
-
+{% endcomment %}
 
+  </div>
   {% endif %}
 
 
-  <hr>
-
   {% if possible %}
 
   <p class="lead">
@@ -95,5 +86,4 @@
 
   {% endif %}
 
-
-{% endblock %}
+{% endblock result %}
index ba1357eea038586ae042429d3e5984e732448f39..5511c86ad65f2cd032278863e42c8ec473279318 100644 (file)
@@ -9,24 +9,6 @@
                <a href="{% url teleforma-quiz seminar.id  seminar.quiz.url %}">{{ seminar.quiz.title }}</a>
                 {% endif %}
             </td>
-            <td class="border-top" width="60%">
-               {% 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 %}
-            </td>
-            <td class="border-top" width="5%" align="center">
-               {% if question|submitted:user and not question|validated:user %}
-                       <img src="{{ STATIC_URL }}teleforma/images/chronometer.png" style="vertical-align:middle" alt="" title="{% trans "Waiting for validation" %}" />
-               {% elif question|saved:user and not question|submitted:user %}
-                       <img src="{{ STATIC_URL }}telemeta/images/media-record.png" style="vertical-align:middle" alt="" title="{% trans "Saved" %}" />
-               {% elif question|submitted:user and question|validated:user %}
-                       <img src="{{ STATIC_URL }}telemeta/images/ok.png" style="vertical-align:middle" alt="" title="{% trans "Validated" %}" />
-               {% endif %}
-            </td>
             </tr>
     </tbody>
 </table>
index f230ff962beb5cfe446006e1505c4abe79170576..75b3cffb27e8c9edc35a3ee7ce42454d5ca9fade 100644 (file)
@@ -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)
+