mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
MDL-11718 aggregated grades which depend on hidden grades are now hidden too + cleanup in grader report
This commit is contained in:
parent
93b2ed94a8
commit
b89a70ce8a
5 changed files with 108 additions and 87 deletions
|
@ -476,11 +476,11 @@ class grade_grade extends grade_object {
|
|||
* Return array of grade item ids that are either hidden or indirectly depend
|
||||
* on hidden grades, excluded grades are not returned.
|
||||
* @static
|
||||
* @param array $grades all course grades of one user
|
||||
* @param array $grades all course grades of one user, & used for better internal caching
|
||||
* @param array $items $grade_items array of grade items, & used for better internal caching
|
||||
* @return array
|
||||
*/
|
||||
function get_hiding_affected($grade_grades, &$grade_items) {
|
||||
function get_hiding_affected(&$grade_grades, &$grade_items) {
|
||||
if (count($grade_grades) !== count($grade_items)) {
|
||||
error("Incorrent size of arrays in params of grade_grade::get_hiding_affected()!");
|
||||
}
|
||||
|
|
|
@ -238,6 +238,11 @@ class grade_item extends grade_object {
|
|||
*/
|
||||
var $needsupdate = 1;
|
||||
|
||||
/**
|
||||
* Cached dependson array
|
||||
*/
|
||||
var $dependson_cache = null;
|
||||
|
||||
/**
|
||||
* In addition to update() as defined in grade_object, handle the grade_outcome and grade_scale objects.
|
||||
* Force regrading if necessary
|
||||
|
@ -245,6 +250,9 @@ class grade_item extends grade_object {
|
|||
* @return boolean success
|
||||
*/
|
||||
function update($source=null) {
|
||||
// reset caches
|
||||
$this->dependson_cache = null;
|
||||
|
||||
// Retrieve scale and infer grademax/min from it if needed
|
||||
$this->load_scale();
|
||||
|
||||
|
@ -1149,27 +1157,38 @@ class grade_item extends grade_object {
|
|||
|
||||
/**
|
||||
* Finds out on which other items does this depend directly when doing calculation or category agregation
|
||||
* @param bool $reset_cache
|
||||
* @return array of grade_item ids this one depends on
|
||||
*/
|
||||
function depends_on() {
|
||||
function depends_on($reset_cache=false) {
|
||||
global $CFG;
|
||||
|
||||
if ($reset_cache) {
|
||||
$this->dependson_cache = null;
|
||||
} else if (isset($this->dependson_cache)) {
|
||||
return $this->dependson_cache;
|
||||
}
|
||||
|
||||
if ($this->is_locked()) {
|
||||
// locked items do not need to be regraded
|
||||
return array();
|
||||
$this->dependson_cache = array();
|
||||
return $this->dependson_cache;
|
||||
}
|
||||
|
||||
if ($this->is_calculated()) {
|
||||
if (preg_match_all('/##gi(\d+)##/', $this->calculation, $matches)) {
|
||||
return array_unique($matches[1]); // remove duplicates
|
||||
$this->dependson_cache = array_unique($matches[1]); // remove duplicates
|
||||
return $this->dependson_cache;
|
||||
} else {
|
||||
return array();
|
||||
$this->dependson_cache = array();
|
||||
return $this->dependson_cache;
|
||||
}
|
||||
|
||||
} else if ($grade_category = $this->load_item_category()) {
|
||||
//only items with numeric or scale values can be aggregated
|
||||
if ($this->gradetype != GRADE_TYPE_VALUE and $this->gradetype != GRADE_TYPE_SCALE) {
|
||||
return array();
|
||||
$this->dependson_cache = array();
|
||||
return $this->dependson_cache;
|
||||
}
|
||||
|
||||
// If global aggregateoutcomes is set, override category value
|
||||
|
@ -1217,13 +1236,16 @@ class grade_item extends grade_object {
|
|||
}
|
||||
|
||||
if ($children = get_records_sql($sql)) {
|
||||
return array_keys($children);
|
||||
$this->dependson_cache = array_keys($children);
|
||||
return $this->dependson_cache;
|
||||
} else {
|
||||
return array();
|
||||
$this->dependson_cache = array();
|
||||
return $this->dependson_cache;
|
||||
}
|
||||
|
||||
} else {
|
||||
return array();
|
||||
$this->dependson_cache = array();
|
||||
return $this->dependson_cache;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue