]> git.mjollnir.org Git - moodle.git/commitdiff
grader report MDL-19704 Added ability to hide course and category totals without...
authorAndrew Davis <andrew@affinitysoftware.net>
Mon, 11 Jan 2010 07:35:40 +0000 (07:35 +0000)
committerAndrew Davis <andrew@affinitysoftware.net>
Mon, 11 Jan 2010 07:35:40 +0000 (07:35 +0000)
lib/db/upgrade.php
lib/grade/grade_category.php
lib/grade/grade_item.php
lib/grade/grade_object.php
version.php

index abf1f7f0c97e232d0c6e66b2ca2eea3cea29faa4..8f1e990ba5202c29aceae1e7626129aeef9d80d7 100644 (file)
@@ -2857,6 +2857,17 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
         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;
 }
 
index fac2496382e2e3c8cf7e0e792ff01c1f29e1bc65..7447c83ff5875c961b19f732ab82c949f66cf92d 100644 (file)
@@ -45,7 +45,7 @@ class grade_category extends grade_object {
      */
     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.
@@ -1501,26 +1501,6 @@ class grade_category extends grade_object {
         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().
@@ -1530,7 +1510,10 @@ class grade_category extends grade_object {
      */
     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) {
 
index 1cd11dd85615f85769c087ef39b79184fb6a11eb..2b9c713cf93f7988f0d8a9c50d82b74b4e782a4e 100644 (file)
@@ -214,12 +214,6 @@ class grade_item extends grade_object {
      */
     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
@@ -559,30 +553,6 @@ class grade_item extends grade_object {
         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
@@ -590,8 +560,7 @@ class grade_item extends grade_object {
      * @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))) {
index 72c9ec618e6c864f694fb36f8080dda70f57e972..7a48965e91ff5d6fbeb5959581ce626cc5e0f9f2 100644 (file)
@@ -34,7 +34,7 @@ abstract class grade_object {
      * 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.
@@ -61,6 +61,12 @@ abstract class grade_object {
      */
     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.
@@ -354,4 +360,33 @@ abstract class 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();
+    }
 }
index cd604308c093d5eedf4f718c42178654abad70e0..0a03e2ee1eb221f48babab0213056ab5e1437612 100644 (file)
@@ -6,7 +6,7 @@
 // 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