]> git.parisson.com Git - teleforma.git/commitdiff
add quiz templates, fix url
authorGuillaume Pellerin <yomguy@parisson.com>
Wed, 9 Dec 2015 12:52:29 +0000 (13:52 +0100)
committerGuillaume Pellerin <yomguy@parisson.com>
Wed, 9 Dec 2015 12:52:42 +0000 (13:52 +0100)
14 files changed:
teleforma/templates/quiz/base.html [new file with mode: 0644]
teleforma/templates/quiz/correct_answer.html [new file with mode: 0644]
teleforma/templates/quiz/progress.html [new file with mode: 0644]
teleforma/templates/quiz/question.html [new file with mode: 0644]
teleforma/templates/quiz/quiz/category_list.html [new file with mode: 0644]
teleforma/templates/quiz/quiz/quiz_detail.html [new file with mode: 0644]
teleforma/templates/quiz/quiz/quiz_list.html [new file with mode: 0644]
teleforma/templates/quiz/quiz/sitting_detail.html [new file with mode: 0644]
teleforma/templates/quiz/quiz/sitting_list.html [new file with mode: 0644]
teleforma/templates/quiz/result.html [new file with mode: 0644]
teleforma/templates/quiz/single_complete.html [new file with mode: 0644]
teleforma/templates/quiz/view_quiz_category.html [new file with mode: 0644]
teleforma/templates/teleforma/inc/quiz_list.html
teleforma/urls.py

diff --git a/teleforma/templates/quiz/base.html b/teleforma/templates/quiz/base.html
new file mode 100644 (file)
index 0000000..c565dd4
--- /dev/null
@@ -0,0 +1,3 @@
+{% extends "teleforma/base.html" %}
+{% load i18n %}
+
diff --git a/teleforma/templates/quiz/correct_answer.html b/teleforma/templates/quiz/correct_answer.html
new file mode 100644 (file)
index 0000000..d98a10d
--- /dev/null
@@ -0,0 +1,32 @@
+{% load i18n %}
+{% if previous.answers %}
+
+  {% if user_was_incorrect %}
+    <div class="alert alert-error">
+         <strong>{% trans "You answered the above question incorrectly" %}</strong>
+    </div>
+  {% endif %}
+
+  <table class="table table-striped table-bordered">
+    <tbody>
+         {% for answer in previous.answers %}
+        {% if answer.correct %}
+           <tr class="success">
+                 <td>{{ answer.content }}</td>
+                 <td><strong>{% trans "This is the correct answer" %}</strong></td>
+        {% else %}
+               <tr>
+         <td>{{ answer.content }}</td>
+                 <td>
+                       {% if previous.question_type.MCQuestion %}
+                         {% if answer.id|add:"0" == previous.previous_answer|add:"0" %}
+                           {% trans "This was your answer." %}
+                         {% endif %}
+                       {% endif %}
+                 </td>
+         {% endif %}
+           </tr>
+       {% endfor %}
+    </tbody>
+  </table>
+{% endif %}
diff --git a/teleforma/templates/quiz/progress.html b/teleforma/templates/quiz/progress.html
new file mode 100644 (file)
index 0000000..5337c71
--- /dev/null
@@ -0,0 +1,86 @@
+{% extends "base.html" %}
+{% load i18n %}
+
+{% load quiz_tags %}
+
+{% block title %} {% trans "Progress Page" %} {% endblock %}
+{% block description %} {% trans "User Progress Page" %} {% endblock %}
+
+{% block content %}
+
+  {% if cat_scores %}
+
+  <h1>{% trans "Question Category Scores" %}</h1>
+
+  <table class="table table-bordered table-striped">
+
+       <thead>
+         <tr>
+               <th>{% trans "Category" %}</th>
+               <th>{% trans "Correctly answererd" %}</th>
+               <th>{% trans "Incorrect" %}</th>
+               <th>%</th>
+         </tr>
+       </thead>
+
+       <tbody>
+
+
+         {% for cat, value in cat_scores.items %}
+         <tr>
+               <td>{{ cat }}</td>
+               <td>{{ value.0 }}</td>
+               <td>{{ value.1 }}</td>
+               <td>{{ value.2 }}</td>
+         </tr>
+
+         {% endfor %}
+
+       </tbody>
+
+  </table>
+
+
+  {% endif %}
+
+  {% if exams %}
+
+  <hr>
+
+  <h1>{% trans "Previous exam papers" %}</h1>
+  <p class="lead">
+       {% trans "Below are the results of exams that you have sat." %}
+  </p>
+
+  <table class="table table-bordered table-striped">
+
+       <thead>
+         <tr>
+               <th>{% trans "Quiz Title" %}</th>
+               <th>{% trans "Score" %}</th>
+               <th>{% trans "Possible Score" %}</th>
+               <th>%</th>
+         </tr>
+       </thead>
+
+       <tbody>
+
+         {% for exam in exams %}
+
+         <tr>
+               <td>{{ exam.quiz.title }}</td>
+               <td>{{ exam.current_score }}</td>
+               <td>{{ exam.get_max_score }}</td>
+               <td>{{ exam.get_percent_correct }}</td>
+         </tr>
+
+         {% endfor %}
+
+       </tbody>
+
+  </table>
+
+  {% endif %}
+
+
+{% endblock %}
diff --git a/teleforma/templates/quiz/question.html b/teleforma/templates/quiz/question.html
new file mode 100644 (file)
index 0000000..113f28e
--- /dev/null
@@ -0,0 +1,82 @@
+{% extends "teleforma/base.html" %}
+{% load i18n%}
+
+{% load quiz_tags %}
+
+{% block title %} {{ quiz.title }} {% endblock %}
+{% block description %} {{ quiz.title }} - {{ quiz.description }} {% endblock %}
+
+{% block content %}
+
+{% if previous.answers %}
+
+  <p class="muted"><small>{% trans "The previous question" %}:</small></p>
+  <p>{{ previous.previous_question }}</p>
+
+  {% if previous.previous_outcome %}
+       <div class="alert alert-success">
+  {% else %}
+       <div class="alert alert-warning">
+  {% endif %}
+         <p><small>
+               {% trans "Your answer was" %} </small>
+               <strong>
+                 {{ previous.previous_outcome|yesno:"correct,incorrect" }}
+               </strong>
+         </p>
+
+       </div>
+
+       {% 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 %}
+
+<br />
+
+{% if question %}
+
+{% if progress %}
+<div style="float: right;">
+{% trans "Question" %} {{ progress.0|add:1 }} {% trans "of" %} {{ progress.1 }}
+</div>
+{% endif %}
+
+<p>
+  <small class="muted">{% trans "Question category" %}:</small>
+  <strong>{{ question.category }}</strong>
+</p>
+
+<p class="lead">{{ question.content }}</p>
+
+{% if question.figure %}
+    <img src="{{ question.figure.url }}" alt="{{ question.content }}" />
+{% endif %}
+
+<form action="" method="POST">{% csrf_token %}
+  <input type=hidden name="question_id" value="{{ question.id }}">
+
+  <ul class="list-group">
+
+       {% for answer in form.answers %}
+         <li class="list-group-item">
+           {{ answer }}
+         </li>
+       {% endfor %}
+
+  </ul>
+  <input type="submit" value={% trans "Check" %} class="btn btn-large btn-block btn-warning" >
+</form>
+
+{% endif %}
+
+<hr>
+
+
+{% endblock %}
diff --git a/teleforma/templates/quiz/quiz/category_list.html b/teleforma/templates/quiz/quiz/category_list.html
new file mode 100644 (file)
index 0000000..90ffe0a
--- /dev/null
@@ -0,0 +1,18 @@
+{% extends 'base.html' %}
+{% load i18n %}
+{% block title %}{% trans "All Quizzes" %}{% endblock %}
+
+{% block content %}
+<h2>{% trans "Category list" %}</h2>
+
+<ul>
+  {% for cat in category_list %}
+  <li>
+       <a href="{% url 'quiz_category_list_matching' category_name=cat.category %}">
+         {{ cat.category }}
+       </a>
+  </li>
+  {% endfor %}
+</ul>
+
+{% endblock %}
diff --git a/teleforma/templates/quiz/quiz/quiz_detail.html b/teleforma/templates/quiz/quiz/quiz_detail.html
new file mode 100644 (file)
index 0000000..2681f77
--- /dev/null
@@ -0,0 +1,19 @@
+{% extends 'base.html' %}
+{% load i18n %}
+{% block title %}
+{{ quiz.title }}
+{% endblock %}
+
+{% block content %}
+<h2>{{ quiz.title }}</h2>
+<h3>{% trans "Category" %}: {{ quiz.category }}</h3>
+{% if quiz.single_attempt %}
+  <h4>{% trans "You will only get one attempt at this quiz" %}.</h4>
+{% endif %}
+<p>{{ quiz.description }}</p>
+<p>
+  <a href="{% url 'quiz_question' quiz_name=quiz.url %}">
+       {% trans "Start quiz" %}
+  </a>
+</p>
+{% endblock %}
diff --git a/teleforma/templates/quiz/quiz/quiz_list.html b/teleforma/templates/quiz/quiz/quiz_list.html
new file mode 100644 (file)
index 0000000..0b16375
--- /dev/null
@@ -0,0 +1,43 @@
+{% extends 'teleforma/base.html' %}
+{% load i18n %}
+{% block title %}{% trans "All Quizzes" %}{% endblock %}
+
+{% block content %}
+<h2>{% trans "List of quizzes" %}</h2>
+    {% if quiz_list %}
+               <table class="table table-bordered table-striped">
+
+                 <thead>
+                       <tr>
+                         <th>{% trans "Title" %}</th>
+                         <th>{% trans "Category" %}</th>
+                         <th>{% trans "Exam" %}</th>
+                         <th>{% trans "Single attempt" %}</th>
+                         <th></th>
+                       </tr>
+                 </thead>
+
+                 <tbody>
+
+        {% for quiz in quiz_list %}
+
+                       <tr>
+                         <td>{{ quiz.title }}</td>
+                         <td>{{ quiz.category }}</td>
+                         <td>{{ quiz.exam_paper }}</td>
+                         <td>{{ quiz.single_attempt }}</td>
+                         <td>
+                               <a href="{% url 'quiz_start_page' slug=quiz.url %}">
+                                 {% trans "View details" %}
+                               </a>
+                       </tr>
+
+        {% endfor %}
+                 </tbody>
+
+               </table>
+
+       {% else %}
+        <p>{% trans "There are no available quizzes" %}.</p>
+    {% endif %}
+{% endblock %}
diff --git a/teleforma/templates/quiz/quiz/sitting_detail.html b/teleforma/templates/quiz/quiz/sitting_detail.html
new file mode 100644 (file)
index 0000000..fe8da8c
--- /dev/null
@@ -0,0 +1,59 @@
+{% extends 'base.html' %}
+{% load i18n %}
+{% load quiz_tags %}
+{% block title %}
+{% trans "Result of" %} {{ sitting.quiz.title }} {% trans "for" %} {{ sitting.user }}
+{% endblock %}
+
+{% block content %}
+<h2>{% trans "Quiz title" %}: {{ sitting.quiz.title }}</h2>
+<h3>{% trans "Category" %}: {{ sitting.quiz.category }}</h3>
+<p>{{ sitting.quiz.description }}</p>
+<hr>
+<p>{% trans "User" %}: {{ sitting.user }}</p>
+<p>{% trans "Completed" %}: {{ sitting.end|date }}</p>
+<p>{% trans "Score" %}: {{ sitting.get_percent_correct }}%</p>
+
+<table class="table table-bordered table-striped">
+
+  <thead>
+       <tr>
+         <th>{% trans "Question" %}</th>
+         <th>{% trans "User answer" %}</th>
+         <th></th>
+         <th></th>
+       </tr>
+  </thead>
+
+  <tbody>
+{% for question in questions %}
+
+       <tr>
+      <td>
+        {{ question.content }}
+        {% if question.figure %}
+        <div style="max-width: 100px;"><img src="{{ question.figure.url }}" alt="{{ question.figure }}"/></div>
+        {% endif %}
+      </td>
+         <td>{{ question|answer_choice_to_string:question.user_answer }}</td>
+         <td>
+               {% if question.id in sitting.get_incorrect_questions %}
+                 <p>{% trans "incorrect" %}</p>
+               {% else %}
+                 <p>{% trans "Correct" %}</p>
+               {% endif %}
+         </td>
+         <td>
+               <form action="" method="POST">{% csrf_token %}
+                 <input type=hidden name="qid" value="{{ question.id }}">
+                 <button type="submit" class="btn btn-warning">{% trans "Toggle whether correct" %}</button>
+               </form>
+         </td>
+       </tr>
+
+{% endfor %}
+
+  </tbody>
+
+</table>
+{% endblock %}
diff --git a/teleforma/templates/quiz/quiz/sitting_list.html b/teleforma/templates/quiz/quiz/sitting_list.html
new file mode 100644 (file)
index 0000000..915c8a8
--- /dev/null
@@ -0,0 +1,54 @@
+{% extends 'base.html' %}
+{% load i18n %}
+{% block title %}{% trans "All Quizzes" %}{% endblock %}
+
+{% block content %}
+<h2>{% trans "List of complete exams" %}</h2>
+    {% if sitting_list %}
+
+               <table class="table table-bordered table-striped">
+
+                 <thead>
+                       <tr>
+                         <th>{% trans "User" %}</th>
+                         <th>{% trans "Quiz" %}</th>
+                         <th>{% trans "Completed" %}</th>
+                         <th>{% trans "Score" %}(%)</th>
+                         <th></th>
+                       </tr>
+                 </thead>
+
+                 <tbody>
+                       <tr>
+                         <form action="" method="GET">
+                               <td><input type="text" name="user_filter" /></td>
+                               <td><input type="text" name="quiz_filter" /></td>
+                               <td></td>
+                               <td></td>
+                               <td><button type="submit" class="btn btn-default">{% trans "Filter"%}</button></td>
+                         </form>
+                       </tr>
+
+
+        {% for sitting in sitting_list %}
+
+                       <tr>
+                         <td>{{ sitting.user }}</td>
+                         <td>{{ sitting.quiz }}</td>
+                         <td>{{ sitting.end|date }}</td>
+                         <td>{{ sitting.get_percent_correct }}</td>
+                         <td>
+                               <a href="{% url 'quiz_marking_detail' pk=sitting.id %}">
+                                 {% trans "View details" %}
+                               </a>
+                       </tr>
+
+        {% endfor %}
+
+                 </tbody>
+
+               </table>
+    {% else %}
+        <p>{% trans "There are no matching quizzes" %}.</p>
+    {% endif %}
+{% endblock %}
diff --git a/teleforma/templates/quiz/result.html b/teleforma/templates/quiz/result.html
new file mode 100644 (file)
index 0000000..e99e793
--- /dev/null
@@ -0,0 +1,99 @@
+{% extends "base.html" %}
+{% load i18n %}
+
+{% load quiz_tags %}
+
+{% block title %} {{ quiz.title}} {% endblock %}
+{% block description %} {% trans "Exam Results for" %} {{ quiz.title }} {% endblock %}
+
+{% block 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 %}
+
+  {% if max_score %}
+
+  <div>
+       <h2>{% trans "Exam results" %}</h2>
+       <p>
+         <small class="muted">{% trans "Exam title" %}: </small>
+         <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" %}
+       </p>
+
+       {% if quiz.pass_mark %}
+       <hr>
+        <p class="lead">{{ sitting.result_message }}</p>
+       <hr>
+
+       {% endif %}
+
+       <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>
+
+
+  {% endif %}
+
+
+  <hr>
+
+  {% if possible %}
+
+  <p class="lead">
+       {% trans "Your session score is" %} {{ session }} {% trans "out of a possible" %} {{ possible }}
+  </p>
+
+  <hr>
+
+  {% endif %}
+
+  {% if questions %}
+
+    {% for question in questions %}
+
+      <p class="lead">
+               {{ question.content }}
+         </p>
+
+         {% correct_answer_for_all question %}
+
+      {% if question.user_answer %}
+      <p>{% trans "Your answer" %}: {{ question|answer_choice_to_string:question.user_answer }}</p>
+      {% endif %}
+
+         <p><strong>{% trans "Explanation" %}:</strong></p>
+         <div class="well " style="background-color: #fcf8e3;">
+               <p>{{ question.explanation }}</p>
+         </div>
+
+         <hr>
+
+  {% endfor %}
+
+  {% endif %}
+
+
+{% endblock %}
diff --git a/teleforma/templates/quiz/single_complete.html b/teleforma/templates/quiz/single_complete.html
new file mode 100644 (file)
index 0000000..9b016f9
--- /dev/null
@@ -0,0 +1,18 @@
+{% extends "base.html" %}
+{% load i18n %}
+
+{% load quiz_tags %}
+
+{% block title %} {{ quiz.title }} {% endblock %}
+{% block description %} {{ quiz.title }} - {{ quiz.description }} {% endblock %}
+
+{% block content %}
+
+
+{% if user.is_authenticated %}
+  <p>{% trans "You have already sat this exam and only one sitting is permitted" %}.</p>
+{% else %}
+  <p>{% trans "This exam is only accessible to signed in users" %}.</p>
+{% endif %}
+
+{% endblock %}
diff --git a/teleforma/templates/quiz/view_quiz_category.html b/teleforma/templates/quiz/view_quiz_category.html
new file mode 100644 (file)
index 0000000..29aeda6
--- /dev/null
@@ -0,0 +1,23 @@
+{% extends 'base.html' %}
+{% load i18n %}
+{% block title %}{% trans "Quizzes related to" %} {{ category.category }}{% endblock %}
+
+{% block content %}
+<h1>{% trans "Quizzes in the" %} <strong>{{ category.category }} </strong>{% trans "category" %}</h1>
+
+  {% with object_list as quizzes %}
+    {% if quizzes %}
+        <ul>
+        {% for quiz in quizzes %}
+            <li>
+                         <a href="{% url 'quiz_question' quiz_name=quiz.url %}">
+                               {{ quiz.title }}
+                         </a>
+                       </li>
+        {% endfor %}
+        </ul>
+    {% else %}
+        <p>{% trans "There are no quizzes" %}</p>
+    {% endif %}
+  {% endwith %}
+{% endblock %}
index 68152d32e0c0af78062242ca96423b9b8630e8f6..ba1357eea038586ae042429d3e5984e732448f39 100644 (file)
@@ -5,7 +5,10 @@
     <tbody>
             <tr>
             <td class="border-top" width="35%">
-               <a href="{% url teleforma-quiz seminar.id quiz.id %}">{{ quiz.title }}</a></td>
+                {% if seminar.quiz %}
+               <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 }}
@@ -25,6 +28,5 @@
                {% endif %}
             </td>
             </tr>
-        {% endfor %}
     </tbody>
 </table>
index bcf3317cb694551c588fc909e210b959c1ea440d..611dbd087dbc188f50d195724187315e5865db74 100644 (file)
@@ -104,7 +104,7 @@ urlpatterns = patterns('',
     # Evaluations
     url(r'^forms/', include('forms_builder.forms.urls')),
     url(r'^desk/seminars/(?P<pk>.*)/form/$', evaluation_form_detail, name="teleforma-seminar-form"),
-    url(r'^desk/seminars/(?P<pk>.*)/quiz/$', QuizTake.as_view(), name="teleforma-quiz"),
+    url(r'^desk/seminars/(?P<pk>.*)/quiz/(?P<quiz_name>[\w-]+)/$', QuizTake.as_view(), name="teleforma-quiz"),
 
     # Testimonial
     url(r'^desk/seminars/(?P<pk>.*)/testimonial/$', TestimonialView.as_view(),