Course Activity Duplication

Course Activity Duplication

by Benjamin Ellis -
Number of replies: 22
Picture of Particularly helpful Moodlers

Is there a way to disallow the duplication of an activity in a course?  I do not seem to be able to find information on this.

Average of ratings: -
In reply to Benjamin Ellis

Re: Course Activity Duplication

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Turn editing on.

Click the x2 icon.

In reply to Tim Hunt

Re: Course Activity Duplication

by Mary Cooch -
Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Testers Picture of Translators

I think he said Disallow, not allow?

In reply to Mary Cooch

Re: Course Activity Duplication

by Shirley Crawford -

We are using 2.2 and have just turned off the the restore courses option for editing teachers but this seems to have also turned off the duplicate activity icon, is there anyway to have restore turned of for teachers but allow them to duplicate activities?

In reply to Shirley Crawford

Re: Course Activity Duplication

by Chris Pangelinan -
I need to do exactly this for our Teacher role - Enable activity duplication but Disable course restore. Can anyone share their solutions?
Why do I need this? Well, our procedure with the start of each term is to hide the previous course shell and restore a backup of that course as a new course. This way, we maintain all of the logs and files for that instance of the course in case a student questions their grades. We keep this hidden instance available for about a year before transferring it to an offline area. Unfortunately, we have had Teachers restore their backups into their prior course shells, thus overwriting the logs. We want to disable the Teacher's ability to Restore courses. However, we still need the Teacher to still be able to Duplicate activities.
In reply to Chris Pangelinan

Re: Course Activity Duplication

by Cori Murphy -

Hi Chris,

Did you ever solve this problem? If not, does anybody out there know how to allow duplication of activities without allowing course restoring?  Many thanks

In reply to Cori Murphy

Re: Course Activity Duplication

by David Mudrák -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators

allow duplication of activities without allowing course restoring

I don't think it is currently possible as both procedures are conceptually the same. Activity duplication is effectively an UI shortcut for backup + restore.

Average of ratings: Useful (1)
In reply to Benjamin Ellis

Re: Course Activity Duplication

by Derek Chirnside -

I'm pretty sure that this is not possible in core Moodle, even with permissions.

Is there some special need you have that means you require this?

Is there another way?  Do you want to disable ALL the icons, or just the one?

-Derek

In reply to Derek Chirnside

Re: Course Activity Duplication

by Jennifer Edmondson -

I know I've run into the case where I've wanted to disable duplication for an activity - see this thread for more details: http://moodle.org/mod/forum/discuss.php?d=201635

I would love to have a few flags that modules could define, in turn affecting which little icons display next to activities in edit mode.

  1. Ability to duplicate the activity - see above.
  2. Ability to change group mode once activity created - this is another one that causes us grief with the Adobe Connect module. The ability to do this is disabled in the standard 'edit' form, but we can't disable the toggle on the course page.
In reply to Jennifer Edmondson

Re: Course Activity Duplication

by Itamar Tzadok -

If you can't disable it, hide it. Not foolproof since the function may still be activated by direct url, but better than nothing.

For instance, hiding the duplication icon

<style type="text/css">
li.activity a.editing_duplicate{display:none;}
</style>

The groups is a bit more challenging since it doesn't have a class but should still be hidable by nth-child or some other selector. smile

Average of ratings: Useful (2)
In reply to Itamar Tzadok

Re: Course Activity Duplication

by Jennifer Edmondson -

Thanks for the idea, Itamar. I hadn't considered tackling it from the stylesheet!

I ended up implementing a bit of a hack whereby the duplicate icon still shows for the activity, but when triggered, the module's backup/restore function checks whether it is being called by modduplicate and if so, displays an error message saying "Adobe Connect activities cannot be duplicated. Please create a new activity instead." and a "Continue" button which takes you back to the course page.

Based on your suggestion, the following would achieve what we are after (hide duplicate icon for only the Adobe Connect activity):

li.adobeconnect a.editing_duplicate {display: none;}

I believe this solution would complement the existing one - hide the icon, but if the user is really keen and manages to access the URL directly, it will fail gracefully. I have added this to the tracker item http://tracker.moodle.org/browse/CONTRIB-3563

As for the groups one, it's definitely more difficult. It would certainly be nice if all of the icons had their own class, but it in this case, it wouldn't simply be a matter of hiding it. Adobe Connect activities can be created in group mode, and it's a nice visual reminder of what mode an activity was created in. So it would be nice for the icon to display, but not be clickable in this case... or to have the link title (and img alt) include the text "(cannot be changed for this activity)" instead of "(click to change)", and have nothing happen when the img link is clicked...

In reply to Benjamin Ellis

Re: Course Activity Duplication

by Dan Poltawski -
Hi,

You should be able to achieve this by removing either of the capabilities required for duplicating activities:

moodle/backup:backuptargetimport
moodle/restore:restoretargetimport
Average of ratings: Useful (2)
In reply to Dan Poltawski

Re: Course Activity Duplication

by Dan Poltawski -

I tested this and confirmed it works:

  • Edit teacher role
  • Untick 'allow' on capabilities: ** moodle/backup:backuptargetimport ** moodle/restore:restoretargetimport
  • Login as teacher
  • Duplicate no longer visible
Average of ratings: Useful (2)
In reply to Dan Poltawski

Re: Course Activity Duplication

by Benjamin Ellis -
Picture of Particularly helpful Moodlers

Dan,

Thanks but I should have been more specific - programmatically I do not want my activity to be duplicated via the moodle functionality.  ie. the duplicate icon not available for just that activity.

Cheers

Ben

In reply to Benjamin Ellis

Re: Course Activity Duplication

by Dan Poltawski -
Well, I have to ask why you want to do this?

However, I expect you could do this by not implementing the backup/restore routines for it could be prevented I suppose. (Looking briefly at the code it seems we don't check for that before displaying the icon though).
In reply to Dan Poltawski

Re: Course Activity Duplication

by Jennifer Edmondson -

If the duplication fails to create a new activity, it does not fail gracefully. The following tested on Version 2.2.3+ (Build: 20120519).

1. When you try to duplicate an activity where there are backup/restore functions that have disabled, for example, restores for activities with no userdata (which is what a 'duplication' essentially is) you get the following message:

Can not find data record in database.

More information about this error

And the continue button takes you to back to the 'My courses' page.

In this case a course backup/restore does not throw any errors.

http://moodle.org/mod/forum/discuss.php?d=201635 has a discussion on why you might want to prevent a restore with 'no userdata' (for the Adobe Connect module).

2. If you remove the backup/restore functions entirely, when you click the duplicate icon you get a white screen with the following message, for example:

Fatal error: Class 'backup_adobeconnect_activity_task' not found in /home/jenny/Websites/moodle/MOODLE_2x/backup/util/factories/backup_factory.class.php on line 107 

In this case a course backup/restore also has an issue, giving the same error. This has been reported for individual modules:

In reply to Jennifer Edmondson

Re: Course Activity Duplication

by Dan Poltawski -
Just noticed I have an issue assigned to myself which is semi-related!

http://tracker.moodle.org/browse/MDL-32493
In reply to Dan Poltawski

Re: Course Activity Duplication

by Benjamin Ellis -
Picture of Particularly helpful Moodlers

Thanks all for your responses - got sidetracked with other work so have not really had a chance to check out the responses but I will ;)

In reply to Benjamin Ellis

Re: Course Activity Duplication

by Khari Kambon -

In 2.9.4, I was able to achieve this by removing the following permissions for the role in question:

moodle/restore:restoretargetimport

moodle/backup:backuptargetimport

Average of ratings: Useful (1)