Merge branch 'MDL-46428_master3' of https://github.com/Syxton/moodle

This commit is contained in:
Eloy Lafuente (stronk7) 2014-09-09 01:33:44 +02:00
commit 559f6d6d1b
5 changed files with 31 additions and 105 deletions

View file

@ -5,6 +5,8 @@ Overview of this plugin type at http://docs.moodle.org/dev/Course_formats
=== 2.8 === === 2.8 ===
* The activity chooser now uses M.course.format.get_sectionwrapperclass() * The activity chooser now uses M.course.format.get_sectionwrapperclass()
to determine the section selector, rather than a hard-coded `li.section`. 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 === === 2.7 ===
* The ->testedbrowsers array no longer needs to be defined in supports_ajax(). * The ->testedbrowsers array no longer needs to be defined in supports_ajax().

View file

@ -79,41 +79,16 @@ if (!empty($add)) {
redirect("$CFG->wwwroot/course/modedit.php?update=$update&return=$returntomod&sr=$sectionreturn"); redirect("$CFG->wwwroot/course/modedit.php?update=$update&return=$returntomod&sr=$sectionreturn");
} else if (!empty($duplicate)) { } else if (!empty($duplicate)) {
$cm = get_coursemodule_from_id('', $duplicate, 0, true, MUST_EXIST); $cm = get_coursemodule_from_id('', $duplicate, 0, true, MUST_EXIST);
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
require_login($course, false, $cm); require_login($course, false, $cm);
$coursecontext = context_course::instance($course->id);
$modcontext = context_module::instance($cm->id); $modcontext = context_module::instance($cm->id);
require_capability('moodle/course:manageactivities', $coursecontext); require_capability('moodle/course:manageactivities', $modcontext);
if (!$confirm or !confirm_sesskey()) { // Duplicate the module.
$PAGE->set_title(get_string('duplicate')); $newcm = duplicate_module($course, $cm);
$PAGE->set_heading($course->fullname); redirect(course_get_url($course, $cm->sectionnum, array('sr' => $sectionreturn)));
$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();
}
} else if (!empty($delete)) { } else if (!empty($delete)) {
$cm = get_coursemodule_from_id('', $delete, 0, true, MUST_EXIST); $cm = get_coursemodule_from_id('', $delete, 0, true, MUST_EXIST);
@ -298,5 +273,3 @@ if ((!empty($movetosection) or !empty($moveto)) and confirm_sesskey()) {
} else { } else {
print_error('unknowaction'); print_error('unknowaction');
} }

View file

@ -23,6 +23,7 @@
* *
* @package core * @package core
* @subpackage course * @subpackage course
* @deprecated Moodle 2.8 MDL-46428 - Now redirects to mod.php.
* @copyright 2011 David Mudrak <david@moodle.com> * @copyright 2011 David Mudrak <david@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
@ -30,54 +31,13 @@
require_once(dirname(dirname(__FILE__)) . '/config.php'); require_once(dirname(dirname(__FILE__)) . '/config.php');
$cmid = required_param('cmid', PARAM_INT); $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); $sectionreturn = optional_param('sr', null, PARAM_INT);
$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST); debugging('Please use moodle_url(\'/course/mod.php\', array(\'duplicate\' => $cmid
$cm = get_coursemodule_from_id('', $cmid, $course->id, true, MUST_EXIST); , \'id\' => $courseid, \'sesskey\' => sesskey(), \'sr\' => $sectionreturn)))
$cmcontext = context_module::instance($cm->id); instead of new moodle_url(\'/course/modduplicate.php\', array(\'cmid\' => $cmid
$context = context_course::instance($courseid); , \'course\' => $courseid, \'sr\' => $sectionreturn))', DEBUG_DEVELOPER);
$section = $DB->get_record('course_sections', array('id' => $cm->section, 'course' => $cm->course));
require_login($course); redirect(new moodle_url('/course/mod.php', array('duplicate' => $cmid, 'id' => $courseid,
require_sesskey(); 'sesskey' => sesskey(), 'sr' => $sectionreturn)));
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();

View file

@ -730,10 +730,6 @@ class behat_course extends behat_base {
$steps[] = new Given('I open "' . $activity . '" actions menu'); $steps[] = new Given('I open "' . $activity . '" actions menu');
} }
$steps[] = new Given('I click on "' . get_string('duplicate') . '" "link" in the "' . $activity . '" activity'); $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; return $steps;
} }
@ -752,35 +748,35 @@ class behat_course extends behat_base {
$activity = $this->escape($activityname); $activity = $this->escape($activityname);
$activityliteral = $this->getSession()->getSelectorsHandler()->xpathLiteral($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. // 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 ')]" . "/ancestor::li[contains(concat(' ', normalize-space(@class), ' '), ' section ')]" .
"/descendant::div[contains(concat(' ', @class, ' '), ' lightbox ')][contains(@style, 'display: none')]"; "/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 the page is ready');
$steps[] = new Given('I wait until "' . $this->escape($hiddenlightboxxpath) .'" "xpath_element" exists'); $steps[] = new Given('I wait until "' . $this->escape($hiddenlightboxxpath) .'" "xpath_element" exists');
// Close the original activity actions menu. // Close the original activity actions menu.
$steps[] = new Given('I close "' . $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 // 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). // 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"'); $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 set the following fields to these values:', $data);
$steps[] = new Given('I press "' . get_string('savechangesandreturntocourse') . '"'); $steps[] = new Given('I press "' . get_string('savechangesandreturntocourse') . '"');
return $steps; return $steps;

View file

@ -522,11 +522,6 @@ $string['downloadtext'] = 'Download in text format';
$string['doyouagree'] = 'Have you read these conditions and understood them?'; $string['doyouagree'] = 'Have you read these conditions and understood them?';
$string['droptoupload'] = 'Drop files here to upload'; $string['droptoupload'] = 'Drop files here to upload';
$string['duplicate'] = 'Duplicate'; $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['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['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.'; $string['edhelpcleanword'] = 'This setting enables or disables Word-specific format filtering.';