Skip to content

Commit

Permalink
MDL-45029 core_course: set aggregationcoef while creating a new cours…
Browse files Browse the repository at this point in the history
…e module
  • Loading branch information
lameze committed Aug 20, 2014
1 parent e1eb180 commit 78618bc
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
22 changes: 22 additions & 0 deletions course/modlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,23 @@ function edit_module_post_actions($moduleinfo, $course) {
}
$moduleinfo->gradecat = $grade_category->id;
}
$gradecategory = $grade_item->get_parent_category();
foreach ($items as $itemid=>$unused) {
$items[$itemid]->set_parent($moduleinfo->gradecat);
if ($itemid == $grade_item->id) {
// Use updated grade_item.
$grade_item = $items[$itemid];
}
if (!empty($moduleinfo->add)) {
if (grade_category::aggregation_uses_aggregationcoef($gradecategory->aggregation)) {
if ($gradecategory->aggregation == GRADE_AGGREGATE_WEIGHTED_MEAN) {
$grade_item->aggregationcoef = 1;
} else {
$grade_item->aggregationcoef = 0;
}
$grade_item->update();
}
}
}
}

Expand Down Expand Up @@ -273,6 +284,17 @@ function edit_module_post_actions($moduleinfo, $course) {
} else if (isset($moduleinfo->gradecat)) {
$outcome_item->set_parent($moduleinfo->gradecat);
}
$gradecategory = $outcome_item->get_parent_category();
if ($outcomeexists == false) {
if (grade_category::aggregation_uses_aggregationcoef($gradecategory->aggregation)) {
if ($gradecategory->aggregation == GRADE_AGGREGATE_WEIGHTED_MEAN) {
$outcome_item->aggregationcoef = 1;
} else {
$outcome_item->aggregationcoef = 0;
}
$outcome_item->update();
}
}
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions mod/workshop/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,17 @@ function workshop_grade_item_category_update($workshop) {
$gradeitem->set_parent($workshop->gradinggradecategory);
}
}
if (!empty($workshop->add)) {
$gradecategory = $gradeitem->get_parent_category();
if (grade_category::aggregation_uses_aggregationcoef($gradecategory->aggregation)) {
if ($gradecategory->aggregation == GRADE_AGGREGATE_WEIGHTED_MEAN) {
$gradeitem->aggregationcoef = 1;
} else {
$gradeitem->aggregationcoef = 0;
}
$gradeitem->update();
}
}
}
}
}
Expand Down

0 comments on commit 78618bc

Please sign in to comment.