Crashes if you accidentally select assignment with no points
Canvas allows assignments to display grades in different manners:
I accidentally selected an assignment with Complete/Incomplete
set on it, and the script just crashed:
Traceback (most recent call last):
File "./analyze_grades.py", line 147, in <module>
assess_course(course_selection)
File "./analyze_grades.py", line 138, in assess_course
assess_assignments(course, major_partitions, answer != '' and answer[0].upper() == 'Y')
File "./analyze_grades.py", line 106, in assess_assignments
print_statistics(oat_assignment, major_partitions)
File "./analyze_grades.py", line 74, in print_statistics
print_statistics_for_some_majors(assignment, computing_majors, major_partitions)
File "./analyze_grades.py", line 59, in print_statistics_for_some_majors
scores: List[float] = [assignment.get_score(student) for student in student_subset
File "./analyze_grades.py", line 60, in <listcomp>
if assignment.get_score(student) is not None]
File "/home/fac/cabohn/abet-oat/api/canvas_classes.py", line 523, in get_score
return float(submission.grade) if submission.grade is not None else None
ValueError: could not convert string to float: 'complete'
The script probably should handle that a bit more gracefully.
And I do not have any assignments to test it, but suspect if one is set to something other than Points
(such as Percentage
) it would probably not work as expected--though it might not crash in that case.
Another edge case is probably if the total points is set to 0 - does it divide by 0 on line 63?