Fixing https://tracker.moodle.org/browse/CONTRIB-4322, thanks to Elizabeth Dalton