mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 17:06:53 +02:00
MDL-9506 small fix
This commit is contained in:
parent
76127f3797
commit
cb64c6b257
2 changed files with 18 additions and 18 deletions
|
@ -193,17 +193,10 @@ class grade_category extends grade_object {
|
|||
|
||||
$result = parent::update();
|
||||
|
||||
/**
|
||||
// Notify parent category of need to update.
|
||||
// Use $this->path to update all parent categories
|
||||
if ($result && $qualifies) {
|
||||
$this->load_parent_category();
|
||||
if (!empty($this->parent_category)) {
|
||||
if (!$this->parent_category->flag_for_update()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$this->flag_for_update();
|
||||
}
|
||||
*/
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
@ -256,7 +249,7 @@ class grade_category extends grade_object {
|
|||
|
||||
$this->grade_item = $grade_item;
|
||||
}
|
||||
/**
|
||||
|
||||
// Notify parent category of need to update.
|
||||
if ($result) {
|
||||
$this->load_parent_category();
|
||||
|
@ -266,7 +259,6 @@ class grade_category extends grade_object {
|
|||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
@ -299,7 +291,8 @@ class grade_category extends grade_object {
|
|||
* This is triggered whenever any change in any lower level may cause grade_finals
|
||||
* for this category to require an update. The flag needs to be propagated up all
|
||||
* levels until it reaches the top category. This is then used to determine whether or not
|
||||
* to regenerate the raw and final grades for each category grade_item.
|
||||
* to regenerate the raw and final grades for each category grade_item. This is accomplished
|
||||
* thanks to the path variable, so we don't need to use recursion.
|
||||
* @return boolean Success or failure
|
||||
*/
|
||||
function flag_for_update() {
|
||||
|
@ -316,11 +309,17 @@ class grade_category extends grade_object {
|
|||
|
||||
$result = $result && $this->grade_item->update();
|
||||
|
||||
$this->load_parent_category();
|
||||
if (!empty($this->parent_category)) {
|
||||
$result = $result && $this->parent_category->flag_for_update();
|
||||
$paths = explode('/', $this->path);
|
||||
|
||||
$wheresql = '';
|
||||
|
||||
foreach ($paths as $categoryid) {
|
||||
$wheresql .= "iteminstance = $categoryid OR";
|
||||
}
|
||||
|
||||
$wheresql = substr($wheresql, 0, strrpos($wheresql, 'OR'));
|
||||
|
||||
// TODO use this sql fragment to set needsupdate to true for all grade_items whose iteminstance matches the categoryids
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,8 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
require_once('grade_object.php');
|
||||
|
||||
global $db;
|
||||
$db->debug = true;
|
||||
/**
|
||||
* Class representing a grade item. It is responsible for handling its DB representation,
|
||||
* modifying and returning its metadata.
|
||||
|
@ -759,9 +760,9 @@ class grade_item extends grade_object {
|
|||
* @return boolean Success or failure
|
||||
*/
|
||||
function flag_for_update() {
|
||||
$result = true;
|
||||
|
||||
$this->needsupdate = true;
|
||||
|
||||
$result = $this->update();
|
||||
$category = $this->get_category();
|
||||
|
||||
if (!empty($category)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue