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

Fix test-case construction by giving old nodes the correct nodename.

parent d6bf3aed
Branches
No related tags found
No related merge requests found
......@@ -96,7 +96,7 @@ class qtype_stack_question extends question_graded_automatically_with_countback
public $inputs = array();
/**
* @var stack_potentialresponse_tree[] STACK specific: respones tree number => ...
* @var stack_potentialresponse_tree_lite[] STACK specific: respones tree number => ...
*/
public $prts = array();
......@@ -764,7 +764,7 @@ class qtype_stack_question extends question_graded_automatically_with_countback
public function is_complete_response(array $response) {
// If all PRTs are gradable, then the question is complete. Optional inputs may be blank.
foreach ($this->prts as $index => $prt) {
foreach ($this->prts as $prt) {
// Formative PRTs do not contribute to complete responses.
if (!$prt->is_formative() && !$this->can_execute_prt($prt, $response, false)) {
return false;
......@@ -991,7 +991,7 @@ class qtype_stack_question extends question_graded_automatically_with_countback
// has_necessary_prt_inputs, and then does the computation, which ensures
// there are no CAS errors.
$result = $this->get_prt_result($prt->get_name(), $response, $acceptvalid);
return null !== $result->is_evaluated() && !$result->get_errors();
return $result->is_evaluated() && !$result->get_errors();
}
/**
......@@ -1130,7 +1130,7 @@ class qtype_stack_question extends question_graded_automatically_with_countback
$p = new prt_evaluatable($this->get_cached('prt-signature')[$name],
$prt->get_value(), new castext2_static_replacer($this->get_cached('static-castext-strings')));
if (isset($prts[$name])) {
// Always manke sure it get called wit simp:false.
// Always make sure it gets called with simp:false.
$session->add_statement(new stack_secure_loader('simp:false', 'prt-simplification'));
$session->add_statement($p);
}
......
......@@ -421,7 +421,7 @@ class stack_potentialresponse_node {
/**
* @return object with fields for the branches for the compiled PRT upgrade
* @return object with fields for the branches for the compiled PRT upgrade.
*/
public function summarise_branches_extended() {
$summary = new stdClass();
......
......@@ -2615,6 +2615,8 @@ class qtype_stack_test_helper extends question_test_helper {
$newprt->autosimplify = $oldprt->get_simplify();
foreach ($oldprt->get_nodes() as $nname => $oldnode) {
// Make sure old nodes have the correct nodeid set.
$oldnode->nodeid = $nname;
$newnode = $oldnode->summarise_branches_extended();
// In the new world we don't parse these to AST-containers in general execution
// as that is a waste of time, we only do that during compilation of the whole PRT.
......
......@@ -154,8 +154,11 @@ class question_test extends qtype_stack_testcase {
$q = $this->get_test_stack_question('test3');
$q->start_attempt(new question_attempt_step(), 1);
$this->assertEquals(array(2.5 / 4, question_state::$gradedpartial),
$q->grade_response(array('ans1' => 'x^3', 'ans2' => 'x^2', 'ans3' => 'x', 'ans4' => 'false')));
$result = $q->grade_response(array('ans1' => 'x^3', 'ans2' => 'x^2', 'ans3' => 'x^2', 'ans4' => 'false'));
$this->assertEquals(array(2.5 / 4, question_state::$gradedpartial), $result);
$result = $q->grade_response(array('ans1' => 'x^3', 'ans2' => 'x^2', 'ans3' => 'x', 'ans4' => 'false'));
$this->assertEquals(array(2.5 / 4, question_state::$gradedpartial), $result);
}
public function test_grade_response_test3_incomplete() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment