Skip to main content

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

  1. Quick Installation
  2. Student Usage
  3. Spec Format
  4. Troubleshooting
  5. 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

  1. Install the library: pip install ub-grader
  2. Create your solution: Write your solution function in a Python file
  3. Register: Use init_students() with your student ID and name (supports single or multiple students)
  4. Load spec: Use load_spec() with the assignment specification URL provided by your instructor
  5. Grade: Use grade() with your solution function
  6. 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

ub_grader-0.3.5.tar.gz (17.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ub_grader-0.3.5-py3-none-any.whl (19.6 kB view details)

Uploaded Python 3

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

Hashes for ub_grader-0.3.5.tar.gz
Algorithm Hash digest
SHA256 64414f6a304780fb5a790a4fd9cd2a1b1adf244f0d9df1ec75d3dd23ecabba2f
MD5 b40238fcd779d2e8a809ab9014bf7831
BLAKE2b-256 8d6c96f3e08d7661cb5ab859fffb29d3eff53b5982e5c5488bc8054c03b3eb4c

See more details on using hashes here.

Provenance

The following attestation bundles were made for ub_grader-0.3.5.tar.gz:

Publisher: publish.yml on pablomartinezm/ub-grader

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for ub_grader-0.3.5-py3-none-any.whl
Algorithm Hash digest
SHA256 87bd24562f1f2d0a79e3d1679864d6a409adeb07f363cac9afc09d292a068780
MD5 fb90b892d0981ea0fb8b29c9e219fab1
BLAKE2b-256 f48ec125aada1fd78c43019fdeb48bfb007f2599a07042bacc9362c68e440afe

See more details on using hashes here.

Provenance

The following attestation bundles were made for ub_grader-0.3.5-py3-none-any.whl:

Publisher: publish.yml on pablomartinezm/ub-grader

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page