Short Answer - Trim spaces at the beginning and at the end of the answer

Short Answer - Trim spaces at the beginning and at the end of the answer

by Alexander Kuptsov -
Number of replies: 1

Hello everyone,

I've always thought that Moodle somehow trims white spaces at the beginning and at the end of a short answer that the student inputs but apparently it does not. Today I had a question where the answer was 'is' and my student typed in 'is   ', hitting the space bar accidentally or something. His answer was marked as incorrect and I had to rack my brain and experiment before I realised what was wrong.

Is it somehow possible to tweak the Moodle code, so that it would first trim all the white spaces at the beginning and at the end of short answers? In this very case, for example, for my answer 'is' answers like '    is' and ' is     ' would be correct.

I appreciate any help


Average of ratings: -
In reply to Alexander Kuptsov

Re: Short Answer - Trim spaces at the beginning and at the end of the answer

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Moodle does trim whitespace (https://github.com/moodle/moodle/blob/master/question/type/shortanswer/question.php#L48)

However, in the world of unicode, what exactly is whitespace is a complicated question. Can you get the exact sequence of unicode characters that has been submitted?

Average of ratings: Useful (1)