Skip to content

Commit 7175255

Browse files
committed
Make errors in question runtime, and testcase input generation more prominent. #1703.
1 parent 9d240de commit 7175255

3 files changed

Lines changed: 15 additions & 1 deletion

File tree

doc/en/STACK_question_admin/Testing.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,11 @@ This test will throw an error when `n` is zero.
153153

154154
In many situations this kind of test creation will be simpler than mapping onto student inputs.
155155

156+
1. If you place `s_assert` in the question variables then any run-time errors will stop the question being used by students. These errors will appear when you bulk-test the question variants.
157+
2. If you place `s_assert` in the feedback variables of a PRT then any run-time errors will be ignored.
158+
159+
Note, the purpose of `s_assert` is unit testing of question variables within question testing.
160+
156161
## STACK-Maxima sandbox ##
157162

158163
It is very useful to be able to use the desktop Maxima application to test questions. To do this it is very helpful to load all the STACK libraries. Details on how to do this are in the [STACK-Maxima sandbox](../CAS/STACK-Maxima_sandbox.md) page.

stack/questiontest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,17 @@ public function process_results($question, $response) {
160160
if ($inputresponse != '') {
161161
$emptytestcase = false;
162162
}
163+
$inputerrors = $inputstate->errors;
164+
if (!empty($question->runtimeerrors)) {
165+
$inputerrors = implode('; ', array_keys($question->runtimeerrors));
166+
}
163167
$results->set_input_state(
164168
$inputname,
165169
$inputresponse,
166170
$inputstate->contentsmodified,
167171
$inputstate->contentsdisplayed,
168172
$inputstate->status,
169-
$inputstate->errors
173+
$inputerrors
170174
);
171175
}
172176
}

stack/questiontestresult.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,11 @@ public function passed() {
344344
if ($this->emptytestcase) {
345345
return false;
346346
}
347+
foreach ($this->get_input_states() as $state) {
348+
if ($state->errors !== "") {
349+
return false;
350+
}
351+
}
347352
foreach ($this->get_prt_states() as $state) {
348353
if (!$state->testoutcome) {
349354
return false;

0 commit comments

Comments
 (0)