upgrade_main_savepoint($result, 2010010601);
}
+ if ($result && $oldversion < 2010010601.01) {
+ $table = new xmldb_table('grade_categories');
+ $field = new xmldb_field('hidden', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, 0);
+
+ if (!$dbman->field_exists($table, $field)) {
+ $dbman->add_field($table, $field);
+ }
+
+ upgrade_main_savepoint($result, 2010010601.01);
+ }
+
return $result;
}
*/
public $required_fields = array('id', 'courseid', 'parent', 'depth', 'path', 'fullname', 'aggregation',
'keephigh', 'droplow', 'aggregateonlygraded', 'aggregateoutcomes',
- 'aggregatesubcats', 'timecreated', 'timemodified');
+ 'aggregatesubcats', 'timecreated', 'timemodified', 'hidden');
/**
* The course this category belongs to.
return $result;
}
- /**
- * Returns the hidden state/date of the associated grade_item. This method is also available in
- * grade_item.
- *
- * @return boolean
- */
- public function is_hidden() {
- $this->load_grade_item();
- return $this->grade_item->is_hidden();
- }
-
- /**
- * Check grade hidden status. Uses data from both grade item and grade.
- * @return boolean true if hiddenuntil, false if not
- */
- public function is_hiddenuntil() {
- $this->load_grade_item();
- return $this->grade_item->is_hiddenuntil();
- }
-
/**
* Sets the grade_item's hidden variable and updates the grade_item.
* Method named after grade_item::set_hidden().
*/
public function set_hidden($hidden, $cascade=false) {
$this->load_grade_item();
+ //this hides the associated grade item (the course total)
$this->grade_item->set_hidden($hidden);
+ //this hides the category itself and everything it contains
+ parent::set_hidden($hidden, $cascade);
if ($cascade) {
*/
public $decimals = null;
- /**
- * 0 if visible, 1 always hidden or date not visible until
- * @var int $hidden
- */
- public $hidden = 0;
-
/**
* Grade item lock flag. Empty if not locked, locked if any value present, usually date when item was locked. Locking prevents updating.
* @var int $locked
return $this->locktime;
}
- /**
- * Returns the hidden state of this grade_item
- * @return boolean hidden state
- */
- public function is_hidden() {
- return ($this->hidden == 1 or ($this->hidden != 0 and $this->hidden > time()));
- }
-
- /**
- * Check grade hidden status. Uses data from both grade item and grade.
- * @return boolean true if hiddenuntil, false if not
- */
- public function is_hiddenuntil() {
- return $this->hidden > 1;
- }
-
- /**
- * Check grade item hidden status.
- * @return int 0 means visible, 1 hidden always, timestamp hidden until
- */
- public function get_hidden() {
- return $this->hidden;
- }
-
/**
* Set the hidden status of grade_item and all grades, 0 mean visible, 1 always hidden, number means date to hide until.
* @param int $hidden new hidden status
* @return void
*/
public function set_hidden($hidden, $cascade=false) {
- $this->hidden = $hidden;
- $this->update();
+ parent::set_hidden($hidden, $cascade);
if ($cascade) {
if ($grades = grade_grade::fetch_all(array('itemid'=>$this->id))) {
* Array of required table fields, must start with 'id'.
* @var array $required_fields
*/
- public $required_fields = array('id', 'timecreated', 'timemodified');
+ public $required_fields = array('id', 'timecreated', 'timemodified', 'hidden');
/**
* Array of optional fields with default values - usually long text information that is not always needed.
*/
public $timemodified;
+ /**
+ * 0 if visible, 1 always hidden or date not visible until
+ * @var int $hidden
+ */
+ var $hidden = 0;
+
/**
* Constructor. Optionally (and by default) attempts to fetch corresponding row from DB.
* @param array $params an array with required parameters for this grade object.
*/
function notify_changed($deleted) {
}
+
+ /**
+ * Returns the hidden state of this grade_item
+ * @return boolean hidden state
+ */
+ function is_hidden() {
+ return ($this->hidden == 1 or ($this->hidden != 0 and $this->hidden > time()));
+ }
+
+ /**
+ * Check grade hidden status. Uses data from both grade item and grade.
+ * @return boolean true if hiddenuntil, false if not
+ */
+ function is_hiddenuntil() {
+ return $this->hidden > 1;
+ }
+
+ /**
+ * Check grade item hidden status.
+ * @return int 0 means visible, 1 hidden always, timestamp hidden until
+ */
+ function get_hidden() {
+ return $this->hidden;
+ }
+
+ function set_hidden($hidden, $cascade=false) {
+ $this->hidden = $hidden;
+ $this->update();
+ }
}
// This is compared against the values stored in the database to determine
// whether upgrades should be performed (see lib/db/*.php)
- $version = 2010010601; // YYYYMMDD = date of the last version bump
+ $version = 2010010601.01; // YYYYMMDD = date of the last version bump
// XX = daily increments
$release = '2.0 dev (Build: 20100111)'; // Human-friendly version name