MDL-9506 Number of important changes, restored unit test stability, on to next changes...
[moodle.git] / lib / grade / grade_category.php
CommitLineData
8a31e65c 1<?php // $Id$
2
3///////////////////////////////////////////////////////////////////////////
4// //
5// NOTICE OF COPYRIGHT //
6// //
7// Moodle - Modular Object-Oriented Dynamic Learning Environment //
8// http://moodle.com //
9// //
10// Copyright (C) 2001-2003 Martin Dougiamas http://dougiamas.com //
11// //
12// This program is free software; you can redistribute it and/or modify //
13// it under the terms of the GNU General Public License as published by //
14// the Free Software Foundation; either version 2 of the License, or //
15// (at your option) any later version. //
16// //
17// This program is distributed in the hope that it will be useful, //
18// but WITHOUT ANY WARRANTY; without even the implied warranty of //
19// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
20// GNU General Public License for more details: //
21// //
22// http://www.gnu.org/copyleft/gpl.html //
23// //
24///////////////////////////////////////////////////////////////////////////
25
26require_once('grade_object.php');
27
3058964f 28class grade_category extends grade_object {
8a31e65c 29 /**
3058964f 30 * DB Table (used by grade_object).
8a31e65c 31 * @var string $table
32 */
33 var $table = 'grade_categories';
34
35 /**
36 * Array of class variables that are not part of the DB table fields
37 * @var array $nonfields
38 */
3058964f 39 var $nonfields = array('table', 'nonfields');
8a31e65c 40
8a31e65c 41
42 /**
43 * The course this category belongs to.
44 * @var int $courseid
45 */
46 var $courseid;
47
48 /**
49 * The category this category belongs to (optional).
50 * @var int $categoryid
51 */
52 var $categoryid;
53
54 /**
55 * The name of this category.
56 * @var string $fullname
57 */
58 var $fullname;
59
60 /**
61 * A constant pointing to one of the predefined aggregation strategies (none, mean, median, sum etc) .
62 * @var int $aggregation
63 */
64 var $aggregation;
65
66 /**
67 * Keep only the X highest items.
68 * @var int $keephigh
69 */
70 var $keephigh;
71
72 /**
73 * Drop the X lowest items.
74 * @var int $droplow
75 */
76 var $droplow;
77
78 /**
79 * Date until which to hide this category. If null, 0 or false, category is not hidden.
80 * @var int $hidden
81 */
82 var $hidden;
83
84 /**
85 * Array of grade_items or grade_categories nested exactly 1 level below this category
86 * @var array $children
87 */
88 var $children;
8a31e65c 89
90
8a31e65c 91 /**
92 * Finds and returns a grade_category object based on 1-3 field values.
93 *
8a31e65c 94 * @param string $field1
95 * @param string $value1
96 * @param string $field2
97 * @param string $value2
98 * @param string $field3
99 * @param string $value3
100 * @param string $fields
101 * @return object grade_category object or false if none found.
102 */
3058964f 103 function fetch($field1, $value1, $field2='', $value2='', $field3='', $value3='', $fields="*")
8a31e65c 104 {
8a31e65c 105 if ($grade_category = get_record('grade_categories', $field1, $value1, $field2, $value2, $field3, $value3, $fields)) {
3058964f 106 if (!isset($this)) {
8a31e65c 107 $grade_category = new grade_category($grade_category);
108 return $grade_category;
109 } else {
110 foreach ($grade_category as $param => $value) {
111 $this->$param = $value;
112 }
113 return $this;
114 }
115 } else {
116 return false;
117 }
118 }
119
120}
121
122?>