Skip to content

Commit

Permalink
gradebook MDL-15457 hide grade item when activity is hidden in the co…
Browse files Browse the repository at this point in the history
…urse
  • Loading branch information
Andrew Davis committed Sep 3, 2010
1 parent 5a5db5d commit f5e2602
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion course/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2581,7 +2581,7 @@ function set_coursemodule_idnumber($id, $idnumber) {
* the course module back to what it was originally.
*/
function set_coursemodule_visible($id, $visible, $prevstateoverrides=false) {
global $DB;
global $DB, $CFG;
if (!$cm = $DB->get_record('course_modules', array('id'=>$id))) {
return false;
}
Expand All @@ -2597,6 +2597,14 @@ function set_coursemodule_visible($id, $visible, $prevstateoverrides=false) {
}
}
}

//hide the grade item so the teacher doesn't also have to go to the gradebook and hide it there
require_once($CFG->libdir.'/gradelib.php');
$grade_item = grade_item::fetch(array('itemtype'=>'mod', 'itemmodule'=>$modulename, 'iteminstance'=>$cm->instance, 'courseid'=>$cm->course));
if ($grade_item !== false) {
$grade_item->set_hidden(!$visible);
}

if ($prevstateoverrides) {
if ($visible == '0') {
// Remember the current visible state so we can toggle this back.
Expand Down

0 comments on commit f5e2602

Please sign in to comment.