Skip to content

Commit

Permalink
MDL-15457 gradebook: fixing a regression, plain fetch() does not work…
Browse files Browse the repository at this point in the history
… with modules having multiple grade items per instance such as workshop
  • Loading branch information
mudrd8mz committed Sep 16, 2010
1 parent e101180 commit 0f07802
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions course/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2577,6 +2577,8 @@ function set_coursemodule_idnumber($id, $idnumber) {
*/
function set_coursemodule_visible($id, $visible, $prevstateoverrides=false) {
global $DB, $CFG;
require_once($CFG->libdir.'/gradelib.php');

if (!$cm = $DB->get_record('course_modules', array('id'=>$id))) {
return false;
}
Expand All @@ -2593,11 +2595,12 @@ 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);
// 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) {
$grade_item->set_hidden(!$visible);
}
}

if ($prevstateoverrides) {
Expand Down

0 comments on commit 0f07802

Please sign in to comment.