MDL-30995 completion: Fixed up PHPdocs for activity completion
[moodle.git] / lib / completion / completion_aggregation.php
CommitLineData
2be4d090 1<?php
2be4d090
MD
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/**
19 * Course completion critieria aggregation
20 *
836375ec
SH
21 * @package core_completion
22 * @category completion
2be4d090 23 * @copyright 2009 Catalyst IT Ltd
836375ec
SH
24 * @author Aaron Barnes <aaronb@catalyst.net.nz>
25 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
2be4d090 26 */
836375ec
SH
27
28defined('MOODLE_INTERNAL') || die();
2be4d090
MD
29require_once($CFG->libdir.'/completion/data_object.php');
30
31/**
32 * Course completion critieria aggregation
836375ec
SH
33 *
34 * @package core_completion
35 * @category completion
36 * @copyright 2009 Catalyst IT Ltd
37 * @author Aaron Barnes <aaronb@catalyst.net.nz>
38 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
2be4d090
MD
39 */
40class completion_aggregation extends data_object {
41
42 /**
836375ec
SH
43 * Database table name that stores completion aggregation information
44 * @var string
2be4d090
MD
45 */
46 public $table = 'course_completion_aggr_methd';
47
48 /**
49 * Array of required table fields, must start with 'id'.
836375ec
SH
50 * Defaults to id, course, criteriatype, method, value
51 * @var array
2be4d090
MD
52 */
53 public $required_fields = array('id', 'course', 'criteriatype', 'method', 'value');
54
55 /**
56 * Course id
836375ec 57 * @var int
2be4d090
MD
58 */
59 public $course;
60
61 /**
62 * Criteria type this aggregation method applies to, or NULL for overall course aggregation
836375ec 63 * @var int
2be4d090
MD
64 */
65 public $criteriatype;
66
67 /**
68 * Aggregation method (COMPLETION_AGGREGATION_* constant)
836375ec 69 * @var int
2be4d090
MD
70 */
71 public $method;
72
73 /**
74 * Method value
836375ec 75 * @var mixed
2be4d090
MD
76 */
77 public $value;
78
79
80 /**
81 * Finds and returns a data_object instance based on params.
2be4d090
MD
82 *
83 * @param array $params associative arrays varname=>value
836375ec 84 * @return data_object instance of data_object or false if none found.
2be4d090
MD
85 */
86 public static function fetch($params) {
87 return self::fetch_helper('course_completion_aggr_methd', __CLASS__, $params);
88 }
89
90
91 /**
92 * Finds and returns all data_object instances based on params.
2be4d090
MD
93 *
94 * @param array $params associative arrays varname=>value
95 * @return array array of data_object insatnces or false if none found.
96 */
97 public static function fetch_all($params) {}
98
99 /**
100 * Set the aggregation method
836375ec
SH
101 *
102 * @param int $method One of COMPLETION_AGGREGATION_ALL or COMPLETION_AGGREGATION_ANY
2be4d090
MD
103 */
104 public function setMethod($method) {
105 $methods = array(
106 COMPLETION_AGGREGATION_ALL,
107 COMPLETION_AGGREGATION_ANY,
108 );
109
110 if (in_array($method, $methods)) {
111 $this->method = $method;
112 } else {
113 $this->method = COMPLETION_AGGREGATION_ALL;
114 }
115 }
836375ec 116}