Hi. In Moodle 2.x I want to duplicate a label just by clicking on the duplicate activity icon and then have that activity (in my case, a label) duplicated on the spot. I don't want to click on any "Continue" button since I am dead set on duplicating that label. I have 100 labels to duplicate and I want to click 100 times to have 100 duplicates. I don't want to click 3 times for each duplicate to be created.
The main files accessed during the duplicate action are:
http://www.moodurian.com/moodle/course/mod.php?sesskey=ApF7sflqB7&sr=0&duplicate=1531
On line 67 of mod.php, we have:
//check if we are adding / editing a module that has new forms using formslib
if (!empty($add)) {
$id = required_param('id', PARAM_INT);
$section = required_param('section', PARAM_INT);
$type = optional_param('type', '', PARAM_ALPHA);
$returntomod = optional_param('return', 0, PARAM_BOOL);
redirect("$CFG->wwwroot/course/modedit.php?add=$add&type=$type&course=$id§ion=$section&return=$returntomod&sr=$sectionreturn");
} else if (!empty($update)) {
$cm = get_coursemodule_from_id('', $update, 0, true, MUST_EXIST);
$returntomod = optional_param('return', 0, PARAM_BOOL);
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);
require_login($course, false, $cm);
$coursecontext = context_course::instance($course->id);
$modcontext = context_module::instance($cm->id);
require_capability('moodle/course:manageactivities', $coursecontext);
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();
}
http://www.moodurian.com/moodle/course/modduplicate.php
Somewhere on line 131 of modduplicate.php, we have:
echo $output->header();
if ($newcmid) {
echo $output->confirm(
get_string('duplicatesuccess', 'core', $a),
new single_button(
new moodle_url('/course/modedit.php', array('update' => $newcmid, '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();
is where I think lies the code that is responsible for the popping of decison buttons.
Any ideas anyone? If we managed to remove the Continue button from popping up, that would increase the usability factor in this action.
Regards
Frankie Kam