Skip to content
Snippets Groups Projects
Commit 71ac2478 authored by Chris Sangwin's avatar Chris Sangwin
Browse files

Fix issues with bulk testing: round penalties/scores and catch exceptions/notices.

parent b9bcee3f
Branches
No related tags found
No related merge requests found
......@@ -444,11 +444,13 @@ foreach ($testresults as $key => $result) {
foreach ($result->get_prt_states() as $prtname => $state) {
$prtinputs = array();
if ($inputsneeded != null) {
foreach(array_keys($inputsneeded[$prtname]) as $inputname) {
if (array_key_exists($inputname, $typeininputs)) {
$prtinputs[] = $typeininputs[$inputname];
}
}
}
if ($prtinputs != array()) {
$prtinputs[] = "/* ------------------- */\n";
}
......
......@@ -143,6 +143,12 @@ class stack_potentialresponse_tree_lite {
// Get the compiled one and work on it.
$code = $this->question->get_cached('prt-definition')[$this->name];
// The bulk tester will get called on questions which no longer work.
// In this case we want to bail here and not try to parse null in the line below which
// throws an exception and halts the bulk tester.
if ($code === null) {
return stack_string('errors');
}
// Parse that and remove some less relevant parts.
$ast = maxima_parser_utils::parse($code);
// Remove the feedback rendering parts, no need to see that CASText2.
......
......@@ -136,7 +136,15 @@ class stack_question_test_result {
$state = new stdClass();
$state->expectedscore = $expectedresult->score;
if (!is_null($state->expectedscore)) {
// Single PRTs only work to three decimal places, so we only expect that level.
$state->expectedscore = round($state->expectedscore + 0, 3);
}
$state->expectedpenalty = $expectedresult->penalty;
if (!is_null($state->expectedpenalty)) {
// Single PRTs only work to three decimal places, so we only expect that level.
$state->expectedpenalty = round($state->expectedpenalty + 0, 3);
}
$state->expectedanswernote = reset($expectedanswernote);
if (array_key_exists($prtname, $this->actualresults)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment