]> git.parisson.com Git - teleforma.git/commitdiff
add more progression bars, update colors, real percent update in answer progressbar
authoryomguy <yomguy@parisson.com>
Mon, 17 Dec 2012 00:57:59 +0000 (01:57 +0100)
committeryomguy <yomguy@parisson.com>
Mon, 17 Dec 2012 00:57:59 +0000 (01:57 +0100)
teleforma/static/teleforma/css/teleforma.css
teleforma/static/teleforma/js/charCount.js
teleforma/templates/teleforma/answer_form.html
teleforma/templates/teleforma/seminar_detail.html
teleforma/templates/teleforma/seminars.html
teleforma/templates/telemeta/base.html
teleforma/views/pro.py

index 2ca17c7bf0236a2653623c37c3fd1f014b068cfc..581e2663ac9f9ac7ad22b427d4930c4f30199660 100644 (file)
@@ -1680,29 +1680,6 @@ input,textarea{
     font-size: 1.2em;
     }
 
-
-.ui-progressbar  { 
-    height: 10px;
-   /*webkit rainbow gradient*/
-   background-image: -webkit-gradient(linear,  left top,  right top, 
-    color-stop(0.00, blue),
-    color-stop(25%, green),
-    color-stop(50%, yellow),
-    color-stop(75%, orange),
-    color-stop(1.00, red)
-    );
-
-    transform:rotate(180deg);
-    -ms-transform:rotate(180deg); /* IE 9 */
-    -moz-transform:rotate(180deg); /* Firefox */
-    -webkit-transform:rotate(180deg); /* Safari and Chrome */
-    -o-transform:rotate(180deg); /* Opera */  
-
-        -moz-border-radius: 8px 0px 8px 8px;
-        -webkit-border-radius: 8px 0px 8px 8px;
-        border-radius: 8px 0px 8px 8px;
-    }
-
 .messages {
     padding: 0.5em;
 }
@@ -1752,3 +1729,48 @@ form .exceed{
         border: 1px solid #adadad;
         color:#080;
     }
+
+.progress {
+    background-color: white;
+    -moz-border-radius: 8px 0px 8px 8px;
+    -webkit-border-radius: 8px 0px 8px 8px;
+    border-radius: 8px 0px 8px 8px;
+}
+
+.progress ul {
+    -moz-border-radius: 8px 0px 8px 8px;
+    -webkit-border-radius: 8px 0px 8px 8px;
+    border-radius: 8px 0px 8px 8px;
+    
+}
+
+.progress li {
+    font-size: 1.2em;
+}
+
+.ui-progressbar  {
+    margin-top: 0.5em; 
+    height: 10px;
+
+   /*webkit rainbow gradient*/
+   background-color: white;
+    -moz-border-radius: 8px 0px 8px 8px;
+    -webkit-border-radius: 8px 0px 8px 8px;
+    border-radius: 8px 0px 8px 8px;
+    }
+
+#progressbar-general .ui-progressbar-value { 
+    background-color: #4f628a;
+}
+
+
+#progressbar-seminar .ui-progressbar-value  { 
+    background-color: green;
+    }
+
+
+#progressbar-answer .ui-progressbar-value  { 
+    background-color: #bb0000;
+    }
+
index 5cc239f222f6b823f063897213d2f71c477d6ce9..5307208ce4ecb9feaad5f011825e5a588cb3da17 100644 (file)
@@ -28,7 +28,7 @@
                }; 
                        
                var options = $.extend(defaults, options); 
-               
+
                function calculate(obj){
                        var count = $(obj).val().length;
                        if(count >= options.necessary){
                        }
                        
                        $(obj).next().html(options.counterText + count + ' / ' + options.necessary);
+                       var percent = parseInt(count / options.necessary * 100);
+                       if ( percent >= 100 ) {
+                               percent = 100;
+                       }
+                       $('#answer-progress').html(percent);
+                       $('#progressbar-answer').progressbar({ value: percent });
                };
                                
                this.each(function() {                          
-                       $(this).after('<'+ options.counterElement +' id="counter" class="' + options.css + '">'+ options.counterText +'</'+ options.counterElement +'>');
+                       $(this).after('<'+ options.counterElement +' id="counter" class="' + options.css + '">'+ options.counterText +'</'+ options.counterElement +'>');                       
                        calculate(this);
                        $(this).keyup(function(){calculate(this)});
                        $(this).change(function(){calculate(this)});
index 35a4991e41533604a9ac9c9ddc99ff5fe437b5aa..1d6003744acfc16b8c0637947713bf30969d3199 100644 (file)
@@ -59,8 +59,29 @@ $(document).ready(function(){
 <a href="#" class="component_icon button icon_save"
    onclick="document.getElementById('_AnswerForm').submit();">{% trans "Save" %}</a>
 
-<a href="#" id="submit_button" class="component_icon button icon_ok"
-">{% trans "Submit it" %}</a>
+<a href="#" id="submit_button" class="component_icon button icon_ok">{% trans "Submit it" %}</a>
 
 {% endblock course_content %}
 
+
+{% block progress %}
+<div class="module">
+  <h3><img src="{{STATIC_URL}}teleforma/images/status.png" alt="status" style="vertical-align:middle" /> {% trans "Progress" %}</h3>
+ <div class="progress">
+  <ul>
+    <li>{% trans "General progress" %} : {{ total_progress }}%
+     <div id="progressbar-general"></div>
+    </li>
+    <li>{% trans "Seminar progress" %} : {{ seminar_progress }}%
+     <div id="progressbar-seminar"></div>
+    </li>
+    <li>{% trans "Answer progress" %} : <span id="answer-progress">0</span>%
+     <div id="progressbar-answer"></div>
+    </li>
+
+  </ul>
+
+ </div>
+</div>
+{% endblock progress %}
+
index 6b3294da1f084e90d3de5ae9bd2f3c4e616a3305..bc7621d2a69d10c3563a6951870692b2a1724259 100644 (file)
 </div>
 {% endblock course %}
 
-{% block local_progress %}
+
+{% block progress %}
 <div class="module">
-  <h3><img src="{{STATIC_URL}}teleforma/images/status.png" alt="status" style="vertical-align:middle" /> {% trans "Progression" %} : {{ 100|sub:progress }}%</h3>
+  <h3><img src="{{STATIC_URL}}teleforma/images/status.png" alt="status" style="vertical-align:middle" /> {% trans "Progress" %}</h3>
  <div style="background: white;">
-  <div id="progressbar"></div>
+  <ul>
+    <li>{% trans "General progress" %} : {{ total_progress }}%
+     <div id="progressbar-general"></div>
+    </li>
+    <li>{% trans "Seminar progress" %} : {{ seminar_progress }}%
+     <div id="progressbar-seminar"></div>
+    </li>
+  </ul>
  </div>
 </div>
-{% endblock local_progress %}
\ No newline at end of file
+{% endblock progress %}
+
index 948abe5a110d63c56a4c2bb6c23cf0d72e344d16..663506b95ae46926080f3a9e8a0aaee9794496c4 100644 (file)
@@ -15,6 +15,21 @@ $(function () {
 </script>
 {% endblock extra_javascript %}
 
+{% block infra_javascript %}
+<script type="text/javascript">
+$(function() {
+        $( "#progressbar-general" ).progressbar({
+            value: {{ total_progress }}
+        });
+    });
+$(function() {
+        $( "#progressbar-seminar" ).progressbar({
+            value: {{ seminar_progress }}
+        });
+    });
+</script>
+{% endblock infra_javascript %}
+
 {% block content %}
 
 <div id="module-set-left" style="width: 18%">
@@ -93,14 +108,18 @@ $(function () {
 
 <div id="module-set" style="width: 22%">
 
-{% block local_progress %}
+{% block progress %}
 <div class="module">
   <h3><img src="{{STATIC_URL}}teleforma/images/status.png" alt="status" style="vertical-align:middle" /> {% trans "Informations" %}</h3>
  <div style="background: white;">
-  <div id="progressbar"></div>
+  <ul>
+    <li>{% trans "General progress" %} : {{ total_progess }}
+     <div id="progressbar-general"></div>
+    </li>
+  </ul>
  </div>
 </div>
-{% endblock local_progress %}
+{% endblock progress %}
 
 {% block status %}
 {% get_telecaster as telecaster %}
index ac56ee9de594c3b3ed77c774dd4d2144d4d02cfc..ed4a869dfacf8fd3983360339050cf215e0eff13 100644 (file)
 <script src="{{ STATIC_URL }}teleforma/js/jquery-ui.js" type="text/javascript"></script>
 <script src="{{ STATIC_URL }}teleforma/js/jquery.expander.min.js" type="text/javascript"></script>
 <script src="{{ STATIC_URL }}teleforma/js/messi.min.js" type="text/javascript"></script>
-<script>
-$(function() {
-        $( "#progressbar" ).progressbar({
-            value: {{ progress }}
-        });
-    });
-</script>
 
 {% if user.is_authenticated %}
 <script type='text/javascript'>var CURRENT_USER_NAME="{{ user.username }}";</script>
@@ -72,6 +65,7 @@ $(function() {
 {% endblock %}
 
 {% block extra_javascript %}{% endblock %}
+{% block infra_javascript %}{% endblock %}
 
 </head>
 
index 9fa958cd6f30baf90f983ade188088ee9691d7e9..7bde06011b870b93be9fc13290688e5182391ce4 100644 (file)
@@ -63,7 +63,6 @@ def get_seminars(user):
 
 def seminar_progress(user, seminar):    
     """return the user progress of a seminar in percent
-    WARNING! the result is 100-progress so that we can customize the progress bar background.
     """
 
     progress = 0
@@ -84,26 +83,27 @@ def seminar_progress(user, seminar):
             progress += question.weight
 
     if total != 0:
-        return 100-int(progress*100/total)
+        return int(progress*100/total)
     else:
-        return 100
+        return 0
 
 
 def total_progress(user):
     """return the user progress of all seminars in percent"""
 
-    revisions = user.seminar_revision.all()
     progress = 0
-    n = 0
-
-    for revision in revisions:
-        progress += revision.progress
-        n += 1
+    auditor = user.auditor.all()
+    if auditor:
+        seminars = auditor[0].seminars.all()        
+    elif user.is_superuser or user.is_staff:
+        seminars = Seminar.objects.all()
+    for seminar in seminars:
+        progress += seminar_progress(user, seminar)
 
-    if n:
-        return 100-int(progress/n)
+    if seminars:
+        return int(progress/len(seminars))
     else:
-        return 100
+        return 0
 
 def seminar_validated(user, seminar):
     validated = []
@@ -129,7 +129,7 @@ class SeminarView(DetailView):
         context = super(SeminarView, self).get_context_data(**kwargs)
         seminar = self.get_object()
         context['all_seminars'] = get_seminars(self.request.user)
-        context['progress'] = seminar_progress(self.request.user, seminar)
+        context['seminar_progress'] = seminar_progress(self.request.user, seminar)
         context['total_progress'] = total_progress(self.request.user)
         context['validated'] = seminar_validated(self.request.user, seminar)
         return context
@@ -146,9 +146,8 @@ class SeminarsView(ListView):
 
     def get_context_data(self, **kwargs):
         context = super(SeminarsView, self).get_context_data(**kwargs)
-        user = self.request.user
         context['all_seminars'] = self.seminars
-        context['total_progress'] = total_progress(user)
+        context['total_progress'] = total_progress(self.request.user)
         return context
 
     @method_decorator(login_required)
@@ -226,7 +225,8 @@ class AnswerView(FormView):
         context['all_seminars'] = get_seminars(self.request.user)
         context['question'] = self.question
         context['seminar'] = self.question.seminar
-        context['progress'] = seminar_progress(self.request.user, self.question.seminar)
+        context['seminar_progress'] = seminar_progress(self.request.user, self.question.seminar)
+        context['total_progress'] = total_progress(self.request.user)
         return context
 
     def get_success_url(self):
@@ -247,7 +247,8 @@ class MediaPackageView(DetailView):
         context['all_seminars'] = all_seminars
         context['seminar'] = seminar
         context['media_package'] = media_package
-        context['progress'] = seminar_progress(self.request.user, seminar)
+        context['seminar_progress'] = seminar_progress(self.request.user, seminar)
+        context['total_progress'] = total_progress(self.request.user)
         return context
 
     @method_decorator(login_required)