Google Sheets Grade Override¶
This plugin allows you to override test case scores during grading by specifying the new score in a
Google Sheet that is pulled in. To use this plugin, you must set up a Google Cloud project and
obtain credentials for the Google Sheets API. This plugin relies on gspread
to interact with the
Google Sheets API and its documentation contains
instructions on how to obtain credentials. Once you have created credentials, download them as a
JSON file.
This plugin requires two configurations: the path to the credentials JSON file and the URL of the
Google Sheet. The former should be entered with the key credentials_json_path
and the latter
sheet_url
; for example, in Otter Assign:
plugins:
- otter.plugins.builtin.GoogleSheetsGradeOverride:
credentials_json_path: /path/to/google/credentials.json
sheet_url: https://docs.google.com/some/google/sheet
The first tab in the sheet is assumed to be the override information.
During Otter Generate, the plugin will read in this JSON file and store the relevant data in the
otter_config.json
for use during grading. The Google Sheet should have the following format:
Assignment ID |
Test Case |
Points |
||
---|---|---|---|---|
123456 |
q1a - 1 |
1 |
false |
Assignment ID
should be the ID of the assignment on Gradescope (to allow one sheet to be used for multiple assignments)Email
should be the student’s email address on GradescopeTest Case
should be the name of the test case as a string (e.g. if you have a test fileq1a.py
with 3 test cases, overriding the second case would beq1a - 2
)Points
should be the point value to assign the student for that test casePDF
should be whether or not a PDF should be re-submitted (to prevent losing manual grades on Gradescope for regrade requests)
Note that the use of this plugin requires specifying gspread
in your requirements, as it is
not included by default in Otter’s container image.
otter.plugins.builtin.GoogleSheetsGradeOverride
Reference¶
The actions taken by at hook for this plugin are detailed below.
- class otter.plugins.builtin.GoogleSheetsGradeOverride(submission_path, submission_metadata, plugin_config)¶
Otter plugin for overriding test case scores with values in a Google Sheet on Gradescope. Uses provided Google Service Account credentials to pull in the spreadsheet as a dataframe and edits test case scores by matching on the Gradescope assignment ID, student email, and test case name.
Implements the
during_generate
,before_grading
, andafter_grading
events. Make sure to list this plugin asotter.plugins.builtin.GoogleSheetsGradeOverride
, otherwise theduring_generate
event of this plugin will not work.The google sheet should have the following format:
Assignment ID
Email
Question
Points
PDF
123456
q1a - 1
1
false
Assignment ID
should be the ID of the assignment on Gradescope,Email
should be the email address corresponding to the student’s Gradescope account,Question
should be the name of the question, andPoints
should be the number of points that the student should be assigned.PDF
should befalse
if the student’s PDF should not be regenerated during this run of the autograder.- after_grading(results)¶
Modifies the results of grading by pulling in the Google Sheet as a dataframe and updating the scores for the test cases found.
- Parameters
results (
otter.test_files.GradingResults
) – the results of grading
- before_grading(config)¶
Controls whether or not a PDF is generated by setting the
token
key of the grading config toNone
if any of the rows in the dataframe matching this (email, assignment ID) tuple indicate that a PDF should not be generated.- Parameters
config (
dict
) – the grading configurations
- property df¶
The grade override information dataframe
- during_generate(otter_config, assignment)¶
Takes a path to Google Service Account credentials stored in this plugin’s config as key
credentials_json_path
and extracts the data from that file into the plugin’s config as keyservice_account_credentials
.- Parameters
otter_config (
dict
) – the parsed Otter configuration JSON fileassignment (
otter.assign.assignment.Assignment
) – the assignment configurations if Otter Assign is used