In moodle 1.6, the default add page for multiple choice type questions had four choice, which is about the standard required for MCQ's. In moodle 1.8, i find that the options have been reduced to 3, with options to add 3 more at a time.
When we make a quiz of 50 questions, clicking on 'Blanks for 3 more choices' is too frequent and could be reduced by changing the default display to show 4 choices.
Would appreciate if someone guided on what editing needs to be done to change this.
TIA
define("QUESTION_NUMANS_START", 3);
and
define("QUESTION_NUMANS_ADD", 3);
Tim,
Thank you! My colleagues are amazed that I can change these things for them in Moodle. I am completely clueless, though, without the knowledge you and others so freely share.
bill
We now have an admin who actually knows what he's doing when he tinkers around with moodle. Happy day for me, although I do feel a bit like the "outsider" now!
Thanks again for your help.
bill
I have been looking and cannot find the area
where can add the the code:
In lib/questionlib.php, near the top:
define("QUESTION_NUMANS_START", 3);
and
define("QUESTION_NUMANS_ADD", 3);
to increase the number of options.
thank-you: Albert
this is in moodle 1.8 only, file moodle/lib/questionlib.php line 66.
Joseph
Thanks
Albert
Tim,
that modification of code works great but is there a way for a user to enter in how many they want to add? I'd like to change it to a higher value but the majority of our users wouldn't want 10+.
Is there a way to enter in the value wanted or even a work around via modifying the URL?
On another note, when I add more blanks but I don't fill out some, they are still there. Is there a way to remove a choice if I decide I didn't need to add more?
Thanks!
Oleg was working on letting the user specify how many choices they wanted, rather than having to click add more choices repeatedly. Unfortunately, I kept being too busy to review his code or help him, so it never got finished. It is still a good idea.
Any choices you don't want, just leave blank. Blank choices are ignored.
That's exactly what our issue is. We have a few teachers who continually add to the "acceptable answers" list when students enter in answers that are correct but are not "exactly" right. They have a very very long list and keep adding. When they add theyare adding a bunch at a time.
Each time they add "3 more" the page takes forever to load because of all of their "Acceptable answers". So, if they were able to add or choose 15 or 20 at a time they would only haveto wait for the page ot load once, instead of 5-6 times.
The code you gave in that questionlib.php worked for me, and it would help them out if I changed it to 15 but the issue is that all of the other teachers who would only want maybe 2 more or 3 more would be forced to add 15 more blanks - meaning 13 blank records loading and adding a bunch of boxes that can't ever remove!
I wonder if there is a way to duplicate the button and have a choice from 3 or 15..?
I'm looking in the Quiz in 2.0 and theer doesn't seem to be any improvements that would help me, however I did see a development wiki page on moodle docs that talked about javascript and making it so you don't have to refresh the page when you add more blanks..ugh, i can't find the link now..I have no idea if that was in develpment for future releases or what.
(I hope that made sense!)
No, there are no changes in Moodle 2.0 in this area.
Over the years, there have been a lot of changes to all the other parts of the quiz and question system, but that leaves the question editing forms as the oldest and most unloved part of the system now, and it shows. (Fingers crossed, one of the other OU developers may get some time to work on this soon.)
Sadly, the way it works, the number of extra fields to add is set in the PHP code. In a parallel universe, there might be some hidden form-field in the HTML to say how many fields to add, but sadly it does not work like that.
The code that affects this is in the add_per_answer_fields method in question/type/edit_question_form.php. The simplest suggestion I can think of which would slightly decrease the number of clicks for you users would be some code there, perhaps
$addoptions = max($addoptions, $repeatsatstart);
before the $this->repeat_elements( ... line. That would cause each button click to double the number of answers.
(The bug about Oleg's changes is MDL-17064 if you want to take a look.)
Great, thanks for the information (although not what I wanted to hear :P)
I'm still a bit confused on the "$addoptions = max($addoptions, $repeatsatstart);" in "question/type/edit_question_form.php." though. What exactly would I be doing there? It looks like that is doign the same thing as below:
In lib/questionlib.php, near the top:
define("QUESTION_NUMANS_START", 3);
and
define("QUESTION_NUMANS_ADD", 3);
I tried the above code to 5 and it works but I'd like to change it to 10. However, I would like to keep the "$minoptions" to 3, so when someone adds 10, saves it, it will only show 3 blanks at the most next time. I do not know if this is possible as I see the two variables are tied together?
I tested the $addoptions = max($addoptions, $repeatsatstart); (in /type/edit_question_form.php) and I now understand better what this is doing.
I think this may be an even better way of accomplishing what we need, because even though it may potentially scary for users to add so many blanks - after it's saved it will only have the default (3 or 8 in my case) blanks the next time.
Thanks!
Just making sure this still works in 2.4...or if there are any changes? thanks!
Yes, those two constants still control things in Moodle 2.4.
Hey Tim, I just wanted to make sure thatt he following will increase the 'add 3 blanks' to 'add 8 blanks' for the short answer:
In lib/questionlib.php, near the top:
define("QUESTION_NUMANS_START", 8);
and
define("QUESTION_NUMANS_ADD", 8);
We're using version 1.9.9+. Should it be in lib/questionlib.php or the question, type folder like your other post? Just want to be sure before I change it. I've tested on my other testing environment and it seems okay. Thanks!
Yes, those are the constants to change. I recommend that you make a copy of questoinlib.php before you start editing, so you can easily get back to the original version if anything goes wrong.
And, if you do that, it should be quite safe to experiment with different values as see what effect they have.
Great, will do!
One final question, if I change the "Q_N"ADD"to "8" and the "Q_N_START" to "3" will it add 8 and then once saved, and then opened it will only show 3 blanks instead of 8?
define("QUESTION_NUMANS_START", 3); <---- if not all 8 blanks are inputted w/ a value, the next time it will only show 3 blanks?
and
define("QUESTION_NUMANS_ADD", 8);
I've tested this and it doesn't seem to work that way, but it looks like it should.
What is going on is that the number of answers shown on the form is the larger of
- QUESTION_NUMANS_START
- (The number of answers already there) + QUESTION_NUMANS_ADD
So, even if (The number of answers already there) is 0, if QUESTION_NUMANS_ADD > QUESTION_NUMANS_START then QUESTION_NUMANS_START will be ignored.
It seems like there has to be a way to get to the end result I want but that does make sense, thanks!
And the below code means...? It seems like the comments describe this as the same as the other two ones?
/**
* Constant determines the number of answer boxes supplied in the editing
* form for multiple choice and similar question types.
*/
define("QUESTION_NUMANS", "10");
That was used in Moodle 1.7 and before. We should probably delete it now.
You can get what you want, but only by hacking the code in question/type/question_edit_form.php, which is a bit scarier than just changing some contstant values. I think the method to chagen is add_per_answer_fields, or something like that. Sorry, I closed my editor so I don't have the code in front of my at the moment.
Also, if there was a tracker issue regarding improvements in adding more blanks. Looks like it works with Modle 2 but it's annoying having all of the extra blanks each time. If not I'd like to start one but not quite sure how to word it.
I don't know if there is a tracker issue for this yet, but I think we will get rid of the extra blank boxes as part of the question editing form changes we are doing for Moodle 2.5.