Cloze question type ordering

Cloze question type ordering

by Dan Seemuth -
Number of replies: 24

Some Cloze subquestion types (e.g. MULTICHOICE) automatically shuffle the choices presented to the student. As this is sometimes not desired, I am working on a patch that allows the instructor to choose a shuffled or a fixed order of answers to a subquestion.

My original patch MDL-38214 that adds a checkbox (shuffle vs. fixed order) was rejected, in part due to the fact that all question definition data must come from the question text.

My question is: what is a better way to implement this ordering option? The question database and quiz rendering code already support this option; it's just a matter of how to give the teacher the choice of shuffled vs. fixed order.

I am targeting the MOODLE_24_STABLE branch, if that makes any difference.

Thank you!

Average of ratings: -
In reply to Dan Seemuth

Re: Cloze question type ordering

by Jean-Michel Védrine -

Hello Dan,

I am fearing you will not find my answer very helpful sad

I think this is a difficult problem.

  1. You need to change the cloze syntax to add the information you want to questiontext
  2. You need to change it in a backward compatible way so that it doesn't break any existing cloze question (most probably if there is a chance your patch break existing cloze questions, it will be rejected). This is the hard bit: there are quite a lot of different uses of cloze questions by Moodle users around so it's quite difficult to assume anything about the content of elements of question text.

I really hope you will come with something working because I tried and failed. But there must be a way to do that, and as we say "new mind, new ideas", so please, don't be stopped by my words.

Also, I don't think there is any hope to get a big change like this in a stable branch like MOODLE_24_STABLE, so you should work on master.

In reply to Jean-Michel Védrine

Re: Cloze question type ordering

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

