Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-59989

count_words can miss things it is meant to count

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Minor Minor
    • None
    • 3.2.4, 3.3, 3.4
    • Libraries
    • 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)

            timhunt Tim Hunt
            peter.spicer Peter Spicer
            Votes:
            4 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.