MDL-43068 course&gradebook: show/hide cm & CONTROLS_GRADE_VISIBILITY

Making a quiz visible on the course page, of via the settings form,
could cause the grade item to become visible in the gradebook, even
though the quiz supports FEATURE_CONTROLS_GRADE_VISIBILITY to ensure
that when the grades are hidden in the quiz settings, they do not appear
in the gradebook.

Now, if a module supports FEATURE_CONTROLS_GRADE_VISIBILITY, then
set_coursemodule_visible calls the _grade_item_update callback to update
the grade item(s).

In addition, there was a bug when saving the quiz form, where it used
the value of $cm->visible from the database, which was wrong if the
value of cm->visible had just been changed on the setting form.
This commit is contained in:
Tim Hunt 2013-11-27 17:40:40 +00:00
parent f7434db109
commit 1c73df9eea
2 changed files with 23 additions and 10 deletions

View file

@ -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') {