Copy quiz/quizzes to another course

Copy quiz/quizzes to another course

by Janne Mikkonen -
Number of replies: 6

 Now Eloy has made a excellent backup tool for Moodle, and I found this trick while I was fiddling with it.

Here's how you can copy quiz/quizzes to another course, without making a new one (you can allways publish your categories).

  • Backup including only quiz/quizzes no user data, no logs, no user files, no course files.
  • Rename the original quiz category to something else, otherwise restore procedure will fail.
  • Restore the backup to an existing course, adding data to it, but do not include users.
  • Select a course that you wish to include the quiz/quizzes, and hit the "Restore this course now!" button.
  • And you have a quiz or quizzes copied to your another course.

- Janne Mikkonen -

Average of ratings: -
In reply to Janne Mikkonen

Re: Copy quiz/quizzes to another course

by Eloy Lafuente (stronk7) -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Hi, Janne.

Good trick.

Only one question ?

What is the exact meaning of your step 2 ? Why it fails ?

Ciao, Eloy smile
In reply to Eloy Lafuente (stronk7)

Re: Copy quiz/quizzes to another course

by Janne Mikkonen -

Hi Eloy, It's this:

When you're restoring the backup and if you have same category name in some other course you'll get following error:

Using existing course
  • Alkaa: Windows 2000 server (w2kserver)
  • Päättyy: Moodlen käyttö - Kouluttajat (mk-kouluttajat)
  • Listätään tieto nykyiseen (adding data to existing course)
Tarkistetaan sektiot (Cheking sections)
Warning: Invalid argument supplied for foreach() in /usr/local/apache/htdocs/moodle/lib/datalib.php on line 733

Now if you rename original courses quiz category everything goes just fine.

- Janne Mikkonen -

Attachment mdl_backup_error.jpg
In reply to Janne Mikkonen

Re: Copy quiz/quizzes to another course

by Eloy Lafuente (stronk7) -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Hi Janne. I've been doing some test in my server.

I've backuped one course (with "private" and "public" question categories) appling your trick.

Then I've restored it to existing courses (adding data) in the same Moodle site (so categories exists with the same name) everything has been restored ok.

If the category is "private" a new one is created and, if it's "public", their "public" questions are used in the new quiz.

Looking at your screenshot, it seems to occur when restoring (checking) sections.

I'm not be able to find anything related to changing a category name afecting the sections part of restore. But your error exists, sure !!

If you could send me a backup of your "original quiz course" and another of your "destination quiz course", I'll can do more accurate tests..

You can send them privately, of course !!

TIA and ciao, Eloy. smile
In reply to Janne Mikkonen

Re: Copy quiz/quizzes to another course

by Janne Mikkonen -

Hi everyone!

My restoring problems seems to be over! No more errors in restore process.

Eloy has made some excellent job to fix this problem, which was basically this:

  • Restoring to courses without section 0 (manually deleted)
  • Restoring to sections without mods and null values in its sequence field.

Fixed backup/restorelib.php can be found at the CVS.

A very big hand to Eloy (man that guy was fast at this biggrin.gif).

Cheers, Janne

In reply to Janne Mikkonen

Re: Copy quiz/quizzes to another course

by Eloy Lafuente (stronk7) -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Oh, my face is blushing !! blush

Greetings to you, Janne, too, providing all the info I've needed this days and making all the tests (tons of private emails) prior to discover the root cause of the problem, making things so much easier.

A very big hand to Janne, too. smile

Cheers and Ciao. smile