If you have a custom question (multichoice) with more than one answer that is right, ie that has more than one answer with a score > 0
example:
- how many nails do mammals have on one foot?
- 1 (15)
- 2 (15)
- 3 (0)
- 4 (15)
- 5 (15)
- first weird behaviour:
- the total of that question is 15 but should be 60 (the answer is correct if you choos all of the items!)
- let select the first 2 answers
- the feedback is set to "wrong answer"
- you get 15 points out of 15
============= FIRST ISSUE ================
I understand the need of scaling the answers from one totally correct, down to totally wrong ones, as for
- Do mammals lay eggs?
- never (90)
- some peculiar species (100)
- yes (0)
in which the right answer is the second but the first is almost right...
This small sub-issue is resolved assigning a maxvalue to the question itself, and the score given for that question is min(question_max_value, useranswer_total_score) or just using multichoice-one answer only question type!
Comming back to the main first issue, it is resolved by changing the lines in /mod/lesson/locallib.php near line 1474
// Find the highest possible score per page to get our total
foreach ($answers as $answer) {
if(!isset($bestscores[$answer->pageid]))
}
in
// Find the highest possible score per page to get our total
foreach ($answers as $answer) {
if(!isset($bestscores[$answer->pageid]))
$bestscores[$answer->pageid] += $answer->score);
}
=========== SECOND ISSUE =========
The second issue should be resolved in file /mod/lesson/action/continue.php rewriting the logic of how the correctness is evaluated: in the example case, you got half the question right and no wrong answers!
It should be implemented as a tristate variable.
I did implement in another way:
- first set to false a flag for wrong answers ($wronguseranswer)!
- add a flag for incemplete answers that defaults to false ($missinganswers)
- in the check cycle set it to true if the user has sent a wrong answer
- on the final check reverse the filter (near line 313)
if ((count($useranswers) == $ncorrect) and ($nhits == $ncorrect)) { $correctanswer = true; $response = $correctresponse; $newpageid = $correctpageid; }else
{ $response = $wrongresponse; $newpageid = $wrongpageid; }will then be
if($wronguseranswer)
{ // at least one useranswer is wrong $response = $wrongresponse; $newpageid = $wrongpageid; } else {
// no wrong answers and the user has provided at least one answer
if ($nhits!= $ncorrect)
$correctanswer = true;
$response = $correctresponse;
$newpageid = $correctpageid;
}
On the result page the user then shoul be presented with a third type of report: "Answer provided are correct but incomplete"
Hope this helps