-
Bug
-
Resolution: Duplicate
-
Minor
-
None
-
3.2.4, 3.3, 3.4
-
None
-
MOODLE_32_STABLE, MOODLE_33_STABLE, MOODLE_34_STABLE
count_words can miscount the number of words in a submission if the last word in a paragraph doesn't have punctuation on it, depending on the punctuation.
I noticed it while testing my own code which was a JS port of the count_words function, but I see others have run into the same situation - https://github.com/damyon/moodle-atto_count/issues/6
What happens is that the paragraphs in the Atto (and under some circumstances TinyMCE) editor don't have whitespace between them, leading to the strip_tags call splicing together the ends of lines without any breaks.
If the content ends in punctuation as it should, this usually shouldn't be a problem though if the punctuation is a single quote, or sentences end/start with numbers, this can be edge-case behaviour.
The way I'd fix this would be to do a simple text find/replace on the source, replacing >< with > < to add a space between adjacent tags like </p><p> as would be seen in this sort of case. This should also cope with cases where people have made only part of a word bold or italic (though not both at the same time)
- duplicates
-
MDL-46256 count_words returns too few words when dealing with html tags
-
- Closed
-