mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
Merge branch 'MDL-75186-master' of https://github.com/sarjona/moodle
This commit is contained in:
commit
359e7c7ca4
@ -142,8 +142,9 @@ class presets implements templatable, renderable {
|
||||
$actionmenu->set_action_label(get_string('actions'));
|
||||
$actionmenu->attributes['class'] .= ' presets-actions';
|
||||
|
||||
// Only users with mod/data:manageuserpresets capability have options to edit the preset.
|
||||
if ($preset->can_manage()) {
|
||||
$canmanage = $preset->can_manage();
|
||||
// Edit.
|
||||
if ($canmanage) {
|
||||
$params = [
|
||||
'd' => $this->id,
|
||||
'action' => 'edit',
|
||||
@ -162,7 +163,23 @@ class presets implements templatable, renderable {
|
||||
$attributes
|
||||
));
|
||||
|
||||
// Delete.
|
||||
}
|
||||
|
||||
// Export.
|
||||
$params = [
|
||||
'd' => $this->id,
|
||||
'presetname' => $preset->name,
|
||||
'action' => 'export',
|
||||
];
|
||||
$exporturl = new moodle_url('/mod/data/preset.php', $params);
|
||||
$actionmenu->add(new action_menu_link_secondary(
|
||||
$exporturl,
|
||||
null,
|
||||
get_string('export', 'mod_data'),
|
||||
));
|
||||
|
||||
// Delete.
|
||||
if ($canmanage) {
|
||||
$params = [
|
||||
'd' => $this->id,
|
||||
'action' => 'delete',
|
||||
|
@ -88,7 +88,10 @@ if ($action === 'export') {
|
||||
throw new \moodle_exception('headersent');
|
||||
}
|
||||
|
||||
$preset = preset::create_from_instance($manager, $data->name);
|
||||
// Check if we should export a given preset or the current one.
|
||||
$presetname = optional_param('presetname', $data->name, PARAM_FILE);
|
||||
|
||||
$preset = preset::create_from_instance($manager, $presetname);
|
||||
$exportfile = $preset->export();
|
||||
$exportfilename = basename($exportfile);
|
||||
header("Content-Type: application/download\n");
|
||||
|
@ -287,3 +287,17 @@ Feature: Users can view and manage data presets
|
||||
And I should see "Test field name"
|
||||
And I should see "This is a short text"
|
||||
Then "Use preset" "button" should exist
|
||||
|
||||
@javascript
|
||||
Scenario: Teachers can export any saved preset
|
||||
Given I am on the "Mountain landscapes" "data activity" page logged in as teacher1
|
||||
When I follow "Presets"
|
||||
# Plugin presets can't be exported.
|
||||
And I should not see "Actions" in the "Image gallery" "table_row"
|
||||
# The teacher should be able to export any saved preset.
|
||||
And I open the action menu in "Saved preset by teacher1" "table_row"
|
||||
Then I should see "Export"
|
||||
And following "Export" "link" in the "Saved preset by teacher1" "table_row" should download between "1" and "5000" bytes
|
||||
And I open the action menu in "Saved preset 1" "table_row"
|
||||
And I should see "Export"
|
||||
And following "Export" "link" in the "Saved preset 1" "table_row" should download between "1" and "5000" bytes
|
||||
|
Loading…
x
Reference in New Issue
Block a user