An package for easy autograding.
Grade: Get Readymade Autograding Done Efficiently
A utility for programming assignment autograding.
Grade attempts alleviate typical problems in autograding workflows.
By providing easy-to-use wrappers to work directly with executable files, Grade can test almost anything.
Combining that with the
ScoringMixin and the
GradedRunner, allows you to output your scores for Gradescope or an in-house Markdown report.
python -m pip install grade
- Create a
- Optionally, add in the
- For each question, you can use
self.weight = xto set the weight of a question.
- If you wish to assign partial credit for some portion of a test, you can use
self.score = x. (Warning: if you leave a test with partial credit, the student will receive that score, to give full credit at the end simply run
self.score = self.weight)
- Run the tests using
grade.runners.GradedRunner().run(TestSuite), which returns a
- Once you have the results, you can output them to
jsonvia the property
To properly output scores for Gradescope, simply write the
json results to
Option 1: Redirection
Given the following python snippet at the end of your test file:
if __name__ == "__main__": suite = unittest.TestLoader().discover('./', pattern='test*') print(runners.GradedRunner().run(suite).json)
Simply redirect the output:
python test.py > autograder/results/results.json
Option 2: Direct Writing
Of course, you can also write directly to the file in your code.
Ensure you only do this in one place, or it may overwrite your work!
if __name__ == "__main__": suite = unittest.TestLoader().discover('./', pattern='test*') results = runners.GradedRunner().run(suite).json with open('/autograder/results/results.json', 'w') as f: f.write(results.json)
Release history Release notifications
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size grade-0.7.3-py3-none-any.whl (19.6 kB)||File type Wheel||Python version py3||Upload date||Hashes View|
|Filename, size grade-0.7.3.tar.gz (9.3 kB)||File type Source||Python version None||Upload date||Hashes View|