diff options
author | Prabhu Ramachandran | 2011-11-25 00:57:41 +0530 |
---|---|---|
committer | Prabhu Ramachandran | 2011-11-25 00:57:41 +0530 |
commit | 3375839bfc531329adc45994659be382295038b6 (patch) | |
tree | 987582097b8bc5e96d27f86874e1e3b47bfc823d /exam | |
parent | 92cdea62ed993acd8a6c3c2798c6b89143c3cfb5 (diff) | |
download | online_test-3375839bfc531329adc45994659be382295038b6.tar.gz online_test-3375839bfc531329adc45994659be382295038b6.tar.bz2 online_test-3375839bfc531329adc45994659be382295038b6.zip |
ENH: Adding a convenient grading interface.
With this, you can grade a student's answer paper and give comments for
each quiz paper they attempt. Also added a link to this grading
interface to the user_data view.
Diffstat (limited to 'exam')
-rw-r--r-- | exam/urls.py | 1 | ||||
-rw-r--r-- | exam/views.py | 28 |
2 files changed, 29 insertions, 0 deletions
diff --git a/exam/urls.py b/exam/urls.py index 129a83f..34e329f 100644 --- a/exam/urls.py +++ b/exam/urls.py @@ -10,6 +10,7 @@ urlpatterns = patterns('exam.views', url(r'^monitor/$', 'monitor'), url(r'^monitor/(?P<quiz_id>\d+)/$', 'monitor'), url(r'^user_data/(?P<username>[a-zA-Z0-9_.]+)/$', 'user_data'), + url(r'^grade_user/(?P<username>[a-zA-Z0-9_.]+)/$', 'grade_user'), url(r'^(?P<q_id>\d+)/$', 'question'), url(r'^(?P<q_id>\d+)/check/$', 'check'), ) diff --git a/exam/views.py b/exam/views.py index 1f92553..cd91ef8 100644 --- a/exam/views.py +++ b/exam/views.py @@ -311,3 +311,31 @@ def user_data(request, username): return my_render_to_response('exam/user_data.html', context, context_instance=RequestContext(request)) +def grade_user(request, username): + """Present an interface with which we can easily grade a user's papers + and update all their marks and also give comments for each paper. + """ + current_user = request.user + if not current_user.is_authenticated() and not current_user.is_staff: + raise Http404('You are not allowed to view this page!') + + data = get_user_data(username) + if request.method == 'POST': + papers = data['papers'] + for paper in papers: + for question, answers in paper.get_question_answers().iteritems(): + marks = float(request.POST.get('q%d_marks'%question.id)) + last_ans = answers[-1] + last_ans.marks = marks + last_ans.save() + paper.comments = request.POST.get('comments_%d'%paper.quiz.id) + paper.save() + + context = {'data': data} + return my_render_to_response('exam/user_data.html', context, + context_instance=RequestContext(request)) + else: + context = {'data': data} + return my_render_to_response('exam/grade_user.html', context, + context_instance=RequestContext(request)) + |