From: Gael Le Mignot Date: Tue, 19 Dec 2017 14:17:03 +0000 (+0100) Subject: Various fixes and additions on remaining steps, quiz, and disabling download link... X-Git-Tag: 2.8.1-pro~213 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=1cbd856d7fae9a838f477fd4ed884f1bc16dd881;p=teleforma.git Various fixes and additions on remaining steps, quiz, and disabling download link for non-admin --- diff --git a/teleforma/context_processors.py b/teleforma/context_processors.py index 13108098..bab539b5 100644 --- a/teleforma/context_processors.py +++ b/teleforma/context_processors.py @@ -36,20 +36,42 @@ from teleforma.views.core import * -def seminar_progress(user, seminar): +def seminar_progress(user, seminar, more=False): """return the user progress of a seminar in percent + if more is True, return additionals informations """ progress = 0 total = 0 - - objects = [seminar.docs_1, seminar.docs_2, seminar.medias, seminar.docs_correct] - for obj in objects: + missing_steps = set() + + objects = [ + { + 'obj': seminar.docs_1, + 'step': '1' + }, + { + 'obj': seminar.medias, + 'step': '2' + }, + { + 'obj': seminar.docs_2, + 'step': '3' + }, + { + 'obj': seminar.docs_correct, + 'step': '5' + }] + for item in objects: + obj = item['obj'] + step = item['step'] for item in obj.all(): if item.weight: total += item.weight if user in item.readers.all(): progress += item.weight + else: + missing_steps.add(step) questions = Question.objects.filter(seminar=seminar, status=3) for question in questions: @@ -59,6 +81,8 @@ def seminar_progress(user, seminar): validated=True, treated=True) if answer: progress += question.weight + else: + missing_steps.add('4') if seminar.quiz: quiz_weight = 3 @@ -66,11 +90,19 @@ def seminar_progress(user, seminar): total += quiz_weight if quiz_validations: progress += quiz_weight + else: + missing_steps.add('2bis') if total != 0: - return int(progress*100/total) + progress = int(progress*100/total) + else: + progress = 0 + if not more: + return progress else: - return 0 + return {'progress':progress, 'missing_steps':missing_steps} + + def seminar_validated(user, seminar): validated = [] @@ -78,7 +110,7 @@ def seminar_validated(user, seminar): if seminar.quiz: quiz_validations = QuizValidation.objects.filter(user=user, quiz=seminar.quiz, validated=True) if not quiz_validations: - return False + return False if questions: for question in questions: answers = Answer.objects.filter(question=question, user=user, diff --git a/teleforma/locale/fr/LC_MESSAGES/django.mo b/teleforma/locale/fr/LC_MESSAGES/django.mo index 920cb5c2..ee44003e 100644 Binary files a/teleforma/locale/fr/LC_MESSAGES/django.mo and b/teleforma/locale/fr/LC_MESSAGES/django.mo differ diff --git a/teleforma/locale/fr/LC_MESSAGES/django.po b/teleforma/locale/fr/LC_MESSAGES/django.po index ce4a7b6e..d9e6d432 100644 --- a/teleforma/locale/fr/LC_MESSAGES/django.po +++ b/teleforma/locale/fr/LC_MESSAGES/django.po @@ -2111,11 +2111,13 @@ msgstr "" #: views/pro.py:190 msgid "" "Your connexion time is not sufficient. In order to get your testimonial, you " -"have to work at least the time required for this seminar." +"still have to work at least %(time)s." msgstr "" -"Votre de temps de connexion est insuffisant. Afin d'obtenir votre " -"attestation vous devez consacrer au moins le temps validé pour ce séminaire " -"à l'accomplissement de votre formation" +"Afin d'obtenir votre attestation vous devez consacrer au moins %(time)s, soit le temps validé " +"pour ce séminaire à l'accomplissement de votre formation." + +msgid "You still need to complete step %(step)s in order to get yout testimonial." +msgstr "Vous devez encore terminer l'étape %(step)s avant de valider votre formation." #: views/pro.py:255 msgid "You have successfully saved your answer." diff --git a/teleforma/templates/teleforma/course_media.html b/teleforma/templates/teleforma/course_media.html index 5c91979a..7393173c 100644 --- a/teleforma/templates/teleforma/course_media.html +++ b/teleforma/templates/teleforma/course_media.html @@ -160,4 +160,4 @@ $(document).ready(function(){ {% include "teleforma/inc/chat_room.html" %} {% endwith %} {% endif %} -{% endblock chat %} \ No newline at end of file +{% endblock chat %} diff --git a/teleforma/templates/teleforma/inc/document_simple_list.html b/teleforma/templates/teleforma/inc/document_simple_list.html index 83df34bb..00c70f1e 100644 --- a/teleforma/templates/teleforma/inc/document_simple_list.html +++ b/teleforma/templates/teleforma/inc/document_simple_list.html @@ -6,7 +6,7 @@ {% for doc in docs.all %} {% if doc.file %}{% endif %} {{ doc.title }}{% if doc.file %}{% endif %} - {% if doc.file %}{% if user in doc.readers.all %} {% endif %}{% endif %} + {% if doc.file %}{% if user in doc.readers.all %}{% else %} {% endif %}{% endif %} {% endfor %} diff --git a/teleforma/templates/teleforma/inc/media_list.html b/teleforma/templates/teleforma/inc/media_list.html index dea22473..c96bbd86 100644 --- a/teleforma/templates/teleforma/inc/media_list.html +++ b/teleforma/templates/teleforma/inc/media_list.html @@ -51,7 +51,7 @@ {% elif not media.is_published and user.is_staff %} {% endif %} - {% if media.item.file %} + {% if media.item.file and user.is_staff %} diff --git a/teleforma/templates/teleforma/inc/media_package_list.html b/teleforma/templates/teleforma/inc/media_package_list.html index 7584f6d1..9f58496e 100644 --- a/teleforma/templates/teleforma/inc/media_package_list.html +++ b/teleforma/templates/teleforma/inc/media_package_list.html @@ -42,12 +42,14 @@ {% if user in media.readers.all %} + {% else %} + {% endif %} - {% if media.item.file %} + diff --git a/teleforma/templates/teleforma/inc/question_list.html b/teleforma/templates/teleforma/inc/question_list.html index f87b7b7b..507a5a0f 100644 --- a/teleforma/templates/teleforma/inc/question_list.html +++ b/teleforma/templates/teleforma/inc/question_list.html @@ -23,6 +23,8 @@ {% elif question|submitted:user and question|validated:user %} + {% else %} + {% endif %} diff --git a/teleforma/templates/teleforma/inc/quiz_list.html b/teleforma/templates/teleforma/inc/quiz_list.html index 6745d308..a6ba8aea 100644 --- a/teleforma/templates/teleforma/inc/quiz_list.html +++ b/teleforma/templates/teleforma/inc/quiz_list.html @@ -10,13 +10,15 @@ {% endif %} - {% if seminar.quiz|quiz_validated:user %} - {% trans "validé le" %} {{ seminar.quiz|quiz_validated:user }} + {% if seminar|quiz_validated:user %} + {% trans "validé le" %} {{ seminar|quiz_validated:user }} {% endif %} - {% if seminar.quiz|quiz_validated:user %} + {% if seminar|quiz_validated:user %} + {% else %} + {% endif %} diff --git a/teleforma/templatetags/teleforma_tags.py b/teleforma/templatetags/teleforma_tags.py index 60a9bb55..415d731b 100644 --- a/teleforma/templatetags/teleforma_tags.py +++ b/teleforma/templatetags/teleforma_tags.py @@ -242,8 +242,11 @@ def validated(question, user): return '' @register.filter -def quiz_validated(quiz, user): - validations = QuizValidation.objects.filter(quiz=quiz, user=user, validated=True) +def quiz_validated(seminar, user): + quiz = seminar.quiz + startdate = seminar.date_added + enddate = seminar.expiry_date + validations = QuizValidation.objects.filter(quiz=quiz, user=user, validated=True,date_validated__range=[startdate, enddate]) if validations: return validations[0].date_validated else: diff --git a/teleforma/views/pro.py b/teleforma/views/pro.py index 2285561a..da13bacd 100644 --- a/teleforma/views/pro.py +++ b/teleforma/views/pro.py @@ -197,20 +197,29 @@ class SeminarView(SeminarAccessMixin, DetailView): # mess.moderation_status = 'a' # mess.save() # notify_user(mess, 'acceptance') + progress_data = seminar_progress(user, seminar, more=True) - - progress = seminar_progress(user, seminar) + progress = progress_data['progress'] + missing_steps = progress_data['missing_steps'] context['seminar_progress'] = progress context['seminar_validated'] = validated delta_sec = context['delta_sec'] if progress == 100 and not validated and self.template_name == 'teleforma/seminar_detail.html': messages.info(self.request, _("You have successfully terminated your e-learning seminar. A training testimonial will be available as soon as the pedagogical team validate all your answers (48h maximum).")) - elif progress < 100 and validated and self.template_name == 'teleforma/seminar_detail.html': + elif progress < 100 and validated and self.template_name == 'teleforma/seminar_detail.html' and missing_steps == set('5'): messages.info(self.request, _("All your answers have been validated. You can now read the corrected documents (step 5).")) elif progress == 100 and validated and delta_sec >= 0 and self.template_name == 'teleforma/seminar_detail.html': messages.info(self.request, _("You have successfully terminated all steps of your e-learning seminar. You can now download your training testimonial below.")) + elif len(missing_steps) == 1: + messages.warning(self.request, _("You still need to complete step %(step)s in order to get yout testimonial.") % {'step':missing_steps.pop()}) if progress == 100 and validated and delta_sec < 0: - messages.info(self.request, _("Your connexion time is not sufficient. In order to get your testimonial, you have to work at least the time required for this seminar.")) + minutes = -delta_sec / 60 + hours = minutes / 60 + missing = "%d minutes" % minutes + if hours >= 1: + missing = "%dh%02d" % (hours, minutes % 60) + messages.warning(self.request, _("Your connexion time is not sufficient. In order to get your testimonial, you " + "still have to work at least %(time)s.") % {'time':missing}) return context