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