Skip to content
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

Fixed issue related to grades of invalid students in legacy dashboard #225

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion lms/djangoapps/instructor/views/legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def domatch(student):
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:
if hasattr(student, 'grades') and len(student.grades) >= aidx and student.grades[aidx] is not None:
ddata.append(
[
student.email,
Expand Down Expand Up @@ -767,6 +767,9 @@ def get_student_grade_summary_data(
gtab = GradeTable()

for student in enrolled_students:
if not student.id or not student.profile:
continue

datarow = [student.id, student.username, student.profile.name, student.email]
try:
datarow.append(student.externalauthmap.external_email)
Expand All @@ -775,8 +778,12 @@ def get_student_grade_summary_data(

if get_grades:
gradeset = student_grades(student, request, course, keep_raw_scores=get_raw_scores, use_offline=use_offline)
if not gradeset:
continue
log.debug(u'student=%s, gradeset=%s', student, gradeset)
with gtab.add_row(student.id) as add_grade:
if not add_grade:
continue
if get_raw_scores:
# The following code calls add_grade, which is an alias
# for the add_row method on the GradeTable class. This adds
Expand All @@ -793,6 +800,8 @@ def get_student_grade_summary_data(
else:
category_cnts = Counter()
progress_summary = grades._progress_summary(student, request, course)
if not progress_summary:
continue
for grade_item in gradeset['section_breakdown']:
category = grade_item['category']
try:
Expand All @@ -807,6 +816,7 @@ def get_student_grade_summary_data(
# student has not attempted it or it is not grade able.
add_grade(grade_item['label'], grade_item['percent'], possible=1)
category_cnts[category] += 1

student.grades = gtab.get_grade(student.id)

data.append(datarow)
Expand Down