You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add inject-based test case support to evaluation function and docs
Implemented support for `inject`-based test cases, allowing variables to be pre-set before student code execution instead of relying on stdin. Updated the evaluation function, added unit tests for `inject` mode, and revised documentation (`CLAU
"inject": {"n": 5}, // variables set before student code runs — no input() needed
59
+
"expected_output": "25\n",
60
+
"hidden": false
54
61
}
55
62
]
56
63
}
57
64
```
58
65
66
+
| Field | Description |
67
+
|-------|-------------|
68
+
|`input`| Text piped to stdin. Mutually exclusive with `inject`. |
69
+
|`inject`| Dict of `{variable_name: value}` prepended as assignments before student code. Values can be any JSON type. Mutually exclusive with `input`. |
70
+
|`expected_output`| Expected stdout; trailing whitespace stripped before comparison. |
71
+
|`hidden`|`true` = suppress input/variables and expected output from feedback. |
72
+
59
73
-`tests` is required; an empty list sets `is_correct = true` with `0/0 tests passed`.
60
-
-`hidden: true` replaces input/output details with `"Hidden test N: failed."` so students cannot reverse-engineer the answer.
74
+
-`hidden: true` replaces details with `"Hidden test N: failed."` so students cannot reverse-engineer the answer.
75
+
- With `inject`, feedback shows a "Variables:" block (e.g. `n = 5`) instead of "Input:".
61
76
- Matplotlib figures generated during a test are uploaded to S3 and embedded in the feedback.
62
77
63
78
Feedback tags produced per test: `pass`, `fail`, or `hidden_fail`. Global: `summary`, `error` (timeout / runtime error).
Copy file name to clipboardExpand all lines: docs/user.md
+30-6Lines changed: 30 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,11 +44,14 @@ Runs the student's code once per test case, feeding it a string via stdin and co
44
44
45
45
### Test case fields
46
46
47
-
| Field | Required | Description |
48
-
|-------|----------|-------------|
49
-
|`input`| No | Text sent to the program's stdin. Use `\n` for newlines. Omit or use `""` if the program reads no input. |
50
-
|`expected_output`| Yes | The exact stdout the program should produce. Trailing whitespace is ignored during comparison. |
51
-
|`hidden`| No | Set to `true` to hide the input and expected output from the student. They see only "Hidden test N: passed/failed." |
47
+
Each test case uses **either**`input` (student reads via `input()`) **or**`inject` (variables are pre-set, no `input()` needed):
48
+
49
+
| Field | Description |
50
+
|-------|-------------|
51
+
|`input`| Text sent to stdin. Student code reads it with `input()`. Use `\n` for newlines. |
52
+
|`inject`| Dict of variable names and values injected before student code runs. Student uses the variables directly — no `input()` required. Values can be numbers, strings, lists, or dicts. |
53
+
|`expected_output`| The exact stdout the program should produce. Trailing whitespace is ignored. |
54
+
|`hidden`|`true` = hide the input/variables and expected output from the student. They see only "Hidden test N: passed/failed." |
52
55
53
56
### Tips
54
57
@@ -57,7 +60,7 @@ Runs the student's code once per test case, feeding it a string via stdin and co
57
60
- Matplotlib figures produced during a passing or failing test are shown to the student.
58
61
- A 25-second per-test timeout applies; timed-out tests count as failures.
59
62
60
-
### Example — square a number
63
+
### Example — square a number (stdin-based)
61
64
62
65
Student code:
63
66
```python
@@ -77,6 +80,27 @@ Params:
77
80
}
78
81
```
79
82
83
+
### Example — square a number (inject-based)
84
+
85
+
Use `inject` when students shouldn't need to handle input themselves — they just write an expression or use the named variable directly:
0 commit comments