diff options
-rw-r--r-- | exam/views.py | 10 | ||||
-rw-r--r-- | templates/exam/question.html | 2 |
2 files changed, 5 insertions, 7 deletions
diff --git a/exam/views.py b/exam/views.py index 892b35f..c178a0b 100644 --- a/exam/views.py +++ b/exam/views.py @@ -9,6 +9,7 @@ from django.contrib.auth import login, logout, authenticate from django.shortcuts import render_to_response, get_object_or_404, redirect from django.template import RequestContext from django.http import Http404 +from django.db.models import Sum # Local imports. from exam.models import Quiz, Question, QuestionPaper, Profile, Answer, User @@ -262,6 +263,7 @@ def complete(request, reason=None): else: return my_redirect('/exam/') + def monitor(request, quiz_id=None): """Monitor the progress of the papers taken so far.""" user = request.user @@ -282,12 +284,8 @@ def monitor(request, quiz_id=None): papers = [] quiz = None else: - papers = QuestionPaper.objects.filter(quiz=quiz, - user__profile__isnull=False) - - papers = sorted(papers, - cmp=lambda x, y: cmp(x.get_total_marks(), y.get_total_marks()), - reverse=True) + papers = QuestionPaper.objects.all().annotate( + total=Sum('answers__marks')).order_by('-total') context = {'papers': papers, 'quiz': quiz, 'quizzes': None} return my_render_to_response('exam/monitor.html', context, diff --git a/templates/exam/question.html b/templates/exam/question.html index 62b8b3d..8b589b6 100644 --- a/templates/exam/question.html +++ b/templates/exam/question.html @@ -65,7 +65,7 @@ function update_time() <input name="answer" type="radio" value="{{option}}" />{{option}} <br/> {% endfor %} {% else %} -<textarea rows="20" cols="100" name="answer">{% if last_attempt %}{{last_attempt.strip}}{% else %}# Enter your answer here.{% endif %}</textarea> +<textarea rows="20" cols="100" name="answer">{% if last_attempt %}{{last_attempt.strip}}{% else %}{% if question.type == "bash" %}#!/bin/bash{% else %}# Enter your answer here.{% endif %}{% endif %}</textarea> {% endif %} <br/> {% if question.type == "mcq" %} |