This program (ga) create the files which Autolab's autograde
needed for NTU BME Computer Programming Course. File tree is as follow,
├───autograde-Makefile
├───autograde.tar
│ ├───score.py
│ └───gtest.cpp
├───answers.yml
You can walk through autograde-Makefile
to have the overview of whole concept.
score.py
is the main code to grade student score.
gtest.cpp
is the Google Test code.
- curl: get source code template.
- jq (v1.5): command-line JSON processor.
- yq (v3.4.0): command-line YAML processor.
- gtest: google unit test
- g++
git clone https://github.com/WesleyCh3n/NTUBME-Autograde.git & cd NTUBME-Autograde
sudo make install
ga [-n <HW number>] [-L] -Y <answer.yml>
-n
: create blank answer.yml
with HW
number
-Y
: parsing YAML file
-L
: for scoring lab purpose
In detail:
-
First, goto the homework folder, ex.
~/Autolab/courses/<course_name>/<hw_name>/
. -
Create sample
answers.yml
by typingga
-
In
answers.yml
, modify parameters to create the tests you want:--- Autograde: Homework: 4c AdditionalTar: ["./Document.txt", "./foo.txt"] VariableType: [int, float, double] Test: - input: [1, 0.2, -32] answer: - L: abs(ans1) op: '<=' R: 11/3
-
Once you finished editing, type following cmd to generate autograding code
ga -Y answers.yml
Parameters | Info | Format | Exmaple |
---|---|---|---|
Autograde | Top level | ||
Homework | HW number | number+problem | 6c |
AdditionalTar | Additional files | file1, file2 | [file1, file2] |
VariableType | The tatal type of answer variables in this question. | use list to store types | [float, double, int] |
Google Test field (Test:
): using yaml list syntax to store the lists of tests also lists of logical operation each test. Remember not to write unnecessary -
, that may loss some of tests.
This is an example of two test with one and two logical operations.
...
Test:
- input: []
answer:
- L:
op: ''
R:
- input: []
answer:
- L:
op: ''
R:
- L:
op: ''
R:
Parameters | Info | Format | Exmaple |
---|---|---|---|
input | The User input for Google Test. | use list to store the test input | [12, 13] |
answer | The right answers. For example, answer1 should be 32, answer2 less than 0.02, etc. | see L , op , R below |
Parameters | Info | Format | Exmaple |
---|---|---|---|
L | Left side of operator | Use ans<num> describe which variable you want to test. Can implement with mathematical operation like: abs(ans1-ans2) |
sqrt(ans1) |
op | logical operator | Use quote.
|
'<=' |
R | Right side of operator | Value. Fraction with double-type denominator is also acceptable. | (11/3.0)-12 |
If there is no input, leave it empty. If there is no test, just delete Test:
field.
- Put following code to shellrc(e.g.
~/.bashrc
) to usega
normally as cli.
ga() {
docker run --rm -e HOST_USER_ID=$(id -u) -e HOST_USER_GID=$(id -g) -v `pwd`:/workdir/ ghcr.io/wesleych3n/autograde:latest ga $@
}
# After re-login
# ga -n {HW number}
# ga -Y {filename}.yml
sudo make uninstall