forked from openedx/edx-platform
-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added normalize column to export grade book to remote gradebook #190
Closed
amir-qayyum-khan
wants to merge
2
commits into
master
from
enhancement/aq/add_normalization_info_lagacy_dashboard_remote_gradebook_mitocw#147
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,11 +97,11 @@ def get_expected_grade_data( | |
], | ||
'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 | ||
] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,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 | ||
|
@@ -36,7 +36,6 @@ | |
from courseware import grades | ||
from courseware.access import has_access | ||
from courseware.courses import get_course_with_access, get_cms_course_link | ||
from courseware.models import StudentModule | ||
from django_comment_common.models import FORUM_ROLE_ADMINISTRATOR | ||
from django_comment_client.utils import has_forum_access | ||
from instructor.offline_gradecalc import student_grades, offline_grades_available | ||
|
@@ -238,25 +237,41 @@ def domatch(student): | |
elif action in ['Display grades for assignment', 'Export grades for assignment to remote gradebook', | ||
'Export CSV file of grades for assignment']: | ||
|
||
normalize_grades_enable = 1 if request.POST.get('normalize_grades', None) else 0 | ||
log.debug(action) | ||
datatable = {} | ||
aname = request.POST.get('assignment_name', '') | ||
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=False if normalize_grades_enable == 1 else 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'), _('normalize')]} | ||
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], | ||
normalize_grades_enable | ||
], | ||
) | ||
else: | ||
log.debug(u'No grade for assignment %(idx)s (%(name)s) for student %(email)s', { | ||
"idx": aidx, | ||
"name": aname, | ||
|
@@ -736,8 +751,20 @@ def get_student_grade_summary_data( | |
else: | ||
add_grade(score.section, score.earned) | ||
else: | ||
category_cnts = Counter() | ||
progress_summary = grades._progress_summary(student, request, course) | ||
for grade_item in gradeset['section_breakdown']: | ||
add_grade(grade_item['label'], grade_item['percent']) | ||
category = grade_item['category'] | ||
try: | ||
location = gradeset['totaled_scores'][category][category_cnts[category]].module_id | ||
earned, possible = progress_summary.score_for_module(location) | ||
if get_score_max is True: | ||
add_grade(grade_item['label'], earned, possible=possible) | ||
else: | ||
add_grade(grade_item['label'], grade_item['percent'], possible=1) | ||
except (IndexError, KeyError): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a comment explaining when you expect to hit this exception There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
add_grade(grade_item['label'], grade_item['percent']) | ||
category_cnts[category] += 1 | ||
student.grades = gtab.get_grade(student.id) | ||
|
||
data.append(datarow) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pdpinch @pwilkins
possible=1
because code above (https://github.com/mitocw/edx-platform/pull/190/files#diff-5dd41ae768fed10fe37df53a1d9e78c8R268) is expecting a tuple (earned, possible).https://github.com/mitocw/edx-platform/pull/190/files#diff-5dd41ae768fed10fe37df53a1d9e78c8R268 ??