From 3636a44fd713e06484434f39057b1d8bf9c85bb9 Mon Sep 17 00:00:00 2001 From: Yoan Le Clanche Date: Thu, 26 Apr 2018 14:58:39 +0200 Subject: [PATCH] Add personalized home page and quiz --- teleforma/admin.py | 6 + teleforma/exam/views.py | 0 teleforma/locale/fr/LC_MESSAGES/django.mo | Bin 14965 -> 15061 bytes teleforma/locale/fr/LC_MESSAGES/django.po | 8 + teleforma/migrations/0092_auto__add_home.py | 577 +++++++++++++++++ ...d_field_home_video__chg_field_home_text.py | 582 +++++++++++++++++ .../0094_auto__add_field_course_quiz.py | 599 +++++++++++++++++ .../0095_auto__del_field_course_quiz.py | 611 ++++++++++++++++++ teleforma/models/core.py | 2 + teleforma/models/crfpa.py | 21 + teleforma/static/teleforma/js/application.js | 15 + teleforma/templates/quiz/category_list.html | 18 + teleforma/templates/quiz/correct_answer.html | 32 + teleforma/templates/quiz/progress.html | 86 +++ teleforma/templates/quiz/question.html | 82 +++ teleforma/templates/quiz/quiz_detail.html | 20 + teleforma/templates/quiz/quiz_list.html | 43 ++ teleforma/templates/quiz/result.html | 92 +++ teleforma/templates/quiz/single_complete.html | 18 + teleforma/templates/quiz/sitting_detail.html | 59 ++ teleforma/templates/quiz/sitting_list.html | 54 ++ .../templates/quiz/view_quiz_category.html | 23 + .../templates/teleforma/course_detail.html | 48 +- teleforma/templates/teleforma/courses.html | 33 +- teleforma/templatetags/teleforma_tags.py | 2 + teleforma/views/core.py | 7 +- 26 files changed, 3020 insertions(+), 18 deletions(-) mode change 100644 => 100755 teleforma/exam/views.py create mode 100644 teleforma/migrations/0092_auto__add_home.py create mode 100644 teleforma/migrations/0093_auto__add_field_home_video__chg_field_home_text.py create mode 100644 teleforma/migrations/0094_auto__add_field_course_quiz.py create mode 100644 teleforma/migrations/0095_auto__del_field_course_quiz.py create mode 100644 teleforma/templates/quiz/category_list.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_detail.html create mode 100644 teleforma/templates/quiz/quiz_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/sitting_detail.html create mode 100644 teleforma/templates/quiz/sitting_list.html create mode 100644 teleforma/templates/quiz/view_quiz_category.html diff --git a/teleforma/admin.py b/teleforma/admin.py index 806e3d95..226dd59e 100644 --- a/teleforma/admin.py +++ b/teleforma/admin.py @@ -159,6 +159,11 @@ class ConferenceAdmin(admin.ModelAdmin): list_filter = ('course', 'period', 'date_begin', 'session') search_fields = ['public_id', 'id', 'course__code', 'course__title', 'session'] +class HomeAdmin(admin.ModelAdmin): + def get_form(self, request, obj=None, **kwargs): + form = super(HomeAdmin, self).get_form(request, obj, **kwargs) + form.base_fields['video'].queryset = Media.objects.filter(type='webm') + return form admin.site.unregister(User) admin.site.register(Organization) @@ -181,3 +186,4 @@ admin.site.register(Student, StudentAdmin) admin.site.register(Professor, ProfessorAdmin) admin.site.register(StudentGroup, StudentGroupAdmin) admin.site.register(GroupedMessage) +admin.site.register(Home, HomeAdmin) diff --git a/teleforma/exam/views.py b/teleforma/exam/views.py old mode 100644 new mode 100755 diff --git a/teleforma/locale/fr/LC_MESSAGES/django.mo b/teleforma/locale/fr/LC_MESSAGES/django.mo index a9b175a7b6a523984d2d7b2a31c181564d522857..68127c16d5b7131cfb049d359d86f86eb1958eba 100644 GIT binary patch delta 6371 zcmZA5d3;V+9>?)3n^+>7h$JFGMC{85jT*I$it(bxR*Z>#sU>8o)Rc!I(^`i<_N}&3 z`@W5>p_VeL7*otd(NX)-sihe7^UeKb{+RoE{k+dP_uO-S=bZaI9v)|%&-Ppn^PBB( z)hyyT<#1v#$C*j_ZkSpfr%sgP6vw*AEvGRy##Wes6YT!y7*2f~7R6&&3QuDIUN*1W z{k!PzI3DK_1x@fAOQL_Y;{;+Dsvd)Wn1t$A6E(pbsD4c`2ve~HcEvK-7nSg6RR4*n z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6GopQQFNp||!ogfDT1(4{w3*XJ((`!|+EbVZ>)=SPVQ zqL|PXN30^+6Uzx*dTAOHb!@Eu#yg-_`Aeb;v5DB0Hzg*q`ejPDh+0H0F_-8?>>zUT zHpj$pMY0&ZrKzD6aOJHiCRonml#i3*H#zrzYp_5W8*!)wU#KHNc@ecOMF0d zBTf^4C3KB+@&1qXKPZPV^H6+)c#+shEFj9S!xS14N33CuxezB4d-P^kVv<-YRZ-Vp zi0R%EUt9QyxI(NY?i244^{uZzR zLOtRhv5ZKvfp1cNLX=-A)_#|Ub;K?rlD6YGn|MZyB}Nb}iKaveF_rj9 z^nLh(7S>gh2&3V3yr2fI_guVR;2-9d#3i=6NK1sZK1H&3IuXN&DvU0_@+oX5IuQGd fYF5n;Ecz;Ok8jb^=2) { + $tbody.find('tr:not(:first)').remove(); + $tbody.append('Voir la suite') + } + }); + }) + } +}); \ No newline at end of file diff --git a/teleforma/templates/quiz/category_list.html b/teleforma/templates/quiz/category_list.html new file mode 100644 index 00000000..e595e8bb --- /dev/null +++ b/teleforma/templates/quiz/category_list.html @@ -0,0 +1,18 @@ +{% extends 'teleforma/base.html' %} +{% load i18n %} +{% block title %}{% trans "All Quizzes" %}{% endblock %} + +{% block content %} +

{% trans "Category list" %}

+ + + +{% endblock %} 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..12b7b927 --- /dev/null +++ b/teleforma/templates/quiz/progress.html @@ -0,0 +1,86 @@ +{% extends "teleforma/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..29733ebd --- /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 %} +

+ Votre réponse est + + {{ 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 %} + +{% if question.category %}

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

{% endif %} + +

{{ 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_detail.html b/teleforma/templates/quiz/quiz_detail.html new file mode 100644 index 00000000..800afbc2 --- /dev/null +++ b/teleforma/templates/quiz/quiz_detail.html @@ -0,0 +1,20 @@ +{% extends 'teleforma/base.html' %} +{% load i18n %} +{% block title %} +{{ quiz.title }} +{% endblock %} + +{% block content %} + + +{% 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_list.html b/teleforma/templates/quiz/quiz_list.html new file mode 100644 index 00000000..0b163759 --- /dev/null +++ b/teleforma/templates/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/result.html b/teleforma/templates/quiz/result.html new file mode 100644 index 00000000..d5bb4d27 --- /dev/null +++ b/teleforma/templates/quiz/result.html @@ -0,0 +1,92 @@ +{% extends "teleforma/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 }}

+

Votre réponse est + + {{ 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 %} + +
+ + + {% 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..2dc0e25f --- /dev/null +++ b/teleforma/templates/quiz/single_complete.html @@ -0,0 +1,18 @@ +{% extends "teleforma/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/sitting_detail.html b/teleforma/templates/quiz/sitting_detail.html new file mode 100644 index 00000000..c76bf94d --- /dev/null +++ b/teleforma/templates/quiz/sitting_detail.html @@ -0,0 +1,59 @@ +{% extends 'teleforma/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/sitting_list.html b/teleforma/templates/quiz/sitting_list.html new file mode 100644 index 00000000..f29180ad --- /dev/null +++ b/teleforma/templates/quiz/sitting_list.html @@ -0,0 +1,54 @@ +{% extends 'teleforma/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/view_quiz_category.html b/teleforma/templates/quiz/view_quiz_category.html new file mode 100644 index 00000000..374a4663 --- /dev/null +++ b/teleforma/templates/quiz/view_quiz_category.html @@ -0,0 +1,23 @@ +{% extends 'teleforma/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/course_detail.html b/teleforma/templates/teleforma/course_detail.html index fe86cb0c..3f9c696a 100644 --- a/teleforma/templates/teleforma/course_detail.html +++ b/teleforma/templates/teleforma/course_detail.html @@ -18,31 +18,53 @@ $(document).ready(function(){ {% endblock courses %} {% block course %} +
+ + + + +

{% for c in courses %} {% with c.course as course %} {% for type in c.types %} + {% if course.quiz.all or type.name != 'Quiz' %}
{{ course.title }} - {{ type }}{% if course.description %} - {{ course.description }}{% endif %}
- {% if not user.correctors.all or user.is_staff %} - {% block conference %} - {% include "teleforma/inc/conference_list.html" %} - {% endblock %} + {% if type.name == 'Quiz' %} +
+ + + {% for quiz in course.quiz.all %} + + + {% endfor %} + +
{{quiz.title}}{{quiz.description}}
+
- {% block media %} - {% include "teleforma/inc/media_list.html" %} - {% endblock %} - {% endif %} + {% else %} + {% if not user.correctors.all or user.is_staff %} + {% block conference %} + {% include "teleforma/inc/conference_list.html" %} + {% endblock %} + + {% block media %} + {% include "teleforma/inc/media_list.html" %} + {% endblock %} + {% endif %} - {% block document %} - {% with forloop.counter as type_counter %} - {% include "teleforma/inc/document_list.html" %} - {% endwith %} - {% endblock %} + {% block document %} + {% with forloop.counter as type_counter %} + {% include "teleforma/inc/document_list.html" %} + {% endwith %} + {% endblock %} + {% endif %}
+ {% endif %} {% endfor %} {% endwith %} {% endfor %} diff --git a/teleforma/templates/teleforma/courses.html b/teleforma/templates/teleforma/courses.html index 50c05fca..fdc2f599 100644 --- a/teleforma/templates/teleforma/courses.html +++ b/teleforma/templates/teleforma/courses.html @@ -1,5 +1,6 @@ {% extends "telemeta/base.html" %} {% load teleforma_tags %} +{% load thumbnail %} {% load telemeta_utils %} {% load i18n %} @@ -73,7 +74,32 @@ $(document).ready(function(){ {% block course %} -
+
+ + {% autoescape off %} + {{ home_text }} + {% endautoescape %} + + {% if home_video.type == 'webm' %} +

{% if home_video.title %}{{ home_video.title }}{% else %}{{ home_video.course.title }}{% endif %}

+ + {% endif %} {% for c in courses %} {% with c.course as course %} @@ -89,14 +115,14 @@ $(document).ready(function(){ {% block media %} {% with "Passed conferences" as title %} - {% include "teleforma/inc/media_list.html" %} + {% include "teleforma/inc/media_list.html" with show_only=1 %} {% endwith %} {% endblock %} {% comment %} {% block webclass %} {% with "Web class" as title %} - {% include "teleforma/inc/media_list.html" %} + {% include "teleforma/inc/media_list.html" with show_only=1 %} {% endwith %} {% endblock %} {% endcomment %} @@ -106,7 +132,6 @@ $(document).ready(function(){ {% include "teleforma/inc/document_list.html" %} {% endwith %} {% endblock %} -
{% endfor %} {% endwith %} diff --git a/teleforma/templatetags/teleforma_tags.py b/teleforma/templatetags/teleforma_tags.py index 8b20662d..33d02a39 100644 --- a/teleforma/templatetags/teleforma_tags.py +++ b/teleforma/templatetags/teleforma_tags.py @@ -226,6 +226,8 @@ def untreated_scripts_count(user, period): @register.simple_tag def treated_scripts_count(user, period): + if not period: + return '' Q1 = Q(status=4, author=user, period=period) Q2 = Q(status=4, corrector=user, period=period) scripts = Script.objects.filter(Q1 | Q2) diff --git a/teleforma/views/core.py b/teleforma/views/core.py index 7f91d9d3..7d8e36f2 100644 --- a/teleforma/views/core.py +++ b/teleforma/views/core.py @@ -245,7 +245,7 @@ class HomeRedirectView(View): period = get_default_period(periods) return HttpResponseRedirect(reverse('teleforma-desk-period-list', kwargs={'period_id': period.id})) else: - HttpResponseRedirect(reverse('telemeta-admin')) + return HttpResponseRedirect(reverse('telemeta-admin')) else: return HttpResponseRedirect(reverse('teleforma-login')) @@ -296,6 +296,11 @@ class CourseListView(CourseAccessMixin, ListView): context['doc_types'] = DocumentType.objects.all() context['list_view'] = True context['courses'] = sorted(context['all_courses'], key=lambda k: k['date'], reverse=True)[:1] + home = Home.objects.all() + if home: + home = home[0] + context['home_text'] = home.text + context['home_video'] = home.video return context @method_decorator(login_required) -- 2.39.5