MDL-78905 grades: Carry over form data without validation

Avoids validating form data which is carried over from the
simple dynamic form to the advanced form page when creating
or editing grade items, categories and outcomes in the
Gradebook setup.
This commit is contained in:
Mihail Geshoski 2023-08-04 12:31:22 +02:00
parent c6e727732a
commit 867e05ea34
4 changed files with 26 additions and 4 deletions

View File

@ -133,7 +133,8 @@ if ($id) {
$mform = new edit_category_form(null, array('current'=>$category, 'gpr'=>$gpr));
$simpleform = new add_category(null, ['category' => $grade_category->id, 'courseid' => $courseid, 'gpr' => $gpr]);
if ($simpledata = $simpleform->get_data()) {
// Data has been carried over from the dynamic form.
if ($simpledata = $simpleform->get_submitted_data()) {
$mform->set_data($simpledata);
}

View File

@ -109,7 +109,8 @@ $item->cancontrolvisibility = $grade_item->can_control_visibility();
$mform = new edit_item_form(null, array('current'=>$item, 'gpr'=>$gpr));
$simpleform = new add_item(null, ['itemid' => $grade_item->id, 'courseid' => $courseid, 'gpr' => $gpr]);
if ($simpledata = $simpleform->get_data()) {
// Data has been carried over from the dynamic form.
if ($simpledata = $simpleform->get_submitted_data()) {
$mform->set_data($simpledata);
}

View File

@ -114,7 +114,8 @@ if (empty($parent_category)) {
$mform->set_data($item);
$simpleform = new add_outcome(null, ['itemid' => $grade_item->id, 'courseid' => $courseid, 'gpr' => $gpr]);
if ($simpledata = $simpleform->get_data()) {
// Data has been carried over from the dynamic form.
if ($simpledata = $simpleform->get_submitted_data()) {
$mform->set_data($simpledata);
}

View File

@ -1,4 +1,4 @@
@core @core_grades @javascript
@core @core_grades @javascript @testtt
Feature: We carry over data from modal to advanced grade item settings
In order to setup grade items quickly
As an teacher
@ -103,6 +103,25 @@ Feature: We carry over data from modal to advanced grade item settings
| grade_item_aggregationcoef2 | 100 |
| Parent category | Some cool grade category |
And I press "Cancel"
And I choose the "Add category" item in the "Add" action menu
# Confirm that the form values are carried over even if some mandatory fields are missing (e.g. Category name).
And I set the following fields to these values:
| Aggregation | Mean of grades |
| Minimum grade | 1 |
| Maximum grade | 99 |
| Weight adjusted | 1 |
| grade_item_aggregationcoef2 | 100 |
| Parent category | Some cool grade category |
And I click on "Show more..." "link" in the ".modal-dialog" "css_element"
And the following fields match these values:
| Category name | |
| Aggregation | Mean of grades |
| Minimum grade | 1 |
| Maximum grade | 99 |
| Weight adjusted | 1 |
| grade_item_aggregationcoef2 | 100 |
| Parent category | Some cool grade category |
And I press "Cancel"
And I wait until the page is ready
And I choose the "Add outcome item" item in the "Add" action menu
And I set the following fields to these values: