more than 10 answers in a question: a problem

more than 10 answers in a question: a problem

by nik pap -
Number of replies: 9
Hi everybody,
I am not a programmer but I have managed to make a slight code change so that instead of given an option of up to 10 answers to a question I can now have 10.
I did that by changing the value of
    define("QUIZ_MAX_NUMBER_ANSWERS", "10");
to
     define("QUIZ_MAX_NUMBER_ANSWERS", "50");
in the file quiz/lib.php

Now I can insert 50 questions but when they are presented they are numbered as such: a,b,c,d.....z. when they reach the last letter of the alphabet they go on showing some annoying artifacts which I think are the next ASCII or UTF characters:
.
.
.

z. Απάντηση 26

{. Απάντηση 27

|. Απάντηση 28

}. Απάντηση 29

~. Απάντηση 30

. Απάντηση 31

. Απάντηση 32

�. Απάντηση 33


.
.

How can I correct this problem?
Average of ratings: -
In reply to nik pap

Re: more than 10 answers in a question: a problem

by nik pap -
let me add that i am greek and 'Απάντηση' means 'Reply'
In reply to nik pap

Re: more than 10 answers in a question: a problem

by Julian Sedding -
In the file /mod/quiz/questiontypes/multichoice/questiontype.php find the line "$qnumchar = chr(ord('a') + $key);" and replace it with "$qnumchar = multichoice_safe_chr($key);". Additionally define the function multichoice_safe_chr at the bottom of this file (before '?>'). A possible function could look like this:

function multichoice_safe_chr($num) {
$returnvalue = '';
if ($num > 25) {
$newnum = (($num - ($num % 26)) / 26) - 1;
$returnvalue .= multichoice_safe_chr($newnum);
}
$returnvalue .= chr(ord('a') + ($num % 26));
return $returnvalue;
}

The above will continue with 'aa', 'ab', ... after 'z'.

Julian
Average of ratings: Useful (1)
In reply to Julian Sedding

Re: more than 10 answers in a question: a problem

by nik pap -
that was what i wanted. thanks
In reply to Julian Sedding

Re: more than 10 answers in a question: a problem

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Julian,

You might have noticed in a recent post there was a problem with the GIFT import format being restricted to 10 answers. Is this something for the to-do list to increase the number if editable answers from 10. There seems to be a steady number of people wanting more than that!
In reply to Howard Miller

Re: more than 10 answers in a question: a problem

by Julian Sedding -
Hi Howard,

I modified the match questiontype to display all defined answers plus one empty answer slot if QUIZ_MAX_NUMBER_ANSWERS (=10) is exceeded. E.g. if 10 answers are defined an additional 11th answer field is displayed. If you import a question with 30 answer (provided that gift relaxes this constraint) then 31 answer fields will be displayed.

Of course it would be ideal to provide a button on the editing page to add more answer fields, but that would envolve far more work and time.

Julian
In reply to Julian Sedding

Re: more than 10 answers in a question: a problem

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
So effectively I can simply take the check out of GIFT import and it will work fine?

I only just changed it to respect the constant big grin
In reply to Howard Miller

Re: more than 10 answers in a question: a problem

by Julian Sedding -
Right, I have made the same changes for multichoice and shortanswer as well now.
In reply to Julian Sedding

Re: more than 10 answers in a question: a problem

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I'm done.... checks taken out of GIFT format. All seems to work very nicely smile