mirror of
https://github.com/moodle/moodle.git
synced 2025-04-20 07:56:06 +02:00
MDL-72377 grade: fix category form hidden/until fields.
Ensure the saved values for the hidden and hidden until fields are populated when editing a grade category. Fix behaviour on enabling the hidden until field. Re-enable tests commented out in eba1d32c.
This commit is contained in:
parent
67b15496c3
commit
3596fc1fe6
@ -229,7 +229,7 @@ class edit_category_form extends moodleform {
|
||||
$mform->addElement('checkbox', 'grade_item_hidden', get_string('hidden', 'grades'));
|
||||
$mform->addHelpButton('grade_item_hidden', 'hidden', 'grades');
|
||||
$mform->addElement('date_time_selector', 'grade_item_hiddenuntil', get_string('hiddenuntil', 'grades'), array('optional'=>true));
|
||||
$mform->disabledIf('grade_item_hidden', 'grade_item_hiddenuntil[off]', 'notchecked');
|
||||
$mform->disabledIf('grade_item_hidden', 'grade_item_hiddenuntil[enabled]', 'checked');
|
||||
|
||||
/// locking
|
||||
$mform->addElement('checkbox', 'grade_item_locked', get_string('locked', 'grades'));
|
||||
@ -440,7 +440,12 @@ class edit_category_form extends moodleform {
|
||||
$grade_category = grade_category::fetch(array('id'=>$id));
|
||||
$grade_item = $grade_category->load_grade_item();
|
||||
|
||||
$mform->setDefault('grade_item_hidden', (int) $grade_item->hidden);
|
||||
// Load appropriate "hidden"/"hidden until" defaults.
|
||||
if ($grade_item->is_hiddenuntil()) {
|
||||
$mform->setDefault('grade_item_hiddenuntil', $grade_item->get_hidden());
|
||||
} else {
|
||||
$mform->setDefault('grade_item_hidden', $grade_item->get_hidden());
|
||||
}
|
||||
|
||||
if ($grade_item->is_outcome_item()) {
|
||||
// we have to prevent incompatible modifications of outcomes if outcomes disabled
|
||||
|
@ -93,7 +93,7 @@ class edit_grade_form extends moodleform {
|
||||
$mform->addElement('checkbox', 'hidden', get_string('hidden', 'grades'));
|
||||
$mform->addHelpButton('hidden', 'hidden', 'grades');
|
||||
$mform->addElement('date_time_selector', 'hiddenuntil', get_string('hiddenuntil', 'grades'), array('optional'=>true));
|
||||
$mform->disabledIf('hidden', 'hiddenuntil[off]', 'notchecked');
|
||||
$mform->disabledIf('hidden', 'hiddenuntil[enabled]', 'checked');
|
||||
|
||||
/// locking
|
||||
$mform->addElement('advcheckbox', 'locked', get_string('locked', 'grades'));
|
||||
|
@ -78,7 +78,7 @@ class edit_outcomeitem_form extends moodleform {
|
||||
$mform->addElement('checkbox', 'hidden', get_string('hidden', 'grades'));
|
||||
$mform->addHelpButton('hidden', 'hidden', 'grades');
|
||||
$mform->addElement('date_time_selector', 'hiddenuntil', get_string('hiddenuntil', 'grades'), array('optional'=>true));
|
||||
$mform->disabledIf('hidden', 'hiddenuntil[off]', 'notchecked');
|
||||
$mform->disabledIf('hidden', 'hiddenuntil[enabled]', 'checked');
|
||||
|
||||
//locking
|
||||
$mform->addElement('advcheckbox', 'locked', get_string('locked', 'grades'));
|
||||
|
@ -69,7 +69,6 @@ class create_gradecategories_test extends \externallib_advanced_testcase {
|
||||
// Check the path is correct.
|
||||
$this->assertEquals('/' . implode('/', [$courseparentcat->id, $record1->id, $record2->id]) . '/', $record2->path);
|
||||
|
||||
/* MDL-72377 commenting broken test.
|
||||
// Now create a category with some customised data and check the returns. This customises every value.
|
||||
$customopts = [
|
||||
'aggregation' => GRADE_AGGREGATE_MEAN,
|
||||
@ -118,7 +117,7 @@ class create_gradecategories_test extends \externallib_advanced_testcase {
|
||||
$this->assertEquals(1, $cat3->grade_item->weightoverride);
|
||||
// Coefficient is converted to percentage.
|
||||
$this->assertEquals(0.2, $cat3->grade_item->aggregationcoef2);
|
||||
$this->assertEquals($record2->id, $cat3->parent);*/
|
||||
$this->assertEquals($record2->id, $cat3->parent);
|
||||
|
||||
// Now test creating 2 in parallel, and nesting them.
|
||||
$status4 = create_gradecategories::execute($course->id, [
|
||||
|
@ -307,7 +307,6 @@ class core_grades_external_testcase extends externallib_advanced_testcase {
|
||||
// Check the path is correct.
|
||||
$this->assertEquals('/' . implode('/', [$courseparentcat->id, $record1->id, $record2->id]) . '/', $record2->path);
|
||||
|
||||
/* MDL-72377 commenting broken test.
|
||||
// Now create a category with some customised data and check the returns. This customises every value.
|
||||
$customopts = [
|
||||
'aggregation' => GRADE_AGGREGATE_MEAN,
|
||||
@ -354,7 +353,7 @@ class core_grades_external_testcase extends externallib_advanced_testcase {
|
||||
$this->assertEquals(1, $cat3->grade_item->weightoverride);
|
||||
// Coefficient is converted to percentage.
|
||||
$this->assertEquals(0.2, $cat3->grade_item->aggregationcoef2);
|
||||
$this->assertEquals($record2->id, $cat3->parent);*/
|
||||
$this->assertEquals($record2->id, $cat3->parent);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user