Permalink
Browse files

MDL-36757 course: avoid accidently overwriting the hidden/visible val…

…ues set on grade items
  • Loading branch information...
1 parent 3e90b10 commit e7052c0349d175c18b3a28dd827f8aa2677f4f2c @andyjdavis andyjdavis committed Dec 19, 2012
Showing with 8 additions and 1 deletion.
  1. +8 −1 course/lib.php
View
@@ -2868,6 +2868,13 @@ function set_coursemodule_visible($id, $visible) {
if (!$cm = $DB->get_record('course_modules', array('id'=>$id))) {
return false;
}
+
+ // Create events and propagate visibility to associated grade items if the value has changed.
+ // Only do this if it's changed to avoid accidently overwriting manual showing/hiding of student grades.
+ if ($cm->visible == $visible) {
+ return true;
+ }
+
if (!$modulename = $DB->get_field('modules', 'name', array('id'=>$cm->module))) {
return false;
}
@@ -2881,7 +2888,7 @@ function set_coursemodule_visible($id, $visible) {
}
}
- // hide the associated grade items so the teacher doesn't also have to go to the gradebook and hide them there
+ // Hide the associated grade items so the teacher doesn't also have to go to the gradebook and hide them there.
$grade_items = grade_item::fetch_all(array('itemtype'=>'mod', 'itemmodule'=>$modulename, 'iteminstance'=>$cm->instance, 'courseid'=>$cm->course));
if ($grade_items) {
foreach ($grade_items as $grade_item) {

0 comments on commit e7052c0

Please sign in to comment.