## Quiz

I have been uploading GIFT format questions and the default setting for "shuffle" has been set to "no". Is there a way to set it to "yes"?

Average of ratings: -
Here is what I did for Moodle 1.6.3+ - these are from my customization notes:

1. Question – Shuffle Answers Default changed to true for GIFT Import to allow imported questions to be shuffled. I have requested this be changed in Moodle core (bug #6768). Further I have requested that GIFT format be expanded to allow for this option to be specifically set during import and export (bug #6769)

a. \question\format.php

i. change line 179 from

1.  $question->shuffleanswers = 0; ii. to 1.$question->shuffleanswers = 1;

Average of ratings: -

Hi

The default to not shuffle answers is a pain when you have hundreds of questions to write. Looking back through posts it says you can change the default by editing the file mod.html in moodle/mod/quiz. Is this the only file our administrator would need to edit, so that all questions (uploaded from file or created manually) would show Shuffle Answers with YES by default?

regards

Paul

Average of ratings: -
If I am not mistaken, the default for mod.html is to have the value default to shuffle-able. The file you need to change for importing questions is the format.php as I have described above. Then the behavior is consistent to allow a matching question to be shuffle-able by default. AFAIK, mod.html is for the user interface and does not factor in to the equation when importing questions. Peace.

Average of ratings: -
Please correct me if I'm wrong, but to my knowledge, there are only two places to set "shuffle questions."  One is in the site settings under/modules/activities/quiz and the other is the first screen when creating an instance of a quiz.  When you are importing items, regardless of how you do it, you there is no way, nor any reason to specify how questions or choices are sorted.  That's done at a different step in the quiz creation process.

Average of ratings: -
You are correct, there are 2 options using the Moodle interface for setting the value. On the question level whether an individual matching question is shuffle-able and the other in the quiz as to whether or not to shuffle the shuffle-able questions. When importing questions however, the shuffleanswers in the mdl_questions_match table defaults to false because that is what format.php currently sets it to. I believe it should default to true because that is what happens by default when using the Moodle user interface to create a matching question. If you agree please vote for MDL-6768. It is a quick and easy patch that will IMHO make the default import behavior consistent with the default creation behavior. Otherwise, a person importing questions from GIFT (and I tend to create mine in GIFT) has to manually go in and change each matching question to allow shuffling via the Moodle user interface.

Average of ratings: -
Mmm...

I think you are right. Unless anybody objects I will change it to default on. This will affect all import formats not just GIFT of course.

Average of ratings: -
Why not set it to $CFG->quiz_shuffleanswers? Average of ratings: - Re: Shuffle answers default of no for GIFT upload Errr..... that's so obvious it's frightening Average of ratings: - Re: Shuffle answers default of no for GIFT upload Tim and Howard - Being somewhat of a perfectionist, I think it should be both. In other words, I believe that we should have a variable and change the default value of the question->shuffleanswers variable. The default behavior IMHO ought to have$CFG->quiz_shuffleanswers set to 1; however, I am wondering if the variable ought to be $CFG->question_shuffleanswers to be consistent. Since we are really referring to the question's ability to be shuffled rather than the quiz's option to actually shuffle the answers. Peace - Anthony. Average of ratings: - Re: Shuffle answers default of no for GIFT upload Another thought I have is whether this should be a site variable or a course variable? Allowing each teacher to change the value for their particular course may be better and provide greater flexibility. Average of ratings: - Re: Shuffle answers default of no for GIFT upload I must admit, I'm not terribly up on this 'global' shuffleanswer function. Are you saying that is cannot be changed anywhere - I can't see anywhere to change it at a quick glance. Average of ratings: - Re: Shuffle answers default of no for GIFT upload It is not clear where Tim is thinking of assigning the CFG->quiz_shuffleanswers variable. This can be accomplished either (and I think preferably) through the administration GUI (what was previously /admin/configvars.php in version 1.6) or directly in the config.php file as a required variable. I am raising a follow up question as to whether it is better for it to be a site variable or a course variable. I think making it a course variable would provide greater flexibility. I am also questioning whether the naming of the variable would not more accurately be questions->shuffleanswers rather than quiz_shuffleanswers because we are talking about an option for the question. It really is a question option/variable and not a quiz variable. Both the quiz and lesson modules could check to see whether a particular question is set to be 'shuffle-able'. When Tim gets a chance, hopefully he will be able to shed some light on this. Peace - Anthony Average of ratings: - Re: Shuffle answers default of no for GIFT upload Yes, sorry - I mostly understood that. I just wasn't sure if it was a "user" option anywhere other than the setting in configvars, or indeed if Tim is thinking of adding this possibility. Anyway (maybe this prompted your post), I updated the code in 1.7+ and HEAD to use this setting. If this needs to change, please let me know! Average of ratings: - Re: Shuffle answers default of no for GIFT upload The code in /question/format.php is fine. The problem is, where is it defined? I would immediately suggest adding it as a variable to /config-dist.php or having a place for it to be set. If it is to be obscure at the very least it needs to be defined as a default value in mdl_config. My point being, we want to make sure that with the change you have checked in that users will not get an undefined variable when /question/format.php is called. Average of ratings: - Re: Shuffle answers default of no for GIFT upload Is that a possibility? It is curently defined in mod/quiz/defaults.php. Is there a possibility of that not getting called (using the questionbank code from somewhere other than the actual quiz module)? I would be easy enough to wrap the code in question/format.php in a check to make sure it is defined. Average of ratings: - Re: Shuffle answers default of no for GIFT upload Oh, in my inexperience, I missed where it was being defined which is an example of where having the changes made in CVS listed on the tracker report would be helpful. So the code should be OK. I better understand now what your change is doing - which is setting the question->shuffleanswers value to whatever the default value is for the quiz->shuffleanswers and thus making the two consistent and configurable for the site. In my mind, I was thinking that quiz->shuffleanswers was new but the light bulb finally went off and made the connection. The next step would be to allow it to be configured per course or perhaps per instructor but that is a task for another day. Thanks for your work on this and patience with me. Peace. Average of ratings: - Re: Shuffle answers default of no for GIFT upload Until Tim mentioned it many posts back I didn't know it existed either Average of ratings: - Re: Shuffle answers default of no for GIFT upload Bumping this one because I think there should be some freedom for teachers in this. Doing imports - which is the way I often do quizzes - means not having any choice at all. And since I often have questions with a fixed and repeating set of answers, shuffling them is not desirable. Some options: 1. Allow the setting to be teacher or course specific. 2. Allow the setting to be specified in GIFT format. 3. Allow the setting to be easily changed in the Editing Quiz screen. Oh, and the same should go for the numbering option. Average of ratings: - Re: Shuffle answers default of no for GIFT upload John - It has been a long time since I looked at this code. Could you tell me what you are experiencing and what you would like to happen. As for the options, lets handle it one at a time. Ideally, I would like to see these as tracker requests and let me know and I will see if I can work up a patch. Thanks for the bump as this had fallen off my radar. Peace - Anthony Average of ratings: - Re: Shuffle answers default of no for GIFT upload I thought this was resolved However, things have moved on a bit in the code. I'll take a look and report back. Average of ratings: - Re: Shuffle answers default of no for GIFT upload Howard - If it is in fact resolved, that would explain why it fell of my radar Thanks for following up on this. Peace - Anthony Average of ratings: - Re: Shuffle answers default of no for GIFT upload I am still using a very old moodle and GIFT import. I can't seem to find where a shuffle answers setting became part of the GIFT import format, or where the default is set when importing. There is no mention of the word "shuffle" in this change log. http://cvs.moodle.org/moodle/question/format/gift/format.php nor instance of the string in the what appears to be the latest version of gift/format.php Hmm...I have shuffle answers set to on in my administration settings, but that is for the quizes and not for the questions. Now that questions is seperate from quiz, it would be nice if it had its own Administration Configuration Questions. Or perhaps it does these days. I know from this thread that respondus import format.php does include a shuffle answers setting as of March this year. I am thinking of including$question->shuffleanswers = 1;
or even to use the brainwave of Tim Hunt
$question->shuffleanswers =$CFG->quiz_shuffleanswers;

Just before the
//$question->defaultgrade = 1; //$question->image = "";   // No images with this format

Which is also in my much older version.

The code to import multiple choice questions is below, with the suggested change.

BUT id did not work!

Could not insert quiz multichoice options!
 An error occurred during import processing

However
$question->shuffleanswers = 1; does seem to work okay case MULTICHOICE: if (strpos($answertext,"=") === false) {
$question->single = 0; // multiple answers are enabled if no single answer is 100% correct } else {$question->single = 1;   // only one answer allowed (the default)
}

$answertext = str_replace("=", "~=",$answertext);
$answers = explode("~",$answertext);
if (isset($answers[0])) {$answers[0] = trim($answers[0]); } if (empty($answers[0])) {
array_shift($answers); }$countanswers = count($answers); if (!$this->check_answer_count( 2,$answers,$text )) {
return false;
break;
}

foreach ($answers as$key => $answer) {$answer = trim($answer); // determine answer weight if ($answer[0] == "=") {
$answer_weight = 1;$answer = substr($answer, 1); } elseif (preg_match($gift_answerweight_regex, $answer)) { // check for properly formatted answer weight$answer_weight = $this->answerweightparser($answer);

} else {     //default, i.e., wrong anwer
$answer_weight = 0; }$question->fraction[$key] =$answer_weight;
$question->feedback[$key] = $this->commentparser($answer); // commentparser also removes comment from $answer$question->answer[$key] =$this->escapedchar_post($answer);$question->correctfeedback = '';
$question->partiallycorrectfeedback = '';$question->incorrectfeedback = '';
// $question->shuffleanswers =$CFG->quiz_shuffleanswers; //Takemoto did not work
$question->shuffleanswers = 1; //Takemoto, set to shuffle //$question->defaultgrade = 1;
//$question->image = ""; // No images with this format return$question;
break;

Tim

Average of ratings: -

Yes. that seems to work okay.

I am not sure why it is not in there already. Perhaps no one uses GIFT any more!? Or perhaps lots of people are THINKING that their tests are being shuffled when in fact (if they have imported them via GIFT in the past couple of years) then they are not. Or am I the only person that dim.

Should I file a bug report? Searching the bugtracker I realise that I did create a bug for this MDL5377. The conclusion in MDL5369 was to create a post-plugin question/format.php which is referenced in this thread. But there now appears to be no such thing as question/format.php  (although it is still mentioned in the only file question/readme.txt).

Perhpas the default for the shuffling of questions is now controled by some nifty "Aministration >  questions" interface that I know nothing of.

Where has the uber format.php gone to?

I hope everyone is well.

Tim

Average of ratings: -
question/format.php still exists. http://cvs.moodle.org/moodle/question/

The most likely reason your change failed is that you forgot to add
global $CFG; to that function. (I do that all the time ) Average of ratings: - Re: Shuffle answers default of no for GIFT upload Thank you Tim I was looking in the wrong place. It is still at (in my install) line 179$question->shuffleanswers = 0;
I could have just changed that.

global $CFG ah. Yes. That is what I needed to do . Until there is a way of setting the defaults in format.php via the admininstration then I think that your suggestion in this thread, above is a good one. function defaultquestion() { // returns an "empty" question // Somewhere to specify question parameters that are not handled // by import but are required db fields. // This should not be overridden. global$CFG;
$question = new stdClass();$question->shuffleanswers = $CFG->quiz_shuffleanswers;$question->defaultgrade = 1;
$question->image = "";$question->usecase = 0;
$question->multiplier = array(); return$question;
}

Average of ratings: -
Well, in Moodle 2.0 there is finally an admin screen for question types, and the potential for different question types to have their own settings, so we could add a page where you can choose default multiple choice question options (but no one has implemented it yet).

Perhaps we also need an admin page for import/export formats at some point.

Or, are you talking about question-type specific settings while you are importing, so you can set options like multichoice shuffle answers for just one import? That would be nice too, but some work.

Average of ratings: -
I had thought about import/export formats having their own "configuration" page that is loaded as a second step in the process if it is defined. That would allow for more finely-grained control.

Average of ratings: -
That would be great if you have the time.

Would need quite a lot of rework in the formats, but no harm in that in the 2.0 or 2.1 time-frames.

Average of ratings: -
"if you have the time"

Well, I'm not going to promise anything

Average of ratings: -

Thanks Tim, hi Howard

Waffle.

A configuration page for questions as a whole sounds fine for me (I only use GIFT).

If there were to be a configuration page for seperate formats then I would rather that it were not a *step* in the process. If a configuration page exists then I'd like it to exist as a seperate configuration page (accessable from the questions configuration page presumably).

But then....no...

I am the sole user of my moodles. Most moodles have an administrator and teachers that can not access the administration pages.

And I am using a very old moodle. In more recent moodle versions one can specify the category in the GIFT file so there is no need for a lot of GIFT file imports.

When I am creating a ten question test, I create ten categories, then import  a gift file containing two or three question-variations into each of those categories, and form the quiz by adding a random question from each of those categories. With the inclusion of category specification and creation (I presume) in the GIFT format, then there is only the need to upload one GIFT file and have it create and populate the ten different categories. (Does GIFT category specification/creation exist in 1.6 stable, I wonder).

All the same, extra *steps* are not ideal. So, perhaps, like on the quiz settings page, an "advanced settings" button might be included on the import page, for teachers to set whether they want e.g. shuffleanswers to be on or of.

This is entirely theoretical because I can't seem myself upgrading even into 1.7. because (apart from the modules/hacks I would loose) I am scared of the speed penalty (and complexity) of roles.

As a language teacher, I use high speed vocabulary tests. Vocabularly tests need to be high speed otherwise the student can use a dictionary as they answer the test. There is no meaning to slowly accessed vocab skill (vocab is a skill, not a knowledge). Even on my 1.6.x speed is an issue especially when there are a lot of students using the moodle. I would like to be able to set 30 or 40 seconds for the time that students can take to answer the test, but when it takes a few seconds for the page to display, and a few for the results to reach the server then this becomes very problematic.

I wish that  I knew how much slower a 1.9 or 2.0 is compared to a 1.6 stable. Perhaps there is little speed penalty.

Tim

Average of ratings: -