Librería para auto-corrección local de prácticas con reporte cifrado y firmado
Project description
ub-grader
Python library for students to self-grade assignments locally and generate reports to submit to instructors.
Table of Contents
- Quick Installation
- Student Usage
- Spec Format
- Troubleshooting
- License
1. Quick Installation
pip install ub-grader
Requires Python 3.10+.
2. Student Usage
Basic Usage
from ub_grader import init_students, load_spec, grade
from solution import solve # your target function
# Register students (single student or multiple for group work)
init_students([
{"niub": "A123", "first_name": "Alice", "last_name": "Doe"},
])
# Load assignment specification
load_spec("https://server/assignments/p1.json") # or file:///abs/path/p1.json
# Grade your solution
result = grade(
solve,
student_id="A123",
)
print("Final score:", result["final_score"], "/", result["max_score"])
After running, a report file will be generated. Submit this file to your instructor.
Step-by-Step Guide
- Install the library:
pip install ub-grader - Create your solution: Write your solution function in a Python file
- Register: Use
init_students()with your student ID and name (supports single or multiple students) - Load spec: Use
load_spec()with the assignment specification URL provided by your instructor - Grade: Use
grade()with your solution function - Submit: Send the generated report file to your instructor
Multiple Students (Group Work)
You can register multiple students at once, which is useful for group assignments or when managing multiple student accounts:
init_students([
{"niub": "A123", "first_name": "Alice", "last_name": "Doe"},
{"niub": "B456", "first_name": "Bob", "last_name": "Smith"},
{"niub": "C789", "first_name": "Charlie", "last_name": "Brown"},
])
# Each student can then generate their own report
result_alice = grade(solve, student_id="A123")
result_bob = grade(solve, student_id="B456")
3. Spec Format
Assignment specifications are provided by your instructor as JSON files. A typical spec includes:
{
"version": "1.0.0",
"assignment_id": "p1",
"tests": [
{
"id": "t1",
"input": { "args": [1, 2], "kwargs": {} },
"expected": 3,
"weight": 1,
"expected_hidden": false,
"time_limit_ms": 500,
"memory_limit_kb": 10000,
"comparison": "equal"
}
],
"scoring": {
"mode": "weighted_sum_with_penalties",
"rounding": 2,
"penalties": {},
"max_score": 10
}
}
Key points for students:
- Tests may have
expected_hidden: true, which means you won't see the expected output, only pass/fail - Each test has time and memory limits
- Exceeding limits may result in penalties applied to your score
4. Troubleshooting
Common Issues
| Issue | Likely Cause | Solution |
|---|---|---|
RuntimeError: No spec loaded |
Forgot to call load_spec() |
Call load_spec() before grade() |
ValueError: Missing required field |
Malformed spec JSON | Contact your instructor for a valid spec |
| Very low score | Tests failing or penalties applied | Review your logic and check time/memory limits |
Best Practices
- Use a dedicated virtual environment:
python -m venv myenv && source myenv/bin/activate - Don't modify the assignment spec file
- Test your solution thoroughly before final grading
- Keep backups of your solution code
Getting Help
- Check that your Python version is 3.10 or higher
- Ensure you have the latest version:
pip install -U ub-grader - Review the error messages carefully - they usually indicate the specific issue
- Contact your instructor if you suspect issues with the assignment specification
5. License
MIT
Project details
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 ub_grader-0.3.5.tar.gz.
File metadata
- Download URL: ub_grader-0.3.5.tar.gz
- Upload date:
- Size: 17.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64414f6a304780fb5a790a4fd9cd2a1b1adf244f0d9df1ec75d3dd23ecabba2f
|
|
| MD5 |
b40238fcd779d2e8a809ab9014bf7831
|
|
| BLAKE2b-256 |
8d6c96f3e08d7661cb5ab859fffb29d3eff53b5982e5c5488bc8054c03b3eb4c
|
Provenance
The following attestation bundles were made for ub_grader-0.3.5.tar.gz:
Publisher:
publish.yml on pablomartinezm/ub-grader
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ub_grader-0.3.5.tar.gz -
Subject digest:
64414f6a304780fb5a790a4fd9cd2a1b1adf244f0d9df1ec75d3dd23ecabba2f - Sigstore transparency entry: 578876154
- Sigstore integration time:
-
Permalink:
pablomartinezm/ub-grader@e95832a628d547cb43e1f4adf44c0e7028362df1 -
Branch / Tag:
refs/tags/v0.3.5 - Owner: https://github.com/pablomartinezm
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e95832a628d547cb43e1f4adf44c0e7028362df1 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ub_grader-0.3.5-py3-none-any.whl.
File metadata
- Download URL: ub_grader-0.3.5-py3-none-any.whl
- Upload date:
- Size: 19.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87bd24562f1f2d0a79e3d1679864d6a409adeb07f363cac9afc09d292a068780
|
|
| MD5 |
fb90b892d0981ea0fb8b29c9e219fab1
|
|
| BLAKE2b-256 |
f48ec125aada1fd78c43019fdeb48bfb007f2599a07042bacc9362c68e440afe
|
Provenance
The following attestation bundles were made for ub_grader-0.3.5-py3-none-any.whl:
Publisher:
publish.yml on pablomartinezm/ub-grader
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ub_grader-0.3.5-py3-none-any.whl -
Subject digest:
87bd24562f1f2d0a79e3d1679864d6a409adeb07f363cac9afc09d292a068780 - Sigstore transparency entry: 578876171
- Sigstore integration time:
-
Permalink:
pablomartinezm/ub-grader@e95832a628d547cb43e1f4adf44c0e7028362df1 -
Branch / Tag:
refs/tags/v0.3.5 - Owner: https://github.com/pablomartinezm
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e95832a628d547cb43e1f4adf44c0e7028362df1 -
Trigger Event:
push
-
Statement type: