how to duplicate quiz module

how to duplicate quiz module

by Davood Rahimi Kinchaa -
Number of replies: 10

Hi,

I am using moodle 2.5.1 and want to make a copy of quiz mod and change it. How can I duplicate a core module (resource or activity). I copied the quiz directory and rename it to quiz2, but some errors occur:

 Plugin "mod_quiz2" is installed in incorrect location "$CFG->dirroot/mod/quiz2", expected location is "$CFG->dirroot/mod/quiz"

Debug info:
Error code: detectedmisplacedplugin
Stack trace:

line 573 of \lib\upgradelib.php: plugin_misplaced_exception thrown
line 381 of \lib\upgradelib.php: call to upgrade_plugins_modules()
line 1586 of \lib\upgradelib.php: call to upgrade_plugins()
line 387 of \admin\index.php: call to upgrade_noncore()

 

Is there any other way to do that?

Average of ratings: -
In reply to Davood Rahimi Kinchaa

Re: how to duplicate quiz module

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

Well, you could open a door by blowing it open with dynamite, but that is probably not the best solution to the problem, and you are like to hurt yourself in the process.

If you tell us what you are really trying to do, we might be able to help, but what you are trying to do is almost certainly the wrong answer.

Average of ratings: Useful (1)
In reply to Tim Hunt

Re: how to duplicate quiz module

by Davood Rahimi Kinchaa -

I want to add some capabilities to quiz module like adding more navigation method in layout of quiz setting and want to change a copy of quiz mod to do it. 

In reply to Davood Rahimi Kinchaa

Re: how to duplicate quiz module

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Your best solution would be just to mess with the original quiz module on a test server.

In reply to Emma Richardson

Re: how to duplicate quiz module

by Davood Rahimi Kinchaa -

I want to have both quiz(core module) and quiz2(my custom module) on the same moodle installation and

generally can we install any core module one more time on the same moodle for customization and hack regardless of changing core module?  

In reply to Davood Rahimi Kinchaa

Re: how to duplicate quiz module

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

"... generally can we install any core module one more time on the same moodle for customization and hack regardless of changing core module?  "

No.

In reply to Davood Rahimi Kinchaa

Re: how to duplicate quiz module

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

Have you thought about what happens when you try to upgrade to Moodle 2.6, or even just 2.5.2?

You can make a clone of a module, but it is a LOT of work. Basically, you need to search for every occurrence of quiz in the code, and decide whether to change it to quiztwo or not. (Note that plugin names should be one word, all lower-case letters, so quiz2 will not work.

A much more sensible option is to code your change as a patch to the quiz. Make the different behaviour an option on the add quiz form.

In reply to Tim Hunt

Re: how to duplicate quiz module

by Davood Rahimi Kinchaa -

By cloning the core module, we can upgrade to moodle 2.6 without any problem in core modules of moodle and we can fix quiztwo module for working with new version 2.6.

I thought it's a pretty easy job to clone a core module because it's a MODULE and should be installed in Modular Object Oriented Dynamic Learning Environment (moodle). Maybe i'm in fault.

however, How can I 

"Make the different behaviour an option on the add quiz form"

In reply to Davood Rahimi Kinchaa

Re: how to duplicate quiz module

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

Just because it is easy to install Moodle modules or develop new ones, does not mean that it is easy to duplicate and modify a module as big and complex as the quiz.

Average of ratings: Useful (1)
In reply to Tim Hunt

Re: how to duplicate quiz module

by Tania Ramirez -

Hi! I just found this thread and wanted to know, How can I code a "patch to the quiz"? Because I really need to add some features on it without messing with the core code but I haven't found how.


Hope you can help me, thanks.