diff --git a/common/lib/xmodule/xmodule/graders.py b/common/lib/xmodule/xmodule/graders.py index 64d2d7692372..64d6f16f97d8 100644 --- a/common/lib/xmodule/xmodule/graders.py +++ b/common/lib/xmodule/xmodule/graders.py @@ -13,7 +13,7 @@ Score = namedtuple("Score", "earned possible graded section module_id") -def aggregate_scores(scores, section_name="summary"): +def aggregate_scores(scores, section_name="summary", section_location=None): """ scores: A list of Score objects returns: A tuple (all_total, graded_total). @@ -32,7 +32,7 @@ def aggregate_scores(scores, section_name="summary"): total_possible, False, section_name, - None + section_location ) #selecting only graded things graded_total = Score( @@ -40,7 +40,7 @@ def aggregate_scores(scores, section_name="summary"): total_possible_graded, True, section_name, - None + section_location ) return all_total, graded_total diff --git a/lms/djangoapps/courseware/grades.py b/lms/djangoapps/courseware/grades.py index 1becdeb04b0a..4ad6318ac240 100644 --- a/lms/djangoapps/courseware/grades.py +++ b/lms/djangoapps/courseware/grades.py @@ -6,7 +6,6 @@ import random import logging -from contextlib import contextmanager from django.conf import settings from django.test.client import RequestFactory from django.core.cache import cache @@ -454,11 +453,15 @@ def create_module(descriptor): ) ) - __, graded_total = graders.aggregate_scores(scores, section_name) + __, graded_total = graders.aggregate_scores( + scores, + section_name, + section_location=section_descriptor.location + ) if keep_raw_scores: raw_scores += scores else: - graded_total = Score(0.0, 1.0, True, section_name, None) + graded_total = Score(0.0, 1.0, True, section_name, section_descriptor.location) #Add the graded total to totaled_scores if graded_total.possible > 0: diff --git a/lms/djangoapps/instructor/views/legacy.py b/lms/djangoapps/instructor/views/legacy.py index 51e09e91fb0b..22cf29ce4f8c 100644 --- a/lms/djangoapps/instructor/views/legacy.py +++ b/lms/djangoapps/instructor/views/legacy.py @@ -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,6 +237,7 @@ 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', '') @@ -249,23 +249,27 @@ def domatch(student): course, get_grades=True, use_offline=use_offline, - get_score_max=True + get_score_max=False if normalize_grades_enable == 1 else 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, _('max_pts')]} + datatable = {'header': [_('External email'), aname, _('max_pts'), _('normalize')]} ddata = [] # 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]] + [ + 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', { @@ -748,12 +752,16 @@ def get_student_grade_summary_data( 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']: 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) + 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): add_grade(grade_item['label'], grade_item['percent']) category_cnts[category] += 1 diff --git a/lms/templates/courseware/legacy_instructor_dashboard.html b/lms/templates/courseware/legacy_instructor_dashboard.html index 2ec867f36361..dc41150e0849 100644 --- a/lms/templates/courseware/legacy_instructor_dashboard.html +++ b/lms/templates/courseware/legacy_instructor_dashboard.html @@ -240,7 +240,9 @@

${_("Export grades to remote gradebook")}



-
  • ${_("Assignment name:")} +
  • ${_("Assignment name:")}