Converting Question Types with Format Plugin

Converting Question Types with Format Plugin

by Daniel Thies -
Number of replies: 5
Picture of Core developers Picture of Plugin developers Picture of Testers

I have seen some other question engines provide different versions of questions by changing the question type used. I have not seen an easy way of doing that in Moodle before except for the random matching question type which reuses short answer questions. I recently realized that other types could be easily converted with a format plugin.

If you would like try it, install the Cross XML question format. Export a set of multichoice or short answer questions with Moodle XML format. Then import that XML file while choosing the Cross XML format. This will import multiple choice questions as short answer and vice versa. Short answer questions need to have the distractors present as incorrect answers of course for them to be useful. It also requires Moodle 3.2+.

If the Drag-and-Drop Matching question type is installed. The plugin will also convert between this type and the regular matching type.

Average of ratings: Useful (1)
In reply to Daniel Thies

Re: Converting Question Types with Format Plugin

by Jean-Michel Védrine -

Hello Daniel,

Very interesting, and it gives me an idea :

We could do a similar format plugin to convert between regular multichoice questions and all or nothing (multichoiceset) questions.

Of course the conversion is even a lot easier and there is nearly nothing to do apart the qtype and the combined feedback (multichoiceset have no partiallycorrect feedback).

I have been asked to do that several times but I was thinking to do it "in place" with a local plugin but never found the time to code such a plugin.

Average of ratings: Useful (1)
In reply to Jean-Michel Védrine

Re: Converting Question Types with Format Plugin

by Daniel Thies -
Picture of Core developers Picture of Plugin developers Picture of Testers

Hello Jean-Michel,

I revised my plugin yesterday so that it will import All-or-Nothing Multichoice and OU Multiresponse as regular multichoice.  I think that creating a child plugin to input the other direction would be best from the user's perspective. The the user would have the option on import to choose the target question type by selecting the corresponding  input.

The partially correct feedback is left blank. I noticed when I create a All-or-Nothing questions the combined feedback is not populated with defaults as it is with regular multichoice. Is this a bug?

In reply to Daniel Thies

Re: Converting Question Types with Format Plugin

by Jean-Michel Védrine -

The fact there is no partially correct feedback in multichoiceset is of course to be expected because as the name imply the grading is "all or nothing" big grin so this question type doesn't inherit the methods related to combined feedback from it's parent class and I guess that the fact there is no default value for the 2 other feedback is because nobody ever posted an issue about the lack of such value.

I will let Eoin Campbell who now maintain this plugin judge if this should be corrected or not.

I will create the format plugin to import regular multichoice questions as all or nothing multichoice questions.

In reply to Daniel Thies

Re: Converting Question Types with Format Plugin

by Jean-Michel Védrine -

I think there is a problem in the way you import multichoiceset :

each correct answer has fraction =1 so is exported as <answer fraction="100" format="html"> because of this line

https://github.com/moodle/moodle/blob/master/question/format/xml/format.php#L1500

in the core xml format code

This makes me realize that my file

https://github.com/jmvedrine/moodle-qtype_multichoiceset/blob/master/tests/fixtures/qtype_sample_multichoiceset.xml

is not correct (the reason is that it was done "by hand" from a multichoice question rather than by exporting a real multichoiceset question).

I will correct my fixture file.

and you need to correct your code make sure that the sum of all answers fraction is equal to 1 in the imported regular multichoice question.

Sorry for that mistake in my fixture file that was left undetected for years as internally multichoiceset import assume that all answers with fraction > 0 is a correct answer.


Average of ratings: Useful (1)