From c553b79e1ca009dcde5015d4e0a48b789c86ee5e Mon Sep 17 00:00:00 2001 From: Joel Ostblom Date: Wed, 7 Jul 2021 19:05:04 -0700 Subject: [PATCH] Add support for the canvas override grade column --- CHANGELOG.md | 5 +++++ canvascli/main.py | 14 +++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6734465..a116f81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). Version number is based on [Semver](https://semver.org/). Note that major version zero (0.y.z) is for initial development and anything may change at any time. +## [0.3.2] - 2021-07-07 + +### Added +- Support for the Canvas override final grade column. + ## [0.3.1] - 2021-06-01 ### Added diff --git a/canvascli/main.py b/canvascli/main.py index 7025515..51fa1fb 100644 --- a/canvascli/main.py +++ b/canvascli/main.py @@ -245,13 +245,25 @@ def get_canvas_grades(self): enrollments = self.course.get_enrollments( type=['StudentEnrollment'], state=[self.student_status]) canvas_grades = defaultdict(list) + overridden_grades = [] for enrollment in enrollments: canvas_grades['Student Number'].append(enrollment.user['sis_user_id']) surname, preferred_name = enrollment.user['sortable_name'].split(', ') canvas_grades['Surname'].append(surname) canvas_grades['Preferred Name'].append(preferred_name) - canvas_grades['Percent Grade'].append(enrollment.grades['final_score']) + if 'override_score' in enrollment.grades: + overridden_grades.append( + f"{preferred_name:<12} {surname:<12}" + f" {enrollment.grades['final_score']:<4} ->" + f" {enrollment.grades['override_score']}") + canvas_grades['Percent Grade'].append(enrollment.grades['override_score']) + else: + canvas_grades['Percent Grade'].append(enrollment.grades['final_score']) self.canvas_grades = pd.DataFrame(canvas_grades) + if len(overridden_grades) > 0: + click.echo('Students with manual Canvas override of their final grade:') + [click.echo(grade) for grade in overridden_grades] + click.echo() return def drop_student_entries(self):