diff --git a/djangoapps/courseware/module_render.py b/djangoapps/courseware/module_render.py index d10d13637a..2924aec9df 100644 --- a/djangoapps/courseware/module_render.py +++ b/djangoapps/courseware/module_render.py @@ -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, diff --git a/templates/staff_problem_histogram.js b/templates/staff_problem_histogram.js index 1b74713213..8f7012cbc8 100644 --- a/templates/staff_problem_histogram.js +++ b/templates/staff_problem_histogram.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}, }); diff --git a/templates/staff_problem_info.html b/templates/staff_problem_info.html index 38fd72600a..20370a9c81 100644 --- a/templates/staff_problem_info.html +++ b/templates/staff_problem_info.html @@ -1,4 +1,6 @@