Problem/Motivation
A question with the "Simple scoring" option selected (choice_boolean) should result in the question being marked correct only if all correct answers are selected. Otherwise the totals for quizzes exceed 100%.
Steps to reproduce
- Create a quiz with a question that has 4 options. 3 of the options are correct. For correct answers 1 point if selected -1 if not selected.
- Set the question to have "Simple scoring"
- Set the max score on the questions page for this question to 1.
- Answering all three correctly results in points_awarded of 3 for the quiz question result.
Repeat the steps above, but uncheck simple scoring.
Answering all three correctly still results in points_awarded of 3 for the quiz question result
Repeat the steps in the first scenario, but change the max score to 1 on the questions page (so keep as simple scoring)
Answering all three correctly still results in points_awarded of 3 for the quiz question result.
Repeat the steps in the first scenario, but on the questions page, set to "automatic scoring"
Answering all three correctly still results in points_awarded of 3
Proposed resolution
It appears the problem may be QuizQuestionEntityTrait.php::getAnsweringFormValidate();
Shouldnt' there be a line here to determine if quiz_question__choice_boolean is 1 then set points_awarded to max_score?
Comment | File | Size | Author |
---|---|---|---|
#11 | 3198222-all.patch | 11.41 KB | djdevin |
#11 | 3198222-test.patch | 3.98 KB | djdevin |
#10 | 3198222-mcq.patch | 6.11 KB | djdevin |
#8 | 3198222-mcq.patch | 6.1 KB | djdevin |
#6 | fix-simple-question-scoring-3198222-6.patch | 2.37 KB | hb3 |
Comments
Comment #2
Chris Dart CreditAttribution: Chris Dart at TEN7 commentedIt looks like the actual fix should be here:
quiz/src/Form/QuizQuestionAnsweringForm.php:230
Comment #3
djdevinIt's strange because a question should not be able to make the score in the quiz anything higher than the scaled max. If the question in the quiz is worth 1 point then it shouldn't be possible for a 3 point question to award more than 1 point in the quiz.
There's a few tests that should be looked at, that doesn't seem right...
QuizMultichoiceTestCase::testSimpleScoring
QuizGradingTest::testWeightedScore
QuizGradingTest::testManualWeightedScore
Comment #4
Chris Dart CreditAttribution: Chris Dart at TEN7 commentedMy guess is that this patch is just a hack because the real problem is further upstream in the process.
Comment #5
martin@infinitynetmedia.co.uk CreditAttribution: martin@infinitynetmedia.co.uk as a volunteer commentedIsn't the issue here:
multichoiceResponse.php
ie: if it's a multi choice answer, the score is incremented by score_chosen / not_chosen. If we want simple scoring, wouldn't this be a better solution?
ie: if you want simple scoring (0 or 1) any incorrect response receives a score of zero, and only gets 1 mark if there are no incorrect answers.
Comment #6
hb3 CreditAttribution: hb3 commentedI slightly updated Martins solution, to prevent that a user gets points if he/she selects all alternatives of a multiplechoice question (both correct and wrong ones) and created a patch.
if ((!$selected && $correct) || ($selected && !$correct))
Comment #7
apadernoComment #8
djdevinThere's a couple issue here contributing to the issue:
1. The forgive() method which corrects the multichoice_score_[not_]chosen if omitted, was broken from D7
2. score() was returning more points than the max points when using simple scoring
3. The warn() method was still broken from D7
This should fix that all up against 6.x. Test has to be updated.
Comment #10
djdevinFix MCQ test
Comment #11
djdevinUpdated testSimpleScoring to set 2 correct answers and then check for the proper score, it wasn't doing that before.
Comment #13
djdevinTest patch fails, full patch passes.
Thanks all, fixed!