diff options
author | Prabhu Ramachandran | 2016-02-29 15:59:07 +0530 |
---|---|---|
committer | Prabhu Ramachandran | 2016-02-29 15:59:07 +0530 |
commit | 2bff22d61d5d4d6f038c5b368ec437c6bda1dfbe (patch) | |
tree | a8496bd91dfc49ec74bdfe1e585c1202083f5c1c /yaksh/views.py | |
parent | b1cb1ece826e39639d339f5dee71743044402b74 (diff) | |
parent | 3b055ad0ad3232a25408632a020d5e3c284c245b (diff) | |
download | online_test-2bff22d61d5d4d6f038c5b368ec437c6bda1dfbe.tar.gz online_test-2bff22d61d5d4d6f038c5b368ec437c6bda1dfbe.tar.bz2 online_test-2bff22d61d5d4d6f038c5b368ec437c6bda1dfbe.zip |
Merge pull request #77 from prathamesh920/stats_per_question
Added statistics per question for a quiz
Diffstat (limited to 'yaksh/views.py')
-rw-r--r-- | yaksh/views.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/yaksh/views.py b/yaksh/views.py index 755b33b..6558427 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -1166,6 +1166,32 @@ def complete(request, reason=None, attempt_num=None, questionpaper_id=None): @login_required +def show_statistics(request, questionpaper_id, attempt_number=None): + user = request.user + if not is_moderator(user): + raise Http404('You are not allowed to view this page') + attempt_numbers = AnswerPaper.objects.get_attempt_numbers(questionpaper_id) + quiz = get_object_or_404(QuestionPaper, pk=questionpaper_id).quiz + if attempt_number is None: + context = {'quiz': quiz, 'attempts': attempt_numbers, + 'questionpaper_id': questionpaper_id} + return my_render_to_response('yaksh/statistics_question.html', context, + context_instance=RequestContext(request)) + total_attempt = AnswerPaper.objects.get_count(questionpaper_id, + attempt_number) + if not AnswerPaper.objects.has_attempt(questionpaper_id, attempt_number): + return my_redirect('/exam/manage/') + question_stats = AnswerPaper.objects.get_question_statistics( + questionpaper_id, attempt_number + ) + context = {'question_stats': question_stats, 'quiz': quiz, + 'questionpaper_id': questionpaper_id, + 'attempts': attempt_numbers, '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): """Monitor the progress of the papers taken so far.""" |