From fc55273e0fbe39d2baa8d713028e97e0393e8971 Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Fri, 3 Jul 2015 15:05:30 +0800 Subject: [PATCH] MDL-50612 grades: remove gradepass if there is no grading --- course/moodleform_mod.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/course/moodleform_mod.php b/course/moodleform_mod.php index bc79cfb62a6..8a13aa85e48 100644 --- a/course/moodleform_mod.php +++ b/course/moodleform_mod.php @@ -142,6 +142,7 @@ abstract class moodleform_mod extends moodleform { } } + $hasgradeitems = false; $items = grade_item::fetch_all(array('itemtype'=>'mod', 'itemmodule'=>$modulename,'iteminstance'=>$instance, 'courseid'=>$COURSE->id)); //will be no items if, for example, this activity supports ratings but rating aggregate type == no ratings if (!empty($items)) { @@ -151,6 +152,8 @@ abstract class moodleform_mod extends moodleform { if ($mform->elementExists($elname)) { $mform->hardFreeze($elname); // prevent removing of existing outcomes } + } else { + $hasgradeitems = true; } } @@ -167,6 +170,11 @@ abstract class moodleform_mod extends moodleform { } } + if (!$hasgradeitems && $mform->elementExists('gradepass')) { + // Remove form element 'Grade to pass' since there are no grade items (when rating not selected). + $mform->removeElement('gradepass'); + } + if ($gradecat === false) { // items and outcomes in different categories - remove the option // TODO: add a "Mixed categories" text instead of removing elements with no explanation