MDL-47064 Grades: Add comments to explain this tricky code.

Part of: MDL-46576
This commit is contained in:
Damyon Wiese 2014-09-24 13:22:41 +08:00 committed by Adrian Greeve
parent 852fae0b71
commit 6070e53313
3 changed files with 45 additions and 2 deletions

View file

@ -599,6 +599,8 @@ class grade_category extends grade_object {
unset($grade_values[$this->grade_item->id]);
// Make sure a grade_grade exists for every grade_item.
// We need to do this so we can set the aggregationstatus
// with a set_field call instead of checking if each one exists and creating/updating.
foreach ($items as $itemid => $gradeitem) {
$gradegrade = new grade_grade(array('itemid' => $gradeitem->id,
'userid' => $userid,
@ -630,6 +632,7 @@ class grade_category extends grade_object {
// If null, it means no grade.
if ($this->aggregateonlygraded) {
unset($grade_values[$itemid]);
// Mark this item as dropped because it has no grade.
$novalue[$itemid] = 0;
continue;
}
@ -657,6 +660,8 @@ class grade_category extends grade_object {
if (!$this->aggregateonlygraded) {
$grade_values[$itemid] = 0;
} else {
// We are specifically marking these items that get dropped
// because they are empty.
$novalue[$itemid] = 0;
}
}
@ -726,9 +731,11 @@ class grade_category extends grade_object {
* @param int $userid The user we have aggregated the grades for.
* @param array $usedweights An array with keys for each of the grade_item columns included in the aggregation. The value are the relative weight.
* @param array $novalue An array with keys for each of the grade_item columns skipped because
* they had no value in the aggregation
* they had no value in the aggregation.
* @param array $dropped An array with keys for each of the grade_item columns dropped
* because of any drop lowest/highest settings in the aggregation
* because of any drop lowest/highest settings in the aggregation.
* @param array $extracredit An array with keys for each of the grade_item columns
* considered extra credit by the aggregation.
*/
private function set_usedinaggregation($userid, $usedweights, $novalue, $dropped, $extracredit) {
global $DB;

View file

@ -672,6 +672,9 @@ class grade_grade extends grade_object {
* unknown => list of item ids that may be affected by hiding (with the calculated grade as the value)
* altered => list of item ids that are definitely affected by hiding (with the calculated grade as the value)
* alteredgrademax => for each item in altered or unknown, the new value of the grademax
* alteredgrademin => for each item in altered or unknown, the new value of the grademin
* alteredgradestatus => for each item with a modified status - the value of the new status
* alteredgradeweight => for each item with a modified weight - the value of the new weight
*/
public static function get_hiding_affected(&$grade_grades, &$grade_items) {
global $CFG;