| 1 | 
           efrain | 
           1 | 
           <?php
  | 
        
        
            | 
            | 
           2 | 
           // This file is part of Moodle - http://moodle.org/
  | 
        
        
            | 
            | 
           3 | 
           //
  | 
        
        
            | 
            | 
           4 | 
           // Moodle is free software: you can redistribute it and/or modify
  | 
        
        
            | 
            | 
           5 | 
           // it under the terms of the GNU General Public License as published by
  | 
        
        
            | 
            | 
           6 | 
           // the Free Software Foundation, either version 3 of the License, or
  | 
        
        
            | 
            | 
           7 | 
           // (at your option) any later version.
  | 
        
        
            | 
            | 
           8 | 
           //
  | 
        
        
            | 
            | 
           9 | 
           // Moodle is distributed in the hope that it will be useful,
  | 
        
        
            | 
            | 
           10 | 
           // but WITHOUT ANY WARRANTY; without even the implied warranty of
  | 
        
        
            | 
            | 
           11 | 
           // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  | 
        
        
            | 
            | 
           12 | 
           // GNU General Public License for more details.
  | 
        
        
            | 
            | 
           13 | 
           //
  | 
        
        
            | 
            | 
           14 | 
           // You should have received a copy of the GNU General Public License
  | 
        
        
            | 
            | 
           15 | 
           // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  | 
        
        
            | 
            | 
           16 | 
              | 
        
        
            | 
            | 
           17 | 
           use qtype_ordering\output\correct_response;
  | 
        
        
            | 
            | 
           18 | 
           use qtype_ordering\output\feedback;
  | 
        
        
            | 
            | 
           19 | 
           use qtype_ordering\output\formulation_and_controls;
  | 
        
        
            | 
            | 
           20 | 
           use qtype_ordering\output\num_parts_correct;
  | 
        
        
            | 
            | 
           21 | 
           use qtype_ordering\output\specific_grade_detail_feedback;
  | 
        
        
            | 
            | 
           22 | 
              | 
        
        
            | 
            | 
           23 | 
           /**
  | 
        
        
            | 
            | 
           24 | 
            * Ordering question renderer class.
  | 
        
        
            | 
            | 
           25 | 
            *
  | 
        
        
            | 
            | 
           26 | 
            * @package    qtype_ordering
  | 
        
        
            | 
            | 
           27 | 
            * @copyright  2013 Gordon Bateson (gordonbateson@gmail.com)
  | 
        
        
            | 
            | 
           28 | 
            * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  | 
        
        
            | 
            | 
           29 | 
            */
  | 
        
        
            | 
            | 
           30 | 
           class qtype_ordering_renderer extends qtype_with_combined_feedback_renderer {
  | 
        
        
            | 
            | 
           31 | 
              | 
        
        
            | 
            | 
           32 | 
               public function formulation_and_controls(question_attempt $qa, question_display_options $options): string {
  | 
        
        
            | 
            | 
           33 | 
                   $formulationandcontrols = new formulation_and_controls($qa, $options);
  | 
        
        
            | 
            | 
           34 | 
                   return $this->output->render_from_template('qtype_ordering/formulation_and_controls',
  | 
        
        
            | 
            | 
           35 | 
                       $formulationandcontrols->export_for_template($this->output));
  | 
        
        
            | 
            | 
           36 | 
               }
  | 
        
        
            | 
            | 
           37 | 
              | 
        
        
            | 
            | 
           38 | 
               public function feedback(question_attempt $qa, question_display_options $options): string {
  | 
        
        
            | 
            | 
           39 | 
                   $feedback = new feedback($qa, $options);
  | 
        
        
            | 
            | 
           40 | 
                   return $this->output->render_from_template('qtype_ordering/feedback',
  | 
        
        
            | 
            | 
           41 | 
                       $feedback->export_for_template($this->output));
  | 
        
        
            | 
            | 
           42 | 
               }
  | 
        
        
            | 
            | 
           43 | 
              | 
        
        
            | 
            | 
           44 | 
               /**
  | 
        
        
            | 
            | 
           45 | 
                * Display the grade detail of the response.
  | 
        
        
            | 
            | 
           46 | 
                *
  | 
        
        
            | 
            | 
           47 | 
                * @param question_attempt $qa The question attempt to display.
  | 
        
        
            | 
            | 
           48 | 
                * @return string Output grade detail of the response.
  | 
        
        
            | 
            | 
           49 | 
                * @throws moodle_exception
  | 
        
        
            | 
            | 
           50 | 
                */
  | 
        
        
            | 
            | 
           51 | 
               public function specific_grade_detail_feedback(question_attempt $qa): string {
  | 
        
        
            | 
            | 
           52 | 
                   $specificgradedetailfeedback = new specific_grade_detail_feedback($qa);
  | 
        
        
            | 
            | 
           53 | 
                   return $this->output->render_from_template('qtype_ordering/specific_grade_detail_feedback',
  | 
        
        
            | 
            | 
           54 | 
                       $specificgradedetailfeedback->export_for_template($this->output));
  | 
        
        
            | 
            | 
           55 | 
               }
  | 
        
        
            | 
            | 
           56 | 
              | 
        
        
            | 
            | 
           57 | 
               public function specific_feedback(question_attempt $qa): string {
  | 
        
        
            | 
            | 
           58 | 
                   return $this->combined_feedback($qa);
  | 
        
        
            | 
            | 
           59 | 
               }
  | 
        
        
            | 
            | 
           60 | 
              | 
        
        
            | 
            | 
           61 | 
               public function correct_response(question_attempt $qa): string {
  | 
        
        
            | 
            | 
           62 | 
                   $correctresponse = new correct_response($qa);
  | 
        
        
            | 
            | 
           63 | 
              | 
        
        
            | 
            | 
           64 | 
                   return $this->output->render_from_template('qtype_ordering/correct_response',
  | 
        
        
            | 
            | 
           65 | 
                       $correctresponse->export_for_template($this->output));
  | 
        
        
            | 
            | 
           66 | 
               }
  | 
        
        
            | 
            | 
           67 | 
              | 
        
        
            | 
            | 
           68 | 
               protected function num_parts_correct(question_attempt $qa): string {
  | 
        
        
            | 
            | 
           69 | 
                   $numpartscorrect = new num_parts_correct($qa);
  | 
        
        
            | 
            | 
           70 | 
                   return $this->output->render_from_template('qtype_ordering/num_parts_correct',
  | 
        
        
            | 
            | 
           71 | 
                       $numpartscorrect->export_for_template($this->output));
  | 
        
        
            | 
            | 
           72 | 
               }
  | 
        
        
            | 
            | 
           73 | 
              | 
        
        
            | 
            | 
           74 | 
               public function feedback_image($fraction, $selected = true): string {
  | 
        
        
            | 
            | 
           75 | 
                   return parent::feedback_image($fraction);
  | 
        
        
            | 
            | 
           76 | 
               }
  | 
        
        
            | 
            | 
           77 | 
           }
  |