Merge branch 'MDL-43068_24' of git://github.com/timhunt/moodle into MOODLE_24_STABLE
This commit is contained in:
+16
-8
@@ -2917,14 +2917,6 @@ 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.
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
// Updating visible and visibleold to keep them in sync. Only changing a section visibility will
|
||||
// affect visibleold to allow for an original visibility restore. See set_section_visible().
|
||||
$cminfo = new stdClass();
|
||||
@@ -2933,6 +2925,22 @@ function set_coursemodule_visible($id, $visible) {
|
||||
$cminfo->visibleold = $visible;
|
||||
$DB->update_record('course_modules', $cminfo);
|
||||
|
||||
// Hide the associated grade items so the teacher doesn't also have to go to the gradebook and hide them there.
|
||||
// Note that this must be done after updating the row in course_modules, in case
|
||||
// the modules grade_item_update function needs to access $cm->visible.
|
||||
if (plugin_supports('mod', $modulename, FEATURE_CONTROLS_GRADE_VISIBILITY) &&
|
||||
component_callback_exists('mod_' . $modulename, 'grade_item_update')) {
|
||||
$instance = $DB->get_record($modulename, array('id' => $cm->instance), '*', MUST_EXIST);
|
||||
component_callback('mod_' . $modulename, 'grade_item_update', array($instance));
|
||||
} else {
|
||||
$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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rebuild_course_cache($cm->course, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
+7
-2
@@ -722,8 +722,13 @@ function quiz_grade_item_update($quiz, $grades = null) {
|
||||
if (!$params['hidden']) {
|
||||
// If the grade item is not hidden by the quiz logic, then we need to
|
||||
// hide it if the quiz is hidden from students.
|
||||
$cm = get_coursemodule_from_instance('quiz', $quiz->id);
|
||||
$params['hidden'] = !$cm->visible;
|
||||
if (property_exists($quiz, 'visible')) {
|
||||
// Saving the quiz form, and cm not yet updated in the database.
|
||||
$params['hidden'] = !$quiz->visible;
|
||||
} else {
|
||||
$cm = get_coursemodule_from_instance('quiz', $quiz->id);
|
||||
$params['hidden'] = !$cm->visible;
|
||||
}
|
||||
}
|
||||
|
||||
if ($grades === 'reset') {
|
||||
|
||||
Reference in New Issue
Block a user