Copyright (c) 2023-2024 Jared Daniel Recomendable.
A collection of scripts for manipulating student submissions made to platforms such as GitHub Classroom.
- Unix System (macOS, most GNU/Linux distros, WSL under Windows)
pathos
for parallelismrequests
Library- GitHub API Key
pip3 install pathos requests
See Developer setttings on GitHub to obtain your API key. Be sure to include administration:write
permissions.
The following shows which script(s) to run and in what order (if applicable) depending on the context.
- Run
assignment_repo_cloner.py
, modifying the following configuration values inconfig.json
:github_api_key
github_org
assignment_prefix
assignment_date_filter
path_to_clone_assignment_repos
- Run
code_owner_permissions_modifier.py
, modifying the following configuration values inconfig.json
:github_api_key
github_org
assignment_prefix
path_to_repo_mappings
collaborator_permission
- Copy
git_actions_runner.sh
to the directory containing the student repos, then adapt the script accordingly. - Remember to set execute permissions prior to running.
Do this prior to the start of a peer review assignment.
- Run
peer_review_group_creator.py
, modifying the following configuration values inconfig.json
:github_api_key
github_classroom_assignment_id
path_to_github_classroom_roster
peer_count
peer_assignment_interval
path_to_repo_mappings
path_to_peer_review_mappings
- Next, run
peer_review_repo_access.py
, passing inadd
as the argument and modifying the following configuration values inconfig.json
:github_api_key
path_to_repo_mappings
path_to_peer_review_mappings
Do this when a peer review assignment has concluded, and to pass on peer reviews to the target recipients.
- Block out existing peer reviewers from accessing their peers' repos by running
peer_review_repo_access.py
, passing inremove
as the argument and modifying the following configuration values inconfig.json
:github_api_key
path_to_repo_mappings
path_to_peer_review_mappings
- Next, inspect directories for any improperly-formatted Markdown files, or Markdown files that do not follow the naming convention of
{target_recipient_gh_username}.md
, making corrections (and applying penalties) where necessary. - Next, run
peer_review_md_to_html_compiler.py
, modifying the following configuration values inconfig.json
:assignment_prefix
path_to_peer_review_src
path_to_github_classroom_roster
- Next, run
peer_review_sorter.py
, modifying the following configuration values inconfig.json
:assignment_prefix
path_to_github_classroom_roster
path_to_peer_review_src
path_to_peer_review_dest
- Next, inspect the directory bearing the Markdown files for distributions for anomalies. E.g. students may have mispelt the name of a GitHub username while naming their Markdown files for peer reviews, leading to duplicate entries for the target recipient. Make corrections where necessary, and apply penalties to the source of the peer review where needed.
- Next, if the recipient should not know the source of their peer reviews, run
peer_review_anonymizer.py
, modifying the following configuration values inconfig.json
:path_to_peer_review_dest
- Next, zip each directory containing the peer reviews for each recipient, adapting
git_actions_runner.sh
where needed. - Next, stage each recipient's ZIP file containing their peer reviews onto their Git repositories, adapting
git_actions_runner.sh
where needed. - Finally, commit the changes and push to the remote repo for each recipient, adapting
git_actions_runner.sh
where needed.
The Python scripts takes its configuration from config.json
, which is included in .gitignore
.
Below are descriptions of each key in config.json
.
The API key obtained from the GitHub Developer settings. Required to make GitHub API requests to manipulate GitHub Orgnanization and GitHub Classroom repos.
The assignment ID assigned by GitHub Classroom to an assignment. Required to list accepted assignments in GitHub Classroom.
To obtain this, make a GET request to https://api.github.com/classrooms/{CLASSROOM_ID}/assignments with your GitHub API key.
Meanwhile, to obtain CLASSROOM_ID
, make a GET request to https://api.github.com/classrooms with your GitHub API key.
The name of the GitHub Organization that stores the GitHub assignment repos.
A string that prefixes the assignment repo names. Typically this is the name of the starter/template repo made for the GitHub Classroom assignment, plus a dash at the end.
A (partial) date string in ISO-8601 used to filter for assignment repos when cloning them from a GitHub Organization based on creation time.
Useful for GitHub Organizations that lump together submissions from different iterations of a course (e.g. over the years).
E.g. to obtain repos created in 2024, assign the value 2024-
to assignment_date_filter
. To further limit the search to April 2024, assign the value 2024-04-
instead.
The path to the directory where the repos will be cloned to, i.e. will store the subdirectories where each subdirectory is a repo for an assignment submission.
The path to the roster file generated from the GitHub Classroom web user interface.
The number of peer reviewers per peer in peer assignments.
For peer reviews, each student reviews every nth peer from its ordinal rank, where n is defined as the peer_assignment_interval
. In the case that the nth peer from the student's ordinal rank occurs after the end of the list, a wraparound occurs to the start of the list.
Path to the directory containing subdirectories, where each subdirectory is a cloned repository from GitHub.
Each cloned repository contains peer reviews written by the student assigned to that repository.
Each peer review is written in a Markdown file. The Markdown file may reference live media, such as GIFs and screencasts. They need to be converted into self-contained HTML files for distribution to the target peers reviewed by the student.
Path to the directory containing subdirectories, where each subdirectory contains HTML files.
Each subdirectory is named after a student who has received a peer review from peers.
Path to the file mapping GitHub usernames to assignment repository URLs.
Path to the file mapping a student to peers whom they will review.
The permission to give collaborators of a repo.
Typically used to control student access to their repos, e.g. when the due date has lapsed.
Available values can be found by reading the GitHub API docs.
Requires admin
permission on a repo to successfully update other collaborators' permissions.