From f76241b8779838d4f876cbcfe144714787ae3b6b Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Wed, 9 Dec 2015 13:52:29 +0100 Subject: [PATCH] add quiz templates, fix url --- teleforma/templates/quiz/base.html | 3 + teleforma/templates/quiz/correct_answer.html | 32 ++++++ teleforma/templates/quiz/progress.html | 86 ++++++++++++++++ teleforma/templates/quiz/question.html | 82 +++++++++++++++ .../templates/quiz/quiz/category_list.html | 18 ++++ .../templates/quiz/quiz/quiz_detail.html | 19 ++++ teleforma/templates/quiz/quiz/quiz_list.html | 43 ++++++++ .../templates/quiz/quiz/sitting_detail.html | 59 +++++++++++ .../templates/quiz/quiz/sitting_list.html | 54 ++++++++++ teleforma/templates/quiz/result.html | 99 +++++++++++++++++++ teleforma/templates/quiz/single_complete.html | 18 ++++ .../templates/quiz/view_quiz_category.html | 23 +++++ .../templates/teleforma/inc/quiz_list.html | 6 +- teleforma/urls.py | 2 +- 14 files changed, 541 insertions(+), 3 deletions(-) create mode 100644 teleforma/templates/quiz/base.html create mode 100644 teleforma/templates/quiz/correct_answer.html create mode 100644 teleforma/templates/quiz/progress.html create mode 100644 teleforma/templates/quiz/question.html create mode 100644 teleforma/templates/quiz/quiz/category_list.html create mode 100644 teleforma/templates/quiz/quiz/quiz_detail.html create mode 100644 teleforma/templates/quiz/quiz/quiz_list.html create mode 100644 teleforma/templates/quiz/quiz/sitting_detail.html create mode 100644 teleforma/templates/quiz/quiz/sitting_list.html create mode 100644 teleforma/templates/quiz/result.html create mode 100644 teleforma/templates/quiz/single_complete.html create mode 100644 teleforma/templates/quiz/view_quiz_category.html diff --git a/teleforma/templates/quiz/base.html b/teleforma/templates/quiz/base.html new file mode 100644 index 00000000..c565dd49 --- /dev/null +++ b/teleforma/templates/quiz/base.html @@ -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 index 00000000..d98a10d9 --- /dev/null +++ b/teleforma/templates/quiz/correct_answer.html @@ -0,0 +1,32 @@ +{% load i18n %} +{% if previous.answers %} + + {% if user_was_incorrect %} +
+ {% trans "You answered the above question incorrectly" %} +
+ {% endif %} + + + + {% for answer in previous.answers %} + {% if answer.correct %} + + + + {% else %} + + + + {% endif %} + + {% endfor %} + +
{{ answer.content }}{% trans "This is the correct answer" %}
{{ answer.content }} + {% if previous.question_type.MCQuestion %} + {% if answer.id|add:"0" == previous.previous_answer|add:"0" %} + {% trans "This was your answer." %} + {% endif %} + {% endif %} +
+{% endif %} diff --git a/teleforma/templates/quiz/progress.html b/teleforma/templates/quiz/progress.html new file mode 100644 index 00000000..5337c71c --- /dev/null +++ b/teleforma/templates/quiz/progress.html @@ -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 %} + +

{% trans "Question Category Scores" %}

+ + + + + + + + + + + + + + + + {% for cat, value in cat_scores.items %} + + + + + + + + {% endfor %} + + + +
{% trans "Category" %}{% trans "Correctly answererd" %}{% trans "Incorrect" %}%
{{ cat }}{{ value.0 }}{{ value.1 }}{{ value.2 }}
+ + + {% endif %} + + {% if exams %} + +
+ +

{% trans "Previous exam papers" %}

+

+ {% trans "Below are the results of exams that you have sat." %} +

+ + + + + + + + + + + + + + + {% for exam in exams %} + + + + + + + + + {% endfor %} + + + +
{% trans "Quiz Title" %}{% trans "Score" %}{% trans "Possible Score" %}%
{{ exam.quiz.title }}{{ exam.current_score }}{{ exam.get_max_score }}{{ exam.get_percent_correct }}
+ + {% endif %} + + +{% endblock %} diff --git a/teleforma/templates/quiz/question.html b/teleforma/templates/quiz/question.html new file mode 100644 index 00000000..113f28e6 --- /dev/null +++ b/teleforma/templates/quiz/question.html @@ -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 %} + +

{% trans "The previous question" %}:

+

{{ previous.previous_question }}

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

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

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

{% trans "Explanation" %}:

+
+

{{ previous.previous_question.explanation }}

+
+ +
+ +{% endif %} + +
+ +{% if question %} + +{% if progress %} +
+{% trans "Question" %} {{ progress.0|add:1 }} {% trans "of" %} {{ progress.1 }} +
+{% endif %} + +

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

+ +

{{ question.content }}

+ +{% if question.figure %} + {{ question.content }} +{% endif %} + +
{% csrf_token %} + + +
    + + {% for answer in form.answers %} +
  • + {{ answer }} +
  • + {% endfor %} + +
+ +
+ +{% endif %} + +
+ + +{% endblock %} diff --git a/teleforma/templates/quiz/quiz/category_list.html b/teleforma/templates/quiz/quiz/category_list.html new file mode 100644 index 00000000..90ffe0a7 --- /dev/null +++ b/teleforma/templates/quiz/quiz/category_list.html @@ -0,0 +1,18 @@ +{% extends 'base.html' %} +{% load i18n %} +{% block title %}{% trans "All Quizzes" %}{% endblock %} + +{% block content %} +

{% trans "Category list" %}

+ + + +{% endblock %} diff --git a/teleforma/templates/quiz/quiz/quiz_detail.html b/teleforma/templates/quiz/quiz/quiz_detail.html new file mode 100644 index 00000000..2681f778 --- /dev/null +++ b/teleforma/templates/quiz/quiz/quiz_detail.html @@ -0,0 +1,19 @@ +{% extends 'base.html' %} +{% load i18n %} +{% block title %} +{{ quiz.title }} +{% endblock %} + +{% block content %} +

{{ quiz.title }}

+

{% trans "Category" %}: {{ quiz.category }}

+{% if quiz.single_attempt %} +

{% trans "You will only get one attempt at this quiz" %}.

+{% endif %} +

{{ quiz.description }}

+

+ + {% trans "Start quiz" %} + +

+{% endblock %} diff --git a/teleforma/templates/quiz/quiz/quiz_list.html b/teleforma/templates/quiz/quiz/quiz_list.html new file mode 100644 index 00000000..0b163759 --- /dev/null +++ b/teleforma/templates/quiz/quiz/quiz_list.html @@ -0,0 +1,43 @@ +{% extends 'teleforma/base.html' %} +{% load i18n %} +{% block title %}{% trans "All Quizzes" %}{% endblock %} + +{% block content %} +

{% trans "List of quizzes" %}

+ {% if quiz_list %} + + + + + + + + + + + + + + + {% for quiz in quiz_list %} + + + + + + + + + {% endfor %} + + +
{% trans "Title" %}{% trans "Category" %}{% trans "Exam" %}{% trans "Single attempt" %}
{{ quiz.title }}{{ quiz.category }}{{ quiz.exam_paper }}{{ quiz.single_attempt }} + + {% trans "View details" %} + +
+ + {% else %} +

{% trans "There are no available quizzes" %}.

+ {% endif %} +{% endblock %} diff --git a/teleforma/templates/quiz/quiz/sitting_detail.html b/teleforma/templates/quiz/quiz/sitting_detail.html new file mode 100644 index 00000000..fe8da8c2 --- /dev/null +++ b/teleforma/templates/quiz/quiz/sitting_detail.html @@ -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 %} +

{% trans "Quiz title" %}: {{ sitting.quiz.title }}

+

{% trans "Category" %}: {{ sitting.quiz.category }}

+

{{ sitting.quiz.description }}

+
+

{% trans "User" %}: {{ sitting.user }}

+

{% trans "Completed" %}: {{ sitting.end|date }}

+

{% trans "Score" %}: {{ sitting.get_percent_correct }}%

+ + + + + + + + + + + + + +{% for question in questions %} + + + + + + + + +{% endfor %} + + + +
{% trans "Question" %}{% trans "User answer" %}
+ {{ question.content }} + {% if question.figure %} +
{{ question.figure }}
+ {% endif %} +
{{ question|answer_choice_to_string:question.user_answer }} + {% if question.id in sitting.get_incorrect_questions %} +

{% trans "incorrect" %}

+ {% else %} +

{% trans "Correct" %}

+ {% endif %} +
+
{% csrf_token %} + + +
+
+{% endblock %} diff --git a/teleforma/templates/quiz/quiz/sitting_list.html b/teleforma/templates/quiz/quiz/sitting_list.html new file mode 100644 index 00000000..915c8a8e --- /dev/null +++ b/teleforma/templates/quiz/quiz/sitting_list.html @@ -0,0 +1,54 @@ +{% extends 'base.html' %} +{% load i18n %} +{% block title %}{% trans "All Quizzes" %}{% endblock %} + +{% block content %} +

