Quiz development: Random Questions/Answers

Quiz development: Random Questions/Answers

by Petronel Postolache -
Number of replies: 2

Anyone working on this or already done?

 

Average of ratings: -
In reply to Petronel Postolache

Re: Quiz development: Random Questions/Answers

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Yes. Someone recently hired me to write some code related to this that will be available in the next release. You can see some of it in the current CVS.

There is a new "Random Match" question type that randomly picks from among the "Short Answer" questions in the same category to build "Matching Questions" (eg four questions at once with four answers that need to be matched). The client had 30,000 existing short-answer questions which can now be imported and implemented using this method.

There will also be a "Random Multiple Choice" question type that will simply choose one of the existing "Multiple Choice" questions (random for each quiz attempt).

There will also be a quiz option to jumble up the order of questions in a quiz each time it is attempted.
In reply to Martin Dougiamas

Re: Quiz development: Random Questions/Answers

by Petronel Postolache -

I found something very easy that satisfy my needs. Shuffle the order of displaying answers.

I just changed mod/quiz/lib.php line 487 to:

$answerids = explode(",", $options->answers);
//shuffle answers order
srand ((float)microtime()*1000000);
shuffle ($answerids);

foreach ($answerids as $key => $answerid) {

To shuffle the order of questions just add:

shuffle ($questions);

after
$questions = explode(",", $quiz->questions);