Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/question/behaviour/manualgraded/behaviour.php
Go to the documentation of this file.
00001 <?php
00002 // This file is part of Moodle - http://moodle.org/
00003 //
00004 // Moodle is free software: you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation, either version 3 of the License, or
00007 // (at your option) any later version.
00008 //
00009 // Moodle is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00016 
00027 defined('MOODLE_INTERNAL') || die();
00028 
00029 
00040 class qbehaviour_manualgraded extends question_behaviour_with_save {
00041     const IS_ARCHETYPAL = true;
00042 
00043     public static function get_unused_display_options() {
00044         return array('correctness', 'marks', 'specificfeedback', 'generalfeedback',
00045                 'rightanswer');
00046     }
00047 
00048     public function adjust_display_options(question_display_options $options) {
00049         parent::adjust_display_options($options);
00050 
00051         if ($this->qa->get_state()->is_finished()) {
00052             // Hide all feedback except genfeedback and manualcomment.
00053             $save = clone($options);
00054             $options->hide_all_feedback();
00055             $options->generalfeedback = $save->generalfeedback;
00056             $options->manualcomment = $save->manualcomment;
00057         }
00058     }
00059 
00060     public function process_action(question_attempt_pending_step $pendingstep) {
00061         if ($pendingstep->has_behaviour_var('comment')) {
00062             return $this->process_comment($pendingstep);
00063         } else if ($pendingstep->has_behaviour_var('finish')) {
00064             return $this->process_finish($pendingstep);
00065         } else {
00066             return $this->process_save($pendingstep);
00067         }
00068     }
00069 
00070     public function summarise_action(question_attempt_step $step) {
00071         if ($step->has_behaviour_var('comment')) {
00072             return $this->summarise_manual_comment($step);
00073         } else if ($step->has_behaviour_var('finish')) {
00074             return $this->summarise_finish($step);
00075         } else {
00076             return $this->summarise_save($step);
00077         }
00078     }
00079 
00080     public function process_finish(question_attempt_pending_step $pendingstep) {
00081         if ($this->qa->get_state()->is_finished()) {
00082             return question_attempt::DISCARD;
00083         }
00084 
00085         $response = $this->qa->get_last_step()->get_qt_data();
00086         if (!$this->question->is_complete_response($response)) {
00087             $pendingstep->set_state(question_state::$gaveup);
00088         } else {
00089             $pendingstep->set_state(question_state::$needsgrading);
00090         }
00091         $pendingstep->set_new_response_summary($this->question->summarise_response($response));
00092         return question_attempt::KEEP;
00093     }
00094 }
 All Data Structures Namespaces Files Functions Variables Enumerations