mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-75492 mod_data: Remove redirection messages on preset apply process
This commit is contained in:
parent
9b343752e2
commit
1c968103b7
11 changed files with 36 additions and 55 deletions
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
namespace mod_data\local\importer;
|
namespace mod_data\local\importer;
|
||||||
|
|
||||||
|
use core\notification;
|
||||||
use mod_data\manager;
|
use mod_data\manager;
|
||||||
use mod_data\preset;
|
use mod_data\preset;
|
||||||
use stdClass;
|
use stdClass;
|
||||||
|
@ -428,16 +429,14 @@ abstract class preset_importer {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function finish_import_process(bool $overwritesettings, stdClass $instance): void {
|
public function finish_import_process(bool $overwritesettings, stdClass $instance): void {
|
||||||
global $DB;
|
$result = $this->import($overwritesettings);
|
||||||
$this->import($overwritesettings);
|
if ($result) {
|
||||||
$strimportsuccess = get_string('importsuccess', 'data');
|
notification::success(get_string('importsuccess', 'mod_data'));
|
||||||
$straddentries = get_string('addentries', 'data');
|
|
||||||
$strtodatabase = get_string('todatabase', 'data');
|
|
||||||
if (!$DB->get_records('data_records', ['dataid' => $instance->id])) {
|
|
||||||
\core\notification::success("$strimportsuccess <a href='edit.php?d=$instance->id'>$straddentries</a> $strtodatabase");
|
|
||||||
} else {
|
} else {
|
||||||
\core\notification::success($strimportsuccess);
|
notification::error(get_string('cannotapplypreset', 'mod_data'));
|
||||||
}
|
}
|
||||||
|
$backurl = new \moodle_url('/mod/data/field.php', ['d' => $instance->id]);
|
||||||
|
redirect($backurl);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -108,13 +108,9 @@ $data->instance = $cm->instance;
|
||||||
$renderer = $manager->get_renderer();
|
$renderer = $manager->get_renderer();
|
||||||
|
|
||||||
if ($action == 'finishimport' && confirm_sesskey()) {
|
if ($action == 'finishimport' && confirm_sesskey()) {
|
||||||
data_print_header($course, $cm, $data, false);
|
|
||||||
$overwritesettings = optional_param('overwritesettings', false, PARAM_BOOL);
|
$overwritesettings = optional_param('overwritesettings', false, PARAM_BOOL);
|
||||||
$importer = preset_importer::create_from_parameters($manager);
|
$importer = preset_importer::create_from_parameters($manager);
|
||||||
$importer->finish_import_process($overwritesettings, $data);
|
$importer->finish_import_process($overwritesettings, $data);
|
||||||
echo $OUTPUT->continue_button(new moodle_url('/mod/data/field.php', ['d' => $data->id]));
|
|
||||||
echo $OUTPUT->footer();
|
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($mode) {
|
switch ($mode) {
|
||||||
|
@ -260,7 +256,7 @@ switch ($mode) {
|
||||||
if ($importer->import(false)) {
|
if ($importer->import(false)) {
|
||||||
notification::success(get_string('importsuccess', 'mod_data'));
|
notification::success(get_string('importsuccess', 'mod_data'));
|
||||||
} else {
|
} else {
|
||||||
notification::error(get_string('presetapplied', 'mod_data'));
|
notification::error(get_string('cannotapplypreset', 'mod_data'));
|
||||||
}
|
}
|
||||||
redirect($backurl);
|
redirect($backurl);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,6 @@ $string['action'] = 'Action';
|
||||||
$string['actionsmenu'] = 'Actions menu';
|
$string['actionsmenu'] = 'Actions menu';
|
||||||
$string['add'] = 'Add entry';
|
$string['add'] = 'Add entry';
|
||||||
$string['addcomment'] = 'Add comment';
|
$string['addcomment'] = 'Add comment';
|
||||||
$string['addentries'] = 'Add entries';
|
|
||||||
$string['addtemplate'] = 'Add entry template';
|
$string['addtemplate'] = 'Add entry template';
|
||||||
$string['advancedsearch'] = 'Advanced search';
|
$string['advancedsearch'] = 'Advanced search';
|
||||||
$string['allowcomments'] = 'Allow comments on entries';
|
$string['allowcomments'] = 'Allow comments on entries';
|
||||||
|
@ -61,6 +60,7 @@ $string['cannotadd'] = 'Can not add entries!';
|
||||||
$string['cannotdeletepreset'] = 'Error deleting a preset!';
|
$string['cannotdeletepreset'] = 'Error deleting a preset!';
|
||||||
$string['cannotoverwritepreset'] = 'Error overwriting preset';
|
$string['cannotoverwritepreset'] = 'Error overwriting preset';
|
||||||
$string['cannotunziptopreset'] = 'Cannot unzip to the preset directory';
|
$string['cannotunziptopreset'] = 'Cannot unzip to the preset directory';
|
||||||
|
$string['cannotapplypreset'] = 'Error applying the preset.';
|
||||||
$string['closebeforeopen'] = 'You have specified an end date before the start date.';
|
$string['closebeforeopen'] = 'You have specified an end date before the start date.';
|
||||||
$string['columns'] = 'columns';
|
$string['columns'] = 'columns';
|
||||||
$string['comment'] = 'Comment';
|
$string['comment'] = 'Comment';
|
||||||
|
@ -221,7 +221,7 @@ $string['expired'] = 'Sorry, this activity closed on {$a} and is no longer avail
|
||||||
$string['importentries'] = 'Import entries';
|
$string['importentries'] = 'Import entries';
|
||||||
$string['importpreset'] = 'Import preset';
|
$string['importpreset'] = 'Import preset';
|
||||||
$string['importapreset'] = 'Import a preset';
|
$string['importapreset'] = 'Import a preset';
|
||||||
$string['importsuccess'] = 'The preset has been successfully applied.';
|
$string['importsuccess'] = 'Preset applied.';
|
||||||
$string['importpresetmissingcapability'] = 'You don\'t have permission to import a preset.';
|
$string['importpresetmissingcapability'] = 'You don\'t have permission to import a preset.';
|
||||||
$string['includeapproval'] = 'Include approval status';
|
$string['includeapproval'] = 'Include approval status';
|
||||||
$string['includetags'] = 'Include tags';
|
$string['includetags'] = 'Include tags';
|
||||||
|
@ -439,7 +439,6 @@ $string['text'] = 'Text';
|
||||||
$string['textarea'] = 'Text area';
|
$string['textarea'] = 'Text area';
|
||||||
$string['timeadded'] = 'Time added';
|
$string['timeadded'] = 'Time added';
|
||||||
$string['timemodified'] = 'Time modified';
|
$string['timemodified'] = 'Time modified';
|
||||||
$string['todatabase'] = 'to this database.';
|
|
||||||
$string['type'] = 'Field type';
|
$string['type'] = 'Field type';
|
||||||
$string['undefinedprocessactionmethod'] = 'No action method defined in Data_Preset to handle action "{$a}".';
|
$string['undefinedprocessactionmethod'] = 'No action method defined in Data_Preset to handle action "{$a}".';
|
||||||
$string['unsupportedfields'] = 'Unsupported fields';
|
$string['unsupportedfields'] = 'Unsupported fields';
|
||||||
|
@ -479,3 +478,5 @@ $string['pleaseaddsome'] = 'Please create some below or <a href="{$a}">choose a
|
||||||
$string['blank'] = 'Blank';
|
$string['blank'] = 'Blank';
|
||||||
$string['savetemplate'] = 'Save template';
|
$string['savetemplate'] = 'Save template';
|
||||||
$string['addedby'] = 'Added by';
|
$string['addedby'] = 'Added by';
|
||||||
|
$string['addentries'] = 'Add entries';
|
||||||
|
$string['todatabase'] = 'to this database.';
|
||||||
|
|
|
@ -6,4 +6,6 @@ pleaseaddsome,mod_data
|
||||||
blank,mod_data
|
blank,mod_data
|
||||||
savetemplate,mod_data
|
savetemplate,mod_data
|
||||||
addedby,mod_data
|
addedby,mod_data
|
||||||
|
addentries,mod_data
|
||||||
|
todatabase,mod_data
|
||||||
|
|
||||||
|
|
|
@ -151,8 +151,6 @@ if ($action === 'preview') {
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
echo $OUTPUT->header();
|
|
||||||
|
|
||||||
if ($action === 'finishimport') {
|
if ($action === 'finishimport') {
|
||||||
if (!confirm_sesskey()) {
|
if (!confirm_sesskey()) {
|
||||||
throw new moodle_exception('invalidsesskey');
|
throw new moodle_exception('invalidsesskey');
|
||||||
|
@ -160,12 +158,10 @@ if ($action === 'finishimport') {
|
||||||
$overwritesettings = optional_param('overwritesettings', false, PARAM_BOOL);
|
$overwritesettings = optional_param('overwritesettings', false, PARAM_BOOL);
|
||||||
$importer = preset_importer::create_from_parameters($manager);
|
$importer = preset_importer::create_from_parameters($manager);
|
||||||
$importer->finish_import_process($overwritesettings, $data);
|
$importer->finish_import_process($overwritesettings, $data);
|
||||||
|
|
||||||
echo $OUTPUT->continue_button(new moodle_url('/mod/data/preset.php', ['d' => $data->id]));
|
|
||||||
echo $OUTPUT->footer();
|
|
||||||
exit(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
echo $OUTPUT->header();
|
||||||
|
|
||||||
$actionbar = new \mod_data\output\action_bar($data->id, $url);
|
$actionbar = new \mod_data\output\action_bar($data->id, $url);
|
||||||
echo $actionbar->get_presets_action_bar();
|
echo $actionbar->get_presets_action_bar();
|
||||||
$presets = new \mod_data\output\presets($manager, $presets, new \moodle_url('/mod/data/field.php'), true);
|
$presets = new \mod_data\output\presets($manager, $presets, new \moodle_url('/mod/data/field.php'), true);
|
||||||
|
|
|
@ -128,7 +128,7 @@ class mod_data_renderer extends plugin_renderer_base {
|
||||||
$html .= html_writer::end_tag('div');
|
$html .= html_writer::end_tag('div');
|
||||||
|
|
||||||
$actionbuttons = html_writer::start_div();
|
$actionbuttons = html_writer::start_div();
|
||||||
$cancelurl = new moodle_url('/mod/data/preset.php', ['d' => $datamodule->id]);
|
$cancelurl = new moodle_url('/mod/data/field.php', ['d' => $datamodule->id]);
|
||||||
$actionbuttons .= html_writer::tag('a', get_string('cancel') , [
|
$actionbuttons .= html_writer::tag('a', get_string('cancel') , [
|
||||||
'href' => $cancelurl->out(false),
|
'href' => $cancelurl->out(false),
|
||||||
'class' => 'btn btn-secondary mr-2',
|
'class' => 'btn btn-secondary mr-2',
|
||||||
|
|
|
@ -313,10 +313,10 @@ Feature: Users can view and manage data presets
|
||||||
And I choose "Import preset" in the open action menu
|
And I choose "Import preset" in the open action menu
|
||||||
And I upload "mod/data/tests/fixtures/image_gallery_preset.zip" file to "Preset file" filemanager
|
And I upload "mod/data/tests/fixtures/image_gallery_preset.zip" file to "Preset file" filemanager
|
||||||
Then I click on "Import preset and apply" "button" in the ".modal-dialog" "css_element"
|
Then I click on "Import preset and apply" "button" in the ".modal-dialog" "css_element"
|
||||||
Then I should see "The preset has been successfully applied."
|
Then I should see "Preset applied"
|
||||||
# I am on the field page.
|
# I am on the field page.
|
||||||
And I should see "Manage fields"
|
And I should see "Manage fields"
|
||||||
Then I should see "The preset has been successfully applied."
|
Then I should see "Preset applied"
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
| user |
|
| user |
|
||||||
|
|
|
@ -113,9 +113,7 @@ Feature: Users can import presets
|
||||||
And I upload "mod/data/tests/fixtures/image_gallery_preset.zip" file to "Preset file" filemanager
|
And I upload "mod/data/tests/fixtures/image_gallery_preset.zip" file to "Preset file" filemanager
|
||||||
When I click on "Import preset and apply" "button"
|
When I click on "Import preset and apply" "button"
|
||||||
And I click on "Continue" "button"
|
And I click on "Continue" "button"
|
||||||
And I should see "The preset has been successfully applied"
|
And I should see "Preset applied"
|
||||||
And I click on "Continue" "button"
|
|
||||||
And I follow "Fields"
|
|
||||||
Then I should see "title"
|
Then I should see "title"
|
||||||
And I should see "description" in the "description" "table_row"
|
And I should see "description" in the "description" "table_row"
|
||||||
And I should see "image" in the "image" "table_row"
|
And I should see "image" in the "image" "table_row"
|
||||||
|
@ -137,9 +135,7 @@ Feature: Users can import presets
|
||||||
And I should see "Create a new field" in the "oldtitle" "table_row"
|
And I should see "Create a new field" in the "oldtitle" "table_row"
|
||||||
And I set the field "id_title" to "Map to oldtitle"
|
And I set the field "id_title" to "Map to oldtitle"
|
||||||
And I click on "Continue" "button"
|
And I click on "Continue" "button"
|
||||||
And I should see "The preset has been successfully applied"
|
And I should see "Preset applied"
|
||||||
And I click on "Continue" "button"
|
|
||||||
And I follow "Fields"
|
|
||||||
Then I should not see "oldtitle"
|
Then I should not see "oldtitle"
|
||||||
And I should see "title"
|
And I should see "title"
|
||||||
And I should see "description" in the "description" "table_row"
|
And I should see "description" in the "description" "table_row"
|
||||||
|
@ -158,12 +154,10 @@ Feature: Users can import presets
|
||||||
When I click on "Import preset and apply" "button"
|
When I click on "Import preset and apply" "button"
|
||||||
And I should see "Fields mappings"
|
And I should see "Fields mappings"
|
||||||
And I click on "Continue" "button"
|
And I click on "Continue" "button"
|
||||||
And I should see "The preset has been successfully applied"
|
And I should see "Preset applied"
|
||||||
And I click on "Continue" "button"
|
|
||||||
And I follow "Fields"
|
|
||||||
And I follow "Presets"
|
And I follow "Presets"
|
||||||
And I choose the "Import preset" item in the "Action" action menu
|
And I choose the "Import preset" item in the "Action" action menu
|
||||||
And I upload "mod/data/tests/fixtures/image_gallery_preset.zip" file to "Preset file" filemanager
|
And I upload "mod/data/tests/fixtures/image_gallery_preset.zip" file to "Preset file" filemanager
|
||||||
And I click on "Import preset and apply" "button"
|
And I click on "Import preset and apply" "button"
|
||||||
Then I should not see "Fields mappings"
|
Then I should not see "Fields mappings"
|
||||||
And I should see "The preset has been successfully applied"
|
And I should see "Preset applied"
|
||||||
|
|
|
@ -161,5 +161,5 @@ Feature: Users can preview presets
|
||||||
When I follow "Presets"
|
When I follow "Presets"
|
||||||
And I click on "Saved preset by teacher1" "link"
|
And I click on "Saved preset by teacher1" "link"
|
||||||
And I click on "Use this preset" "button"
|
And I click on "Use this preset" "button"
|
||||||
Then I should see "The preset has been successfully applied"
|
Then I should see "Preset applied"
|
||||||
And I should see "My URL field"
|
And I should see "My URL field"
|
||||||
|
|
|
@ -36,10 +36,8 @@ Feature: Users can use predefined presets
|
||||||
And I should see "Apply preset Image gallery"
|
And I should see "Apply preset Image gallery"
|
||||||
And I click on "Map fields" "button"
|
And I click on "Map fields" "button"
|
||||||
And I should see "Fields mappings"
|
And I should see "Fields mappings"
|
||||||
And I click on "Continue" "button"
|
When I click on "Continue" "button"
|
||||||
And I should see "The preset has been successfully applied"
|
And I should see "Preset applied"
|
||||||
And I click on "Continue" "button"
|
|
||||||
When I follow "Fields"
|
|
||||||
Then I should see "title"
|
Then I should see "title"
|
||||||
And I should see "description" in the "description" "table_row"
|
And I should see "description" in the "description" "table_row"
|
||||||
And I should see "image" in the "image" "table_row"
|
And I should see "image" in the "image" "table_row"
|
||||||
|
@ -64,9 +62,7 @@ Feature: Users can use predefined presets
|
||||||
And I should see "Create a new field" in the "oldtitle" "table_row"
|
And I should see "Create a new field" in the "oldtitle" "table_row"
|
||||||
And I set the field "id_title" to "Map to oldtitle"
|
And I set the field "id_title" to "Map to oldtitle"
|
||||||
And I click on "Continue" "button"
|
And I click on "Continue" "button"
|
||||||
And I should see "The preset has been successfully applied"
|
And I should see "Preset applied"
|
||||||
And I click on "Continue" "button"
|
|
||||||
And I follow "Fields"
|
|
||||||
Then I should not see "oldtitle"
|
Then I should not see "oldtitle"
|
||||||
And I should see "title"
|
And I should see "title"
|
||||||
And I should see "description" in the "description" "table_row"
|
And I should see "description" in the "description" "table_row"
|
||||||
|
@ -90,7 +86,7 @@ Feature: Users can use predefined presets
|
||||||
# We map existing field to keep the entry data
|
# We map existing field to keep the entry data
|
||||||
And I set the field "id_title" to "Map to Test field name"
|
And I set the field "id_title" to "Map to Test field name"
|
||||||
And I click on "Continue" "button"
|
And I click on "Continue" "button"
|
||||||
And I should see "The preset has been successfully applied"
|
And I should see "Preset applied"
|
||||||
And I follow "Fields"
|
And I follow "Fields"
|
||||||
And I should see "title"
|
And I should see "title"
|
||||||
And I follow "Database"
|
And I follow "Database"
|
||||||
|
@ -105,12 +101,12 @@ Feature: Users can use predefined presets
|
||||||
And I click on "Map fields" "button"
|
And I click on "Map fields" "button"
|
||||||
And I set the field "id_title" to "Map to Test field name"
|
And I set the field "id_title" to "Map to Test field name"
|
||||||
And I click on "Continue" "button"
|
And I click on "Continue" "button"
|
||||||
And I should see "The preset has been successfully applied"
|
And I should see "Preset applied"
|
||||||
And I follow "Presets"
|
And I follow "Presets"
|
||||||
And I click on "fullname" "radio" in the "Image gallery" "table_row"
|
And I click on "fullname" "radio" in the "Image gallery" "table_row"
|
||||||
And I click on "Use this preset" "button"
|
And I click on "Use this preset" "button"
|
||||||
Then I should not see "Apply preset Image gallery"
|
Then I should not see "Apply preset Image gallery"
|
||||||
And I should see "The preset has been successfully applied"
|
And I should see "Preset applied"
|
||||||
|
|
||||||
Scenario: Using a preset from preset preview page on a non empty database could create new fields
|
Scenario: Using a preset from preset preview page on a non empty database could create new fields
|
||||||
Given the following "mod_data > fields" exist:
|
Given the following "mod_data > fields" exist:
|
||||||
|
@ -126,7 +122,7 @@ Feature: Users can use predefined presets
|
||||||
And I click on "Use this preset" "button"
|
And I click on "Use this preset" "button"
|
||||||
And I should see "Apply preset Image gallery"
|
And I should see "Apply preset Image gallery"
|
||||||
When I click on "Apply preset" "button"
|
When I click on "Apply preset" "button"
|
||||||
And I should see "The preset has been successfully applied"
|
And I should see "Preset applied"
|
||||||
And I follow "Fields"
|
And I follow "Fields"
|
||||||
Then I should see "title"
|
Then I should see "title"
|
||||||
And I should see "description" in the "description" "table_row"
|
And I should see "description" in the "description" "table_row"
|
||||||
|
@ -152,9 +148,7 @@ Feature: Users can use predefined presets
|
||||||
And I should see "Create a new field" in the "oldtitle" "table_row"
|
And I should see "Create a new field" in the "oldtitle" "table_row"
|
||||||
And I set the field "id_title" to "Map to oldtitle"
|
And I set the field "id_title" to "Map to oldtitle"
|
||||||
And I click on "Continue" "button"
|
And I click on "Continue" "button"
|
||||||
And I should see "The preset has been successfully applied"
|
And I should see "Preset applied"
|
||||||
And I click on "Continue" "button"
|
|
||||||
And I follow "Fields"
|
|
||||||
Then I should not see "oldtitle"
|
Then I should not see "oldtitle"
|
||||||
And I should see "title"
|
And I should see "title"
|
||||||
And I should see "description" in the "description" "table_row"
|
And I should see "description" in the "description" "table_row"
|
||||||
|
@ -178,7 +172,7 @@ Feature: Users can use predefined presets
|
||||||
# We map existing field to keep the entry data
|
# We map existing field to keep the entry data
|
||||||
And I set the field "id_title" to "Map to Test field name"
|
And I set the field "id_title" to "Map to Test field name"
|
||||||
And I click on "Continue" "button"
|
And I click on "Continue" "button"
|
||||||
And I should see "The preset has been successfully applied"
|
And I should see "Preset applied"
|
||||||
And I follow "Fields"
|
And I follow "Fields"
|
||||||
And I should see "title"
|
And I should see "title"
|
||||||
And I follow "Database"
|
And I follow "Database"
|
||||||
|
@ -195,13 +189,12 @@ Feature: Users can use predefined presets
|
||||||
And I should see "Fields mappings"
|
And I should see "Fields mappings"
|
||||||
And I set the field "id_title" to "Map to Test field name"
|
And I set the field "id_title" to "Map to Test field name"
|
||||||
And I click on "Continue" "button"
|
And I click on "Continue" "button"
|
||||||
And I should see "The preset has been successfully applied"
|
And I should see "Preset applied"
|
||||||
And I click on "Continue" "button"
|
|
||||||
And I follow "Presets"
|
And I follow "Presets"
|
||||||
And I click on "Image gallery" "link"
|
And I click on "Image gallery" "link"
|
||||||
And I click on "Use this preset" "button"
|
And I click on "Use this preset" "button"
|
||||||
Then I should not see "Fields mappings"
|
Then I should not see "Fields mappings"
|
||||||
And I should see "The preset has been successfully applied"
|
And I should see "Preset applied"
|
||||||
|
|
||||||
Scenario: Apply preset dialogue should show helpful information to the user
|
Scenario: Apply preset dialogue should show helpful information to the user
|
||||||
Given the following "activities" exist:
|
Given the following "activities" exist:
|
||||||
|
|
|
@ -54,7 +54,7 @@ Feature: Zero state page (no fields created)
|
||||||
And I upload "mod/data/tests/fixtures/image_gallery_preset.zip" file to "Preset file" filemanager
|
And I upload "mod/data/tests/fixtures/image_gallery_preset.zip" file to "Preset file" filemanager
|
||||||
Then I click on "Import preset and apply" "button" in the ".modal-dialog" "css_element"
|
Then I click on "Import preset and apply" "button" in the ".modal-dialog" "css_element"
|
||||||
And I should see "Manage fields"
|
And I should see "Manage fields"
|
||||||
Then I should see "The preset has been successfully applied."
|
Then I should see "Preset applied"
|
||||||
|
|
||||||
@javascript
|
@javascript
|
||||||
Scenario: Teacher can use a preset from zero state page on an empty database
|
Scenario: Teacher can use a preset from zero state page on an empty database
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue