Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.
   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   * @package    backup-convert
  18   * @copyright  2012 Darko Miletic <dmiletic@moodlerooms.com>
  19   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  20   */
  21  
  22  defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.');
  23  
  24  class cc_assesment_question_essay extends cc_assesment_question_proc_base {
  25      public function __construct($quiz, $questions, $manifest, $section, $question_node, $rootpath, $contextid, $outdir) {
  26          parent::__construct($quiz, $questions, $manifest, $section, $question_node, $rootpath, $contextid, $outdir);
  27          $this->qtype = cc_qti_profiletype::essay;
  28          $maximum_quiz_grade = (int)$this->quiz->nodeValue('/activity/quiz/grade');
  29          $this->total_grade_value = ($maximum_quiz_grade + 1).'.0000000';
  30      }
  31  
  32      public function on_generate_metadata() {
  33          parent::on_generate_metadata();
  34          // Mark essay for manual grading.
  35          $this->qmetadata->enable_scoringpermitted();
  36          $this->qmetadata->enable_computerscored(false);
  37      }
  38  
  39      public function on_generate_presentation() {
  40          parent::on_generate_presentation();
  41          $response_str = new cc_assesment_response_strtype();
  42          $response_fib = new cc_assesment_render_fibtype();
  43          $row_value = (int)$this->questions->nodeValue('plugin_qtype_essay_question//responsefieldlines', $this->question_node);
  44          $response_fib->set_rows($row_value);
  45          $response_str->set_render_fib($response_fib);
  46          $this->qpresentation->set_response_str($response_str);
  47      }
  48  
  49      public function on_generate_response_processing() {
  50          parent::on_generate_response_processing();
  51  
  52          // Response conditions.
  53          if (!empty($this->general_feedback)) {
  54              $qrespcondition = new cc_assesment_respconditiontype();
  55              $qrespcondition->set_title('General feedback');
  56              $this->qresprocessing->add_respcondition($qrespcondition);
  57              // Define the condition for success.
  58              $qconditionvar = new cc_assignment_conditionvar();
  59              $qrespcondition->set_conditionvar($qconditionvar);
  60              $qother = new cc_assignment_conditionvar_othertype();
  61              $qconditionvar->set_other($qother);
  62              $qdisplayfeedback = new cc_assignment_displayfeedbacktype();
  63              $qrespcondition->add_displayfeedback($qdisplayfeedback);
  64              $qdisplayfeedback->set_feedbacktype(cc_qti_values::Response);
  65              $qdisplayfeedback->set_linkrefid('general_fb');
  66          }
  67      }
  68  }
  69