Cloze multiple choice always displaying correct answer first.

Cloze multiple choice always displaying correct answer first.

by Mark Iannone -
Number of replies: 21

I am using Moodle 3.03 and one of my Chem 12 students has informed me that the clozed multiple choice questions always show the correct answer at the top of the drop down list. The students know to take the top answer and it will be correct every time. I am not sure how long this has been going on. I checked about 10 quiz questions and confirmed this to be true. Is this a known issue with Moodle 3.03? I am going to upgrade to 3.1 and I hope that this issue will be corrected.

Thanks in advance for any help,

Mark Iannone

Chemistry Teacher

Average of ratings: Useful (2)
In reply to Mark Iannone

Re: Cloze multiple choice always displaying correct answer first.

by John Provasnik -
Picture of Particularly helpful Moodlers Picture of Testers

The answer choices do appear to shuffle for me on 3.1, but I don't know how they were created or set up, so I'll just point to the Cloze Docs until someone else has something more useful:

  • When the quiz question behavior shuffle option IS SET YES, the following multiple choice sub-questions elements will be shuffled,
  • multiple choice (MULTICHOICE_S or MCS), represented as a dropdown menu in-line in the text,
  • multiple choice (MULTICHOICE_VS or MCVS), represented as a vertical column of radio buttons, or
  • multiple choice (MULTICHOICE_HS or MCHS), represented as a horizontal row of radio-buttons.
Note: MCS, MCVS, MCHS are new (Moodle 3.0) Cloze subquestion types with shuffling of answers. See MDL-38214.

In reply to Mark Iannone

Re: Cloze multiple choice always displaying correct answer first.

by Mark Iannone -

I have now upgraded to Moodle 3.1+ and I have the same problem. I made two new questions, one with the cloze editor and both show the correct answer first. The question formats are below:


The sky is {1:MC:=blue~geen~red~brown}

The answer blue is always first. 


