Some helpers to help writing correction bots, use by hackinscience.org.
Project description
Correction Helper
Project
This is just a set of tools to help writing correction bots in Python for Python.
It is used for hackinscience, but could be used elsewhere.
Security considerations
Running student code is probably really unsafe, unless you trust your students not to drop you a backdoor.
This projet does not help with security in any ways, maybe take a
look at firejail if you have
trust issues (Yes you can use correction-helper inside firejail).
Usage
To install it, run: pip install correction-helper.
In your checking code, you can use it like this:
The student_code decorator
This decorator is aimed to catch most problems that could happen in student code, use it simply as:
with student_code():
their_function()
Find a more complete example in the examples/ directory.
Allowed parameters for student_code, and their default values
exception_prefix="Got an exception:"
Printed right before the exception, if any.
friendly=False
To use, or not friendly-traceback instead of bare Python exceptions.
print_allowed=False
To allow the use to print to stdout / stderr, you can read what they printed using the value of the context manager:
with student_code(print_allowed=True) as run:
their_function()
assert run.stderr == ""
assert run.stdout == "42"
print_allowed can be set to None meaning "neither allowed nor
really denied": the student output will be printed along with the
print_prefix, but it's not considered a failure.
print_prefix="Your code printed something (it should **not**):"
Message to display when they printed and print_allowed was False.
Good practices
Try first if the student code works, if it works, it works. Only if the code does not work, try to understand why.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file correction-helper-2021.11.2.tar.gz.
File metadata
- Download URL: correction-helper-2021.11.2.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ac675452dbede64be237aa509e8e5446f08854a6c37b0ab14dd82274cee4864
|
|
| MD5 |
f319182087fa46b86d9919ab8568cf84
|
|
| BLAKE2b-256 |
7ce3b41a6b23d5ae2c83d23857f434d1cc11f4c2f7cc397fcead176679638fed
|
File details
Details for the file correction_helper-2021.11.2-py3-none-any.whl.
File metadata
- Download URL: correction_helper-2021.11.2-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1bdceef6c91c63a67b6c487f4da7e0b20f2836a9a09f0a93c6c38858a841870e
|
|
| MD5 |
80e03c87c1b8c37078283cd8d60d6905
|
|
| BLAKE2b-256 |
41342685f835f41570029a04079eaaa6c44aa16ef577dd1ce3bb5f49dd3d9093
|