Skip to content

Commit d924c80

Browse files
committed
Send raw score and max points to remote gradebook.
Raw scores and max points are more useful to instructors in the remote gradebook than the calculated scores sent now. Fixes #36 @pdpinch
1 parent e2b0213 commit d924c80

File tree

2 files changed

+29
-10
lines changed

2 files changed

+29
-10
lines changed

lms/djangoapps/instructor/tests/test_legacy_raw_download_csv.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ def get_expected_grade_data(
9797
],
9898
'data': [
9999
[
100-
1, u'u1', u'username', u'view@test.com', '', 0.0, 0, 0, 0, 0, 0, 0, 0, 0,
100+
1, u'u1', u'username', u'view@test.com', '', (0.0, 1.0), 0, 0, 0, 0, 0, 0, 0, 0,
101101
0, 0, 0, 0.0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
102102
],
103103
[
104-
2, u'u2', u'username', u'view2@test.com', '', 0.3333333333333333, 0, 0, 0,
104+
2, u'u2', u'username', u'view2@test.com', '', (1.0, 3.0), 0, 0, 0,
105105
0, 0, 0, 0, 0, 0, 0, 0, 0.03333333333333333, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
106106
0, 0, 0, 0, 0
107107
]

lms/djangoapps/instructor/views/legacy.py

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import requests
1414
import urllib
1515

16-
from collections import defaultdict, OrderedDict
16+
from collections import defaultdict, OrderedDict, Counter
1717
from markupsafe import escape
1818
from requests.status_codes import codes
1919
from StringIO import StringIO
@@ -244,19 +244,30 @@ def domatch(student):
244244
if not aname:
245245
msg += "<font color='red'>{text}</font>".format(text=_("Please enter an assignment name"))
246246
else:
247-
allgrades = get_student_grade_summary_data(request, course, get_grades=True, use_offline=use_offline)
247+
allgrades = get_student_grade_summary_data(
248+
request,
249+
course,
250+
get_grades=True,
251+
use_offline=use_offline,
252+
get_score_max=True
253+
)
248254
if aname not in allgrades['assignments']:
249255
msg += "<font color='red'>{text}</font>".format(
250256
text=_("Invalid assignment name '{name}'").format(name=aname)
251257
)
252258
else:
253259
aidx = allgrades['assignments'].index(aname)
254-
datatable = {'header': [_('External email'), aname]}
260+
datatable = {'header': [_('External email'), aname, _('max_pts')]}
255261
ddata = []
256-
for student in allgrades['students']: # do one by one in case there is a student who has only partial grades
257-
try:
258-
ddata.append([student.email, student.grades[aidx]])
259-
except IndexError:
262+
# do one by one in case there is a student who has only partial grades
263+
for student in allgrades['students']:
264+
if len(student.grades) >= aidx and student.grades[aidx] is not None:
265+
ddata.append(
266+
[student.email,
267+
student.grades[aidx][0],
268+
student.grades[aidx][1]]
269+
)
270+
else:
260271
log.debug(u'No grade for assignment %(idx)s (%(name)s) for student %(email)s', {
261272
"idx": aidx,
262273
"name": aname,
@@ -736,8 +747,16 @@ def get_student_grade_summary_data(
736747
else:
737748
add_grade(score.section, score.earned)
738749
else:
750+
category_cnts = Counter()
739751
for grade_item in gradeset['section_breakdown']:
740-
add_grade(grade_item['label'], grade_item['percent'])
752+
category = grade_item['category']
753+
try:
754+
earned = gradeset['totaled_scores'][category][category_cnts[category]].earned
755+
possible = gradeset['totaled_scores'][category][category_cnts[category]].possible
756+
add_grade(grade_item['label'], earned, possible=possible)
757+
except (IndexError, KeyError):
758+
add_grade(grade_item['label'], grade_item['percent'])
759+
category_cnts[category] += 1
741760
student.grades = gtab.get_grade(student.id)
742761

743762
data.append(datarow)

0 commit comments

Comments
 (0)