Gapfill : Blank response in quiz review

Gapfill : Blank response in quiz review

by Howard Miller -
Number of replies: 5
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Moodle 3.1

We've had some students and staff complaining that their wrong answer in a gapfill question is not shown. Here's an example...


Note that the answer box is empty but the response history shows that an answer was saved. 

Looking at the generated HTML, it shows this....


So, the correct select is being generated but there is no 'selected' next to the appropriate answer (1680).

Thoughts?

Average of ratings: -
In reply to Howard Miller

Re: Gapfill : Blank response in quiz review

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

I have never seen anything like that before. Did you get a chance to look at the html in the gap where the answer should have been? (right mouse inspect). I am very happy to chase this down further if you contact me directly at marcusavgreen at gmail.com

I was working on the feedback bit of a question type renderer only last night (I live life close to the edge)

In reply to Marcus Green

Re: Gapfill : Blank response in quiz review

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

Answering my own question, it's a combination of spaces in the distractors and using a drop-down instead of drag-and-drop.

https://github.com/marcusgreen/moodle-qtype_gapfill/issues/24

In reply to Howard Miller

Re: Gapfill : Blank response in quiz review

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Thanks Howard, I will pursue your excellent description and see what I can do.

In reply to Howard Miller

Re: Gapfill : Blank response in quiz review

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

I have reproduced your experience. The problem seems to be linked with blanks in the distractors as you suggested. As a result the correct answer was present in the HTML you could see but the selected answer did not have a 'selected' string to make it get displayed. 

I have just tried a fix by doing a trim on the distractors and it seems to fix it. However I need to experiment in case there is some reason why leading blanks are necessary to preserve (I cannot think of any reason why that would be true)

For reference and not for live this is what I have just tried (once on a test machine that nobody uses). In the file questiontype.php

In the method get_answer_fields

Around line 354 I changed 

$question->wronganswers['text'] = rtrim($question->wronganswers['text'], ',');

To read

$question->wronganswers['text'] = trim(rtrim($question->wronganswers['text'], ','));

Note the additional trim that trims blanks after the first call has trimmed trailing commas.

I will experiment, test and write a new phpunit test and come up with version 1.92 and post here when it is ready.




Average of ratings: Useful (1)