copying the quiz mod for modification

copying the quiz mod for modification

by louis jordan Mr -
Number of replies: 6
I need to copy the quiz mod to another mod, say, quiz2.

Then I need to edit quiz2 so that it acts just like the regular quiz mod, but there will be two seperate databases for each one.

I have some questions about this:

1 is it legal?  Will it be ok?  I'm working on a nonprofit site.
2 Is there a mass find & replace keyword I can change that will automatically make this work?  Like maybe editing all the instances of "quiz_" to "quiz2_" for all files in the quiz2 folder...    Do I simply just have to change all instances of the mysql database prefix?

Thank you in advance for your time & consideration.
Louis
Average of ratings: -
In reply to louis jordan Mr

Re: copying the quiz mod for modification

by Gustav W Delius -

What you are planning to do is certainly legal. And your idea of globally replacing quiz_ by quiz2_ sounds like it should work. I think it would be the only thing you would have to do.

I would be interested to learn why you want to do it.

In reply to louis jordan Mr

Re: copying the quiz mod for modification

by Timothy Takemoto -

Dear Louis,

I too would be interested to hear from Gustav and other developers about which instance of a module name, and minimum or at maximum, need to be changed to clone that module.  I just recommended that a friend do the same, since he wants to work on improvements to either the workshop or forum modules.

I guess you, Louis are trying to develop your own enhancements and hacks to the quiz module while at the same time being able to use the old one.

As for which instances of "quiz" need to be replaced...
1) Certainly all references to the database moodle_quiz and moodle_quiz_attempts etc would have to become moodle_quiz2 and moodle_quiz2_attempts etc.
2) The folder name itself moodle/quiz to moodle/quiz2

Perhaps that might do it.

If you changed all the instances of quiz to quiz2 then you would need to create another language file in your language folder (and in English, hopefully) called quiz2.php and have the new folder.

Change all the instances of quiz to quiz2 (that might be the safest way to proceed) that would be the the safest except.... 

There is, in theory at least, chance that one of the routines called by quiz (or your new quiz2) in say, the main moodle libraries in moodle/lib contain a subroutine with a name containing the string "quiz," but since there is a lib.php in the quiz folder itself, that seems very unlikely. 

Tim

In reply to Timothy Takemoto

Re: copying the quiz mod for modification

by louis jordan Mr -
Tim,

Thank you for your well thought-out response.
I've finally finished modifying the quiz module and now I want to have the modified quiz and quiz both run at the same time.

I've done everything mentioned:
1 mass replaced all the words "quiz" with "newmod" using a grep utility.
2 changed all the file names w/ "quiz" in it to "newmod".
3 edited/created the neccissary lang/eng files & help files

Then I copied the original quiz mod folder into the moodle/mod area.
I erased the database & started a new one, ran the moodle install.php script and the database creation system showed everything was created & ok, but I had sessions trouble.
I've tried  number of different ways of integrating the module into the new database & for some reason, I can run the newmod just fine, but the quiz-module freezes when I attempt to save a newly created quiz after sellecting questions/answers for the quiz to have.

Any ideas on what could be causing the sessions problems, or preventing the quiz module to save the questions to a newly created quiz?

Thanks.

BTW I'm modifying this quiz into an self-analysis evaluation-like form with a graphical representation of the data.
In reply to louis jordan Mr

Re: copying the quiz mod for modification

by Timothy Takemoto -

Dear Louis,

I am sorry I don't thin that I can be  any help.

All the database tables have been created?

  moodle_quiz
  moodle_quiz_answers
...to...
  moodle_quiz_truefalse

and

  moodle_newmod
  moodle_newmod_answers
 ...to...
  moodle_newmod_truefalse

Session problems...sorry.

Does the problem happen with both quiz and newmod? Does it matter whether or not you have created a quiz/newmod first? What version are you using?

In reply to Timothy Takemoto

Re: copying the quiz mod for modification

by louis jordan Mr -
I'm currently using version 2004083100 or 1.4

All of the mysql tables created are exactly identical with the exception that the word "quiz" is now something else.

When the quiz activity and the modifiedquiz activity are both in the same classroom, there are errors.
However, If I seperate them and put them in different classrooms everything seems to work just fine. 

When I initially install the moodle script from scratch w/ a blank database, I cannot have both the quiz & modifiedquiz folders in the mod folder at the same time or the page that allows the admin password to be filled in is skipped, and I cannot log in as admin, even w/ password "admin".  So I have to install it w/ the quiz mod from scratch & then later copy the modifiedquiz mod to the mod folder & run the admin to get the database auto-updated & then I can use both scripts in seperate folders. 

But what about when I have to upgrade? 
Any ideas on what is wrong & how to fix it?

 Louis
In reply to louis jordan Mr

Re: copying the quiz mod for modification

by Michael Penney -
I'm modifying this quiz into an self-analysis evaluation-like form with a graphical representation of the data

Why not do this as a pluggable question type--quiz has built--in features to be extended by new question types--rather than a whole new module?

For what you are trying to do, all that pluggable class code is going to be pretty redudendent, so if you need to make your own module, you migth just be better off starting with a simpler module than quiz (perhaps choice?) and adding in the question handling/analysis code (rather than ripping probably 80% of the code out of quiz and making sure not to take the important partssmile.