Modifying Lesson code to not randomize multi-choice answers

Modifying Lesson code to not randomize multi-choice answers

by Ellen K -
Number of replies: 11
I know this is a frequently mentioned topic in this forum. I know the Lesson format does not currently allow unrandomizing the Multi-Choice question answers and that this could be worked around using Quiz. However, the Lesson format is more suitable to my needs.

Can someone give me some pointers on what code to modify to unrandomize the order of questions within the multiple choice questions in a Lesson?

Thank you so much in advance.
Average of ratings: -
In reply to Ellen K

Re: Modifying Lesson code to not randomize multi-choice answers

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Very easy, in file mod/lesson/view.php, simply comment out line 612 (in current moodle 1.9.7 version)
case LESSON_MULTICHOICE :
$i = 0;
//shuffle($answers);
foreach ($answers as $answer) {...
Average of ratings: Useful (1)
In reply to Joseph Rézeau

Re: Modifying Lesson code to not randomize multi-choice answers

by brian avery -
Hi,

I tried exactly this, as suggested, using 1.9.9+ on windows and it made no difference at all but then I realised this says multi-choice. What do I alter to make the same change for multiple choice questions (one of three answers only is correct)? Or is multichoice the same thing?

Brian
In reply to brian avery

Re: Modifying Lesson code to not randomize multi-choice answers

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

Brian,

Just tried the hack I had suggested on a 1.9.9 version of Moodle and it works as advertised. In the user interface this question type is called "Multiple choice", but in the php files it's referred to as LESSON_MULTICHOICE.

The "recipe" I gave has not changed:

in file mod/lesson/view.php, simply comment out line 612:

case LESSON_MULTICHOICE :
$i = 0;
//shuffle($answers);
foreach ($answers as $answer) {...

Joseph

In reply to Ellen K

Re: Modifying Lesson code to not randomize multi-choice answers

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

Hello Ellyn Kao,

Did my answer of Wednesday, 16 December 2009 help you at all with your randomize problem?

In these forums, many of us "Moodle helpers" like to help users with their problems, but we also like to have some feedback and know that the time spent looking for a solution was time well-spent.wink

Providing feedback when you have been helped is not only gratifying for the "helpers", it also encourages them to continue their work.

All the best,

Joseph

Average of ratings: Useful (1)
In reply to Joseph Rézeau

Re: Modifying Lesson code to not randomize multi-choice answers

by Ellen K -
Joseph,

I apologize for not seeing your answer. I had disabled email notification since I was on vacation smile

It looks like it might be exactly what I need. I'll log in to the code files later and see if I can do as you instructed.

Many many thanks for providing detailed technical instructions. This may save a lot of headache for us.

Ellen
In reply to Ellen K

Re: Modifying Lesson code to not randomize multi-choice answers

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
That's fine, Ellyn, I sometimes tend to forget that people cut off their link to the Web when they go on vacation.wink
Please keep us posted when you get my hack to work.
ATB
Joseph
In reply to Joseph Rézeau

Re: Modifying Lesson code to not randomize multi-choice answers

by Ellen K -
Joseph,

I went in to the lesson/view.php file as you had instructed and commented out the one line. Voila! It worked exactly as needed. smile

Many thanks for sharing your expertise on this matter. I had seen the same question asked by others before, but no specific fixes.

Ellen
In reply to Ellen K

Re: Modifying Lesson code to not randomize multi-choice answers

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Ellen,
I'm glad it worked for you,
ATB
Joseph
In reply to Ellen K

Re: Modifying Lesson code to not randomize multi-choice answers

by Edward Beckmann -
Hi

Funnily enough I did this mod the other day as well (do note that there are a few similar lines of code for different types of question - you can comment them out if you like as well).

Anyway, I have a note to try 2.0 when on general release and if that does not have a lesson setting to turn on and off randomising answers, We will add that mod as a setting as well.

We would do it as a global switch (i.e. either the lesson shuffles or it does not) for all types of question that are in it.

All the best

Ed
In reply to Edward Beckmann

Re: Modifying Lesson code to not randomize multi-choice answers

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Edward,
Could you please enter a bug report in the tracker asking for this new feature to be added to forthcoming moodle 2.0 version?
thanks
Joseph
In reply to Joseph Rézeau

Re: Modifying Lesson code to not randomize multi-choice answers

by Edward Beckmann -
happy to - I'll get onto it. Seems that someone has suggested one and the same as bug #18070 (http://tracker.moodle.org/browse/MDL-18070) so I have added my support for it. Anyone else who has followed this thread, please add your votes / comments.

Thanks for suggesting it Joseph, I missed it the first time round.

Ed