[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/question/behaviour/manualgraded/ -> behaviour.php (source)

   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  /**
  18   * Question behaviour for questions that can only be graded manually.
  19   *
  20   * @package    qbehaviour
  21   * @subpackage manualgraded
  22   * @copyright  2009 The Open University
  23   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  24   */
  25  
  26  
  27  defined('MOODLE_INTERNAL') || die();
  28  
  29  
  30  /**
  31   * Question behaviour for questions that can only be graded manually.
  32   *
  33   * The student enters their response during the attempt, and it is saved. Later,
  34   * when the whole attempt is finished, the attempt goes into the NEEDS_GRADING
  35   * state, and the teacher must grade it manually.
  36   *
  37   * @copyright  2009 The Open University
  38   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  39   */
  40  class qbehaviour_manualgraded extends question_behaviour_with_save {
  41  
  42      public function is_compatible_question(question_definition $question) {
  43          return $question instanceof question_with_responses;
  44      }
  45  
  46      public function adjust_display_options(question_display_options $options) {
  47          parent::adjust_display_options($options);
  48  
  49          if ($this->qa->get_state()->is_finished()) {
  50              // Hide all feedback except genfeedback and manualcomment.
  51              $save = clone($options);
  52              $options->hide_all_feedback();
  53              $options->generalfeedback = $save->generalfeedback;
  54              $options->manualcomment = $save->manualcomment;
  55          }
  56      }
  57  
  58      public function process_action(question_attempt_pending_step $pendingstep) {
  59          if ($pendingstep->has_behaviour_var('comment')) {
  60              return $this->process_comment($pendingstep);
  61          } else if ($pendingstep->has_behaviour_var('finish')) {
  62              return $this->process_finish($pendingstep);
  63          } else {
  64              return $this->process_save($pendingstep);
  65          }
  66      }
  67  
  68      public function summarise_action(question_attempt_step $step) {
  69          if ($step->has_behaviour_var('comment')) {
  70              return $this->summarise_manual_comment($step);
  71          } else if ($step->has_behaviour_var('finish')) {
  72              return $this->summarise_finish($step);
  73          } else {
  74              return $this->summarise_save($step);
  75          }
  76      }
  77  
  78      public function process_finish(question_attempt_pending_step $pendingstep) {
  79          if ($this->qa->get_state()->is_finished()) {
  80              return question_attempt::DISCARD;
  81          }
  82  
  83          $response = $this->qa->get_last_step()->get_qt_data();
  84          if (!$this->question->is_complete_response($response)) {
  85              $pendingstep->set_state(question_state::$gaveup);
  86          } else {
  87              $pendingstep->set_state(question_state::$needsgrading);
  88          }
  89          $pendingstep->set_new_response_summary($this->question->summarise_response($response));
  90          return question_attempt::KEEP;
  91      }
  92  }


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1