Commit 7f069ac2 by Bridger Maxwell Committed by Kyle Fiedler

Made sure that histogram graph doesn't show up for modules without scores.…

Made sure that histogram graph doesn't show up for modules without scores. Modified look of histogram graph.
parent 752a6252
......@@ -103,8 +103,9 @@ def grade_histogram(module_id):
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
if (len(grades) == 1 and grades[0][0] == None):
return []
return grades
def render_x_module(user, request, xml_module, module_object_preload):
......@@ -147,10 +148,14 @@ def render_x_module(user, request, xml_module, module_object_preload):
init_js = instance.get_init_js()
destory_js = instance.get_destroy_js()
if user.is_staff:
histogram = grade_histogram(module_id)
render_histogram = len(histogram) > 0
content=content+render_to_string("staff_problem_info.html", {'xml':etree.tostring(xml_module),
'module_id' : module_id})
init_js = init_js+render_to_string("staff_problem_histogram.js", {'histogram' : grade_histogram(module_id),
'module_id' : module_id})
'module_id' : module_id,
'render_histogram' : render_histogram})
if render_histogram:
init_js = init_js+render_to_string("staff_problem_histogram.js", {'histogram' : histogram,
'module_id' : module_id})
content = {'content':content,
"destroy_js":destory_js,
......
......@@ -9,6 +9,7 @@ xticks = []
yticks = []
maxx = 1
maxy = 1.5
#Here we change the y-axis (count) to be logorithmic. We also define better ticks
for score, count in histogram:
score = score or 0 #Sometimes score is None. This fixes that
......@@ -30,9 +31,9 @@ $.plot($("#histogram_${module_id}"), [{
align: 'center',
lineWidth: 0,
fill: 1.0 },
color: "#600101",
color: "#b72121",
}],
{
xaxis: {min: -1, max: ${maxx}, ticks: ${ json.dumps(xticks) }},
xaxis: {min: -1, max: ${maxx}, ticks: ${ json.dumps(xticks) }, tickLength: 0},
yaxis: {min: 0.0, max: ${maxy}, ticks: ${ json.dumps(yticks) }, labelWidth: 50},
});
<div class="staff_info">
${xml | h}
</div>
<div id="histogram_${module_id}" style="width:200px;height:150px"></div>
%if render_histogram:
<div id="histogram_${module_id}" style="width:200px;height:150px"></div>
%endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment