Random Question Test

Random Question Test

بواسطة - Nate Nate
عدد الردود: 25
I'm building a quiz that has 25 Essay questions in a category built for that quiz.  And I want it to pull 5 random questions.  So I clicked on the drop down, clicked on 5, clicked Add.  It added the 5 Random questions to the test, but when I go to preview it I get this error...
The number of random questions required is more than this category contains! (923)

I built 4 other quizzes that have 45 random questions in them and I didn't have any problems with those.  The only difference is that the other 4 aren't pulling essay type questions in for the questions.  Thanks for any help.
متوسط التقييمات: -
رداً على Nate Nate

Re: Random Question Test

بواسطة - Anthony Borrow
صورة Core developers صورة Plugin developers صورة Testers
I'm not sure which version of Moodle you are using but AFAIK there was a patch the excluded the essay type question from being randomized. I would like to see this added back in so that they can be but currently you cannot count essay type questions as being available for random selection.
رداً على Anthony Borrow

Re: Random Question Test

بواسطة - Eduardo Hernandez
I'm running Moodle 1.6 and I get the same message.. is there any workaround?

Eduardo
رداً على Eduardo Hernandez

randomizing essay questions in 1.6

بواسطة - Eduardo Hernandez
I did some research on essay/random questions as I was getting the error that appears in the starting post of this thread.

I put an echo to the print_question function to display the $question->qtype.

When I have a quiz consisting of only 1 random question taken from a category with 2 multiple choice questions, and if I go to "preview" my echo says ...

"random"

But... but... If I create a new Quiz, consisting of only 1 random question taken from a category with 2 essay questions, and If I go to "Preview" my echo says...

"description"

My question... why "description"?..Could it be the reason or the bug why essay questions are not working as random questions ???

When attempt.php (in line 275 aprox.) calls to

if (!$questions = get_records_sql($sql)) {

$questions returns, for my quiz,

Array
(
    [14] => stdClass Object
        (
            [id] => 14
            [0] => 4
            [category] => 4
            [1] => 14
            [parent] => 14
            [2] => Pregunta aleatoria (2)
            [name] => Pregunta aleatoria (2)
            [3] => 0
            [questiontext] => 0
            [4] => 0
            [questiontextformat] => 0
            [5] =>
            [image] =>
            [6] => 1
            [defaultgrade] => 1
            [7] => 0
            [penalty] => 0
            [8] => random
            [qtype] => random
            [9] => 1
            [length] => 1
            [10] => localhost+060812035535+ahQTBw
            [stamp] => localhost+060812035535+ahQTBw
            [11] => localhost+060812035535+hHbtWw
            [version] => localhost+060812035535+hHbtWw
            [12] => 0
            [hidden] => 0
            [13] => 1
            [maxgrade] => 1
            [14] => 11
            [instance] => 11
        )

)

But at line 293 there's a call to

if (!$states = get_question_states($questions, $quiz, $attempt)) {

and after this call $question changes to

Please note how now it is set to "description" (why?).

By the way...
"El número requerido de preguntas es mayor de las que contiene esta categoría." means in Spanish "The number of random questions required is more than this category contains"

Array
(
    [14] => stdClass Object
        (
            [id] => 14
            [0] => 4
            [category] => 4
            [1] => 14
            [parent] => 14
            [2] => Pregunta aleatoria (2)
            [name] => Pregunta aleatoria (2)
            [3] => 0
            [questiontext] => El número requerido de preguntas es mayor de las que contiene esta categoría.
            [4] => 0
            [questiontextformat] => 0
            [5] =>
            [image] =>
            [6] => 1
            [defaultgrade] => 1
            [7] => 0
            [penalty] => 0
            [8] => random
            [qtype] => description
            [9] => 1
            [length] => 1
            [10] => localhost+060812035535+ahQTBw
            [stamp] => localhost+060812035535+ahQTBw
            [11] => localhost+060812035535+hHbtWw
            [version] => localhost+060812035535+hHbtWw
            [12] => 0
            [hidden] => 0
            [13] => 1
            [maxgrade] => 1
            [14] => 11
            [instance] => 11
            [name_prefix] => resp14_
        )



)


Eduardo
رداً على Eduardo Hernandez

Re: randomizing essay questions in 1.6

بواسطة - Tim Hunt
صورة Core developers صورة Documentation writers صورة Particularly helpful Moodlers صورة Peer reviewers صورة Plugin developers
Essays are excluded from random question types. I don't know why. This was all developed before I took over as quiz maintainer. There is probably a good reason.

If you want to experiment. Go into question/type/random/questiontype.php and at the top, where it says

     var $excludedtypes = array("'random'", "'randomsamatch'", "'essay'", "'description'");


try removing essay from that list. I have no idea whether it will work.


The behavior Eduardo notices above is just the code using a trick to display an error message in the middle of the quiz.
رداً على Tim Hunt

Re: randomizing essay questions in 1.6

بواسطة - Michael Penney
Hi Tim, see:
http://moodle.org/bugs/bug.php?op=show&bugid=4004&pos=12
&
http://moodle.org/bugs/bug.php?op=show&bugid=5065&pos=21

By the way, the search function in the bugtracker is not very good, Google advanced search, limit domain to moodle.org/bugs (in this case: random essay site:http://moodle.org/bugs/), perhaps works okغمزة.
رداً على Michael Penney

Re: randomizing essay questions in 1.6

بواسطة - Eduardo Hernandez
Hi Michael,

So more than a problem of randomizing essay questions (that seems to work fine if they are removed from excluded types), it is more a problem of grading them (when a random question is an essay question).

Eduardo

رداً على Michael Penney

Re: randomizing essay questions in 1.6

بواسطة - Eduardo Hernandez
I have been trying to make essay questions work with random questions, and I have been studying how a quiz works in the backstage.. and I have a question.

I have been trying to see when/how/where a randon question is *linked* to an original question, and the only place a see a reference is in table mdl_question_states where the answer column says, for example, random7-..., where I can say "this randon question is showin the question with id 7 from mdl_question"

Is this the right place to see the original question a random question is pointed at?.

Eduardo

رداً على Eduardo Hernandez

random essay questions in 1.6.1 (working) - not perfect

بواسطة - Eduardo Hernandez
Hello,

After some research, I see my random essay questions working in 1.6.1.

After all the hints and tips taken from this thread, I saw that random essay questions is more an issue of grading them, than selecting them randomly.

As, Tim said before I went to question/type/random/questiontype.php and at the top, where it says

var $excludedtypes = array("'random'", "'randomsamatch'", "'essay'", "'description'");

I changed it to

var $excludedtypes = array("'random'", "'randomsamatch'", "'description'");

With the modification above, you can add random essay questions to any quiz, and student will be seeing a normal quiz, with random essay questions (cool!).

The problem arises when a teacher now wants to grade answers. Going to "Manual Grading" tabs shows nothing left to grade, as questions are "random" not "essay". To include the random questions I have modified the code at mod/   quiz/report/grading/report.php at line 141 , to include 'random'

 $sql = "SELECT q.*, i.grade AS maxgrade, i.id AS instance".
               "  FROM {$CFG->prefix}question q,".
               "       {$CFG->prefix}quiz_question_instances i".
               " WHERE i.quiz = '$quiz->id' AND q.id = i.question".
               "   AND q.id IN ($questionlist)".
               "   AND q.qtype IN ($QTYPE_MANUAL,'random')".
               "   ORDER BY q.name";
 
the problem is that with this, it will include any random question, not only "random essay ". However, since any multiplechoice or true/false question are automatically graded, they are listed in manual grading  but it correctly says that no questions must be graded. Only essay and random essay questions are listed with the number of questions waiting for a manual grade.

The perfect solution would be to list only random essay and essay question, but... that will result in a more complex SQL query.. as I really don't know where to look - correctly- the real question a random is poiting at ...

Anyway...for now it works.

Cheers
Eduardo
رداً على Eduardo Hernandez

Re: random essay questions in 1.6.1 (working) - not perfect

بواسطة - Tim Hunt
صورة Core developers صورة Documentation writers صورة Particularly helpful Moodlers صورة Peer reviewers صورة Plugin developers
Unfortunately, to do a better query, you would have to completely rewrite the report code, because different students will have been allocated differente essays via the same random question. It is certainly possible, but not easy. And I think the required SQL query would have to join together pretty much all the quiz and question tables.
رداً على Tim Hunt

Re: random essay questions in 1.6.1 (working) - not perfect

بواسطة - Eduardo Hernandez
Yes Tim; I totally agree with you. As our teachers like random essay question we had to give them a solution ASAP. So far, including random questions in the manual report has not produced problems for audience (after some little explation on why random questions appear).

Ed
رداً على Eduardo Hernandez

Re: random essay questions in 1.6.1 (working) - not perfect

بواسطة - Paulo Matos
Just shrinked the list a bit more, selecting only the random questions that had at least one QTYPE_MANUAL on its category


$sql = "SELECT q.*, i.grade AS maxgrade, i.id AS instance".
" FROM {$CFG->prefix}question q,".
" {$CFG->prefix}quiz_question_instances i".
" WHERE i.quiz = '$quiz->id' AND q.id = i.question".
" AND q.id IN ($questionlist)".

" AND ( q.qtype IN ($QTYPE_MANUAL) ".
" OR ( ".
" q.qtype = 'random' AND " .
" EXISTS ( select * from {$CFG->prefix}question q2 WHERE q2.category = q.category and q2.qtype IN ($QTYPE_MANUAL) ) " .
" ) ".
" ) ".

" ORDER BY q.name";


As far as I understood, random qtype chooses a non-random question among it's own category.

Cheers,

Paulo Matos
رداً على Paulo Matos

Re: random essay questions in 1.6.1 (working) - not perfect

بواسطة - Olli Savolainen
Here's another thumbs up for getting this fixed ASAP in moodle wide eyes.

Thanks a bunch Paulo! مبتسم Got it fixed. This is a major issue for the electronic exam application being developed in the University of Tampere, it should definitely be somewhere in the quiz module GUI in BIG red letters so that it would be easy to acknowledge, until this finally and correctly gets fixed. I suppose it didn't get fixed yet in 1.7? How about saying "The number of random questions required is more than are still available in the category! (Note: 'random', 'randomsamatch', 'essay', 'description' type questions are currently not supported. If you want to support them, see http://moodle.org/mod/forum/post.php?reply=259905)" in that error message, or something similar?


رداً على Olli Savolainen

Re: random essay questions

بواسطة - David Mudrák
صورة Core developers صورة Documentation writers صورة Moodle HQ صورة Particularly helpful Moodlers صورة Peer reviewers صورة Plugin developers صورة Plugins guardians صورة Testers صورة Translators
I have just spent several hours dealing with this problem. And I would really love if there was such a warning sleepy.
The feature still does not appear to be implemented in 1.7 nor in 1.8 dev. IMHO it is waiting for manual grading support for all question types... How far is it in the Quiz Roadplan?

I know there is a lot of other issues as well but I vote for this to be fixed in 1.8 غمزة
رداً على Olli Savolainen

Re: random essay questions in 1.6.1 (working) - not perfect

بواسطة - Gwen Rodgers
We get the message "The number of random questions required is more than are still available in the category!" on all random quizzes created.  Currently on Version 1.7.   Random quizzes worked fine for us before this version. There are definitely enough questions in the category. We get the message even when adding one question from a category. Thanks in advance for any help!
رداً على Gwen Rodgers

Re: random essay questions in 1.6.1 (working) - not perfect

بواسطة - Eduardo Hernandez
I have not seen random essay question on 1.7, but probably you seeing this message because random essay questions are not a 1.7 feature (there were not in 1.6); and you should apply the changes described in this forum, similar to 1.6.x; to make them work....
رداً على Paulo Matos

Re: random essay questions in 1.6.1 (working) - not perfect

بواسطة - Manuel de la Torre
Is there a fix for this problem in version 1.7+, I will appreciate any comments...

met.
رداً على Manuel de la Torre

Re: random essay questions in 1.6.1 (working) - not perfect

بواسطة - venkatesan iyengar
I could get random essay question running by modifying

function is_usable_by_random() {
return false;
}

in /moodle/question/type/essay/questiontype.php to

function is_usable_by_random() {
return true;
}

I tested in 1.8

رداً على venkatesan iyengar

Re: random essay questions in 1.6.1 (working) - not perfect

بواسطة - Timothy Takemoto

function is_usable_by_random()

does not seem to in my questiontype.php in 1.6.4

I see that there is a lot more complex stuff futher up this thread.

Okay
1) Changed
ar $excludedtypes = array("'random'", "'randomsamatch'", "'essay'", "'description'");
var $excludedtypes = array("'random'", "'randomsamatch'", "'description'");
2) Reinsert the random question (I missed this stage at first)

Question can now be seen by students.


رداً على Timothy Takemoto

Re: random essay questions in 1.6.1 (working) - not perfect

بواسطة - Timothy Takemoto
I added the code suggested by Paulo to mod/quiz/report/grading/report.php but it says that there are "no manually graded questions" under the Manual Grading tab of the results tab. However, the code by Eduardo Hernandez does seem to work and since I do not have any non-essay questions in the quiz (they are all randomly presented essay questions) I think that this is going to work.

Thank you very much Eduardo.

The ability to give random questions is very important since it is the best way to lessen cheating.

Tim



رداً على venkatesan iyengar

Re: random essay questions in 1.6.1 (working) - not perfect

بواسطة - Tomas Torres
Venkatesan

I tried in moodle 1.8.3, not working, I modified

in /moodle/question/type/essay/questiontype.php to

function is_usable_by_random() {
return true;
}
I got to do something else.

Thanks a lot
رداً على Anthony Borrow

Re: Random Question Test

بواسطة - Genner Cerna
hopefully essay random question will available soon in next release... thanks
رداً على Genner Cerna

Re: Random Question Test

بواسطة - Jonathan Bergmann
Please fix this.  I have written severeal essay type questions and I want moodle to pick one at random for my kids.