{% trans "List of complete exams" %}

+ {% if sitting_list %} + + + + + + + + + + + + + + + + + + + + + + + + + + {% for sitting in sitting_list %} + + + + + + + + + {% endfor %} + + + +
{% trans "User" %}{% trans "Quiz" %}{% trans "Completed" %}{% trans "Score" %}(%)
{{ sitting.user }}{{ sitting.quiz }}{{ sitting.end|date }}{{ sitting.get_percent_correct }} + + {% trans "View details" %} + +
+ {% else %} +

{% trans "There are no matching quizzes" %}.

+ {% endif %} +{% endblock %} diff --git a/teleforma/templates/quiz/result.html b/teleforma/templates/quiz/result.html new file mode 100644 index 00000000..e99e7932 --- /dev/null +++ b/teleforma/templates/quiz/result.html @@ -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 %} + +

{% 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 %} + + {% if max_score %} + +
+

{% trans "Exam results" %}

+

+ {% trans "Exam title" %}: + {{ quiz.title }}

+ +

+ {% 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 }}

+
+ + {% endif %} + +

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

+ + {% if user.is_authenticated %} + +

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

+ + {% endif %} +
+ + + {% endif %} + + +
+ + {% if possible %} + +

+ {% trans "Your session score is" %} {{ session }} {% trans "out of a possible" %} {{ possible }} +

+ +
+ + {% endif %} + + {% if questions %} + + {% for question in questions %} + +

+ {{ question.content }} +

+ + {% correct_answer_for_all question %} + + {% if question.user_answer %} +

{% trans "Your answer" %}: {{ question|answer_choice_to_string:question.user_answer }}

+ {% endif %} + +

{% trans "Explanation" %}:

+
+

{{ question.explanation }}

+
+ +
+ + {% endfor %} + + {% endif %} + + +{% endblock %} diff --git a/teleforma/templates/quiz/single_complete.html b/teleforma/templates/quiz/single_complete.html new file mode 100644 index 00000000..9b016f97 --- /dev/null +++ b/teleforma/templates/quiz/single_complete.html @@ -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 %} +

{% trans "You have already sat this exam and only one sitting is permitted" %}.

+{% else %} +

{% trans "This exam is only accessible to signed in users" %}.

+{% endif %} + +{% endblock %} diff --git a/teleforma/templates/quiz/view_quiz_category.html b/teleforma/templates/quiz/view_quiz_category.html new file mode 100644 index 00000000..29aeda62 --- /dev/null +++ b/teleforma/templates/quiz/view_quiz_category.html @@ -0,0 +1,23 @@ +{% extends 'base.html' %} +{% load i18n %} +{% block title %}{% trans "Quizzes related to" %} {{ category.category }}{% endblock %} + +{% block content %} +

{% trans "Quizzes in the" %} {{ category.category }} {% trans "category" %}

+ + {% with object_list as quizzes %} + {% if quizzes %} + + {% else %} +

{% trans "There are no quizzes" %}

+ {% endif %} + {% endwith %} +{% endblock %} diff --git a/teleforma/templates/teleforma/inc/quiz_list.html b/teleforma/templates/teleforma/inc/quiz_list.html index 68152d32..ba1357ee 100644 --- a/teleforma/templates/teleforma/inc/quiz_list.html +++ b/teleforma/templates/teleforma/inc/quiz_list.html @@ -5,7 +5,10 @@ - {{ quiz.title }} + {% if seminar.quiz %} + {{ seminar.quiz.title }} + {% endif %} + {% if question|submitted:user and not question|validated:user %} {% trans "submitted on" %} {{ question|submitted:user }} @@ -25,6 +28,5 @@ {% endif %} - {% endfor %} diff --git a/teleforma/urls.py b/teleforma/urls.py index bcf3317c..611dbd08 100644 --- a/teleforma/urls.py +++ b/teleforma/urls.py @@ -104,7 +104,7 @@ urlpatterns = patterns('', # Evaluations url(r'^forms/', include('forms_builder.forms.urls')), url(r'^desk/seminars/(?P.*)/form/$', evaluation_form_detail, name="teleforma-seminar-form"), - url(r'^desk/seminars/(?P.*)/quiz/$', QuizTake.as_view(), name="teleforma-quiz"), + url(r'^desk/seminars/(?P.*)/quiz/(?P[\w-]+)/$', QuizTake.as_view(), name="teleforma-quiz"), # Testimonial url(r'^desk/seminars/(?P.*)/testimonial/$', TestimonialView.as_view(), -- 2.39.5