cpGrader is designed to be used with the course "NTNU CSIE Computer Programming I/II" by instructor neokent (紀博文 Po-Wen Chi).
pip install cpGrader
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.
- Download all the student submissions from Moodle.
- Think about the testcases and strategies that how to grade the student's assignment.
- Write a config file.
- Design the verify function.
- Run your grader.
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.
[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
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
pytest -k 2023-cp1-hw01
pytest -vs -n auto