grader report MDL-19704 Added ability to hide course and category totals without hiding anything else

This commit is contained in:
Andrew Davis 2010-01-11 07:35:40 +00:00
parent 086f0e6f46
commit a25bb902f0
5 changed files with 53 additions and 55 deletions

View file

@ -2857,6 +2857,17 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
upgrade_main_savepoint($result, 2010010601); 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; return $result;
} }

View file

@ -45,7 +45,7 @@ class grade_category extends grade_object {
*/ */
public $required_fields = array('id', 'courseid', 'parent', 'depth', 'path', 'fullname', 'aggregation', public $required_fields = array('id', 'courseid', 'parent', 'depth', 'path', 'fullname', 'aggregation',
'keephigh', 'droplow', 'aggregateonlygraded', 'aggregateoutcomes', 'keephigh', 'droplow', 'aggregateonlygraded', 'aggregateoutcomes',
'aggregatesubcats', 'timecreated', 'timemodified'); 'aggregatesubcats', 'timecreated', 'timemodified', 'hidden');
/** /**
* The course this category belongs to. * The course this category belongs to.
@ -1501,26 +1501,6 @@ class grade_category extends grade_object {
return $result; 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. * Sets the grade_item's hidden variable and updates the grade_item.
* Method named after grade_item::set_hidden(). * Method named after grade_item::set_hidden().
@ -1530,7 +1510,10 @@ class grade_category extends grade_object {
*/ */
public function set_hidden($hidden, $cascade=false) { public function set_hidden($hidden, $cascade=false) {
$this->load_grade_item(); $this->load_grade_item();
//this hides the associated grade item (the course total)
$this->grade_item->set_hidden($hidden); $this->grade_item->set_hidden($hidden);
//this hides the category itself and everything it contains
parent::set_hidden($hidden, $cascade);
if ($cascade) { if ($cascade) {

View file

@ -214,12 +214,6 @@ class grade_item extends grade_object {
*/ */
public $decimals = null; 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. * 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 * @var int $locked
@ -559,30 +553,6 @@ class grade_item extends grade_object {
return $this->locktime; 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. * 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 * @param int $hidden new hidden status
@ -590,8 +560,7 @@ class grade_item extends grade_object {
* @return void * @return void
*/ */
public function set_hidden($hidden, $cascade=false) { public function set_hidden($hidden, $cascade=false) {
$this->hidden = $hidden; parent::set_hidden($hidden, $cascade);
$this->update();
if ($cascade) { if ($cascade) {
if ($grades = grade_grade::fetch_all(array('itemid'=>$this->id))) { if ($grades = grade_grade::fetch_all(array('itemid'=>$this->id))) {

View file

@ -34,7 +34,7 @@ abstract class grade_object {
* Array of required table fields, must start with 'id'. * Array of required table fields, must start with 'id'.
* @var array $required_fields * @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. * 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; 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. * Constructor. Optionally (and by default) attempts to fetch corresponding row from DB.
* @param array $params an array with required parameters for this grade object. * @param array $params an array with required parameters for this grade object.
@ -354,4 +360,33 @@ abstract class grade_object {
*/ */
function notify_changed($deleted) { 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();
}
} }

View file

@ -6,7 +6,7 @@
// This is compared against the values stored in the database to determine // This is compared against the values stored in the database to determine
// whether upgrades should be performed (see lib/db/*.php) // 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 // XX = daily increments
$release = '2.0 dev (Build: 20100111)'; // Human-friendly version name $release = '2.0 dev (Build: 20100111)'; // Human-friendly version name