Fix all the PHP syntax errors in this code. I can't think of any valid reason for...
[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
41 /**
42 * The course this category belongs to.
43 * @var int $courseid
44 */
45 var $courseid;
46
47 /**
48 * The category this category belongs to (optional).
e5c674f1 49 * @var int $parent
8a31e65c 50 */
e5c674f1 51 var $parent;
52
53 /**
54 * The number of parents this category has.
55 * @var int $depth
56 */
57 var $depth = 0;
58
59 /**
60 * Shows the hierarchical path for this category as /1/2/3 (like course_categories), the last number being
61 * this category's autoincrement ID number.
62 * @var string $path
63 */
64 var $path;
65
8a31e65c 66 /**
67 * The name of this category.
68 * @var string $fullname
69 */
70 var $fullname;
71
72 /**
73 * A constant pointing to one of the predefined aggregation strategies (none, mean, median, sum etc) .
74 * @var int $aggregation
75 */
76 var $aggregation;
77
78 /**
79 * Keep only the X highest items.
80 * @var int $keephigh
81 */
82 var $keephigh;
83
84 /**
85 * Drop the X lowest items.
86 * @var int $droplow
87 */
88 var $droplow;
89
90 /**
91 * Date until which to hide this category. If null, 0 or false, category is not hidden.
92 * @var int $hidden
93 */
94 var $hidden;
95
96 /**
97 * Array of grade_items or grade_categories nested exactly 1 level below this category
98 * @var array $children
99 */
100 var $children;
8a31e65c 101
e5c674f1 102 /**
103 * Constructor. Extends the basic functionality defined in grade_object.
104 * @param array $params Can also be a standard object.
105 * @param boolean $fetch Wether or not to fetch the corresponding row from the DB.
106 */
107 function grade_category($params=NULL, $fetch=true) {
108 $this->grade_object($params, $fetch);
109 }
110
111
112 /**
113 * Builds this category's path string based on its parents (if any) and its own id number.
114 * This is typically done just before inserting this object in the DB for the first time,
115 * or when a new parent is added or changed.
116 * @todo implement
117 */
118 function build_path() {
119
120 }
121
8a31e65c 122
8a31e65c 123 /**
124 * Finds and returns a grade_category object based on 1-3 field values.
125 *
8a31e65c 126 * @param string $field1
127 * @param string $value1
128 * @param string $field2
129 * @param string $value2
130 * @param string $field3
131 * @param string $value3
132 * @param string $fields
133 * @return object grade_category object or false if none found.
134 */
3058964f 135 function fetch($field1, $value1, $field2='', $value2='', $field3='', $value3='', $fields="*")
8a31e65c 136 {
8a31e65c 137 if ($grade_category = get_record('grade_categories', $field1, $value1, $field2, $value2, $field3, $value3, $fields)) {
3058964f 138 if (!isset($this)) {
8a31e65c 139 $grade_category = new grade_category($grade_category);
140 return $grade_category;
141 } else {
142 foreach ($grade_category as $param => $value) {
143 $this->$param = $value;
144 }
145 return $this;
146 }
147 } else {
148 return false;
149 }
e5c674f1 150 }
8a31e65c 151}
152
153?>