MDL-64862 workshop: Fix grades to pass editing
There was a bug here that had not exposed until MDL-60820 introduced the call $mform->setDefault() at the bottom of the definition_after_data() method. That call triggers the 'updateValue' event on all form elements. For input text elements, this effectively sets their value to the default one, which was empty in this case due to the way how the value had been set. The solution here is to set the value via the same way like the normal set_data() method does it. The attached Behat test reproduces the problem and makes sure the patch works.
This commit is contained in:
@@ -370,8 +370,7 @@ class mod_workshop_mod_form extends moodleform_mod {
|
||||
// gradecategory and gradinggradecategory - grrr QuickForms
|
||||
$decimalpoints = $gradeitem->get_decimals();
|
||||
if ($gradeitem->itemnumber == 0) {
|
||||
$submissiongradepass = $mform->getElement('submissiongradepass');
|
||||
$submissiongradepass->setValue(format_float($gradeitem->gradepass, $decimalpoints));
|
||||
$mform->setDefault('submissiongradepass', format_float($gradeitem->gradepass, $decimalpoints));
|
||||
$group = $mform->getElement('submissiongradegroup');
|
||||
$elements = $group->getElements();
|
||||
foreach ($elements as $element) {
|
||||
@@ -380,8 +379,7 @@ class mod_workshop_mod_form extends moodleform_mod {
|
||||
}
|
||||
}
|
||||
} else if ($gradeitem->itemnumber == 1) {
|
||||
$gradinggradepass = $mform->getElement('gradinggradepass');
|
||||
$gradinggradepass->setValue(format_float($gradeitem->gradepass, $decimalpoints));
|
||||
$mform->setDefault('gradinggradepass', format_float($gradeitem->gradepass, $decimalpoints));
|
||||
$group = $mform->getElement('gradinggradegroup');
|
||||
$elements = $group->getElements();
|
||||
foreach ($elements as $element) {
|
||||
|
||||
@@ -29,6 +29,22 @@ Feature: Setting grades to pass via workshop editing form
|
||||
And the field "Submission grade to pass" matches value "45.00"
|
||||
And the field "Assessment grade to pass" matches value "10.50"
|
||||
|
||||
@javascript
|
||||
Scenario: Grade to pass kept even with submission types without online text (MDL-64862)
|
||||
Given I log in as "teacher1"
|
||||
And I am on "Course1" course homepage with editing mode on
|
||||
When I add a "Workshop" to section "1" and I fill the form with:
|
||||
| Workshop name | Another workshop |
|
||||
| Description | Grades to pass are set here |
|
||||
| Submission grade to pass | 42 |
|
||||
| Assessment grade to pass | 10.1 |
|
||||
| submissiontypetextavailable | 0 |
|
||||
Then I should not see "Adding a new Workshop"
|
||||
And I follow "Another workshop"
|
||||
And I navigate to "Edit settings" in current page administration
|
||||
And the field "Submission grade to pass" matches value "42.00"
|
||||
And the field "Assessment grade to pass" matches value "10.10"
|
||||
|
||||
Scenario: Adding a new workshop with grade to pass fields left empty
|
||||
Given I log in as "teacher1"
|
||||
And I am on "Course1" course homepage with editing mode on
|
||||
|
||||
Reference in New Issue
Block a user