コード例 #1
0
ファイル: behaviour.php プロジェクト: rosenclever/moodle
 public function process_finish(question_attempt_pending_step $pendingstep)
 {
     if ($this->qa->get_state()->is_finished()) {
         return question_attempt::DISCARD;
     }
     $prevtries = $this->qa->get_last_behaviour_var('_try', 0);
     $prevbest = $this->qa->get_fraction();
     if (is_null($prevbest)) {
         $prevbest = 0;
     }
     $laststep = $this->qa->get_last_step();
     $response = $laststep->get_qt_data();
     if (!$this->question->is_gradable_response($response)) {
         $state = question_state::$gaveup;
         $fraction = 0;
     } else {
         if ($laststep->has_behaviour_var('_try')) {
             // Last answer was graded, we want to regrade it. Otherwise the answer
             // has changed, and we are grading a new try.
             $prevtries -= 1;
         }
         list($fraction, $state) = $this->question->grade_response($response);
         $pendingstep->set_behaviour_var('_try', $prevtries + 1);
         $pendingstep->set_behaviour_var('_rawfraction', $fraction);
         $pendingstep->set_new_response_summary($this->question->summarise_response($response));
     }
     $pendingstep->set_state($state);
     $pendingstep->set_fraction(max($prevbest, $this->adjusted_fraction($fraction, $prevtries)));
     return question_attempt::KEEP;
 }
コード例 #2
0
ファイル: behaviour.php プロジェクト: JP-Git/moodle
    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;
    }
コード例 #3
0
ファイル: behaviour.php プロジェクト: evltuma/moodle
 public function process_finish(question_attempt_pending_step $pendingstep)
 {
     if ($this->qa->get_state()->is_finished()) {
         return question_attempt::DISCARD;
     }
     $response = $this->qa->get_last_step()->get_qt_data();
     if (!$this->question->is_gradable_response($response)) {
         $pendingstep->set_state(question_state::$gaveup);
     } else {
         list($fraction, $state) = $this->question->grade_response($response);
         $pendingstep->set_fraction($fraction);
         $pendingstep->set_state($state);
     }
     $pendingstep->set_new_response_summary($this->question->summarise_response($response));
     return question_attempt::KEEP;
 }
コード例 #4
0
ファイル: behaviour.php プロジェクト: pac/CodeRunner
 public function process_finish(question_attempt_pending_step $pendingstep)
 {
     if ($this->qa->get_state()->is_finished()) {
         return question_attempt::DISCARD;
     }
     $prevtries = $this->qa->get_last_behaviour_var('_try', 0);
     $prevbest = $this->qa->get_fraction();
     if (is_null($prevbest)) {
         $prevbest = 0;
     }
     $laststep = $this->qa->get_last_step();
     $response = $laststep->get_qt_data();
     if (!$this->question->is_gradable_response($response)) {
         $state = question_state::$gaveup;
         $fraction = 0;
     } else {
         if ($laststep->has_behaviour_var('_try')) {
             // Last answer was graded, we want to regrade it. Otherwise the answer
             // has changed, and we are grading a new try.
             // There is a Moodle bug here, resulting in regrading of
             // already-graded questions.
             // See https://tracker.moodle.org/browse/MDL-42399
             $prevtries -= 1;
         }
         // *** changed bit #2 begins ***
         // Cache extra data from grade response.
         $gradedata = $this->question->grade_response($response);
         list($fraction, $state) = $gradedata;
         if (count($gradedata) > 2) {
             foreach ($gradedata[2] as $name => $value) {
                 $pendingstep->set_qt_var($name, $value);
             }
         }
         // *** end of changed bit #2 ***
         $pendingstep->set_behaviour_var('_try', $prevtries + 1);
         $pendingstep->set_behaviour_var('_rawfraction', $fraction);
         $pendingstep->set_new_response_summary($this->question->summarise_response($response));
     }
     $pendingstep->set_state($state);
     $pendingstep->set_fraction(max($prevbest, $this->adjusted_fraction($fraction, $prevtries)));
     return question_attempt::KEEP;
 }