protected function is_same_response(question_attempt_step $pendingstep) { if (!parent::is_same_response($pendingstep)) { return false; } // If the question part of the response is exactly the same, then // we need to check if the previous action was a save, and this action // is a submit. if ($pendingstep->has_behaviour_var('submit') && !$this->qa->get_last_step()->has_behaviour_var('submit')) { return false; } return true; }
protected function adaptive_mark_details_from_step(question_attempt_step $gradedstep, question_state $state, $maxmark, $penalty) { if (!isset($this->question->penaltyregime) || $this->question->penaltyregime === '') { $details = parent::adaptive_mark_details_from_step($gradedstep, $state, $maxmark, $penalty); } else { $prevtries = $this->qa->get_last_behaviour_var('_try', 0); $fract = $this->adjusted_fraction(1.0, $prevtries); $details = new qbehaviour_adaptive_mark_details($state); $details->maxmark = $maxmark; $details->actualmark = $gradedstep->get_fraction() * $details->maxmark; $details->rawmark = $gradedstep->get_behaviour_var('_rawfraction') * $details->maxmark; $details->totalpenalty = 1.0 - $fract; $details->currentpenalty = $details->totalpenalty * $details->maxmark; $details->improvable = $this->is_state_improvable($gradedstep->get_state()); } return $details; }
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 process_finish(question_attempt_pending_step $pendingstep) { // Must find out prevbest before parent function get in it's fraction. $prevbest = $this->qa->get_fraction(); if (is_null($prevbest)) { $prevbest = 0; } $status = parent::process_finish($pendingstep); if ($pendingstep->get_state() != question_state::$gaveup) { // State was graded. $laststep = $this->qa->get_last_step(); $total = $this->qa->get_last_behaviour_var('_totalpenalties', 0); if (!$laststep->has_behaviour_var('_try')) { // Submitting ( not previous grading) resulted in finishing, so need to apply penalty. $total += $this->question->penalty; $pendingstep->set_behaviour_var('_penalty', $this->question->penalty); } $pendingstep->set_behaviour_var('_totalpenalties', $total); // Must substract by one submission penalty less , to account for one lawful submission. $pendingstep->set_fraction(max($prevbest, $this->adjusted_fraction($pendingstep->get_behaviour_var('_rawfraction'), $total - $this->question->penalty))); } return question_attempt::KEEP; }