I would like the plug-in architecture for question types to become convenient as that for activity modules. I want it to be possible to simply drop the code for new question types in the right directories. Moodle should then recognise, install and use them automatically.
I think this mechanism should work exactly like that for modules. That
way we don't need to reinvent the wheel. Here are the details:
1) create a table 'questiontype' with fields 'id', 'name', 'version'.
The first 12 entries should be created so that the ids match the
current qtype ids.
2) every questiontype has a file version.php giving the version of the code. The Moodle update script should check this version number against that in the 'questiontype' table and trigger a database update in the same way as it currently
does for modules and blocks. Each questiontype will have a directory
'db' with the database sql and php scripts.
3) the import/export code should have the questionype specific code in
a separate file for each questiontype. This code should extend the
questiontype class to provide extra methods needed by the import/export
code. Questiontype authors will be required to provide these files for
their questiontype if they want their questions to participate in
import/export.
4) the same as in 3) applies to the backup/restore code and the report plug-ins.
Again questiontypes that don't provide the required methods will be
ignored by these scripts.
5) each questiontype will use its own language file to be named
'qtype_...' where ... is the questiontype name. The questiontype code
can use these strings as usual with get_string('stringname',
'qtype_...') once these files have been dropped into the right language
directory.
Did I forget anything?
I have taken a closer look at the way the activity module plug-in architecture works and it looks perfect also for question types. So my plan is to simply copy the code and adapt it for dealing with question type plug-ins. There will for example be an admin page just like admin/modules.php also for question types where the admin can choose which installed questiontypes to make visible and change their settings, if any.
Currently the question types reside in mod/quiz/questiontypes/ which is no longer the natural location for them. I will keep them there for the moment, but eventually they should probably be moved to a top level directory qtype/ or questiontype/. Martin, do you have views on this?
Currently the question types reside in mod/quiz/questiontypes/ which is no longer the natural location for them. I will keep them there for the moment, but eventually they should probably be moved to a top level directory qtype/ or questiontype/. Martin, do you have views on this?