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:
validated=True, treated=True)
if answer:
progress += question.weight
+ else:
+ missing_steps.add('4')
if seminar.quiz:
quiz_weight = 3
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 = []
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,
#: 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."
{% include "teleforma/inc/chat_room.html" %}
{% endwith %}
{% endif %}
-{% endblock chat %}
\ No newline at end of file
+{% endblock chat %}
{% 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>
{% 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>
<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>
<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>
{% 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>
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:
# 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