I am opening a new discussion on counting characters since a previous discussion ↗ which had opened on the same subject has drifted on counting words, not characters.
The purpose of this post is simply to present a script that counts the characters in the Essay question. All there is to do is copy the script into the question's HTML code, and set the minimum and maximum number of characters. Note that the script can be placed elsewhere so that it applies to more than one question at a time.
The same script works when the "Response format" is set to "HTML editor" and using the Atto editor, and to "Plain text".
A different message is displayed when the number of characters is below the minimum, between the minimum and maximum, or above the maximum.
Using a script has several advantages, namely the script:
- counts characters, which the Essay question does not,
- does not require any installation,
- works on all versions of Moodle,
- does not need to be updated,
- can easily be customized.
The script does not count spaces, non-breaking spaces, and new lines. Obviously, it also doesn't count HTML tags. It does not count list symbols (numbers or bullets).
It can be used for texts in English, Japanese and any other language.
You can try the question below at moodleformulas.org - Character count ↗.