]> git.parisson.com Git - teleforma.git/commitdiff
fix period for score list
authorGuillaume Pellerin <yomguy@parisson.com>
Tue, 14 Jul 2015 17:07:53 +0000 (19:07 +0200)
committerGuillaume Pellerin <yomguy@parisson.com>
Tue, 14 Jul 2015 17:08:06 +0000 (19:08 +0200)
teleforma/exam/views.py
teleforma/templates/telemeta/base.html

index 979877a93a5794a2121436be5c7bb646b989abba..836454773fa54dceb71761deb3c5ccdde93e3606 100644 (file)
@@ -229,9 +229,10 @@ class ScriptsScoreAllView(ScriptsTreatedView):
 
     def get_context_data(self, **kwargs):
         context = super(ScriptsScoreAllView, self).get_context_data(**kwargs)
+        period = Period.objects.get(id=self.kwargs['period_id'])
 
         if self.request.user.is_staff or self.request.user.professor.all():
-            scripts = Script.objects.all().exclude(score=None)
+            scripts = Script.objects.filter(period=period).exclude(score=None)
         else:
             scripts = self.get_queryset()
 
@@ -252,14 +253,14 @@ class ScriptsScoreAllView(ScriptsTreatedView):
 
         data = []
         for session in sessions:
-            scripts = Script.objects.filter(session=session).exclude(score=None)
+            scripts = Script.objects.filter(session=session, period=period).exclude(score=None)
             data.append(np.mean([s.score for s in scripts]))
         scores.append({'name': 'Moyenne generale', 'data': data})
 
         for script_type in ScriptType.objects.all():
             data = []
             for session in sessions:
-                scripts = Script.objects.filter(session=session, type=script_type).exclude(score=None)
+                scripts = Script.objects.filter(session=session, period=period, type=script_type).exclude(score=None)
                 data.append(np.mean([s.score for s in scripts]))
             scores.append({'name': 'Moyenne ' + script_type.name, 'data': data})
 
@@ -273,9 +274,10 @@ class ScriptsScoreCourseView(ScriptsScoreAllView):
     def get_context_data(self, **kwargs):
         context = super(ScriptsScoreCourseView, self).get_context_data(**kwargs)
         course = Course.objects.get(id=self.kwargs['course_id'])
+        period = Period.objects.get(id=self.kwargs['period_id'])
 
         if self.request.user.is_staff or self.request.user.professor.all():
-            scripts = Script.objects.all().filter(course=course).exclude(score=None)
+            scripts = Script.objects.all().filter(course=course, period=period).exclude(score=None)
         else:
             scripts = self.get_queryset().filter(course=course)
 
@@ -296,14 +298,14 @@ class ScriptsScoreCourseView(ScriptsScoreAllView):
 
         data = []
         for session in sessions:
-            scripts = Script.objects.filter(session=session, course=course).exclude(score=None)
+            scripts = Script.objects.filter(session=session, course=course, period=period).exclude(score=None)
             data.append(np.mean([s.score for s in scripts]))
         scores.append({'name':'Moyenne generale', 'data': data})
 
         for script_type in ScriptType.objects.all():
             data = []
             for session in sessions:
-                scripts = Script.objects.filter(session=session, type=script_type, course=course).exclude(score=None)
+                scripts = Script.objects.filter(session=session, type=script_type, course=course, period=period).exclude(score=None)
                 data.append(np.mean([s.score for s in scripts]))
             scores.append({'name': 'Moyenne ' + script_type.name, 'data': data})
 
index 9cf52162248112a81554eb04cc83e679df88719a..bb8baf388dac5521c25414e56b9ce86491df7c56 100644 (file)
@@ -142,18 +142,14 @@ alt="logo" />
   {% endif %}
 
  {% if user.is_authenticated %}
-  {% if user.is_staff %}
+  {% if user.is_superuser %}
   <li><a href="{% url telemeta-admin-general %}" class="blue">{% trans "Admin" %}</a></li>
   {% else %}
    <li><a href="{% url teleforma-help %}" class="blue">{% trans "Help" %}</a></li>
  {% endif %}
 
- <li style="a.active{background-image:{{ STATIC_URL }}telemeta/images/user_tr_bk.png; background-repeat: no-repeat;
-    background-position: 1ex .5ex;}"><a href="#accounts#" class="blue">{% if user.first_name and user.last_name %}
- {{ user.first_name }} {{ user.last_name }}
- {% else %}
- {{ user.username }}
- {% endif %}</a>
+ <li style="a.active{background-image:{{ STATIC_URL }}telemeta/images/user_tr_bk.png; background-repeat: no-repeat; background-position: 1ex .5ex;}">
+    <a href="#accounts#" class="blue">{% if user.first_name and user.last_name %}{{ user.first_name }} {{ user.last_name }}{% else %}{{ user.username }}{% endif %}</a>
     <ul>
     <li><a href="{% url telemeta-profile-detail user.username %}" class="yellow">{% trans "Profile" %}</a></li>
     {% if user.is_staff %}