Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/lib/completion/completion_criteria.php
Go to the documentation of this file.
00001 <?php
00002 
00003 
00004 // This file is part of Moodle - http://moodle.org/
00005 //
00006 // Moodle is free software: you can redistribute it and/or modify
00007 // it under the terms of the GNU General Public License as published by
00008 // the Free Software Foundation, either version 3 of the License, or
00009 // (at your option) any later version.
00010 //
00011 // Moodle is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU General Public License
00017 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00018 
00019 
00028 require_once($CFG->libdir.'/completion/data_object.php');
00029 require_once($CFG->libdir.'/completion/completion_criteria_completion.php');
00030 
00031 
00036 define('COMPLETION_CRITERIA_TYPE_SELF',         1);
00037 define('COMPLETION_CRITERIA_TYPE_DATE',         2);
00038 define('COMPLETION_CRITERIA_TYPE_UNENROL',      3);
00039 define('COMPLETION_CRITERIA_TYPE_ACTIVITY',     4);
00040 define('COMPLETION_CRITERIA_TYPE_DURATION',     5);
00041 define('COMPLETION_CRITERIA_TYPE_GRADE',        6);
00042 define('COMPLETION_CRITERIA_TYPE_ROLE',         7);
00043 define('COMPLETION_CRITERIA_TYPE_COURSE',       8);
00044 
00048 global $COMPLETION_CRITERIA_TYPES;
00049 $COMPLETION_CRITERIA_TYPES = array(
00050     COMPLETION_CRITERIA_TYPE_SELF       => 'self',
00051     COMPLETION_CRITERIA_TYPE_DATE       => 'date',
00052     COMPLETION_CRITERIA_TYPE_UNENROL    => 'unenrol',
00053     COMPLETION_CRITERIA_TYPE_ACTIVITY   => 'activity',
00054     COMPLETION_CRITERIA_TYPE_DURATION   => 'duration',
00055     COMPLETION_CRITERIA_TYPE_GRADE      => 'grade',
00056     COMPLETION_CRITERIA_TYPE_ROLE       => 'role',
00057     COMPLETION_CRITERIA_TYPE_COURSE     => 'course',
00058 );
00059 
00060 
00064 abstract class completion_criteria extends data_object {
00069     public $table = 'course_completion_criteria';
00070 
00075     public $required_fields = array('id', 'course', 'criteriatype', 'module', 'moduleinstance', 'courseinstance', 'enrolperiod', 'timeend', 'gradepass', 'role');
00076 
00081     public $course;
00082 
00088     public $criteriatype;
00089 
00094     public $module;
00095 
00100     public $moduleinstance;
00101 
00106     public $enrolperiod;
00107 
00112     public $date;
00113 
00118     public $gradepass;
00119 
00124     public $role;
00125 
00133     public static function fetch_all($params) {}
00134 
00141     public static function factory($params) {
00142         global $CFG, $COMPLETION_CRITERIA_TYPES;
00143 
00144         if (!isset($params->criteriatype) || !isset($COMPLETION_CRITERIA_TYPES[$params->criteriatype])) {
00145             error('invalidcriteriatype', 'completion');
00146         }
00147 
00148         $class = 'completion_criteria_'.$COMPLETION_CRITERIA_TYPES[$params->criteriatype];
00149         require_once($CFG->libdir.'/completion/'.$class.'.php');
00150 
00151         return new $class($params, false);
00152     }
00153 
00161     abstract public function config_form_display(&$mform, $data = null);
00162 
00169     abstract public function update_config(&$data);
00170 
00178     abstract public function review($completion, $mark = true);
00179 
00185     abstract public function get_title();
00186 
00192     abstract public function get_title_detailed();
00193 
00199     abstract public function get_type_title();
00200 
00207     abstract public function get_details($completion);
00208 
00215     public function get_status($completion) {
00216         return $completion->is_complete() ? get_string('yes') : get_string('no');
00217     }
00218 
00226     public function is_pending($completion) {
00227         $review = $this->review($completion, false);
00228 
00229         return $review !== $completion->is_complete();
00230     }
00231 }
 All Data Structures Namespaces Files Functions Variables Enumerations