protected function penalty_info(question_attempt $qa, $mark, question_display_options $options)
 {
     if (!$qa->get_question()->penalty && !$qa->get_last_behaviour_var('_hashint', false)) {
         // No penalty for the attempts and no hinting done.
         return '';
     }
     $output = '';
     // Print details of grade adjustment due to penalties.
     if ($mark->raw != $mark->cur) {
         $output .= ' ' . get_string('gradingdetailsadjustment', 'qbehaviour_adaptive', $mark);
     }
     // Print information about any new penalty, only relevant if the answer can be improved.
     if ($qa->get_behaviour()->is_state_improvable($qa->get_state())) {
         $output .= ' ' . get_string('gradingdetailspenalty', 'qbehaviour_adaptive', format_float($qa->get_last_step()->get_behaviour_var('_penalty'), $options->markdp));
     }
     return $output;
 }
Ejemplo n.º 2
0
 public function correct_response(question_attempt $qa)
 {
     global $DB;
     $output = '';
     $showcorrect = false;
     $question = $qa->get_question();
     if (empty($question->correctresponse)) {
         $output .= html_writer::tag('p', get_string('noresponsedetails', 'qtype_ordering'));
     } else {
         if ($step = $qa->get_last_step()) {
             switch ($step->get_state()) {
                 case 'gradedright':
                     $showcorrect = false;
                     break;
                 case 'gradedpartial':
                     $showcorrect = true;
                     break;
                 case 'gradedwrong':
                     $showcorrect = true;
                     break;
             }
         }
     }
     if ($showcorrect) {
         $output .= html_writer::tag('p', get_string('correctorder', 'qtype_ordering'));
         $output .= html_writer::start_tag('ol');
         $correctresponse = $question->correctresponse;
         foreach ($correctresponse as $position => $answerid) {
             $answer = $question->answers[$answerid];
             $output .= html_writer::tag('li', $answer->answer);
         }
         $output .= html_writer::end_tag('ol');
     }
     return $output;
 }