]> git.parisson.com Git - teleforma.git/commitdiff
chronometer https://trackers.pilotsystems.net/probarreau/0262
authorYoan Le Clanche <yoan@ellington.pilotsystems.net>
Fri, 22 Dec 2017 09:37:12 +0000 (10:37 +0100)
committerYoan Le Clanche <yoan@ellington.pilotsystems.net>
Fri, 22 Dec 2017 09:37:12 +0000 (10:37 +0100)
teleforma/static/teleforma/js/application.js
teleforma/views/pro.py

index 7127d3ffdc1e3021fd0822e580f6a5974476df07..c5f744bca57f56caf8707bd350a0b07511ae0f47 100644 (file)
@@ -30,23 +30,35 @@ var rainbow = new Rainbow();
 rainbow.setSpectrum('#bb0000', '#e65911', '#f3ad17', 'green');
 
 
+function pad(num) {
+    var s = num+"";
+    while (s.length < 2) s = "0" + s;
+    return s;
+}
+
 $(window).ready(function() {
        var pageHeight = $(window).height();
        var navHeight = pageHeight - 125;
        $('#desk_center').css({"max-height": navHeight + 'px'});
-
-       // chronometer
-       $('.autotimer').each(function(){
-               var timer = new Timer();
-               $timerSpan = $(this);
-               var value = $timerSpan.text()
-               // convert text value of timer to seconds
-               var timeArray = value.split(':');
-               var seconds = parseInt(timeArray[0], 10) * 3600 + parseInt(timeArray[1], 10) * 60 + parseInt(timeArray[2], 10);
-               timer.start({precision: 'seconds', startValues: {seconds: seconds}});
-               $timerSpan.html(timer.getTimeValues().toString());
-               timer.addEventListener('secondsUpdated', function (e) {
-                       $timerSpan.html(timer.getTimeValues().toString());
-               });
-       });
+        launchTimer();
 });
+
+
+var launchTimer = function(){
+        // chronometer
+        $('.autotimer').each(function(){
+                window.timer = new Timer();
+                $timerSpan = $(this);
+                var value = $timerSpan.text()
+                // convert text value of timer to seconds
+                var timeArray = value.split(':');
+                var seconds = parseInt(timeArray[0], 10) * 3600 + parseInt(timeArray[1], 10) * 60 + parseInt(timeArray[2], 10);
+                window.timer.start({precision: 'seconds', startValues: {seconds: seconds}}); 
+                window.timer.addEventListener('secondsUpdated', function (e) {
+                    var timeValues = window.timer.getTimeValues();
+                    var hours = timeValues.days * 24 + timeValues.hours
+                    $timerSpan.html(pad(hours) + ':' + pad(timeValues.minutes) + ':' + pad(timeValues.seconds));
+                });
+        });
+}
+
index da13bacd6ebc07065b8a486f7e7d68547c7169b6..9f40ceba65fc27099f88ba0f5f46dcd508522d0e 100644 (file)
@@ -112,6 +112,9 @@ def get_seminar_delta(user, seminar):
     delta = timer - datetime.timedelta(seconds=seminar.duration.as_seconds())
     return delta.total_seconds()
 
+def export_seminar_revisions():
+    pass
+
 
 class SeminarAccessMixin(object):
 
@@ -126,7 +129,11 @@ class SeminarAccessMixin(object):
         timer = get_seminar_timer(user, seminar)
         delta_sec = get_seminar_delta(user, seminar)
         context['delta_sec'] = delta_sec
-        context['timer'] = str(timer).split('.')[0]
+        totsec = timer.total_seconds()
+        h = totsec//3600
+        m = (totsec%3600) // 60
+        sec =(totsec%3600)%60
+        context['timer'] = "%d:%d:%d" %(h,m,sec)
         return context
 
     def render_to_response(self, context):
@@ -204,6 +211,7 @@ class SeminarView(SeminarAccessMixin, DetailView):
         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' and missing_steps == set('5'):