The sky is {1:MULTICHOICE:%100%Blue#~%0%Red#~%0%Green#~%0%Brown#}

The answer blue is always first.

I tried this on two different moodle 3.1+installs with the same results. 

In reply to Mark Iannone

Re: Cloze multiple choice always displaying correct answer first.

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

I would like to point out however that this was always the behavior of cloze questions and it is not that the correct answer is always placed first, it is that the correct answer has always been placed first in the question creation according to the examples above.  It was possible before the invent of CLOSE shuffling to change the order by changing the order of the answers in the question text originally.

In reply to Emma Richardson

Re: Cloze multiple choice always displaying correct answer first.

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

This really is a bug. Before the behavior of MULTICHOICE matched the current behavior for MULTICHOICE_S. The name was changed and a new behavior was developed for MULTICHOICE. Existing questions that were not designed to be unshuffled are now because the syntax for describing a shuffled question changed.

I think that this was not evident at first because of the way the questions are stored. The new behavior would not be evident after a system upgrade, but only after copying or editing a question. This forces them to be parsed again with the new rules.

One fix is to revert the effect of MULTICHOICE to the original by editing the source here by changing all the values for shuffleanswers from 0 to 1. This will have the backward compatible syntax, but may require reloading al the questions to take effect.

In reply to Daniel Thies

Re: Cloze multiple choice always displaying correct answer first.

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

It's not that simple. This was considered when this change was implemented. If you find the tracker issue, it was discussed a lot.

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

Re: Cloze multiple choice always displaying correct answer first.

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

Sorry that was a really much more complicated. I think I understand whey the syntax was changed now. However all the questions of this type really need to be reviewed now. I put together an SQL query for Configurable reports that finds all questions with unshuffled MC subquestions and provides links to test and edit them. 

SELECT DISTINCT
COALESCE(cc.instanceid, m.course) AS courseid,
qc.name AS categoryname,
CONCAT('<a target="_new" href="%%WWWROOT%%/question/preview.php?id=',
parent.id,
CASE WHEN (cm.instanceid IS NULL) THEN '' ELSE CONCAT('&cmid=',cm.instanceid) END,
'">',parent.id,'</a>',
' <a target="_new" href="%%WWWROOT%%/question/question.php?courseid=',
COALESCE(cc.instanceid, m.course),
CASE WHEN (cm.instanceid IS NULL) THEN '' ELSE CONCAT('&cmid=',cm.instanceid) END,
'&id=',parent.id,'">Edit</a>') AS question,
parent.questiontext
FROM prefix_question parent
JOIN prefix_question child ON child.parent = parent.id
JOIN prefix_question_categories qc ON qc.id = parent.category
LEFT JOIN prefix_context cc ON qc.contextid = cc.id AND cc.contextlevel = 50
LEFT JOIN prefix_context cm ON qc.contextid = cm.id AND cm.contextlevel = 70
LEFT JOIN prefix_course_modules m ON m.id = cm.instanceid
WHERE child.qtype = 'multichoice'
AND parent.qtype = 'multianswer'
AND child.qtype = 'multichoice'
AND (child.questiontext LIKE '{%:MC:%'
OR child.questiontext LIKE '{%:MULTICHOICE:%'
OR child.questiontext LIKE '{%:MCV:%'
OR child.questiontext LIKE '{%:MULTICHOICE_V:%'
OR child.questiontext LIKE '{%:MCH:%'
OR child.questiontext LIKE '{%:MULTICHOICE_H:%'
)
ORDER BY courseid, categoryname, question
In reply to Mark Iannone

Re: Cloze multiple choice always displaying correct answer first.

by Mark Iannone -

I have now tried the cloze code on 3 different servers and on 4 different Moodles (all 3.X) that I have access to and have found the same thing. I put in the following question

Match the following cities with the correct state:
San Francisco: {1:MULTICHOICE:=California#OK~Arizona#Wrong}
Every time I preview California is listed first on the drop down menu. 

I am hoping that someone can fix this before my final exams in 2 weeks. Thank-you in advance for any help you can provide. 

Mark Iannone

Chemistry Teacher

Attachment cloze.PNG
In reply to Mark Iannone

Re: Cloze multiple choice always displaying correct answer first.

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

Hi MArk,

Starting in Moodle 3.0, you have to set your cloze type questions for shuffle in the question itself. So your example should be:

Match the following cities with the correct state:
San Francisco: {1:MULTICHOICE_S:=California#OK~Arizona#Wrong}
Please note the _S that is added to MULTICHOICE.

Check here for more info: https://docs.moodle.org/31/en/Embedded_Answers_%28Cloze%29_question_type#Format

Note the last three example formats. I can verify, these do work on my Moodle 3.1.

Another note: If I remember correctly, when editing questions in the question bank, if you preview a cloze question it does NOT shuffle. The shuffle occurs only in a quiz. A quick test shows that this is still true, at least for me.

Average of ratings: Useful (3)
In reply to AL Rachels

Re: Cloze multiple choice always displaying correct answer first.

by Mark Iannone -

Thank-you very much AL! You are correct, I tried it on one question and even the preview was shuffled. Now I need to go through 3 or 4 hundred questions and make the changes. 

Thanks again,

Mark Iannone

Chemistry Teacher

In reply to Mark Iannone

Re: Cloze multiple choice always displaying correct answer first.

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

Hi Mark,

Sorry to hear you have that many to fix. Back when I discovered this, I only had about 30 of them to fix.  thoughtful

Might be worthwhile to try and figure out how cloze questions are stored in the database and try to add _S or S as needed using adminer or phpMyAdmin. Sorry to say, after a quick look, nothing leaped out at me as to which table they might be in.

Might also be worthwhile to export them, add the _S or S as needed in the question file, them import them back into Moodle. Probably would be much faster than waiting for all the page loads needed to do the changes to that many manually.


Average of ratings: Useful (2)
In reply to AL Rachels

Re: Cloze multiple choice always displaying correct answer first.

by Andrew Barrett -

Oh man. We're also been caught out by this. Thanks Mark for this post and Al for your suggested remedies. We've got 1000s of these questions types. Will definitely need to write a script or similar to rectify - will share once complete. 

If anyone else has already done so, please do share your process. 

Many thanks.

Andrew

In reply to Andrew Barrett

Re: Cloze multiple choice always displaying correct answer first.

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

It should be a pretty simple sql script updating the questiontext field in the mdl_question table.

In reply to AL Rachels

Re: Cloze multiple choice always displaying correct answer first.

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

I would not expect changing the question text in the database to be an easy fix to the problem. The questiontext is parsed into subquestions which are stored independently. The original text is stored as well. Updating it is one place would cause inconsistency because a question text would be parsed if and only when that question is opened for editing and saved.

Exporting, editing and importing questions would not have this limitation, but it would not necessary be easy for large or mixed question banks.

It might be easier to revert the code at least temporarily.


In reply to Daniel Thies

Re: Moodle in English: Re: Cloze multiple choice always displaying correct answer first.

by Mark Iannone -
Hi,

If you revert the code some of us, like myself, have fixed the code already. I don't want to change it all back again.

Regards,

mark


From: "Daniel Thies" <noreply@moodle.org>
To: "Mark Iannone" <miannone@shaw.ca>
Sent: Monday, June 6, 2016 8:53:12 AM
Subject: Moodle in English: Re: Cloze multiple choice always displaying correct answer first.

Picture of Daniel Thies
Re: Cloze multiple choice always displaying correct answer first.
by Daniel Thies - Monday, 6 June 2016, 8:22 AM
 

I would not expect changing the question text in the database to be an easy fix to the problem. The questiontext is parsed into subquestions which are stored independently. The original text is stored as well. Updating it is one place would cause inconsistency because a question text would be parsed if and only when that question is opened for editing and saved.

Exporting, editing and importing questions would not have this limitation, but it would not necessary be easy for large or mixed question banks.

It might be easier to revert the code at least temporarily.



You can reply to this via email.


In reply to Mark Iannone

Re: Moodle in English: Re: Cloze multiple choice always displaying correct answer first.

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

Hi Mark,

I was suggesting making a temporary change to your site code until a better solution is available. I do not think it will be changed in the master.

In reply to Mark Iannone

Re: Moodle in English: Re: Cloze multiple choice always displaying correct answer first.

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

Hi Mark,

I was suggesting making a temporary change to your site code until a better solution is available. I do not think it will be changed in the master.

In reply to Daniel Thies

Re: Re: Moodle in English: Re: Cloze multiple choice always displaying correct answer first.

by Mark Iannone -
Right, thanks!


From: "Daniel Thies" <noreply@moodle.org>
To: "Mark Iannone" <miannone@shaw.ca>
Sent: Monday, June 6, 2016 10:29:24 AM
Subject: Moodle in English: Re: Moodle in English: Re: Cloze multiple choice always displaying correct answer first.

Picture of Daniel Thies
Re: Moodle in English: Re: Cloze multiple choice always displaying correct answer first.
by Daniel Thies - Monday, 6 June 2016, 9:58 AM
 

Hi Mark,

I was suggesting making a temporary change to your site code until a better solution is available. I do not think it will be changed in the master.


You can reply to this via email.


In reply to Mark Iannone

Re: Re: Moodle in English: Re: Cloze multiple choice always displaying correct answer first.

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

One possibility I had not considered before, but I just tested and it does seem to work...use the built in Moodle replace capability.

Since there is a definite pattern for how your Cloze questions are currently defined, you can search for and replace them. Just run replace for each of the possible patterns.

Do a backup first, of course, just in case.

I have a 3.1 test site I can give you access to if you want to try it out. Contact me via my email in my profile, if you want to try it. You could do a limited import of your questions to try it with. I only have five Cloze questions there at the moment, which makes it fairly easy to set them to no shuffle, run replace, then see they were all done/fixed.

Average of ratings: Useful (1)
In reply to AL Rachels

Re: Re: Moodle in English: Re: Cloze multiple choice always displaying correct answer first.

by Mark Iannone -

Thanks for everyone for the help and great suggestions. I managed to change my 3-4 hundred questions manually in a few hours. The questions that had many MC spots in them I used the replace function in the editor which was pretty quick. I was lucky that a student told me what was going on and  wonder how many other teachers are experiencing the same thing and are not aware of it. 

Cheers,

Mark Iannone

Chemistry Teacher

In reply to Mark Iannone

Re: Cloze multiple choice always displaying correct answer first.

by Teresa Heap -

Hi, I've been looking at this today as don't have access to the PHP code. I had a simple quiz with Yes/No drop down - I wanted it to always display Yes/No but Moodle was helpfully changing this to No/Yes when the answer was no. Here is the very simple code I ended up using to get round this. Actually can't believe how easy it ended up being so I hope this helps and saves someone else similar pain! smile

Coins are made of metal: {1:MC:=Yes~No}

Banknotes are sometimes made of potato peelings: {1:MC:Yes~=No} 


Basically put the '=' sign before the correct response and you can choose your order. If you want the answers to shuffle change the prefix to 'MCS'.