This is a sample autograder for a Python assignment similar to the C++ assignment described here.
Editing bash scripts (e.g. diffs.sh) on Windows will convert the line endings to Windows style, causing the script to be unusable by the Docker container. Either edit the files in a Unix/Mac environment or use a tool to de-convert the line endings BEFORE uploading your autograder.zip.**
Any extra files (e.g. data files) that should be in the same directory as the student submission while the submission is being executed. In this repo, the EXECUTION-FILES directory has input.txt file from the provided-files directory in the assignment repo.
A reference solution which will be used to generate the expected outcome for all tests. Like student solutions, this solution will be run with all files from EXECUTION-FILES in the same directory.
A bash script that creates the expected test output using the reference solution. Leave this unchanged when creating your own autograder.
A bash script for installing any necessary dependencies for the assignment.
A list (newline-separated) of any Python packages that need to be installed.
A list (newline-separated) of any Python 3 packages that need to be installed.
A bash script describing the tests to be run. See this page for further documentation, especially this handy reference to the annotations
A bash script for generating the results of the student submission. At the top of this file, you must specify the expected student submisson files. This assignment expects files countToN.py, helloFile.py, helloWorld.py, helloStderr.py, readFile.py, and readStdin.py. Thus, grade.sh begins with:
EXPECTED_FILES="countToN.py helloFile.py helloWorld.py helloStderr.py readFile.py readStdin.py "
- Create a new empty private repo, e.g. with the name PRIVATE-cs8-s18-labxx-gs
- Clone the empty repo with
git clone <url> cdinto that directory:cd PRIVATE-cs8-s18-labxx-gs- Add a remote for this sample repo via:
git remote add template git@github.com:ucsb-gradescope-tools/sample-python-diff-autograder.git - Pull from this sample repo via
git pull template master - Push to origin with
git push origin master
-
In
grade.shedit the environment variableEXPECTED_FILESto list the files you expect the student to submit. Only these will be copied from the student submission into the space where the assignment is graded.If you prefer all files to be copied in, edit the
grade.shscript to copy all files from/autograder/submissioninto the target directory. -
Edit the
diffs.shfile to put in the tests that you want to run, along with shell script comments containing JSON indicating the tests. Handy reference to the annotations -
Put a reference solution into REFERENCE-SOLUTION
To test your autograder locally:
Try putting a correct sample solution in the SAMPLE-SOLUTION-1 directory and an incorrect sample solution in the SAMPLE-SOLUTION-2 directory. (You have the option of creating additional SAMPLE-SOLUTION-nn directories, as few or as many as you see fit if you want to test a wider range of solution possibilities.)
To check what will happen, run:
- First, run
./MAKE-REFERENCE.shto generate the output of the reference solution - Then try grading each of your sample solutions:
./grade.sh SAMPLE-SOLUTION-1./grade.sh SAMPLE-SOLUTION-2- etc.
(When converting assignments from UCSB's submit.cs, you might adapt a "perfect" solution and a "flawed" solution from among previous student submissions, by looking at the grade assigned by submit.cs)
In each case, look at the file results.json to see whether it reflects what you expect the resulting grade to be.
Step 4: Create an Autograder.zip using the link-gs-zip-with-repo tool.
- Clone the link-gs-zip-with-repo.
- In that repo, edit
env.shto point to your repo. You don't need to commit that change. - Run the script
./make_deploy_keys.sh - Upload your deploy key to the new repo you created for your assignment.
- Run the script
./make_autograder_zip.shand then upload theAutograder.zipto Gradescope.
You are now ready to test your autograded assignment.