summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPrabhu Ramachandran2011-11-25 00:57:41 +0530
committerPrabhu Ramachandran2011-11-25 00:57:41 +0530
commit3375839bfc531329adc45994659be382295038b6 (patch)
tree987582097b8bc5e96d27f86874e1e3b47bfc823d
parent92cdea62ed993acd8a6c3c2798c6b89143c3cfb5 (diff)
downloadonline_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.
-rw-r--r--exam/urls.py1
-rw-r--r--exam/views.py28
-rw-r--r--templates/exam/grade_user.html62
-rw-r--r--templates/exam/user_data.html6
4 files changed, 97 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))
+
diff --git a/templates/exam/grade_user.html b/templates/exam/grade_user.html
new file mode 100644
index 0000000..f671237
--- /dev/null
+++ b/templates/exam/grade_user.html
@@ -0,0 +1,62 @@
+{% extends "base.html" %}
+
+{% block title %} Grading papers for {{ data.user.get_full_name.title }} {% endblock title %}
+
+{% block content %}
+
+<h1> Grading papers for {{ data.user.get_full_name.title }} </h1>
+
+<p>
+Name: {{ data.user.get_full_name.title }}
+{% if data.profile %}
+(roll number: {{ data.profile.roll_number }}) <br/>
+{{ data.profile.position }},
+{{ data.profile.department }},
+{{ data.profile.institute }}
+{% endif %}
+</p>
+
+{% if data.papers %}
+
+{% for paper in data.papers %}
+
+<h2> Quiz: {{ paper.quiz.description }} </h2>
+
+<p>
+Questions correctly answered: {{ paper.get_answered_str }} <br/>
+Total attempts at questions: {{ paper.answers.count }} <br/>
+Marks obtained: {{ paper.get_total_marks }} <br/>
+Start time: {{ paper.start_time }} <br/>
+</p>
+
+{% if paper.answers.count %}
+<h3> Answers </h3>
+<form id="q{{ paper.quiz.id }}_form"
+ action="{{URL_ROOT}}/exam/grade_user/{{data.user.username}}/" method="post">
+{% csrf_token %}
+{% for question, answers in paper.get_question_answers.items %}
+<p><strong> Question: {{ question.id }}. {{ question.summary }} (Points: {{ question.points }})</strong> </p>
+{% for answer in answers %}
+<pre>
+################################################################################
+{{ answer.answer|safe }}
+# Autocheck: {{ answer.error }}
+</pre>
+Marks: <input id="q{{ question.id }}" type="text"
+ name="q{{ question.id }}_marks" size="4"
+ value="{{ answer.marks }}" />
+{% endfor %} {# for answer in answers #}
+{% endfor %} {# for question, answers ... #}
+<h3>Teacher comments: </h3>
+<textarea id="comments_{{paper.quiz.id}}" rows="10" cols="80"
+ name="comments_{{ paper.quiz.id }}">{{ paper.comments }}</textarea>
+<br/>
+<input type="submit" name="submit_{{paper.quiz.id}}" value="Save marks" />
+</form>
+{% endif %} {# if paper.answers.count #}
+
+{% endfor %} {# for paper in data.papers #}
+
+{% endif %} {# if data.papers #}
+
+{% endblock content %}
diff --git a/templates/exam/user_data.html b/templates/exam/user_data.html
index 7563e0e..1e2c392 100644
--- a/templates/exam/user_data.html
+++ b/templates/exam/user_data.html
@@ -21,6 +21,8 @@ Last login: {{ data.user.last_login }}
</p>
{% if data.papers %}
+<a href="{{URL_ROOT}}/exam/grade_user/{{ data.user.username }}/">
+ Grade/correct paper</a>
{% for paper in data.papers %}
@@ -54,5 +56,9 @@ User IP address: {{ paper.user_ip }}
{% endfor %} {# for paper in data.papers #}
{% endif %} {# if data.papers #}
+<br />
+<hr />
+<a href="{{URL_ROOT}}/exam/grade_user/{{ data.user.username }}/">
+ Grade/correct paper</a>
{% endblock content %}