3 // This file is part of Moodle - http://moodle.org/
5 // Moodle is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
10 // Moodle is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
20 * Course completion critieria aggregation
23 * @copyright 2009 Catalyst IT Ltd
24 * @author Aaron Barnes <aaronb@catalyst.net.nz>
25 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27 require_once($CFG->libdir
.'/completion/data_object.php');
30 * Course completion critieria aggregation
32 class completion_aggregation
extends data_object
{
38 public $table = 'course_completion_aggr_methd';
41 * Array of required table fields, must start with 'id'.
42 * @var array $required_fields
44 public $required_fields = array('id', 'course', 'criteriatype', 'method', 'value');
54 * Criteria type this aggregation method applies to, or NULL for overall course aggregation
61 * Aggregation method (COMPLETION_AGGREGATION_* constant)
76 * Finds and returns a data_object instance based on params.
79 * @param array $params associative arrays varname=>value
80 * @return object data_object instance or false if none found.
82 public static function fetch($params) {
83 return self
::fetch_helper('course_completion_aggr_methd', __CLASS__
, $params);
88 * Finds and returns all data_object instances based on params.
91 * @param array $params associative arrays varname=>value
92 * @return array array of data_object insatnces or false if none found.
94 public static function fetch_all($params) {}
97 * Set the aggregation method
102 public function setMethod($method) {
104 COMPLETION_AGGREGATION_ALL
,
105 COMPLETION_AGGREGATION_ANY
,
108 if (in_array($method, $methods)) {
109 $this->method
= $method;
111 $this->method
= COMPLETION_AGGREGATION_ALL
;