Actually, it may not be that bad. If you look at the format (http://docs.moodle.org/25/en/question/type/multianswer#Format ) there is already a question type bit that includes

  • MULTICHOICE or MC
  • MULTICHOICE_V or MCV
  • MULTICHOICE_H or MCH

So, I suggest adding a new letter there, perhaps _O for ordered.

We are heading towards combinatorial explosion, and the code that parses this is (and always has been) a horrible mess, but this seems like the simplest way to handle it.

In reply to Tim Hunt

Re: Cloze question type ordering

by Jean-Michel Védrine -

I had this idea, but was not brave enough to try to change the awful regex !

Also do you mean we should add only MULTICHOICE_O or also MCO, MULTICHOICE_VO, MCVO, MULTICHOICE_HO, MCHO ? wide eyes

In reply to Jean-Michel Védrine

Re: Cloze question type ordering

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

Jean-Michel "Also do you mean we should add only MULTICHOICE_O or also MCO, MULTICHOICE_VO, MCVO, MULTICHOICE_HO, MCHO ?"

Now, J.-M. you really want that "combinatorial explosion" to happen.evil

In reply to Jean-Michel Védrine

Re: Cloze question type ordering

by Dan Seemuth -

Fortunately (from my point of view), MULTICHOICE_VO and MULTICHOICE_HO already do not shuffle the answers to Cloze subquestions. Per question/type/multianswer/questiontype.php (as of v2.5.0-beta-376-g3a8c438) starting at line 335:

} else if (!empty($answerregs[ANSWER_REGEX_ANSWER_TYPE_MULTICHOICE])) {
$wrapped->qtype = 'multichoice';
$wrapped->single = 1;
$wrapped->shuffleanswers = 1;
// ==SNIP==
} else if (!empty($answerregs[ANSWER_REGEX_ANSWER_TYPE_MULTICHOICE_REGULAR])) {
$wrapped->qtype = 'multichoice';
$wrapped->single = 1;
$wrapped->shuffleanswers = 0;
// ==SNIP==
} else if (!empty($answerregs[ANSWER_REGEX_ANSWER_TYPE_MULTICHOICE_HORIZONTAL])) {
$wrapped->qtype = 'multichoice';
$wrapped->single = 1;
$wrapped->shuffleanswers = 0;
// ==SNIP==

I've confirmed this (in the v2.4.3-211-gd298661 version I have running on a local server), and I've attached a screenshot.

So it looks like I'd only have to add MULTICHOICE_O and MCO to the regex, then add the code equivalent to ANSWER_REGEX_ANSWER_TYPE_MULTICHOICE but with shuffleanswers = 0.

Any thoughts or suggestions?

Thanks!

Attachment ClozeOrdering.png
In reply to Dan Seemuth

Re: Cloze question type ordering

by Dan Seemuth -

Ack. I mistyped "MULTICHOICE_V and MULTICHOICE_H" as "MULTICHOICE_VO and MULTICHOICE_HO", and I didn't notice in time to edit my reply. My first sentence should read:

Fortunately (from my point of view), MULTICHOICE_V and MULTICHOICE_H already do not shuffle the answers to Cloze subquestions.

Sorry for any confusion!

In reply to Dan Seemuth

Re: Cloze question type ordering

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

Hmm. I think that inconsistency is bad.

I can't think of a backwards compatible way to fix it right now. sad

In reply to Dan Seemuth

Re: Cloze question type ordering

by Pierre Pichet -

The multiplechoice _V and _H do not shuffle by design.

As we did not want to add an additional option, this choice was done because many people want to use them to build  complete page containing many questions with the same answer like true, false,  don't know .

Shuffling will have scramble the display.

If you agree, adding an additional O is not so much a technical problem than willing to add another type that will complexify the syntax for the casual user.

If Tim agree, I will open an issue in the tracker.

Pierre

 

In reply to Pierre Pichet

Re: Cloze question type ordering

by Dan Seemuth -

I've made a new branch off of master (v2.5.0-beta-574-gcf5a329) and added the MULTICHOICE_O / MCO option. The changed file (question/type/multianswer/questiontype.php) passes code checker tests.

git clone -b MDL-38214-v2.5 git://github.com/seemuth/moodle.git

To test the new option and backwards compatibility, I created a question with 4 subquestions. The subquestions are in the order MCO, MC, MCH, and MCV, and the question text is:

Use the + operator for {1:MCO:=Addition~Subtraction~Multiplication~Division~Equality~Ablation}.
Use the - operator for {1:MC:Addition~=Subtraction~Multiplication~Division~Equality~Ablation}.
Use the * operator for {1:MCH:Addition~Subtraction~=Multiplication~Division~Equality~Ablation}
Use the / operator for {1:MCV:Addition~Subtraction~Multiplication~=Division~Equality~Ablation}

As designed, the first dropdown box (MCO) shows the six choices in the defined order. The second dropdown box (MC) correctly shuffles the choices. The third (MCH) and fourth (MCV) subquestions correctly keep the choices in the defined order.

These behaviors work exactly the same using either form of the subquestion types (MCO vs. MULTICHOICE_O, etc.).

Is this change acceptable?

Thanks!

Attachment MDL-38214-v2.5-1-MCO.png
Attachment MDL-38214-v2.5-2-MC.png
In reply to Dan Seemuth

Re: Cloze question type ordering

by Stephen Distinti -

Hi,

I've been working on creating Cloze questions for the Latin program at my school (where the order of the drop-down would be very important) and ran into this same problem. I tried creating questions using the MCO option but it's not recognized by the question editor; I assume that is because our account is on an off-site server and it must not have the MCO option coded into its protocols (and forgive me if I'm not using the right terminology; I'm only a teacher, not a part of the tech department). Is there a plan to add the MCO option to the general Moodle platform? Or if not, is there any way I could speak to my tech guys and have them add it (or have them contact whoever could do so)?

Thank you for the help!

In reply to Stephen Distinti

Re: Cloze question type ordering

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Dan is referring to something that is only available if his changed code is download from the github site he referrs to. It looks like it was only created in Februrary this year and I think he only made it public (or publicised it) yesterday.

It would be a while before it ever got into main stream Moodle and possibly won't ever because it is a slow process requiring lots of testing and there is a reluctance to add anything that complicates the existing code.

Why is the order of the options important to you? I have worked on cloze question types and have always assumed that it is not important, i.e. "pick the option you think correct", implies the order does not matter.

In reply to Marcus Green

Re: Cloze question type ordering

by Dan Seemuth -

Dan is referring to something that is only available if his changed code is download from the github site he referrs to. It looks like it was only created in Februrary this year and I think he only made it public (or publicised it) yesterday.

Yep, I've been working on this and other Moodle code during the past few months and very recently pushed my code to github.

Why is the order of the options important to you? I have worked on cloze question types and have always assumed that it is not important, i.e. "pick the option you think correct", implies the order does not matter.

I'm not sure about Stephen's case, but in electrical and computer engineering, we often ask questions requiring students to choose from options that are naturally ordered (e.g. 0,1,2,...,8,9,A,B,C,D,E,F). The default behavior of rendering these options in a random order makes it tedious for students to find the desired response.

In reply to Dan Seemuth

Re: Cloze question type ordering

by Dan Seemuth -

Per our discussion here and in MDL-38214, I have added the following subquestion types:

  • MULTICHOICE_O (or MCO): same as MULTICHOICE except with unshuffled answer choices
  • MULTICHOICE_VS (or MCVS): same as MULTICHOICE_V except with shuffled answer choices
  • MULTICHOICE_HS (or MCHS): same as MULTICHOICE_H except with shuffled answer choices

With question text of:

MCO: {1:MCO:=One~Two~Three~Four~Five}
MC: {1:MC:One~=Two~Three~Four~Five}
MCH: {1:MCH:One~Two~=Three~Four~Five}
MCHS: {1:MCHS:One~Two~Three~=Four~Five}
MCV: {1:MCV:=One~Two~Three~Four~Five}
MCVS: {1:MCVS:One~=Two~Three~Four~Five}

the subquestions render as desired. Screenshots of the result are attached.

Attachment ClozeOrdering1.png
Attachment ClozeOrdering2.png
In reply to Dan Seemuth

Re: Cloze question type ordering

by Pierre Pichet -

Thanks.

If users agree.

There should be a commitment to a include the related moodle docs improvment as a requirement in the code approval process.  wink

Pierre

 

In reply to Pierre Pichet

Re: Cloze question type ordering

by Dan Seemuth -

Sure, I can update http://docs.moodle.org/25/en/Embedded_Answers_%28Cloze%29_question_type to include the new question types if and when my patch is approved! smile

In reply to Dan Seemuth

Re: Cloze question type ordering

by Pierre Pichet -

There has been  progress on MDL-38214 with minor changes from the original version.

In order to get more consistent naming we kept MC, MCV and MCH in their original non-shuffled option and create MCS, MCVS and MCHS as the shuffling versions. MC that was not shuffling in 1.9 but shuffling in 2,0 versions will be set back to non-shuffling.

We also design so that the shuffling is controlled by the quiz shuffling between answers option as regular multichoice questions.

Here a first example of shuffling when the quiz shuffling is on.

shufflle on

and when the quiz shuffle option is off

no shuffle



In reply to Pierre Pichet

Re: Cloze question type ordering

by Pierre Pichet -

The actual moodle code

since MDL-10971 question type multianswer: Respect quiz shuffle option (19 Sep 2014)

give the following result that all thre types MC, MCV, MCH respect the quiz suffle.

shuffle on

and


off

The shuffling is  applied to all multichoice subquestions independently of  the individual subquestion shuffle setting. (1 for MC and 0 for MCH and MCV)

Our proposal offers complete flexibility.
In reply to Pierre Pichet

Shuffling in cloze questions

by Sonja Sperber -

Hi,


Our quizzes are comprised of multiple choice Cloze questions.

Sometimes its useful to shuffle the answers. 

In case e.g. of "yes-and-no questions“ we definitely don’t

want to shuffle.We use Moodle 2.9.1.


So I installed the plugin tinymce_clozeeditor. 

After doing so moodle did not recognize the MCO-option.


So I changed the files:

<MOODLEDIR>question/type/multianswer/edit_multianswer_form.php

<MOODLEDIR>question/type/multianswer/questiontype.php


according to:


https://github.com/moodle/moodle/compare/master...ppichet:MDL-38214


now the table quiz_question_intances is not found.

debugger tells:



Tabelle "quiz_question_instances" existiert nicht

Weitere Informationen über diesen Fehler

Debug info: 

Error code: ddltablenotexist

Stack trace: 

  • line 585 of /lib/dml/moodle_database.php: dml_exception thrown
  • line 1257 of /lib/dml/moodle_database.php: call to moodle_database->where_clause()
  • line 57 of /question/type/multianswer/edit_multianswer_form.php: call to moodle_database->get_records()
  • line 217 of /question/type/questiontypebase.php: call to qtype_multianswer_edit_form->__construct()
  • line 193 of /question/question.php: call to question_type->create_editing_form()



Can you get me started on how to let moodle shuffle answers in  particular multiple

choice questions in a quiz a disable shuffling for other questions

in the same quiz ?


Thanks a lot in advance!


Sonja 




In reply to Sonja Sperber

Re: Shuffling in cloze questions

by AL Rachels -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Hi Sonja,

If I'm not mistaken, to get multiple choice to shuffle and other types to not shuffle, you will need to upgrade to Moodle 3 so that you can take advantage of the 3 new Cloze multiple choice sub-questions. You can find more info here: https://docs.moodle.org/30/en/Embedded_Answers_%28Cloze%29_question_type

In reply to AL Rachels

Re: Shuffling in cloze questions

by Sonja Sperber -

To whom it may concern...


here is a solution I found...

If I only implement the changes for "question/type/multianswer/questiontype.php"

according to https://github.com/moodle/moodle/compare/master...ppichet:MDL-38214 (and leave out the changes for question/type/multianswer/edit_multianswer_form.php)  it works for me. I can take "MCHS" for unordered and MCO for 

ordered answers in Multiple choice questions and compose a test out of it (under Moodle 2.9.1). If there are risks let me know but so far it works ...


Cheers

In reply to Pierre Pichet

Re: Cloze question type ordering

by t k -

Hey Pierre,

It's really great that MDL-38214 is fixed but after 3.0 upgrade this has created a lot of problems with quizzes that have had a lot of MC type of cloze questions. Many teachers have just marked the first choice as the correct one because they know MC will shuffle the choices. It's a hassle to fix these manually or in the database. Would it be possible to create a same kind of tool as the 'Assignment upgrade helper' is?

In reply to t k

Re: Cloze question type ordering

by Pierre Pichet -

Would it be possible to create a same kind of tool as the 'Assignment upgrade helper' is?

Probably yes but being first a chemist and not a computer expert, I don't have the competence to create such a tool.

Sorry

Pierre


In reply to Pierre Pichet

Re: Cloze question type ordering

by t k -

Ok.

For anyone else having the same problem, you have to change two things in the database for the shuffle to work. First in mdl_question 'questiontext' change MULTICHOICE to MULTICHOICE_S (MC to MCS) and also in mdl_qtype_multichoice_options change 'shuffleanswers' to 1 for questions with the same questionid number. Admin replace tool works for the first part but you still have to turn the shuffle on in the database.

Average of ratings: Useful (1)