1
0
mirror of https://github.com/moodle/moodle.git synced 2025-04-25 10:26:17 +02:00

MDL-50612 grades: remove gradepass if there is no grading

This commit is contained in:
Marina Glancy 2015-07-03 15:05:30 +08:00
parent 7dc5dac678
commit fc55273e0f

@ -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