Skip to content

Commit

Permalink
Merge pull request #913 from kordan/useless_parents
Browse files Browse the repository at this point in the history
Format items and autofill no longer can be child items
  • Loading branch information
stronk7 authored Mar 4, 2024
2 parents 9c75753 + c3cb6f8 commit b523996
Show file tree
Hide file tree
Showing 20 changed files with 89 additions and 41 deletions.
1 change: 1 addition & 0 deletions field/autofill/classes/item.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ public function __construct($cm, $surveypro, $itemid, $getparentcontent) {
$this->insetupform['trimonsave'] = false;
$this->insetupform['required'] = false;
$this->insetupform['hideinstructions'] = false;
$this->insetupform['parentid'] = false;

if (!empty($itemid)) {
$this->item_load($itemid, $getparentcontent);
Expand Down
14 changes: 13 additions & 1 deletion field/autofill/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@ function xmldb_surveyprofield_autofill_upgrade($oldversion) {
upgrade_plugin_savepoint(true, 2014051701, 'surveyprofield', 'autofill');
}

if ($oldversion < 2024011101) {
// Drop any parent child relation in EACH past surveypro.
// I am confident I woll not find any.
$sql = 'UPDATE {surveypro_item}
SET parentid = :parentid, parentvalue = :parentvalue
WHERE plugin = :plugin';
$whereparams = ['parentid' => null, 'parentvalue' => null, 'plugin' => 'autofill'];
$DB->execute($sql, $whereparams);

// Surveypro savepoint reached.
upgrade_plugin_savepoint(true, 2024011101, 'surveyprofield', 'autofill');
}

return true;
}

24 changes: 10 additions & 14 deletions field/autofill/tests/behat/itemform.feature
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,16 @@ Feature: Create an autofill item

And I expand all fieldsets
And I set the following fields to these values:
| Content | Your user ID |
| Indent | 1 |
| Question position | left |
| Element number | II.a |
| Variable | A1 |
| Additional note | Additional note |
| Hidden | 1 |
| Search form | 1 |
| Reserved | 1 |
| Parent element | Boolean [1]: Is it true? |
| Parent content | 1 |
| id_element01select | user ID |
| Content | Your user ID |
| Indent | 1 |
| Question position | left |
| Element number | II.a |
| Variable | A1 |
| Additional note | Additional note |
| Hidden | 1 |
| Search form | 1 |
| Reserved | 1 |
| id_element01select | user ID |
And I press "Add"

And I follow "edit_item_2"
Expand All @@ -53,8 +51,6 @@ Feature: Create an autofill item
Then the field "Hidden" matches value "1"
Then the field "Search form" matches value "1"
Then the field "Reserved" matches value "1"
Then the field "Parent element" matches value "Boolean [1]: Is it true?"
Then the field "Parent content" matches value "1"
Then the field "element01select" matches value "user ID"
And I press "Cancel"

Expand Down
2 changes: 1 addition & 1 deletion field/autofill/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2017112201;
$plugin->version = 2024011101;
$plugin->release = '1.0';
$plugin->requires = 2015111600; // Requires this Moodle version.
$plugin->component = 'surveyprofield_autofill'; // Full name of the plugin (used for diagnostics).
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Feature: Submit using character item and check form validation (2 of 7)
| teacher1 | Teacher | teacher | teacher1@nowhere.net |
| student1 | Student1 | user1 | student1@nowhere.net |
And the following "course enrolments" exist:
| user | course | role |
| user | course | role |
| teacher1 | Character item | editingteacher |
| student1 | Character item | student |
And the following "activities" exist:
Expand Down
8 changes: 4 additions & 4 deletions field/checkbox/tests/behat/settings_configuration_03.feature
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ Feature: Submit using checkbox item and check form validation (3 of 4)
# Test number 2: Student submits a standard answer
And I press "New response"
And I set the following fields to these values:
| id_surveypro_field_checkbox_1_0 | 1 |
| id_surveypro_field_checkbox_1_3 | 1 |
| id_surveypro_field_checkbox_1_0 | 1 |
| id_surveypro_field_checkbox_1_3 | 1 |
And I press "Submit"
And I press "Continue to responses list"
Then I should see "2" submissions
Expand Down Expand Up @@ -104,8 +104,8 @@ Feature: Submit using checkbox item and check form validation (3 of 4)
And I press "New response"
Then I should see "At least 2 checkboxes have to be selected"
And I set the following fields to these values:
| id_surveypro_field_checkbox_1_0 | 1 |
| id_surveypro_field_checkbox_1_3 | 1 |
| id_surveypro_field_checkbox_1_0 | 1 |
| id_surveypro_field_checkbox_1_3 | 1 |
And I press "Submit"
And I press "Continue to responses list"
Then I should see "2" submissions
Expand Down
4 changes: 2 additions & 2 deletions field/checkbox/tests/behat/settings_configuration_04.feature
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ Feature: Submit using checkbox item and check form validation (4 of 4)
# Test number 2: Student submits a standard answer
And I press "New response"
And I set the following fields to these values:
| id_surveypro_field_checkbox_1_0 | 1 |
| id_surveypro_field_checkbox_1_3 | 1 |
| id_surveypro_field_checkbox_1_0 | 1 |
| id_surveypro_field_checkbox_1_3 | 1 |
And I press "Submit"
And I press "Continue to responses list"
Then I should see "2" submissions
Expand Down
8 changes: 4 additions & 4 deletions field/checkbox/tests/behat/settings_configuration_05.feature
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ Feature: Submit using checkbox item and check form validation
@javascript
Scenario: Test checkbox element having maximumrequired = 0
Given I set the following fields to these values:
| Content | What do you usually get for breakfast? |
| Maximum allowed options | Unlimited |
| Content | What do you usually get for breakfast? |
| Maximum allowed options | Unlimited |
And I set the multiline field "Options" to "milk\ncoffee\nbutter\nbread"
And I press "Add"

Expand All @@ -40,8 +40,8 @@ Feature: Submit using checkbox item and check form validation
And I press "New response"
Then I should not see "No more than"
And I set the following fields to these values:
| id_surveypro_field_checkbox_1_0 | 1 |
| id_surveypro_field_checkbox_1_3 | 1 |
| id_surveypro_field_checkbox_1_0 | 1 |
| id_surveypro_field_checkbox_1_3 | 1 |
And I press "Submit"
And I press "Continue to responses list"
Then I should see "1" submissions
Expand Down
8 changes: 4 additions & 4 deletions field/fileupload/tests/behat/submit_attachment.feature
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ Feature: Submit using a fileupload item

And I expand all fieldsets
And I set the following fields to these values:
| Content | Please upload your CV |
| Required | 1 |
| Indent | 0 |
| Question position | left |
| Content | Please upload your CV |
| Required | 1 |
| Indent | 0 |
| Question position | left |
And I press "Add"

And I log out
Expand Down
4 changes: 2 additions & 2 deletions field/integer/tests/behat/itemform.feature
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ Feature: Create an integer item
Then I should see "Default does not fall within the specified range"
Then I should see "Lower and upper bounds must be different"
And I set the following fields to these values:
| id_lowerbound | 3 |
| id_upperbound | 21 |
| id_lowerbound | 3 |
| id_upperbound | 21 |
And I press "Add"

Then I should see "Default does not fall within the specified range"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ Feature: Submit using multiselect item and check form validation (1 of 4)
# Test number 3: Student chooses "No answer"
And I press "New response"
And I set the following fields to these values:
| id_surveypro_field_multiselect_1 |milk, bread |
| No answer | 1 |
| id_surveypro_field_multiselect_1 | milk, bread |
| No answer | 1 |
And I press "Submit"
And I press "Continue to responses list"
Then I should see "3" submissions
Expand Down
1 change: 1 addition & 0 deletions format/fieldset/classes/item.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public function __construct($cm, $surveypro, $itemid, $getparentcontent) {
$this->insetupform['variable'] = false;
$this->insetupform['indent'] = false;
$this->insetupform['hideinstructions'] = false;
$this->insetupform['parentid'] = false;

if (!empty($itemid)) {
$this->item_load($itemid, $getparentcontent);
Expand Down
14 changes: 13 additions & 1 deletion format/fieldset/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@ function xmldb_surveyproformat_fieldset_upgrade($oldversion) {
upgrade_plugin_savepoint(true, 2018091301, 'surveyproformat', 'fieldset');
}

if ($oldversion < 2024011101) {
// Drop any parent child relation in EACH past surveypro.
// I am confident I woll not find any.
$sql = 'UPDATE {surveypro_item}
SET parentid = :parentid, parentvalue = :parentvalue
WHERE plugin = :plugin';
$whereparams = ['parentid' => null, 'parentvalue' => null, 'plugin' => 'fieldset'];
$DB->execute($sql, $whereparams);

// Surveypro savepoint reached.
upgrade_plugin_savepoint(true, 2024011101, 'surveyproformat', 'fieldset');
}

return true;
}

2 changes: 1 addition & 1 deletion format/fieldset/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2018091301;
$plugin->version = 2024011101;
$plugin->release = '1.0';
$plugin->requires = 2015111600; // Requires this Moodle version.
$plugin->component = 'surveyproformat_fieldset'; // Full name of the plugin (used for diagnostics).
1 change: 1 addition & 0 deletions format/fieldsetend/classes/item.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public function __construct($cm, $surveypro, $itemid, $getparentcontent) {
$this->insetupform['variable'] = false;
$this->insetupform['indent'] = false;
$this->insetupform['hideinstructions'] = false;
$this->insetupform['parentid'] = false;

if (!empty($itemid)) {
$this->item_load($itemid, $getparentcontent);
Expand Down
14 changes: 13 additions & 1 deletion format/fieldsetend/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@ function xmldb_surveyproformat_fieldsetend_upgrade($oldversion) {
upgrade_plugin_savepoint(true, 2019031901, 'surveyproformat', 'fieldsetend');
}

if ($oldversion < 2024011101) {
// Drop any parent child relation in EACH past surveypro.
// I am confident I woll not find any.
$sql = 'UPDATE {surveypro_item}
SET parentid = :parentid, parentvalue = :parentvalue
WHERE plugin = :plugin';
$whereparams = ['parentid' => null, 'parentvalue' => null, 'plugin' => 'fieldsetend'];
$DB->execute($sql, $whereparams);

// Surveypro savepoint reached.
upgrade_plugin_savepoint(true, 2024011101, 'surveyproformat', 'fieldsetend');
}

return true;
}

2 changes: 1 addition & 1 deletion format/fieldsetend/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2019031901;
$plugin->version = 2024011101;
$plugin->release = '1.0';
$plugin->requires = 2015111600; // Requires this Moodle version.
$plugin->component = 'surveyproformat_fieldsetend'; // Full name of the plugin (used for diagnostics).
1 change: 1 addition & 0 deletions format/label/classes/item.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ public function __construct($cm, $surveypro, $itemid, $getparentcontent) {
$this->insetupform['required'] = false;
$this->insetupform['variable'] = false;
$this->insetupform['hideinstructions'] = false;
$this->insetupform['parentid'] = false;

if (!empty($itemid)) {
$this->item_load($itemid, $getparentcontent);
Expand Down
14 changes: 13 additions & 1 deletion format/label/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@ function xmldb_surveyproformat_label_upgrade($oldversion) {
upgrade_plugin_savepoint(true, 2014051701, 'surveyproformat', 'label');
}

if ($oldversion < 2024011101) {
// Drop any parent child relation in EACH past surveypro.
// I am confident I woll not find any.
$sql = 'UPDATE {surveypro_item}
SET parentid = :parentid, parentvalue = :parentvalue
WHERE plugin = :plugin';
$whereparams = ['parentid' => null, 'parentvalue' => null, 'plugin' => 'label'];
$DB->execute($sql, $whereparams);

// Surveypro savepoint reached.
upgrade_plugin_savepoint(true, 2024011101, 'surveyproformat', 'label');
}

return true;
}

2 changes: 1 addition & 1 deletion format/label/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2017112201;
$plugin->version = 2024011101;
$plugin->release = '1.0';
$plugin->requires = 2015111600; // Requires this Moodle version.
$plugin->component = 'surveyproformat_label'; // Full name of the plugin (used for diagnostics).

0 comments on commit b523996

Please sign in to comment.