Skip to content

Instantly share code, notes, and snippets.

@jlumbroso
Last active March 13, 2022 20:09
Show Gist options
  • Save jlumbroso/7d79c605d28653b1cd7a5ddb8db877a1 to your computer and use it in GitHub Desktop.
Save jlumbroso/7d79c605d28653b1cd7a5ddb8db877a1 to your computer and use it in GitHub Desktop.
codePost snippet to automatically finalize all submissions of an assignment
# the codePost Python SDK must be installed: pip install codepost
import codepost
# variable parameters
# get the API key here: https://codepost.io/settings
API_KEY = "... see above where to get this ..."
COURSE_NAME = "COS126"
COURSE_TERM = "S2022"
ASSIGNMENT = "Programming Exam 1"
# 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)
# iterate over all submissions
for submission in assignment.list_submissions():
# claim submission (must assign a grader, here I assign myself)
submission.grader = "lumbroso@princeton.edu"
# finalize the submission
# (so it is visible to students, once the assignment is "published")
submission.isFinalized = True
# save changes
submission.save()
@jlumbroso
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment