mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
MDL-10109 optional aggregation of outcomes together with grades
This commit is contained in:
parent
e754b3e058
commit
29d509f59a
9 changed files with 70 additions and 8 deletions
|
@ -93,6 +93,12 @@ class grade_category extends grade_object {
|
|||
*/
|
||||
var $droplow = 0;
|
||||
|
||||
/**
|
||||
* Aggregate outcomes together with normal items
|
||||
* @$aggregateoutcomes
|
||||
*/
|
||||
var $aggregateoutcomes = 0;
|
||||
|
||||
/**
|
||||
* Array of grade_items or grade_categories nested exactly 1 level below this category
|
||||
* @var array $children
|
||||
|
@ -308,11 +314,12 @@ class grade_category extends grade_object {
|
|||
|
||||
$db_item = grade_category::fetch(array('id'=>$this->id));
|
||||
|
||||
$aggregationdiff = $db_item->aggregation != $this->aggregation;
|
||||
$keephighdiff = $db_item->keephigh != $this->keephigh;
|
||||
$droplowdiff = $db_item->droplow != $this->droplow;
|
||||
$aggregationdiff = $db_item->aggregation != $this->aggregation;
|
||||
$keephighdiff = $db_item->keephigh != $this->keephigh;
|
||||
$droplowdiff = $db_item->droplow != $this->droplow;
|
||||
$aggoutcomesdiff = $db_item->aggregateoutcomes != $this->aggregateoutcomes;
|
||||
|
||||
return ($aggregationdiff || $keephighdiff || $droplowdiff);
|
||||
return ($aggregationdiff || $keephighdiff || $droplowdiff || $aggoutcomesdiff);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -668,10 +675,15 @@ class grade_category extends grade_object {
|
|||
// recursively resort children
|
||||
if (!empty($category_array['children'])) {
|
||||
$result['children'] = array();
|
||||
//process the category item first
|
||||
$cat_item_id = null;
|
||||
foreach($category_array['children'] as $oldorder=>$child_array) {
|
||||
if ($child_array['type'] == 'courseitem' or $child_array['type'] == 'categoryitem') {
|
||||
$result['children'][$sortorder] = grade_category::_fetch_course_tree_recursion($child_array, $sortorder);
|
||||
} else {
|
||||
}
|
||||
}
|
||||
foreach($category_array['children'] as $oldorder=>$child_array) {
|
||||
if ($child_array['type'] != 'courseitem' and $child_array['type'] != 'categoryitem') {
|
||||
$result['children'][++$sortorder] = grade_category::_fetch_course_tree_recursion($child_array, $sortorder);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -232,6 +232,11 @@ class grade_item extends grade_object {
|
|||
// Retrieve scale and infer grademax/min from it if needed
|
||||
$this->load_scale();
|
||||
|
||||
// make sure there is not 0 in outcomeid
|
||||
if (empty($this->outcomeid)) {
|
||||
$this->outcomeid = null;
|
||||
}
|
||||
|
||||
if ($this->qualifies_for_regrading()) {
|
||||
$this->force_regrading();
|
||||
}
|
||||
|
@ -349,6 +354,11 @@ class grade_item extends grade_object {
|
|||
}
|
||||
}
|
||||
|
||||
// make sure there is not 0 in outcomeid
|
||||
if (empty($this->outcomeid)) {
|
||||
$this->outcomeid = null;
|
||||
}
|
||||
|
||||
if (parent::insert($source)) {
|
||||
// force regrading of items if needed
|
||||
$this->force_regrading();
|
||||
|
@ -1127,10 +1137,17 @@ class grade_item extends grade_object {
|
|||
return array();
|
||||
}
|
||||
|
||||
if (!empty($CFG->enableoutcomes) or $grade_category->aggregateoutcomes) {
|
||||
$outcomes_sql = "";
|
||||
} else {
|
||||
$outcomes_sql = "AND gi.outcomeid IS NULL";
|
||||
}
|
||||
|
||||
$sql = "SELECT gi.id
|
||||
FROM {$CFG->prefix}grade_items gi
|
||||
WHERE gi.categoryid = {$grade_category->id}
|
||||
AND (gi.gradetype = ".GRADE_TYPE_VALUE." OR gi.gradetype = ".GRADE_TYPE_SCALE.")
|
||||
AND (gi.gradetype = ".GRADE_TYPE_VALUE." OR gi.gradetype = ".GRADE_TYPE_SCALE.")
|
||||
$outcomes_sql
|
||||
|
||||
UNION
|
||||
|
||||
|
@ -1138,7 +1155,8 @@ class grade_item extends grade_object {
|
|||
FROM {$CFG->prefix}grade_items gi, {$CFG->prefix}grade_categories gc
|
||||
WHERE (gi.itemtype = 'category' OR gi.itemtype = 'course') AND gi.iteminstance=gc.id
|
||||
AND gc.parent = {$grade_category->id}
|
||||
AND (gi.gradetype = ".GRADE_TYPE_VALUE." OR gi.gradetype = ".GRADE_TYPE_SCALE.")";
|
||||
AND (gi.gradetype = ".GRADE_TYPE_VALUE." OR gi.gradetype = ".GRADE_TYPE_SCALE.")
|
||||
$outcomes_sql";
|
||||
|
||||
if ($children = get_records_sql($sql)) {
|
||||
return array_keys($children);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue