Hello Tim,

The sentence : and even that depends on whether the question text says "Select all of the choices that ..." or "Select the N choices that ...". Moodle's scoring rules are just too flexible

looks quite strange to me.

Why are you suddenly changing the rules of the game ? In all other questions types you never look at the question text who may surely include also some clues changing the probability that a student choose at random some responses. Why are you looking at question text here ? it's irrelevant !

For me random guess is random guess. Dot.

For a shortanswer question it's the probability the "monkey typist" type a right answer so equal 0

For a multichoice with one answer allowed (here the monkey don't type, he click !) the probability is clearly the one given by the code you ahev already done :

$totalfraction = 0;

foreach ($questiondata->options->answers as $answer)

{
$totalfraction += $answer->fraction;
}

return $totalfraction / count($questiondata->options->answers);

In all following calculations let n be the numbers of answers = count($questiondata->options->answers)

Here each radio button has a probability equal to 1/n to be choosen by the monkey so we calculate the expected value of a random variable and your formula is right.

For a multichoice question where the monkey can check multiple checkboxes, each response is a sequence of n numbers who can be either 0 or 1 if we code 0 a non checked checkbox and 1 a checked checkbox.

There is of course 2^n such sequences.

For a given sequence it is quite doable to calculate the resulting marking (after all this is what is doing Moodle when he grade such questions)

The grade is equal to the sum of all fractions corresponding to the 1 numbers in the sequence

For instance 00...0 result in 0 in all cases !

And 11...1 result in the sum of all stems fractions (not necessary a good choice if the teacher uses negatives fractions)

This is where we see Moodle grading scheme of this kind of question is not the only one possible. On an other e-assesment sytem I have used the fraction associated with a stem is awarded if the state (checked or unchecked) is the same in the teacher answer and in the student response, and there is anothe value you can choose (usualy a negative value) wich is "awarded" if the student response (checked or unchecked) is opposite. You can also choose to award grades calculated on the number of "conformity" = number of checkboxes in the same state in the teacher answer and the student response. Very flexible system indeed.

Back to Moodle. For a place i between 1 and n there is exactly 2^(n-1) sequence with a 1 at this place i (wich will be awarded the fraction for this stem) and 2^(n-1) sequence with a 0 at this place (wich will be awarded nothing for this stem). So the formula will be sum(fraction*2^(n-1))/(2^n) there is clearly a big simplification and we find sum(fraction)/2

So random guess is simply the sum of all fractions divided by 2 !

Here is your formula and it is quite doable to calculate it.

But maybe I am simply too tired (I have been working at upgrading the formulas question type to Moodle 2.1 all day) and my calculation is wrong ! I will check tomorrow.

Hello Tim,

{ $totalfraction += $answer->fraction; }The sentence : and even that depends on whether the question text says "Select all of the choices that ..." or "Select the N choices that ...". Moodle's scoring rules are just too flexible

looks quite strange to me.

Why are you suddenly changing the rules of the game ? In all other questions types you never look at the question text who may surely include also some clues changing the probability that a student choose at random some responses. Why are you looking at question text here ? it's irrelevant !

For me random guess is random guess. Dot.

For a shortanswer question it's the probability the "monkey typist" type a right answer so equal 0

For a multichoice with one answer allowed (here the monkey don't type, he click !) the probability is clearly the one given by the code you ahev already done :

$totalfraction = 0;

foreach ($questiondata->options->answers as $answer)

return $totalfraction / count($questiondata->options->answers);

In all following calculations let n be the numbers of answers = count($questiondata->options->answers)

Here each radio button has a probability equal to 1/n to be choosen by the monkey so we calculate the expected value of a random variable and your formula is right.

For a multichoice question where the monkey can check multiple checkboxes, each response is a sequence of n numbers who can be either 0 or 1 if we code 0 a non checked checkbox and 1 a checked checkbox.

There is of course 2^n such sequences.

For a given sequence it is quite doable to calculate the resulting marking (after all this is what is doing Moodle when he grade such questions)

The grade is equal to the sum of all fractions corresponding to the 1 numbers in the sequence

For instance 00...0 result in 0 in all cases !

And 11...1 result in the sum of all stems fractions (not necessary a good choice if the teacher uses negatives fractions)

This is where we see Moodle grading scheme of this kind of question is not the only one possible. On an other e-assesment sytem I have used the fraction associated with a stem is awarded if the state (checked or unchecked) is the same in the teacher answer and in the student response, and there is anothe value you can choose (usualy a negative value) wich is "awarded" if the student response (checked or unchecked) is opposite. You can also choose to award grades calculated on the number of "conformity" = number of checkboxes in the same state in the teacher answer and the student response. Very flexible system indeed.

Back to Moodle. For a place i between 1 and n there is exactly 2^(n-1) sequence with a 1 at this place i (wich will be awarded the fraction for this stem) and 2^(n-1) sequence with a 0 at this place (wich will be awarded nothing for this stem). So the formula will be sum(fraction*2^(n-1))/(2^n) there is clearly a big simplification and we find sum(fraction)/2

So random guess is simply the sum of all fractions divided by 2 !

Here is your formula and it is quite doable to calculate it.

But maybe I am simply too tired (I have been working at upgrading the formulas question type to Moodle 2.1 all day) and my calculation is wrong ! I will check tomorrow.