Created
November 28, 2022 01:51
-
-
Save jlumbroso/43fd74315f16f56f5c18744a0db36ccf to your computer and use it in GitHub Desktop.
codePost snippet to assign graders to specific submissions, given a CSV file
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 | |
# 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 = "[email protected]" | |
# 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