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

Shortanswer questions: case insensitive comparison not working with accented characters

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.6.3, 1.7
    • Fix Version/s: 1.7.1, 1.8
    • Component/s: Questions
    • Labels:
      None
    • Environment:
      Fedora Core 4, MySQL 4.1.20, PHP 5.0.4, Moodle 1.6.2+
    • Affected Branches:
      MOODLE_16_STABLE, MOODLE_17_STABLE
    • Fixed Branches:
      MOODLE_17_STABLE, MOODLE_18_STABLE

      Description

      When shortanswer question is create and with case insensitive comparison, accented characters with wrong case are not recognized. Moodle 1.6 uses strtolower(), 1.7 strcasecmp() for comparing anser / response, but these functions are not UTF-aware. For example, answers "?lov?k" and "?lov?k" are not considered equal (but they should be as "?" is the same character as "?")

      A simple solution is using Moodles $textlib, fix for file /question/type/shortanswer/questiontype.php 1.6.2+ is to change these lines in method compare_responses():

      if (!$question->options->usecase)

      { // Don't compare case $response0 = strtolower($response0); $response1 = strtolower($response1); }

      to

      if (!$question->options->usecase)

      { // Don't compare case $textlib = textlib_get_instance(); $response0 = $textlib->strtolower($response0); $response1 = $textlib->strtolower($response1); }

        Attachments

          Activity

            People

            Assignee:
            timhunt Tim Hunt
            Reporter:
            jsedenka Jaroslav Sed?nka
            Tester:
            Nobody
            Participants:
            Component watchers:
            Tim Hunt, Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              17/Jan/07