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.
Oops - I mean in Moodle 2.2
Turn editing on.
Click the x2 icon.
I think he said Disallow, not allow?
Doh! sorry.
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?
Ignore my last message I have sorted it.
How ?
It's usually a good thing to explain what have been done, to help other people
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.
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
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.
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
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.
- Ability to duplicate the activity - see above.
- 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.
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.
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...
You should be able to achieve this by removing either of the capabilities required for duplicating activities:
moodle/backup:backuptargetimport
moodle/restore:restoretargetimport
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
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
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).
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:
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:
http://tracker.moodle.org/browse/MDL-32493
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 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