diff --git a/lms/djangoapps/instructor/tests/test_legacy_raw_download_csv.py b/lms/djangoapps/instructor/tests/test_legacy_raw_download_csv.py
index 5eeb76cee6b9..b785e65d319d 100644
--- a/lms/djangoapps/instructor/tests/test_legacy_raw_download_csv.py
+++ b/lms/djangoapps/instructor/tests/test_legacy_raw_download_csv.py
@@ -87,11 +87,11 @@ def test_grade_summary_data(self):
],
'data': [
[
- 1, u'u1', u'username', u'view@test.com', '', 0.0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 1, u'u1', u'username', u'view@test.com', '', (0.0, 1.0), 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0.0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
],
[
- 2, u'u2', u'username', u'view2@test.com', '', 0.3333333333333333, 0, 0, 0,
+ 2, u'u2', u'username', u'view2@test.com', '', (1.0, 3.0), 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0.03333333333333333, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0
]
diff --git a/lms/djangoapps/instructor/views/legacy.py b/lms/djangoapps/instructor/views/legacy.py
index b5996c7d8dbf..6c959bd059d6 100644
--- a/lms/djangoapps/instructor/views/legacy.py
+++ b/lms/djangoapps/instructor/views/legacy.py
@@ -12,7 +12,7 @@
import requests
import urllib
-from collections import defaultdict, OrderedDict
+from collections import defaultdict, OrderedDict, Counter
from markupsafe import escape
from requests.status_codes import codes
from StringIO import StringIO
@@ -241,19 +241,30 @@ def domatch(student):
if not aname:
msg += "{text}".format(text=_("Please enter an assignment name"))
else:
- allgrades = get_student_grade_summary_data(request, course, get_grades=True, use_offline=use_offline)
+ allgrades = get_student_grade_summary_data(
+ request,
+ course,
+ get_grades=True,
+ use_offline=use_offline,
+ get_score_max=True
+ )
if aname not in allgrades['assignments']:
msg += "{text}".format(
text=_("Invalid assignment name '{name}'").format(name=aname)
)
else:
aidx = allgrades['assignments'].index(aname)
- datatable = {'header': [_('External email'), aname]}
+ datatable = {'header': [_('External email'), aname, _('max_pts')]}
ddata = []
- for student in allgrades['students']: # do one by one in case there is a student who has only partial grades
- try:
- ddata.append([student.email, student.grades[aidx]])
- except IndexError:
+ # do one by one in case there is a student who has only partial grades
+ for student in allgrades['students']:
+ if len(student.grades) >= aidx and student.grades[aidx] is not None:
+ ddata.append(
+ [student.email,
+ student.grades[aidx][0],
+ student.grades[aidx][1]]
+ )
+ else:
log.debug(u'No grade for assignment %(idx)s (%(name)s) for student %(email)s', {
"idx": aidx,
"name": aname,
@@ -755,8 +766,16 @@ def get_student_grade_summary_data(request, course, get_grades=True, get_raw_sco
for score in gradeset['raw_scores']:
add_grade(score.section, getattr(score, 'earned', score[0]))
else:
+ category_cnts = Counter()
for grade_item in gradeset['section_breakdown']:
- add_grade(grade_item['label'], grade_item['percent'])
+ category = grade_item['category']
+ try:
+ earned = gradeset['totaled_scores'][category][category_cnts[category]].earned
+ possible = gradeset['totaled_scores'][category][category_cnts[category]].possible
+ add_grade(grade_item['label'], earned, possible=possible)
+ except (IndexError, KeyError):
+ add_grade(grade_item['label'], grade_item['percent'])
+ category_cnts[category] += 1
student.grades = gtab.get_grade(student.id)
data.append(datarow)