Commit 3be5423b by Bridger Maxwell

Small refactor on the grades. Also made the gradebook render a graph for each student

--HG--
branch : bridger-grades
parent e2995a9e
<table>
% for s in students:
<h1><a href=/profile/${s['id']}>${s['username']}</a></h1>
% for c in s['grade_info']['grade_summary']:
<h2>${c['category']} </h2>
<p>
% if 'subscores' in c:
<%namespace name="profile_graphs" file="profile_graphs.js"/>
<html>
<head>
<script type="text/javascript" src="${ settings.LIB_URL }jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="${ settings.LIB_URL }jquery-ui-1.8.16.custom.min.js"></script>
<script type="text/javascript" src="/static/js/flot/jquery.flot.js"></script>
<script type="text/javascript" src="/static/js/flot/jquery.flot.stack.js"></script>
<script type="text/javascript" src="/static/js/flot/jquery.flot.symbol.js"></script>
% for s in students:
<script>
${profile_graphs.body(s['grade_info']['grade_summary'], "grade-detail-graph-" + str(s['id']))}
</script>
%endfor
</head>
<body>
% for s in students:
<h1><a href=/profile/${s['id']}>${s['username']}</a></h1>
<div id="grade-detail-graph-${s['id']}" style="width:1000;height:300;"></div>
<!---
% for c in s['grade_info']['grade_summary']:
<h2>${c['category']} </h2>
<p>
% if 'subscores' in c:
% for ss in c['subscores']:
<br>${ss['summary']}
% endfor
% endif
</p>
% endfor
% endfor
</table>
% endif
</p>
% endfor
-->
% endfor
</body>
</html>
<%inherit file="main.html" />
<%namespace name="profile_graphs" file="profile_graphs.js"/>
<%!
from django.core.urlresolvers import reverse
......@@ -9,7 +10,7 @@
<script type="text/javascript" src="/static/js/flot/jquery.flot.stack.js"></script>
<script type="text/javascript" src="/static/js/flot/jquery.flot.symbol.js"></script>
<script>
<%include file="profile_graphs.js"/>
${profile_graphs.body(grade_summary, "grade-detail-graph")}
</script>
<script>
......@@ -93,7 +94,7 @@ $(function() {
<div id="grade-detail-graph"></div>
<ol class="chapters">
%for chapter in chapters:
%for chapter in courseware_summary:
%if not chapter['chapter'] == "hidden":
<li>
<h2><a href="${reverse('courseware_chapter', args=format_url_params([chapter['course'], chapter['chapter']])) }">
......
<%page args="grade_summary, graph_div_id, **kwargs"/>
<%!
import json
%>
......@@ -57,21 +58,21 @@ $(function () {
category_total_label = section['category'] + " Total"
series.append({
'label' : category_total_label,
'data' : [ [tickIndex, section['totalscore']['score']] ],
'data' : [ [tickIndex, section['totalscore']] ],
'color' : colors[sectionIndex]
})
ticks.append( [tickIndex, section['totallabel']] )
detail_tooltips[category_total_label] = [section['totalscore']['summary']]
detail_tooltips[category_total_label] = [section['totalscore_summary']]
else:
series.append({
'label' : section['category'],
'data' : [ [tickIndex, section['totalscore']['score']] ],
'data' : [ [tickIndex, section['totalscore']] ],
'color' : colors[sectionIndex]
})
ticks.append( [tickIndex, section['totallabel']] )
detail_tooltips[section['category']] = [section['totalscore']['summary']]
detail_tooltips[section['category']] = [section['totalscore_summary']]
tickIndex += 1 + sectionSpacer
sectionIndex += 1
......@@ -86,12 +87,12 @@ $(function () {
overviewBarX = tickIndex
for section in grade_summary:
weighted_score = section['totalscore']['score'] * section['weight']
weighted_score = section['totalscore'] * section['weight']
summary_text = "{0} - {1:.1%} of a possible {2:.0%}".format(section['category'], weighted_score, section['weight'])
weighted_category_label = section['category'] + " - Weighted"
if section['totalscore']['score'] > 0:
if section['totalscore'] > 0:
series.append({
'label' : weighted_category_label,
'data' : [ [overviewBarX, weighted_score] ],
......@@ -101,7 +102,7 @@ $(function () {
detail_tooltips[weighted_category_label] = [ summary_text ]
sectionIndex += 1
totalWeight += section['weight']
totalScore += section['totalscore']['score'] * section['weight']
totalScore += section['totalscore'] * section['weight']
ticks += [ [overviewBarX, "Total"] ]
tickIndex += 1 + sectionSpacer
......@@ -128,7 +129,7 @@ $(function () {
legend: {show: false},
};
var $grade_detail_graph = $("#grade-detail-graph");
var $grade_detail_graph = $("#${graph_div_id}");
if ($grade_detail_graph.length > 0) {
var plot = $.plot($grade_detail_graph, series, options);
......@@ -137,7 +138,7 @@ $(function () {
}
var previousPoint = null;
$("#grade-detail-graph").bind("plothover", function (event, pos, item) {
$grade_detail_graph.bind("plothover", function (event, pos, item) {
$("#x").text(pos.x.toFixed(2));
$("#y").text(pos.y.toFixed(2));
if (item) {
......
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