Skip to content

Commit

Permalink
Import exam grades: ignore no score rows (#4759)
Browse files Browse the repository at this point in the history
* Import exam grades: ignore no score rows

* little fix
  • Loading branch information
annagav authored Jan 22, 2021
1 parent e2e9ebd commit 67627ec
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions exams/management/commands/import_edx_exam_grades.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,22 @@ def handle(self, *args, **kwargs): # pylint: disable=unused-argument,too-many-l
exam_authorization.exam_no_show = True
exam_authorization.save()
else:
try:
score = float(row['score'])
except ValueError:
self.stdout.write(
self.style.ERROR('Failed to create grade: empty score for user {} and exam run {}'.format(
user.username,
exam_run.id
))
)
continue

defaults = {
'passing_score': exam_run.passing_score,
'score': float(row['score']),
'score': score,
'grade': row['grade'],
'percentage_grade': float(row['score']) / 100.0 if row['score'] else 0,
'percentage_grade': score / 100.0 if score else 0,
'passed': row['grade'].lower() == EXAM_GRADE_PASS,
'row_data': row,
'exam_date': now_in_utc()
Expand Down

0 comments on commit 67627ec

Please sign in to comment.