|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 // This file is part of Moodle - http://moodle.org/ 00004 // 00005 // Moodle is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // Moodle is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00017 00026 class completion_criteria_self extends completion_criteria { 00027 00032 public $criteriatype = COMPLETION_CRITERIA_TYPE_SELF; 00033 00041 public static function fetch($params) { 00042 $params['criteriatype'] = COMPLETION_CRITERIA_TYPE_SELF; 00043 return self::fetch_helper('course_completion_criteria', __CLASS__, $params); 00044 } 00045 00053 public function config_form_display(&$mform, $data = null) { 00054 $mform->addElement('checkbox', 'criteria_self', get_string('enable')); 00055 00056 if ($this->id ) { 00057 $mform->setDefault('criteria_self', 1); 00058 } 00059 } 00060 00067 public function update_config(&$data) { 00068 if (!empty($data->criteria_self)) { 00069 $this->course = $data->id; 00070 $this->insert(); 00071 } 00072 } 00073 00080 public function complete($completion) { 00081 $this->review($completion, true, true); 00082 } 00083 00091 public function review($completion, $mark = true, $is_complete = false) { 00092 // If we are marking this as complete 00093 if ($is_complete && $mark) 00094 { 00095 $completion->completedself = 1; 00096 $completion->mark_complete(); 00097 00098 return true; 00099 } 00100 00101 return $completion->is_complete(); 00102 } 00103 00109 public function get_title() { 00110 return get_string('selfcompletion', 'completion'); 00111 } 00112 00118 public function get_title_detailed() { 00119 return $this->get_title(); 00120 } 00121 00127 public function get_type_title() { 00128 return get_string('self', 'completion'); 00129 } 00130 00137 public function get_details($completion) { 00138 $details = array(); 00139 $details['type'] = $this->get_title(); 00140 $details['criteria'] = $this->get_title(); 00141 $details['requirement'] = get_string('markingyourselfcomplete', 'completion'); 00142 $details['status'] = ''; 00143 00144 return $details; 00145 } 00146 }