Created
September 17, 2022 16:50
-
-
Save jlumbroso/f43cd5d57b2d0d7893b7bcaf1808d7c6 to your computer and use it in GitHub Desktop.
codePost snippet to recompute the grades of all submissions of an assignment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import codepost | |
# fancy progress bar if available | |
try: | |
from tqdm import tqdm | |
except ModuleNotFoundError: | |
# dummy replacement that does nothing | |
tqdm = lambda x: x | |
# variable parameters | |
# get the API key here: https://codepost.io/settings | |
API_KEY = "... see above where to get this ..." | |
COURSE_NAME = "COS126" | |
COURSE_TERM = "F2022" | |
ASSIGNMENT = "Hello" | |
# authenticate | |
codepost.configure_api_key(API_KEY) | |
# retrieve the course, and then the assignment | |
# (will crash if the user of the API key doesn't have access to the course) | |
course = codepost.course.list_available(name=COURSE_NAME, period=COURSE_TERM)[0] | |
assignment = course.assignments.by_name(name=ASSIGNMENT) | |
# retrieve submissions | |
submissions = assignment.list_submissions() | |
# iterate over all submissions | |
for submission in tqdm(assignment.list_submissions()): | |
# unfinalize (will trigger grade recompute) | |
submission.isFinalized = False | |
submission.save() | |
# refinalize | |
submission.isFinalized = True | |
submission.save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment