public static function run_test($test) { $anst = new stack_ans_test_controller($test->name, $test->studentanswer, $test->teacheranswer, new stack_options(), $test->options); // The false clause is useful for developers to track down which test case is breaking Maxima. if (true) { $result = $anst->do_test(); // This actually executes the answer test in the CAS. $errors = $anst->get_at_errors(); $rawmark = $anst->get_at_mark(); $feedback = $anst->get_at_feedback(); $ansnote = $anst->get_at_answernote(); } else { $feedback = 'AT' . $test->name . '(' . $test->studentanswer . ',' . $test->teacheranswer . ');'; $result = true; // This actually executes the answer test in the CAS. $errors = ''; $rawmark = 0; $ansnote = ''; } $passed = false; if ($rawmark === $test->expectedscore) { $passed = true; } // The test failed, and we expected it to fail. if ($errors === 'TEST_FAILED') { if (-1 === $test->expectedscore) { $passed = true; } else { $passed = false; } } // These tests are all expected to fail, so we make them all pass. if (-2 === $test->expectedscore) { $passed = true; } return array($passed, $errors, $rawmark, $feedback, $ansnote); }
/** * Actually execute the test for this node. */ public function do_test($nsans, $ntans, $ncasopts, $options, stack_potentialresponse_tree_state $results) { if (false === $ncasopts) { $ncasopts = $this->atoptions; } $at = new stack_ans_test_controller($this->answertest, $nsans, $ntans, $options, $ncasopts); $at->do_test(); $testpassed = $at->get_at_mark(); if ($testpassed) { $resultbranch = $this->branches[1]; $branchname = 'prtnodetruefeedback'; } else { $resultbranch = $this->branches[0]; $branchname = 'prtnodefalsefeedback'; } if ($at->get_at_answernote()) { $results->add_answernote($at->get_at_answernote()); } if ($resultbranch['answernote']) { $results->add_answernote($resultbranch['answernote']); } // If the answer test is running in quiet mode we suppress any // automatically generated feedback from the answertest itself. if (!$this->quiet && $at->get_at_feedback()) { $results->add_feedback($at->get_at_feedback()); } if ($resultbranch['feedback']) { $results->add_feedback($resultbranch['feedback'], $resultbranch['feedbackformat'], $branchname, $this->nodeid); } $results->_valid = $results->_valid && $at->get_at_valid(); $results->_score = $this->update_score($results->_score, $resultbranch); if ($resultbranch['penalty'] !== '') { $results->_penalty = $resultbranch['penalty']; } $results->_errors .= $at->get_at_errors(); return $resultbranch['nextnode']; }