/**
  * 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'];
 }