Skip to content

Commit

Permalink
Added normalize column and checkbox in UI and fixed grade max point i…
Browse files Browse the repository at this point in the history
…ssue using gradebook summery
  • Loading branch information
amir-qayyum-khan committed Feb 10, 2016
1 parent d924c80 commit 6a9278f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 16 deletions.
6 changes: 3 additions & 3 deletions common/lib/xmodule/xmodule/graders.py
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -32,15 +32,15 @@ def aggregate_scores(scores, section_name="summary"):
total_possible,
False,
section_name,
None
section_location
)
#selecting only graded things
graded_total = Score(
total_correct_graded,
total_possible_graded,
True,
section_name,
None
section_location
)

return all_total, graded_total
Expand Down
9 changes: 6 additions & 3 deletions lms/djangoapps/courseware/grades.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
26 changes: 17 additions & 9 deletions lms/djangoapps/instructor/views/legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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', '')
Expand All @@ -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 += "<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, _('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', {
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion lms/templates/courseware/legacy_instructor_dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,9 @@ <h3>${_("Export grades to remote gradebook")}</h3>
<br/>
<br/>
</li>
<li>${_("Assignment name:")} <input type="text" name="assignment_name" size=40 >
<li>${_("Assignment name:")} <input type="text" name="assignment_name" size=40 > <input
type="checkbox" name="normalize_grades" id="normalize_grades" checked="checked" /> <label style="display:inline"
for="normalize_grades">${_("Normalize Grades")}</label>
<br/>
<br/>
<input type="submit" name="action" value="Display grades for assignment">
Expand Down

0 comments on commit 6a9278f

Please sign in to comment.