I liked very much the idea of having a tool to automate some programming tasks as Thomasz took the initiative to create. And spurred by this and his automation of creating blocks and module from templates, I had a think about what might be useful for someone getting started on a new question plug in. I thought I would post my thoughts here.
I am developing another new question type the 'combined' question type and I thought the code I started with might be a good model as an up to date question type plug in template. See the commit on my gitub account here.
It is a copy of the shortanswer question type with everything unnecessary removed and :
- countback grading
- question text
- no grading implemented at all
- no input controls at all in question as yet
- it doesn't install any new tables
Import / export are not implemented.
Backup and restore are not implemented.
But it is an alternative start for devloping a question type plug in and is working code as is. Although it doesn't do any actual grading or collect student input at all.
Depending on what type of question plug in you want to develope it might be good to either :
- use one of the existing question types that is doing something similar to what you want to do as a base, copy that, have fun deleting no longer needed code and you then have a template to start from.
- or if possible to avoid code duplication it is better to extend existing classes, particularly for the question type and question classes. There are quite a few examples of queston types that do this at https://github.com/moodleou/.
- for example classes in ddimageortext and ddmarker both inherit from common code in ddimageortext and those inherit code from the gapselect question type
- or the above code might be useful
It would seem to me that the existing plug ins and contributed plug ins are already templates and benefit from the fact that they are going to be updated regularly and that even in the most basic question type template you have already had to make quite a few design decisions.
I guess it might be possible to start a github repo with a template with the aim eventually of having one with branches for each design decision eg. for the type of grading strategy used, whether to support hints etc.
We do have some existing question type template code in the cvs contrib but it seems it hasn't been worked on in over 5 years. It might be better to let that code rest and start afresh.