mirror of
https://github.com/moodle/moodle.git
synced 2025-04-16 14:02:32 +02:00
MDL-46428 course: Remove confirm when duplicating
A confirm dialog is given when Javascript is off but not when it is on. This aligns the two so that they neither have a confirm when duplicating an activity.
This commit is contained in:
parent
457f818026
commit
60df67878b
@ -5,6 +5,8 @@ Overview of this plugin type at http://docs.moodle.org/dev/Course_formats
|
||||
=== 2.8 ===
|
||||
* The activity chooser now uses M.course.format.get_sectionwrapperclass()
|
||||
to determine the section selector, rather than a hard-coded `li.section`.
|
||||
* Activity duplication in /course/modduplicate.php is deprecated and is now done in /course/mod.php. Deprecated calls will be honored by
|
||||
redirecting to /course/mod.php for 3rd party plugin support.
|
||||
|
||||
=== 2.7 ===
|
||||
* The ->testedbrowsers array no longer needs to be defined in supports_ajax().
|
||||
|
@ -79,41 +79,16 @@ if (!empty($add)) {
|
||||
redirect("$CFG->wwwroot/course/modedit.php?update=$update&return=$returntomod&sr=$sectionreturn");
|
||||
|
||||
} else if (!empty($duplicate)) {
|
||||
$cm = get_coursemodule_from_id('', $duplicate, 0, true, MUST_EXIST);
|
||||
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
|
||||
$cm = get_coursemodule_from_id('', $duplicate, 0, true, MUST_EXIST);
|
||||
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
|
||||
|
||||
require_login($course, false, $cm);
|
||||
$coursecontext = context_course::instance($course->id);
|
||||
$modcontext = context_module::instance($cm->id);
|
||||
require_capability('moodle/course:manageactivities', $coursecontext);
|
||||
require_capability('moodle/course:manageactivities', $modcontext);
|
||||
|
||||
if (!$confirm or !confirm_sesskey()) {
|
||||
$PAGE->set_title(get_string('duplicate'));
|
||||
$PAGE->set_heading($course->fullname);
|
||||
$PAGE->navbar->add(get_string('duplicatinga', 'core', format_string($cm->name)));
|
||||
$PAGE->set_pagelayout('incourse');
|
||||
|
||||
$a = new stdClass();
|
||||
$a->modtype = get_string('modulename', $cm->modname);
|
||||
$a->modname = format_string($cm->name);
|
||||
$a->modid = $cm->id;
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->confirm(
|
||||
get_string('duplicateconfirm', 'core', $a),
|
||||
new single_button(
|
||||
new moodle_url('/course/modduplicate.php', array(
|
||||
'cmid' => $cm->id, 'course' => $course->id, 'sr' => $sectionreturn)),
|
||||
get_string('continue'),
|
||||
'post'),
|
||||
new single_button(
|
||||
course_get_url($course, $cm->sectionnum, array('sr' => $sectionreturn)),
|
||||
get_string('cancel'),
|
||||
'get')
|
||||
);
|
||||
echo $OUTPUT->footer();
|
||||
die();
|
||||
}
|
||||
// Duplicate the module.
|
||||
$newcm = duplicate_module($course, $cm);
|
||||
redirect(course_get_url($course, $cm->sectionnum, array('sr' => $sectionreturn)));
|
||||
|
||||
} else if (!empty($delete)) {
|
||||
$cm = get_coursemodule_from_id('', $delete, 0, true, MUST_EXIST);
|
||||
@ -298,5 +273,3 @@ if ((!empty($movetosection) or !empty($moveto)) and confirm_sesskey()) {
|
||||
} else {
|
||||
print_error('unknowaction');
|
||||
}
|
||||
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
*
|
||||
* @package core
|
||||
* @subpackage course
|
||||
* @deprecated Moodle 2.8 MDL-46428 - Now redirects to mod.php.
|
||||
* @copyright 2011 David Mudrak <david@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
@ -30,54 +31,13 @@
|
||||
require_once(dirname(dirname(__FILE__)) . '/config.php');
|
||||
|
||||
$cmid = required_param('cmid', PARAM_INT);
|
||||
$courseid = required_param('course', PARAM_INT);
|
||||
$courseid = optional_param('course', PARAM_INT);
|
||||
$sectionreturn = optional_param('sr', null, PARAM_INT);
|
||||
|
||||
$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
|
||||
$cm = get_coursemodule_from_id('', $cmid, $course->id, true, MUST_EXIST);
|
||||
$cmcontext = context_module::instance($cm->id);
|
||||
$context = context_course::instance($courseid);
|
||||
$section = $DB->get_record('course_sections', array('id' => $cm->section, 'course' => $cm->course));
|
||||
debugging('Please use moodle_url(\'/course/mod.php\', array(\'duplicate\' => $cmid
|
||||
, \'id\' => $courseid, \'sesskey\' => sesskey(), \'sr\' => $sectionreturn)))
|
||||
instead of new moodle_url(\'/course/modduplicate.php\', array(\'cmid\' => $cmid
|
||||
, \'course\' => $courseid, \'sr\' => $sectionreturn))', DEBUG_DEVELOPER);
|
||||
|
||||
require_login($course);
|
||||
require_sesskey();
|
||||
require_capability('moodle/course:manageactivities', $context);
|
||||
// Require both target import caps to be able to duplicate, see course_get_cm_edit_actions()
|
||||
require_capability('moodle/backup:backuptargetimport', $context);
|
||||
require_capability('moodle/restore:restoretargetimport', $context);
|
||||
|
||||
$PAGE->set_title(get_string('duplicate'));
|
||||
$PAGE->set_heading($course->fullname);
|
||||
$PAGE->set_url(new moodle_url('/course/modduplicate.php', array('cmid' => $cm->id, 'courseid' => $course->id)));
|
||||
$PAGE->set_pagelayout('incourse');
|
||||
|
||||
$output = $PAGE->get_renderer('core', 'backup');
|
||||
|
||||
// Duplicate the module.
|
||||
$newcm = duplicate_module($course, $cm);
|
||||
|
||||
echo $output->header();
|
||||
|
||||
$a = new stdClass();
|
||||
$a->modtype = get_string('modulename', $cm->modname);
|
||||
$a->modname = format_string($cm->name);
|
||||
|
||||
if (!empty($newcm)) {
|
||||
echo $output->confirm(
|
||||
get_string('duplicatesuccess', 'core', $a),
|
||||
new single_button(
|
||||
new moodle_url('/course/modedit.php', array('update' => $newcm->id, 'sr' => $sectionreturn)),
|
||||
get_string('duplicatecontedit'),
|
||||
'get'),
|
||||
new single_button(
|
||||
course_get_url($course, $cm->sectionnum, array('sr' => $sectionreturn)),
|
||||
get_string('duplicatecontcourse'),
|
||||
'get')
|
||||
);
|
||||
|
||||
} else {
|
||||
echo $output->notification(get_string('duplicatesuccess', 'core', $a), 'notifysuccess');
|
||||
echo $output->continue_button(course_get_url($course, $cm->sectionnum, array('sr' => $sectionreturn)));
|
||||
}
|
||||
|
||||
echo $output->footer();
|
||||
redirect(new moodle_url('/course/mod.php', array('duplicate' => $cmid, 'id' => $courseid,
|
||||
'sesskey' => sesskey(), 'sr' => $sectionreturn)));
|
||||
|
@ -730,10 +730,6 @@ class behat_course extends behat_base {
|
||||
$steps[] = new Given('I open "' . $activity . '" actions menu');
|
||||
}
|
||||
$steps[] = new Given('I click on "' . get_string('duplicate') . '" "link" in the "' . $activity . '" activity');
|
||||
if (!$this->running_javascript()) {
|
||||
$steps[] = new Given('I press "' . get_string('continue') .'"');
|
||||
$steps[] = new Given('I press "' . get_string('duplicatecontcourse') .'"');
|
||||
}
|
||||
return $steps;
|
||||
}
|
||||
|
||||
@ -752,35 +748,35 @@ class behat_course extends behat_base {
|
||||
$activity = $this->escape($activityname);
|
||||
$activityliteral = $this->getSession()->getSelectorsHandler()->xpathLiteral($activityname);
|
||||
|
||||
if ($this->running_javascript()) {
|
||||
$steps[] = new Given('I duplicate "' . $activity . '" activity');
|
||||
$steps[] = new Given('I duplicate "' . $activity . '" activity');
|
||||
|
||||
// Determine the future new activity xpath from the former one.
|
||||
$duplicatedxpath = "//li[contains(concat(' ', normalize-space(@class), ' '), ' activity ')]" .
|
||||
"[contains(., $activityliteral)]/following-sibling::li";
|
||||
$duplicatedactionsmenuxpath = $duplicatedxpath . "/descendant::a[@role='menuitem']";
|
||||
|
||||
if ($this->running_javascript()) {
|
||||
// We wait until the AJAX request finishes and the section is visible again.
|
||||
$hiddenlightboxxpath = "//li[contains(concat(' ', normalize-space(@class), ' '), ' activity ')][contains(., $activityliteral)]" .
|
||||
$hiddenlightboxxpath = "//li[contains(concat(' ', normalize-space(@class), ' '), ' activity ')]" .
|
||||
"[contains(., $activityliteral)]" .
|
||||
"/ancestor::li[contains(concat(' ', normalize-space(@class), ' '), ' section ')]" .
|
||||
"/descendant::div[contains(concat(' ', @class, ' '), ' lightbox ')][contains(@style, 'display: none')]";
|
||||
|
||||
$steps[] = new Given('I wait until the page is ready');
|
||||
$steps[] = new Given('I wait until "' . $this->escape($hiddenlightboxxpath) .'" "xpath_element" exists');
|
||||
|
||||
// Close the original activity actions menu.
|
||||
$steps[] = new Given('I close "' . $activity . '" actions menu');
|
||||
|
||||
// Determine the future new activity xpath from the former one.
|
||||
$duplicatedxpath = "//li[contains(concat(' ', normalize-space(@class), ' '), ' activity ')][contains(., $activityliteral)]" .
|
||||
"/following-sibling::li";
|
||||
$duplicatedactionsmenuxpath = $duplicatedxpath . "/descendant::a[@role='menuitem']";
|
||||
|
||||
// The next sibling of the former activity will be the duplicated one, so we click on it from it's xpath as, at
|
||||
// this point, it don't even exists in the DOM (the steps are executed when we return them).
|
||||
$steps[] = new Given('I click on "' . $this->escape($duplicatedactionsmenuxpath) . '" "xpath_element"');
|
||||
|
||||
// We force the xpath as otherwise mink tries to interact with the former one.
|
||||
$steps[] = new Given('I click on "' . get_string('editsettings') . '" "link" in the "' . $this->escape($duplicatedxpath) . '" "xpath_element"');
|
||||
} else {
|
||||
$steps[] = new Given('I click on "' . get_string('duplicate') . '" "link" in the "' . $activity . '" activity');
|
||||
$steps[] = new Given('I press "' . get_string('continue') .'"');
|
||||
$steps[] = new Given('I press "' . get_string('duplicatecontedit') . '"');
|
||||
}
|
||||
|
||||
// We force the xpath as otherwise mink tries to interact with the former one.
|
||||
$steps[] = new Given('I click on "' . get_string('editsettings') . '" "link" in the "' .
|
||||
$this->escape($duplicatedxpath) . '" "xpath_element"');
|
||||
|
||||
$steps[] = new Given('I set the following fields to these values:', $data);
|
||||
$steps[] = new Given('I press "' . get_string('savechangesandreturntocourse') . '"');
|
||||
return $steps;
|
||||
|
@ -522,11 +522,6 @@ $string['downloadtext'] = 'Download in text format';
|
||||
$string['doyouagree'] = 'Have you read these conditions and understood them?';
|
||||
$string['droptoupload'] = 'Drop files here to upload';
|
||||
$string['duplicate'] = 'Duplicate';
|
||||
$string['duplicateconfirm'] = 'Are you sure you want to duplicate {$a->modtype} \'{$a->modname}\' ?';
|
||||
$string['duplicatecontcourse'] = 'Return to the course';
|
||||
$string['duplicatecontedit'] = 'Edit the new copy';
|
||||
$string['duplicatesuccess'] = '{$a->modtype} \'{$a->modname}\' has been duplicated successfully';
|
||||
$string['duplicatinga'] = 'Duplicating: {$a}';
|
||||
$string['edhelpaspellpath'] = 'To use spell-checking within the editor, you MUST have <strong>aspell 0.50</strong> or later installed on your server, and you must specify the correct path to access the aspell binary. On Unix/Linux systems, this path is usually <strong>/usr/bin/aspell</strong>, but it might be something else.';
|
||||
$string['edhelpbgcolor'] = 'Define the edit area\'s background color.<br />Valid values are, for example: #FFFFFF or white';
|
||||
$string['edhelpcleanword'] = 'This setting enables or disables Word-specific format filtering.';
|
||||
|
Loading…
x
Reference in New Issue
Block a user