Closed AnupamaSarjoshi closed 3 months ago
Just to be certain, can you confirm that this issue only shows up for someone with site admin role?
Am about to attempt to reproduce it locally
Thanks Marcus. Though I haven't tried, I don't think it is specific to site admin role. Anyone with the capability to access Response history probably will see the same
@AnupamaSarjoshi I would like to try to reproduce your problem, but... You forgot to mention a) the instructions given to the student ("click such and such words") b) if your question uses the Multiword mode c) you forgot to mention the "How questions behave" options you are using Could you please export and attach your question to your reply? Thanks!
I think the question is taken directly from the included examples. I will add instructions in the next release... Good catch on the question behaviour, though I don't think it will be a decider (could be wrong). It seems a strange one. Hope to look further this evening.
Just tested this locally on my Moodle 4.0.1. Works as expected, The submitted words are in the same order as in the text. Agree with @AnupamaSarjoshi however that some kind of separator between those submitted words (or groups of words) would be useful
I wonder if however the core ddwtos question does it might be an inspiration...
My first attempt
I need confirmation of what question behaviour is being used, I suspect from the word submit at the start that it is Deferred feedback. I can see the code that generates the output in the summarise_response method of question.php https://github.com/marcusgreen/moodle-qtype_wordselect/blob/6183f72a45f9ad1d38742d4caed2c5e1d7d51883/question.php#L277
Braces could be added like this
$summary .= "{ " . $allwords[substr($index, 1)]->get_without_delim() . "} ";
With reference to word order, I cannot reproduce what you are seeing. The order is probably determined from how the words are returned from
$allwords = $this->get_words();
But at the moment I cannot figure out how it would be returned in an order other than how it appears in the original text.
I can't work this out either, but I can confirm we are seeing this.
I don't believe the behaviour matters. I just reproduced the issue by previewing Anu's question on our system, and only afterwards notice that was using Interactive with multiple tries.
In case it helps, here is the question: (Github does not like XML files, so I had to rename to add .txt.) questions-U101-20B-WordSelect Reading Comprehension-20220622-1654.xml.txt
There were bugs like this in the past in some core qtypes. Baiscally, when a DB server is new, then in theory, the order of results from any query will be random unless you specify an order-by. However, when DBs are new then typically rows are returned in id order at first, and then with time start getting more random. So, that might possibly explain this hard-to-reproduce bug ... except I just quickly looked at the code, and from what I can see, all the queries have an order-by id. (Example old bugs: MDL-27394 or commit f07d1d319716a0b381ece29435c72999a798f778 - so old, it came before the tracker.)
More debugging needed, but I am out of time for today.
Thanks for the feedback Tim. The behaviour thing was partly to ensure I was seeing exactly the same text before it showed the words, but as you suggest, that is probably not relevant. I was wondering about the order of stuff returned from the db, but I couldn't see how that would happen in this case. I will look further.
I think the the order of the words returned is determined somewhere after here https://github.com/marcusgreen/moodle-qtype_wordselect/blob/6183f72a45f9ad1d38742d4caed2c5e1d7d51883/question.php#L128
Possibly on the line that reads $matches = preg_split($fieldregex, $questiontextnodelim, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
But the order of things returned from preg_split is always the order they were in the original string, so it is not clear how this could lead to the problem. It really is a mystery.
That was my assumption. I would be happier if I could reproduce it. I now want to set one up with exactly the same version of PHP and Postgress, which of course should/could not make any difference whatsoever but you never know (even when you feel you do know)
I am closing this as I don't have the time to work towards a fix. If anyone comes up with a code fix I will be happy to review it.
Hi Marcus,
We have seen the following issue. Could you please have a look? Thanks.
Describe the bug When the WordSelect question is attempted as Admin, the Response history shows the submitted words in Random order and also there is no delimiter around the words to separate each one of them. This seems to be confusing when the submitted words have punctuation marks in them.
To Reproduce Steps to reproduce the behaviour:
Expected behaviour In the Response history the submitted words should be in order to the question text and also the words should be displayed within braces { } to clearly separate out the words selected.
Screenshots![image](https://user-images.githubusercontent.com/81178902/174783179-c502fd21-a892-4482-b5e0-093f9e2b639f.png)
Desktop (please complete the following information):