This repository contains two Python scripts to help autograde student work in a Python programming course that uses GitHub Classroom for assignments and exams.
Contents:
- a script that runs
pytest
-based unit tests on a batch of student assignemnt submissions and saves the resulting grades into a CSV file. - a script that checks
git log
to determine whether each student pushed their code within the allowed time (good for timed exams), and saves results into a CSV file.
A few assumptions:
- all student code for a given assignment is placed within sub-directories (one subdirectory per student) of a main directory for the assignment. This matches the way that GitHub Classroom Assistant delivers student submissions.
pytest
-based unit tests used to evaluate the assignment submissions are placed within each student's directory.- work is delivered to students as GitHub Classroom assignments, where new git repositories are autogenerated for students when they "accept" an assignment.
Install all dependencies with pipenv
, i.e. pipenv install
. Then activate the virtual environment with pipenv shell
.
Alternatively, if you prefer, you can use pip
, i.e. pip install -r requirements.txt
(or pip3 install -r requirements.txt
)
The script, grade_assignments.py, autogrades student work by running pytest
-based unit tests.
- Make this script executable and run,
./grade_assignments.py --base_path path_to_main_assignment_directory
orpython3 grade_assignments.py --base_path path_to_main_assignment_directory
, wherepath_to_main_assignment_directory
is replaced by your main assignment directory. - Grades for all students will be saved into a CSV file named,
test_output_files/marks.csv
within the assignment main directory.
The script, check_git_commits_time.py, identifies students who took longer than allowed to complete an exam or assignment. This is especially useful for exams where students can start at a time of their choosing, but are timed from the moment they begin.
- Make this script executable (i.e.
chmod u+x *.py
) and run,./check_git_commits_time.py --base_path path_to_main_assignment_directory
orpython3 check_git_commits_time.py --base_path path_to_main_assignment_directory
, wherepath_to_main_assignment_directory
is replaced by your main assignment directory. - Add an optional
--time_allowed
flag with the number of minutes allowed for the exam. For example,./check_git_commits_time.py --base_path path_to_main_assignment_directory --time_allowed 120
. The allowed time defaults to3.5
hours. - Names and time taken by students over the allowed limit will be saved into a CSV file named,
git_log_output_files/students.csv
within the assignment main directory.