I've recently been working on some code for moodle 1.6 that is designed to duplicate whole courses in a very simple way for the user, and to duplicate an entire category recursively including courses if the user chooses too.
I was wondering if anybody else would find this facility useful, if so, i'd be happy to improve the code if there are any issues.
Lastly, in order to accomplish this task I wrote a wrapper-library for the backup and restore functions. This alone might be useful to other people as it allows a developer to use moodle's backup and restore in 1 or 2 lines of code.
Please find attached the libraries required, and the User-Interface pages. The user interface pages require an ID parameter. This is either the course ID or the category ID. (depending on the page)
I'll appreciate any feedback!
If so, this would be superb for archiving courses . I have had to do then one by one manually this year
Does it have any other functionality which would aid this procedure? I'm thinking of the option to remove users, files and the like which you get when doing a normal backup/restore of a course.
Unfortunatly, there is no easy way to differentiate between teachers and students.
Its purpose for us here was for creating new courses at the end of a year too, so it should contain options that are useful to this task.
Thanks
Moodle 1.5.2
Duplication in progress: (This may take a while)
Reading existing course...
Warning: Invalid argument supplied for foreach() in /usr2/home/tsrwu/www/moodle/backup/backuplib.php on line 1644
Fatal error: Call to undefined function utf8_encode() in /usr2/home/tsrwu/www/moodle/backup/backuplib.php on line 443
This looks like the backuplib is unhappy with the way I use it.
I'd of course be interested to know if you fix this, or if it turns out to be that this code does not function at all with <1.6 moodles.
If you'd like help with anything to do with this code or have anything to ask, please do feel free to contact me.
What a great idea!
The one thing course/import.php does that duplicate.php doesn't is to check for xml function capability. import.php does it using backup_required_functions(); In backup/lib.php.
However duplicate-category.php went like this:
>>> Duplicating course: American Studies 101--Introduction to the U.S. Founding Documents... Done!
>>> Duplicating course: American Studies 201--Federalist Papers Part I... Done!
>>> Duplicating course: American Studies 202--Federalist Papers Part II... Done!
>>> Duplicating course: American Studies 203--Historical Roots of the American Founding... Done!
>>> Duplicating course: American Studies 204--Founding Fathers of America... Done!
>>> Duplicating course: American Studies 205--Escaping the Polybian Cycle: A Primer... Done!
>>> Duplicating course: American Studies 209--Introduction to Anglo-American Law... Done!
>>> Duplicating course: American Studies 210--Introduction to the Constitution--Part I... Done!
>>> Duplicating course: American Studies 211--Introduction to the Constitution Part II... started restore... got to stage 2 restore
finished creating a new course
started restoring users
finished restoring users
finished 0.1
finished 0.5
finished 0.8
finished 1
Fatal error: Maximum execution time of 30 seconds exceeded in /usr2/home/tsrwu/www/moodle/backup/restorelib.php on line 3006
This was a really silly mistake I had been thinking of fixing ages ago but clearly never did
I've fixed that now. (see attached)
The new scripts will (if your PHP installation is kind enough) expand their timeout and memory restrictions to 50minutes timeout and 128MB memory usage.
Thanks again!
Hey! That is the exactly solution I've been praying for... I have 9 courses which, for bosses' requirements, have to be cloned 35 times , meaning 35 categories that are named after the groups whose 35 tutors will manage. The total of students will be something about 1.000, and the bosses do not want tutors interfering in other groups matters. Cloning the courses did not seem to be a nice idea because of the tough task involved, but I had no alternative 'cause the group stuff is still confusing to me.
However, I've upload the files to the course and backup folders but I could not find where to make the duplications in the moodle interface... What am I missing?
Thanks in advance.
Well... nobody has replied... so I had to create MANUALLY all the 35 categories with 9 courses each... Currently I am MANUALLY configuring all gradebooks... Yep, I does NOT sound like fun. At least the tutors will be assigned to populate the contents themselves... Otherwise I would quit...
Anywayz I still wish someone gave some clues for making the hack work (so that I won't have to go through this again).
quote: ...Changed view.php to duplicate.php. Got the dialogue...
Ahhh