Commit 1837c4c0 by Bridger Maxwell

Changed the profile graph and gradebook to use the GRADE_CUTOFFS from the course settings.

parent f2ae8591
......@@ -87,17 +87,23 @@ def grade_sheet(student):
grader = course_settings.GRADER
grade_summary = grader.grade(totaled_scores)
letter_grade = None
for possible_grade in ['A', 'B', 'C']:
if grade_summary['percent'] >= course_settings.GRADE_CUTOFFS[possible_grade]:
letter_grade = possible_grade
break
letter_grade = grade_for_percentage(grade_summary['percent'])
_log.debug("Final grade: " + str(letter_grade))
return {'courseware_summary' : chapters,
'grade_summary' : grade_summary,
'grade' : letter_grade}
def grade_for_percentage(percentage):
letter_grade = None
for possible_grade in ['A', 'B', 'C']:
if percentage >= course_settings.GRADE_CUTOFFS[possible_grade]:
letter_grade = possible_grade
break
return letter_grade
def aggregate_scores(scores, section_name = "summary"):
total_correct_graded = sum(score.earned for score in scores if score.graded)
......
......@@ -45,10 +45,13 @@ def gradebook(request):
'id' : s.id,
'email': s.email,
'grade_info' : grades.grade_sheet(s),
'realname' : UserProfile.objects.get(user = s).name
'realname' : UserProfile.objects.get(user = s).name,
} for s in student_objects]
return render_to_response('gradebook.html',{'students':student_info})
return render_to_response('gradebook.html',
{'students':student_info,
'grade_cutoffs' : course_settings.GRADE_CUTOFFS,}
)
@cache_control(no_cache=True, no_store=True, must_revalidate=True)
def profile(request, student_id = None):
......@@ -73,7 +76,8 @@ def profile(request, student_id = None):
'language':user_info.language,
'email':student.email,
'format_url_params' : content_parser.format_url_params,
'csrf':csrf(request)['csrf_token']
'csrf':csrf(request)['csrf_token'],
'grade_cutoffs' : course_settings.GRADE_CUTOFFS,
}
context.update(grades.grade_sheet(student))
......
......@@ -6,11 +6,11 @@
<script type="text/javascript" src="/static/js/flot/jquery.flot.symbol.js"></script>
<style type="text/css">
.grade_a {color:green;}
.grade_b {color:Chocolate;}
.grade_c {color:DarkSlateGray;}
.grade_f {color:DimGray;}
.grade_none {color:LightGray;}
.grade_A {color:green;}
.grade_B {color:Chocolate;}
.grade_C {color:DarkSlateGray;}
.grade_F {color:DimGray;}
.grade_None {color:LightGray;}
</style>
</%block>
......@@ -38,15 +38,15 @@
<%def name="percent_data(percentage)">
<%
data_class = "grade_none"
if percentage > .87:
data_class = "grade_a"
elif percentage > .70:
data_class = "grade_b"
elif percentage > .6:
data_class = "grade_c"
elif percentage > 0:
data_class = "grade_f"
letter_grade = 'None'
if percentage > 0:
letter_grade = 'F'
for grade in ['A', 'B', 'C']:
if percentage >= grade_cutoffs[grade]:
letter_grade = grade
break
data_class = "grade_" + letter_grade
%>
<td class="${data_class}">${ "{0:.0%}".format( percentage ) }</td>
</%def>
......@@ -55,7 +55,7 @@
<tr>
<td><a href="/profile/${student['id']}/">${student['username']}</a></td>
%for section in student['grade_info']['grade_summary']['section_breakdown']:
${percent_data( section['percent'] )}
${percent_data( section['percent'])}
%endfor
<th>${percent_data( student['grade_info']['grade_summary']['percent'])}</th>
</tr>
......
......@@ -12,7 +12,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>
${profile_graphs.body(grade_summary, "grade-detail-graph")}
${profile_graphs.body(grade_summary, grade_cutoffs, "grade-detail-graph")}
</script>
<script>
......
<%page args="grade_summary, graph_div_id, **kwargs"/>
<%page args="grade_summary, grade_cutoffs, graph_div_id, **kwargs"/>
<%!
import json
%>
......@@ -91,6 +91,14 @@ $(function () {
totalScore = grade_summary['percent']
detail_tooltips['Dropped Scores'] = dropped_score_tooltips
## ----------------------------- Grade cutoffs ------------------------- ##
grade_cutoff_ticks = [ [1, "100%"], [0, "0%"] ]
for grade in ['A', 'B', 'C']:
percent = grade_cutoffs[grade]
grade_cutoff_ticks.append( [ percent, "{0} {1:.0%}".format(grade, percent) ] )
%>
var series = ${ json.dumps( series ) };
......@@ -98,6 +106,7 @@ $(function () {
var bottomTicks = ${ json.dumps(bottomTicks) };
var detail_tooltips = ${ json.dumps(detail_tooltips) };
var droppedScores = ${ json.dumps(droppedScores) };
var grade_cutoff_ticks = ${ json.dumps(grade_cutoff_ticks) }
//Alwasy be sure that one series has the xaxis set to 2, or the second xaxis labels won't show up
series.push( {label: 'Dropped Scores', data: droppedScores, points: {symbol: "cross", show: true, radius: 3}, bars: {show: false}, color: "#333"} );
......@@ -107,10 +116,10 @@ $(function () {
lines: {show: false, steps: false },
bars: {show: true, barWidth: 0.8, align: 'center', lineWidth: 0, fill: .8 },},
xaxis: {tickLength: 0, min: 0.0, max: ${tickIndex - sectionSpacer}, ticks: ticks, labelAngle: 90},
yaxis: {ticks: [[1, "100%"], [0.87, "A 87%"], [0.7, "B 70%"], [0.6, "C 60%"], [0, "0%"]], min: 0.0, max: 1.0, labelWidth: 50},
yaxis: {ticks: grade_cutoff_ticks, min: 0.0, max: 1.0, labelWidth: 50},
grid: { hoverable: true, clickable: true, borderWidth: 1,
markings: [ {yaxis: {from: 0.87, to: 1 }, color: "#ddd"}, {yaxis: {from: 0.7, to: 0.87 }, color: "#e9e9e9"},
{yaxis: {from: 0.6, to: 0.7 }, color: "#f3f3f3"}, ] },
markings: [ {yaxis: {from: ${grade_cutoffs['A']}, to: 1 }, color: "#ddd"}, {yaxis: {from: ${grade_cutoffs['B']}, to: ${grade_cutoffs['A']} }, color: "#e9e9e9"},
{yaxis: {from: ${grade_cutoffs['C']}, to: ${grade_cutoffs['B']} }, color: "#f3f3f3"}, ] },
legend: {show: false},
};
......
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