]> git.parisson.com Git - teleforma.git/commitdiff
Various fixes and additions on remaining steps, quiz, and disabling download link...
authorGael Le Mignot <gael@pilotsystems.net>
Tue, 19 Dec 2017 14:17:03 +0000 (15:17 +0100)
committerGael Le Mignot <gael@pilotsystems.net>
Tue, 19 Dec 2017 14:17:03 +0000 (15:17 +0100)
teleforma/context_processors.py
teleforma/locale/fr/LC_MESSAGES/django.mo
teleforma/locale/fr/LC_MESSAGES/django.po
teleforma/templates/teleforma/course_media.html
teleforma/templates/teleforma/inc/document_simple_list.html
teleforma/templates/teleforma/inc/media_list.html
teleforma/templates/teleforma/inc/media_package_list.html
teleforma/templates/teleforma/inc/question_list.html
teleforma/templates/teleforma/inc/quiz_list.html
teleforma/templatetags/teleforma_tags.py
teleforma/views/pro.py

index 13108098b859aa1317bb22b5cb04c28440c6503f..bab539b57c3afed4c64a1e669a76e317eacc157e 100644 (file)
 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,
index 920cb5c29a5891ef623f1bd379ae08b02200c5ac..ee44003ed2048c10a91526247473cacb9767d59a 100644 (file)
Binary files a/teleforma/locale/fr/LC_MESSAGES/django.mo and b/teleforma/locale/fr/LC_MESSAGES/django.mo differ
index ce4a7b6e05f030b41b4fabc989a8c6e02df3ae1e..d9e6d4321d98ff40a94e5c14fff858a747b8d163 100644 (file)
@@ -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."
index 5c91979aa5d24d57559f61d54f72f0682db772fa..7393173c55de422a41509ec3db95b3288eb94c42 100644 (file)
@@ -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 %}
index 83df34bb3c3639a70482f361fe1fc5073533e563..00c70f1e517b2ac70ab0b0ae1b7a7da9a682e824 100644 (file)
@@ -6,7 +6,7 @@
         {% for doc in docs.all %}
             <tr>
             <td {% if forloop.first %}class="border-top"{% endif %} width="90%">{% if doc.file %}<a href="{% url teleforma-document-view seminar.id doc.id %}" target="_blank" title="{% trans "View" %}"><img src="{{ STATIC_URL }}/teleforma/images/application-msword.png" style="vertical-align:middle" alt="" />{% endif %} {{ doc.title }}{% if doc.file %}</a>{% endif %}</td>
-            <td {% if forloop.first %}class="border-top"{% endif %} width="10%" align="center">{% if doc.file %}{% if user in doc.readers.all %}<img src="{{ STATIC_URL }}telemeta/images/ok.png" style="vertical-align:middle" alt="" title="{% trans ' viewed' %}" /> {% endif %}<a href="{% url teleforma-document-download seminar.id doc.id %}"><img src="{{ STATIC_URL }}teleforma/images/download.png" style="vertical-align:middle" alt="" title="{% trans "Download" %}" /></a>{% endif %}</td>
+            <td {% if forloop.first %}class="border-top"{% endif %} width="10%" align="center">{% if doc.file %}{% if user in doc.readers.all %}<img src="{{ STATIC_URL }}telemeta/images/ok.png" style="vertical-align:middle" alt="" title="{% trans ' viewed' %}" />{% else %}<img src="{{ STATIC_URL }}telemeta/images/delete.png" style="vertical-align:middle" alt="" title="{% trans ' not viewed yet' %}" /> {% endif %}<a href="{% url teleforma-document-download seminar.id doc.id %}"><img src="{{ STATIC_URL }}teleforma/images/download.png" style="vertical-align:middle" alt="" title="{% trans "Download" %}" /></a>{% endif %}</td>
             </tr>
         {% endfor %}
     </tbody>
index dea22473fdb8569ad1f4c544122158393168fd7a..c96bbd86b4f81530d33d5761e3a226831d9f2dd4 100644 (file)
@@ -51,7 +51,7 @@
             {% elif not media.is_published and user.is_staff %}
              <img src="{{ STATIC_URL }}telemeta/images/delete.png" style="vertical-align:middle" alt="" title="{% trans ' rejected' %}" />
             {% endif %}
-            {% if media.item.file %}
+            {% if media.item.file and user.is_staff %}
              <a href="{{ MEDIA_URL|set_host:HOST }}{{ media.item.file }}">
               <img src="{{ STATIC_URL }}teleforma/images/download_media.png" style="vertical-align:middle" alt="" title="{% trans "Download" %}" />
              </a>
index 7584f6d1db7560245ea9f9d4d341144322ade32b..9f58496e99de2a69353038ce8b732347554d9f65 100644 (file)
             <td {% if forloop.first %}class="border-top"{% endif %} width="10%" align="center">
             {% if user in media.readers.all %}
              <img src="{{ STATIC_URL }}telemeta/images/ok.png" style="vertical-align:middle" alt="" title="{% trans ' viewed' %}" />
+             {% else %}
+                <img src="{{ STATIC_URL }}telemeta/images/delete.png" style="vertical-align:middle" alt="" title="{% trans ' not viewed yet' %}" />
             {% endif %}
-            {% if media.item.file %}
+            <!--{% if media.item.file %}
              <a href="{{ MEDIA_URL }}{{ media.item.file }}">
               <img src="{{ STATIC_URL }}teleforma/images/download_media.png" style="vertical-align:middle" alt="" title="{% trans "Download" %}" />
              </a>
-            {% endif %}
+            {% endif %}-->
             </td>
             </tr>
 
index f87b7b7b377bf424d7fed8c4af2d290fa0757e01..507a5a0f6d48cb0707d30c42408ca3c75504eaf5 100644 (file)
@@ -23,6 +23,8 @@
                        <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" %}" />
+                               {% else %}
+                                       <img src="{{ STATIC_URL }}telemeta/images/delete.png" style="vertical-align:middle" alt="" title="{% trans ' not viewed yet' %}" />
                {% endif %}
             </td>
             </tr>
index 6745d308b401b401053f00a374306ebb6f42bf18..a6ba8aeabca9847c02cd55825b9bad9757f6dd42 100644 (file)
                 {% endif %}
             </td>
             <td class="border-top"width="60%">
-               {% 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 %}
             </td>
             <td class="border-top" width="5%" align="center">
-               {% if seminar.quiz|quiz_validated:user %}
+               {% if seminar|quiz_validated:user %}
                        <img src="{{ STATIC_URL }}telemeta/images/ok.png" style="vertical-align:middle" alt="" title="{% trans "Validated" %}" />
+                {% else %}
+                    <img src="{{ STATIC_URL }}telemeta/images/delete.png" style="vertical-align:middle" alt="" title="{% trans ' not viewed yet' %}" />
                {% endif %}
             </td>
             </tr>
index 60a9bb557cfed4849bf70c558479af2e414bf780..415d731bb784e11b23fc867d38599f35c10cd62c 100644 (file)
@@ -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:
index 2285561a4c69597549a953e10bc994ae9ada3776..da13bacd6ebc07065b8a486f7e7d68547c7169b6 100644 (file)
@@ -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