Differences Between: [Versions 310 and 400] [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403]
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 * This behaviour is for information items. 19 * 20 * @package qbehaviour 21 * @subpackage informationitem 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 informaiton items. 32 * 33 * For example for the 'Description' 'Question type'. There is no grade, 34 * and the question type is marked complete the first time the user navigates 35 * away from a page that contains that question. 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_informationitem extends question_behaviour { 41 42 public function is_compatible_question(question_definition $question) { 43 return true; 44 } 45 46 public function get_expected_data() { 47 if ($this->qa->get_state() == question_state::$todo) { 48 return array('seen' => PARAM_BOOL); 49 } 50 return parent::get_expected_data(); 51 } 52 53 public function get_correct_response() { 54 if ($this->qa->get_state() == question_state::$todo) { 55 return array('seen' => 1); 56 } 57 return array(); 58 } 59 60 public function adjust_display_options(question_display_options $options) { 61 parent::adjust_display_options($options); 62 63 $options->marks = question_display_options::HIDDEN; 64 65 // At the moment, the code exists to process a manual comment on an 66 // information item, but we don't display the UI unless there is already 67 // a comment. 68 if (!$this->qa->get_state()->is_commented()) { 69 $options->manualcomment = question_display_options::HIDDEN; 70 } 71 } 72 73 public function get_state_string($showcorrectness) { 74 return ''; 75 } 76 77 public function process_action(question_attempt_pending_step $pendingstep) { 78 if ($pendingstep->has_behaviour_var('comment')) { 79 return $this->process_comment($pendingstep); 80 } else if ($pendingstep->has_behaviour_var('finish')) { 81 return $this->process_finish($pendingstep); 82 } else if ($pendingstep->has_behaviour_var('seen')) { 83 return $this->process_seen($pendingstep); 84 } else { 85 return question_attempt::DISCARD; 86 } 87 } 88 89 public function summarise_action(question_attempt_step $step) { 90 if ($step->has_behaviour_var('comment')) { 91 return $this->summarise_manual_comment($step); 92 } else if ($step->has_behaviour_var('finish')) { 93 return $this->summarise_finish($step); 94 } else if ($step->has_behaviour_var('seen')) { 95 return get_string('seen', 'qbehaviour_informationitem'); 96 } 97 return $this->summarise_start($step); 98 } 99 100 public function process_comment(question_attempt_pending_step $pendingstep) { 101 if ($pendingstep->has_behaviour_var('mark')) { 102 throw new coding_exception('Information items cannot be graded.'); 103 } 104 return parent::process_comment($pendingstep); 105 } 106 107 public function process_finish(question_attempt_pending_step $pendingstep) { 108 $pendingstep->set_state(question_state::$finished); 109 return question_attempt::KEEP; 110 } 111 112 public function process_seen(question_attempt_pending_step $pendingstep) { 113 $pendingstep->set_state(question_state::$complete); 114 return question_attempt::KEEP; 115 } 116 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body