Grading histogram

This commit is contained in:
Piotr Mitros
2012-04-10 08:03:26 -04:00
parent 22bd9b9443
commit c06c6104ca
2 changed files with 17 additions and 1 deletions

View File

@@ -87,6 +87,18 @@ def modx_dispatch(request, module=None, dispatch=None, id=None):
# Return whatever the module wanted to return to the client/caller
return HttpResponse(ajax_return)
def grade_histogram(module_id):
print module_id
from django.db import connection, transaction
cursor = connection.cursor()
cursor.execute("select courseware_studentmodule.grade,COUNT(courseware_studentmodule.student_id) from courseware_studentmodule where courseware_studentmodule.module_id=%s group by courseware_studentmodule.grade", [module_id])
grades = list(cursor.fetchall())
print grades
grades.sort(key=lambda x:x[0]) # Probably not necessary
return grades
def render_x_module(user, request, xml_module, module_object_preload):
''' Generic module for extensions. This renders to HTML. '''
# Check if problem has an instance in DB
@@ -125,7 +137,8 @@ def render_x_module(user, request, xml_module, module_object_preload):
# Grab content
content = instance.get_html()
if user.is_staff:
content=content+render_to_string("staff_problem_info.html", {'xml':etree.tostring(xml_module)})
content=content+render_to_string("staff_problem_info.html", {'xml':etree.tostring(xml_module),
'histogram':grade_histogram(module_id)})
content = {'content':content,
"destroy_js":instance.get_destroy_js(),
'init_js':instance.get_init_js(),

View File

@@ -1,3 +1,6 @@
<div class="staff_info">
${xml | h}
</div>
<div>
${ str(histogram) }
</div>