Skip to main content

A Python Package to Grade Programming Assignments Automatically.

Project description

cpGrader: A Python Package to Grade Programming Assignments Automatically

Test PyPI python-version

cpGrader is designed to be used with the course "NTNU CSIE Computer Programming I/II" by instructor neokent (紀博文 Po-Wen Chi).

Thanks for your Contribution 🌟

41247001S-盧昱安 41247012S-吳振榮 41247024S-廖妤恩 41247032S-吳俊廷 41247039S-韓欣劭 41247057S-陳育渝

Installation

pip install cpGrader

How does it works?

assets

Stage (You can enable/disable the stage)

  • Extract: Get all the students's source file from moodle submission folder.
  • Build: Copy the support files to the student's folder and Compile the student's program.
  • Execute: Run the student's program by the testcase and Generate output file by each testcase.
  • Verify: Compare the student's output with the correct plaintext output or the correct program's output.

Step

  1. Download all the student submissions from Moodle.
  2. Think about the testcases and strategies that how to grade the student's assignment.
  3. Write a config file.
  4. Design the verify function.
  5. Run your grader.

Getting Started

TOML Config File

  • global: the global settings (Field below is just for global).
    • support [list]: the files copied to the student's folder.
  • case: the testcase settings (Each case can be independent).
    • name [string]: name of testcase.
    • file [string]: filepath of testcase file.
    • pts [float | int]: grading points.
    • correct [string]: the correct file which is program file (.c, .py) or plain text file (.txt, .out).
    • command [string]: the command to run student's program.

Basic Example

Config File

[global]
support = ["input.bmp", "assignment.h"]
correct = "./correct.c"
command = "./assignment"

[[case]]
name = "case1"
file = "./testcase/1.in"
pts = 5

[[case]]
name = "case2"
file = "./testcase/2.in"
pts = 10

Python Code

from cpGrader import Grader

grader = Grader()

@grader.setcase()
def verify(case_name: str, student_output: str, correct_output: str):
    assert student_output == correct_output

grader.run(
    moodle_submission_dir="/path/to/submissions_dir"
)

GO AND SEE MORE REAL EXAMPLES HERE.

Pytest Testing

Run All Examples Test

pytest

Choose the Test to Run (Wildcard)

pytest -k 2023-cp1-hw01

Details and Muti-Threading

pytest -vs -n auto

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

cpgrader-0.1.3.tar.gz (20.2 kB view details)

Uploaded Source

Built Distribution

cpgrader-0.1.3-py3-none-any.whl (20.4 kB view details)

Uploaded Python 3

File details

Details for the file cpgrader-0.1.3.tar.gz.

File metadata

  • Download URL: cpgrader-0.1.3.tar.gz
  • Upload date:
  • Size: 20.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.1 Linux/6.5.0-1025-azure

File hashes

Hashes for cpgrader-0.1.3.tar.gz
Algorithm Hash digest
SHA256 3e6816f772ff5bcc4c886bd2f8036a88af0fe4ea80ed6a0af87a959908a2f294
MD5 7e05f45ccae89d1bc34a2cb6d9751629
BLAKE2b-256 ef753debe882aaa83221585670d948dfc6ef95adcd1582d2ba8cfc88601f1f1f

See more details on using hashes here.

File details

Details for the file cpgrader-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: cpgrader-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 20.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.1 Linux/6.5.0-1025-azure

File hashes

Hashes for cpgrader-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0d5a3e20e741353dcd8c177f8e2b95f0730e6daa9c0ed204df508adbebfe3370
MD5 1f8012382c0d49d4eccec910e7e06064
BLAKE2b-256 dd817f58bb4f590b899e79f6fb99f1ce4861348dc258ebbbccbfb76d647a0658

See more details on using hashes here.

Supported by

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