]> git.parisson.com Git - teleforma.git/commitdiff
add nvd3 scoring prototype
authorGuillaume Pellerin <yomguy@parisson.com>
Thu, 28 May 2015 13:40:56 +0000 (15:40 +0200)
committerGuillaume Pellerin <yomguy@parisson.com>
Thu, 28 May 2015 13:40:56 +0000 (15:40 +0200)
teleforma/exam/templates/exam/scores.html [new file with mode: 0644]
teleforma/exam/templates/exam/scripts.html
teleforma/exam/urls.py
teleforma/exam/views.py

diff --git a/teleforma/exam/templates/exam/scores.html b/teleforma/exam/templates/exam/scores.html
new file mode 100644 (file)
index 0000000..9724164
--- /dev/null
@@ -0,0 +1,24 @@
+{% extends "exam/scripts.html" %}
+{% load telemeta_utils %}
+{% load teleforma_tags %}
+{% load static %}
+{% load nvd3_tags %}
+{% load i18n %}
+
+{% block extra_javascript %}
+<link media="all" href="{{ STATIC_URL }}teleforma/lib/nvd3/build/nv.d3.min.css" rel="stylesheet">
+<script src="{{ STATIC_URL }}teleforma/lib/d3/d3.min.js"></script>
+<script src="{{ STATIC_URL }}teleforma/lib/nvd3/build/nv.d3.min.js"></script>
+{% load_chart data.charttype data.chartdata data.chartcontainer data.extra %}
+{% endblock extra_javascript %}
+
+{% block answers %}
+
+<div class="course_title">
+{% trans "Scores" %}
+</div>
+<br />
+
+{% include_container data.chartcontainer 400 '100%' %}
+
+{% endblock answers %}
index a51d712b956c2eaadf2d189a42bc265e8c3beedf..68add6db39a52eb153d9a419ceb28abd11831333 100644 (file)
@@ -25,6 +25,7 @@
    <li><a href="{% url teleforma-exam-scripts-pending period.id %}">{% trans "Pending" %}{% if user.is_staff or user.quotass.all %}{% untreated_scripts_count user period %}{% endif %}</a></li>
    <li><a href="{% url teleforma-exam-scripts-treated period.id %}">{% trans "Marked" %}{% if not user.is_staff and not user.quotas.all %}{% treated_scripts_count user period %}{% endif %}</a></li>
    <li><a href="{% url teleforma-exam-scripts-rejected period.id %}">{% trans "Rejected" %}</a></li>
+   <li><a href="{% url teleforma-exam-scripts-scores period.id %}">{% trans "Scores" %}</a></li>
   {% endblock courses %}
   </ul>
  </div>
index 43292404fc23ce264108224353ccbc20f0778ce3..61ee45d951a4df2bb94c00bbac7162495e642a98 100644 (file)
@@ -55,6 +55,7 @@ urlpatterns = patterns('',
     url(r'^exam/periods/(?P<period_id>.*)/scripts_pending/$', ScriptsPendingView.as_view(), name="teleforma-exam-scripts-pending"),
     url(r'^exam/periods/(?P<period_id>.*)/scripts_treated/$', ScriptsTreatedView.as_view(), name="teleforma-exam-scripts-treated"),
     url(r'^exam/periods/(?P<period_id>.*)/scripts_rejected/$', ScriptsRejectedView.as_view(), name="teleforma-exam-scripts-rejected"),
+    url(r'^exam/periods/(?P<period_id>.*)/scripts_scores/$', ScriptsScoreView.as_view(), name="teleforma-exam-scripts-scores"),
 
     url(r'^exam/periods/(?P<period_id>.*)/quotas/$', QuotasView.as_view(), name="teleforma-exam-quotas"),
 
index 765a5f45954565d4530165cf2af1ae78f50cfc41..d101ad06689eabbb64a510ac3ba44401463e7309 100644 (file)
@@ -126,7 +126,7 @@ class ScriptCreateView(CreateView):
     model = Script
     template_name='exam/script_form.html'
     form_class = ScriptForm
-    
+
     def get_success_url(self):
         period = Period.objects.get(id=self.kwargs['period_id'])
         return reverse_lazy('teleforma-exam-scripts-pending', kwargs={'period_id':period.id})
@@ -172,4 +172,34 @@ class QuotasView(ListView):
 
     @method_decorator(login_required)
     def dispatch(self, *args, **kwargs):
-        return super(QuotasView, self).dispatch(*args, **kwargs)
\ No newline at end of file
+        return super(QuotasView, self).dispatch(*args, **kwargs)
+
+
+class ScriptsScoreView(ScriptsTreatedView):
+
+    template_name='exam/scores.html'
+
+    def get_nvd3_data(self):
+        scripts = self.get_queryset()
+        xdata = [script.session for script in scripts]
+        ydata = [float(script.score) for script in scripts]
+        chartdata = {'x': xdata,  'name1': 'scores', 'y1': ydata}
+        charttype = "lineChart"
+        chartcontainer = 'linechart_container'
+        data = {
+            'charttype': charttype,
+            'chartdata': chartdata,
+            'chartcontainer': chartcontainer,
+            'extra': {
+            'x_is_date': False,
+            'x_axis_format': '',
+            'tag_script_js': True,
+            'jquery_on_ready': False,}
+            }
+        return data
+
+    def get_context_data(self, **kwargs):
+        context = super(ScriptsScoreView, self).get_context_data(**kwargs)
+        context['title'] = ugettext('Scores')
+        context['data'] = self.get_nvd3_data()
+        return context