From 3c68e49bd4a57d3eae0acfe11061041789c1423f Mon Sep 17 00:00:00 2001
From: prathamesh
Date: Mon, 22 Feb 2016 18:33:55 +0530
Subject: Added statistics per question for a quiz
---
yaksh/templates/yaksh/monitor.html | 1 +
yaksh/templates/yaksh/statistics_question.html | 19 +++++++++++++++++
yaksh/urls.py | 1 +
yaksh/views.py | 29 ++++++++++++++++++++++++++
4 files changed, 50 insertions(+)
create mode 100644 yaksh/templates/yaksh/statistics_question.html
(limited to 'yaksh')
diff --git a/yaksh/templates/yaksh/monitor.html b/yaksh/templates/yaksh/monitor.html
index ecb8b42..cb14ba5 100644
--- a/yaksh/templates/yaksh/monitor.html
+++ b/yaksh/templates/yaksh/monitor.html
@@ -39,6 +39,7 @@
{% if papers %}
Number of papers: {{ papers|length }}
+Question Statisitics
Name |
diff --git a/yaksh/templates/yaksh/statistics_question.html b/yaksh/templates/yaksh/statistics_question.html
new file mode 100644
index 0000000..d9fcd34
--- /dev/null
+++ b/yaksh/templates/yaksh/statistics_question.html
@@ -0,0 +1,19 @@
+{% extends "manage.html" %}
+
+{% block title %} Statistics {% endblock title %}
+
+{% block css %}
+
+{% endblock %}
+{% block subtitle %}
+Statistics for {{quiz_name}}
+{% endblock %}
+{% block manage %}
+Total number of participants(including multiple attempts): {{ total }}
+
+ Question | Type | Answered |
+ {% for question, attempts in question_stats.items %}
+ {{ question.summary }} | {{ question.type }} | {{ attempts }} ({% widthratio attempts total 100 %}%) |
+ {% endfor %}
+
+{% endblock %}
diff --git a/yaksh/urls.py b/yaksh/urls.py
index 61222b8..ea6f5e8 100644
--- a/yaksh/urls.py
+++ b/yaksh/urls.py
@@ -50,6 +50,7 @@ urlpatterns = patterns('yaksh.views',
url(r'^manage/designquestionpaper/manual$', 'manual_questionpaper'),
url(r'^manage/designquestionpaper/manual/(?P\d+)/$',\
'manual_questionpaper'),
+ url(r'^manage/statistics/question/(?P\d+)/$','statistics'),
url(r'^ajax/questionpaper/(?P.+)/$', 'ajax_questionpaper'),
url(r'^ajax/questions/filter/$', 'ajax_questions_filter'),
diff --git a/yaksh/views.py b/yaksh/views.py
index 755b33b..4724f98 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -1164,6 +1164,33 @@ def complete(request, reason=None, attempt_num=None, questionpaper_id=None):
else:
return my_redirect('/exam/')
+@login_required
+def statistics(request, questionpaper_id):
+ user = request.user
+ if not is_moderator(user):
+ raise Http404('You are not allowed to view this page')
+ questions_answered = []
+ question_stats = {}
+ papers = AnswerPaper.objects.filter(question_paper_id=questionpaper_id,
+ status='completed')
+ for paper in papers:
+ questions_answered += paper.questions_answered.split('|')
+ quiz_name = paper.question_paper.quiz.description
+ questions_answered = collections.Counter(map(int, filter(None,
+ questions_answered)))
+ total_attempt = papers.count()
+ questions = Question.objects.filter(id__in=paper.questions.split('|')).\
+ order_by('type')
+ for question in questions:
+ if question.id in questions_answered:
+ question_stats[question] = questions_answered[question.id]
+ else:
+ question_stats[question] = 0
+ context = {'question_stats': question_stats, 'quiz_name': quiz_name,
+ 'total': total_attempt}
+ return my_render_to_response('yaksh/statistics_question.html', context,
+ context_instance=RequestContext(request))
+
@login_required
def monitor(request, questionpaper_id=None):
@@ -1520,3 +1547,5 @@ def design_questionpaper(request):
context = {'form': form}
return my_render_to_response('yaksh/design_questionpaper.html',
context, context_instance=ci)
+
+
--
cgit