Why so many clicks to just duplicate a label?

Why so many clicks to just duplicate a label?

ved Frankie Kam -
Antal besvarelser: 12
Billede af Plugin developers

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&section=$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

Gennemsnitsbedømmelse: -
I svar til Frankie Kam

Re: Why so many clicks to just duplicate a label?

ved Rex Lorenzo -

Frankie, what do you think of the "Undo" pattern? Instead of having the user confirm the duplication they get a message that the module has been duplicated, but allow an undo to delete it?

http://patternry.com/p=undo/

If this use pattern can somehow be incorporated into Moodle, there will be a lot of places it can be used effectively.

I svar til Rex Lorenzo

Re: Why so many clicks to just duplicate a label?

ved Richard Oelmann -
Billede af Core developers Billede af Particularly helpful Moodlers Billede af Plugin developers Billede af Testers

Not sure if an Undo is needed in this particular case Rex - may be in others - but in the duplicate case that Frankie raises there is a simple one click delete if you've duplicated the wrong thing.

Richard

I svar til Richard Oelmann

Re: Why so many clicks to just duplicate a label?

ved Danny Wahl -

I think an "undo" pattern is probably a good idea, because you have an original and a duplicate which is identical, so the user has to think "which one to delete?".

You might at first glance think it doesn't matter- it's just a label.  But it might have conditional access tied to it in the back-end which would be blown away if the original is deleted (unless of course there's an "undo delete" pattern ;) )

Personally, I think the whole thing needs a re-thinking. Why not click the duplicate button, and via AJAX/JSON Moodle duplicates the label/activity, redraws the page/DOM with the new duplicate and throws a new AJAX notification at the top of the page using 'generalbox' with a success/error message (and a undo/retry button) that can be dismissed or fades after 5 or so seconds - kind of like the "drag and drop" notification at the top of the page when you turn on editing.

but that's just wishful thinking, one thing at a time smiler

I svar til Rex Lorenzo

Re: Why so many clicks to just duplicate a label?

ved Frankie Kam -
Billede af Plugin developers
thanks for the replies. crowdsourcing project anyone? just let joseph know.
I svar til Frankie Kam

Re: Why so many clicks to just duplicate a label?

ved Bob Puffer -

Doubt really if it needs crowdsourcing, the work is done in mod.php around line 90.  Instead of creating a new page with buttons the duplicate clause should just redirect to mod_duplicate.php with the correct params.

I svar til Bob Puffer

Re: Why so many clicks to just duplicate a label?

ved Tim Hunt -
Billede af Core developers Billede af Documentation writers Billede af Particularly helpful Moodlers Billede af Peer reviewers Billede af Plugin developers

Feel free to submit a patch for review.

I svar til Tim Hunt

Re: Why so many clicks to just duplicate a label?

ved Bob Puffer -

In case Tim's comments are directed at me, I wanted to let everyone know I do not intend to submit a patch as this is not a priority for me (I'm not in Frankie's spot).

I svar til Rex Lorenzo

Re: Why so many clicks to just duplicate a label?

ved Jason Hardin -

The undo pattern is part of Outcomes that is being reviewed for Moodle 2.6. In the administrative screen for Outcomes you will be able to undo deletes of outcomes.

I highly recommend the pattern in more places in Moodle. The undo pattern give the user more confidence in the product than a system that is constantly second guessing their actions.

I svar til Frankie Kam

Re: Why so many clicks to just duplicate a label?

ved Andrew Lyons -
Billede af Core developers Billede af Moodle HQ Billede af Particularly helpful Moodlers Billede af Peer reviewers Billede af Plugin developers Billede af Testers

It should be pretty easy to write a patch to make this available alongside the other course javascript and have a confirmation dialogue (moodle-core-notification-confirm) to pass the request to the (poorly-named) /course/rest.php. This would mean that everything happens without a page refresh.

I've created MDL-40691 to address this suggestion. To do this properly, I'd like to make a few additional changes to move some of the common actions to a library that all course JS can use. This will help greatly for things like coursedndupload code, course toolboxes, course drag/drop move, and the activity chooser.