public function test_has_var() {
     $step = new question_attempt_step(array('x' => 1, '-y' => 'frog'));
     $this->assertTrue($step->has_qt_var('x'));
     $this->assertTrue($step->has_behaviour_var('y'));
     $this->assertFalse($step->has_qt_var('y'));
     $this->assertFalse($step->has_behaviour_var('x'));
 }
Example #2
0
 public function summarise_action(question_attempt_step $step) {
     if ($step->has_behaviour_var('comment')) {
         return $this->summarise_manual_comment($step);
     } else if ($step->has_behaviour_var('finish')) {
         return $this->summarise_finish($step);
     } else {
         return $this->summarise_save($step);
     }
 }
Example #3
0
 public function summarise_action(question_attempt_step $step)
 {
     if ($step->has_behaviour_var('comment')) {
         return $this->summarise_manual_comment($step);
     } else {
         if ($step->has_behaviour_var('finish')) {
             return $this->summarise_finish($step);
         } else {
             if ($step->has_behaviour_var('seen')) {
                 return get_string('seen', 'qbehaviour_informationitem');
             }
         }
     }
     return $this->summarise_start($step);
 }
 public function apply_attempt_state(question_attempt_step $step)
 {
     if ($step->has_behaviour_var('_applypenalties')) {
         $this->applypenalties = (bool) $step->get_behaviour_var('_applypenalties');
     }
     parent::apply_attempt_state($step);
 }
 public function summarise_action(question_attempt_step $step)
 {
     if ($step->has_behaviour_var('comment')) {
         return $this->summarise_manual_comment($step);
     } else {
         if ($step->has_behaviour_var('finish')) {
             return $this->summarise_finish($step);
         } else {
             if ($step->has_behaviour_var('tryagain')) {
                 return get_string('tryagain', 'qbehaviour_interactive');
             } else {
                 if ($step->has_behaviour_var('submit')) {
                     return $this->summarise_submit($step);
                 } else {
                     return $this->summarise_save($step);
                 }
             }
         }
     }
 }
Example #6
0
    protected function do_grading(question_attempt_step $responsesstep,
            question_attempt_pending_step $pendingstep) {
        if (!$this->question->is_gradable_response($responsesstep->get_qt_data())) {
            $pendingstep->set_state(question_state::$gaveup);

        } else {
            $response = $responsesstep->get_qt_data();
            list($fraction, $state) = $this->question->grade_response($response);

            if ($responsesstep->has_behaviour_var('certainty')) {
                $certainty = $responsesstep->get_behaviour_var('certainty');
            } else {
                $certainty = question_cbm::default_certainty();
                $pendingstep->set_behaviour_var('_assumedcertainty', $certainty);
            }

            $pendingstep->set_behaviour_var('_rawfraction', $fraction);
            $pendingstep->set_fraction(question_cbm::adjust_fraction($fraction, $certainty));
            $pendingstep->set_state($state);
            $pendingstep->set_new_response_summary(question_cbm::summary_with_certainty(
                    $this->question->summarise_response($response),
                    $responsesstep->get_behaviour_var('certainty')));
        }
        return question_attempt::KEEP;
    }
 public function summarise_action(question_attempt_step $step)
 {
     if ($step->has_behaviour_var('helpme')) {
         return $this->summarise_helpme($step);
     } else {
         return parent::summarise_action($step);
     }
 }
 public function summarise_action(question_attempt_step $step)
 {
     // Summarise hint action.
     foreach ($this->question->hints_available_for_student($step->get_qt_data()) as $hintkey) {
         $hintkey = $this->adjust_hintkey($hintkey);
         if ($step->has_behaviour_var($hintkey . 'btn')) {
             return $this->summarise_hint($step, $hintkey);
         }
     }
     return parent::summarise_action($step);
 }