From fed3a20c9aa14d6c4c05309628d283bb5535e32b Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Thu, 28 May 2015 15:40:56 +0200 Subject: [PATCH] add nvd3 scoring prototype --- teleforma/exam/templates/exam/scores.html | 24 +++++++++++++++ teleforma/exam/templates/exam/scripts.html | 1 + teleforma/exam/urls.py | 1 + teleforma/exam/views.py | 34 ++++++++++++++++++++-- 4 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 teleforma/exam/templates/exam/scores.html diff --git a/teleforma/exam/templates/exam/scores.html b/teleforma/exam/templates/exam/scores.html new file mode 100644 index 00000000..97241647 --- /dev/null +++ b/teleforma/exam/templates/exam/scores.html @@ -0,0 +1,24 @@ +{% extends "exam/scripts.html" %} +{% load telemeta_utils %} +{% load teleforma_tags %} +{% load static %} +{% load nvd3_tags %} +{% load i18n %} + +{% block extra_javascript %} + + + +{% load_chart data.charttype data.chartdata data.chartcontainer data.extra %} +{% endblock extra_javascript %} + +{% block answers %} + +
+{% trans "Scores" %} +
+
+ +{% include_container data.chartcontainer 400 '100%' %} + +{% endblock answers %} diff --git a/teleforma/exam/templates/exam/scripts.html b/teleforma/exam/templates/exam/scripts.html index a51d712b..68add6db 100644 --- a/teleforma/exam/templates/exam/scripts.html +++ b/teleforma/exam/templates/exam/scripts.html @@ -25,6 +25,7 @@
  • {% trans "Pending" %}{% if user.is_staff or user.quotass.all %}{% untreated_scripts_count user period %}{% endif %}
  • {% trans "Marked" %}{% if not user.is_staff and not user.quotas.all %}{% treated_scripts_count user period %}{% endif %}
  • {% trans "Rejected" %}
  • +
  • {% trans "Scores" %}
  • {% endblock courses %} diff --git a/teleforma/exam/urls.py b/teleforma/exam/urls.py index 43292404..61ee45d9 100644 --- a/teleforma/exam/urls.py +++ b/teleforma/exam/urls.py @@ -55,6 +55,7 @@ urlpatterns = patterns('', url(r'^exam/periods/(?P.*)/scripts_pending/$', ScriptsPendingView.as_view(), name="teleforma-exam-scripts-pending"), url(r'^exam/periods/(?P.*)/scripts_treated/$', ScriptsTreatedView.as_view(), name="teleforma-exam-scripts-treated"), url(r'^exam/periods/(?P.*)/scripts_rejected/$', ScriptsRejectedView.as_view(), name="teleforma-exam-scripts-rejected"), + url(r'^exam/periods/(?P.*)/scripts_scores/$', ScriptsScoreView.as_view(), name="teleforma-exam-scripts-scores"), url(r'^exam/periods/(?P.*)/quotas/$', QuotasView.as_view(), name="teleforma-exam-quotas"), diff --git a/teleforma/exam/views.py b/teleforma/exam/views.py index 765a5f45..d101ad06 100644 --- a/teleforma/exam/views.py +++ b/teleforma/exam/views.py @@ -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 -- 2.39.5