Skip to content

Instantly share code, notes, and snippets.

@jlumbroso
Created November 28, 2022 01:51
Show Gist options
  • Save jlumbroso/43fd74315f16f56f5c18744a0db36ccf to your computer and use it in GitHub Desktop.
Save jlumbroso/43fd74315f16f56f5c18744a0db36ccf to your computer and use it in GitHub Desktop.
codePost snippet to assign graders to specific submissions, given a CSV file
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 = "F2022"
ASSIGNMENT = "Final Project Proposal PDF"
DEFAULT_TEACHER = "pparedes@princeton.edu"
# read assignments of students -> teacher from a CSV file
student_to_teacher = {
line.strip().split(",")[0] : line.strip().split(",")[1]
for line in open("cos126-f2022-final-project-partnerships-signups.csv").readlines()
if line.strip() != ""
}
# 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)
errors = []
# iterate over all submissions
for submission in assignment.list_submissions():
# lookup grader for this submission
# (we assume both students are assigned the same grader)
teacher = student_to_teacher.get(
submission.students[0],
DEFAULT_TEACHER
)
# claim submission
submission.grader = teacher
try:
# save changes
submission.save()
except:
errors.append(submission)
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment