Skip to content

NTU BME Computer Programming Course. Create Autograde code for C++ assessments by professor.

License

Notifications You must be signed in to change notification settings

WesleyCh3n/NTUBME-Autograde

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NTU BME Autograde

docker action Bash - 5.0.17 Made with - Docker

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.

Prerequisites

  • 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++

Installation

git clone https://github.com/WesleyCh3n/NTUBME-Autograde.git & cd NTUBME-Autograde
sudo make install

Usage - Generate Autograding Code

Basic usage:

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:

  1. First, goto the homework folder, ex. ~/Autolab/courses/<course_name>/<hw_name>/.

  2. Create sample answers.yml by typing

    ga
    
  3. 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
  4. Once you finished editing, type following cmd to generate autograding code

    ga -Y answers.yml
    

YAML Parameters

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.
  • Binary operator: =, >, <, !=, >=, <=
  • String comparasion: &=(String match), &?(String not match)
'<='
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.

Run with Docker

  • Put following code to shellrc(e.g. ~/.bashrc) to use ga 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

Uninstall

sudo make uninstall

About

NTU BME Computer Programming Course. Create Autograde code for C++ assessments by professor.

Topics

Resources

License

Stars

Watchers

Forks

Packages