Skip to content

Commit

Permalink
Send raw score and max points to remote gradebook.
Browse files Browse the repository at this point in the history
Raw scores and max points are more useful to instructors in the
remote gradebook than the calculated scores sent now.

Fixes #36

@pdpinch
  • Loading branch information
pwilkins authored and amir-qayyum-khan committed Feb 10, 2016
1 parent 44e4339 commit fb9fcf2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ def test_grade_summary_data(self):
],
'data': [
[
1, u'u1', u'username', u'[email protected]', '', 0.0, 0, 0, 0, 0, 0, 0, 0, 0,
1, u'u1', u'username', u'[email protected]', '', (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'[email protected]', '', 0.3333333333333333, 0, 0, 0,
2, u'u2', u'username', u'[email protected]', '', (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
]
Expand Down
35 changes: 27 additions & 8 deletions lms/djangoapps/instructor/views/legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -241,19 +241,30 @@ def domatch(student):
if not aname:
msg += "<font color='red'>{text}</font>".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 += "<font color='red'>{text}</font>".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')]}

This comment has been minimized.

Copy link
@noisecapella

noisecapella Feb 18, 2016

We don't want to normalize the names of columns, they need to be exactly the same so that we can use them in lmod_proxy and pylmod

This comment has been minimized.

Copy link
@amir-qayyum-khan

amir-qayyum-khan Feb 19, 2016

@noisecapella can you explain this, what should i do to fix this?

This comment has been minimized.

Copy link
@noisecapella

noisecapella Feb 19, 2016

The _ function is used for localization here, but these strings aren't descriptive text for a human, they're keys used by another computer or library (for example PyLmod). So these strings should not be localized.

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:

This comment has been minimized.

Copy link
@noisecapella

noisecapella Feb 18, 2016

This doesn't fix the case where len(student.grades) == aidx.

This comment has been minimized.

Copy link
@amir-qayyum-khan

amir-qayyum-khan Feb 19, 2016

it say len(student.grades) >= aidx it should cover equal case as well

This comment has been minimized.

Copy link
@noisecapella

noisecapella Feb 19, 2016

It seems like the purpose of len(student.grades) >= aidx is to prevent us from accessing past the end of the student.grades array. Right now, if aidx == len(student.grades) then the check will pass but an exception will be thrown below.

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,
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit fb9fcf2

Please sign in to comment.