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

Backslashes inserted into short answer fields of a multianswer/cloze question

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • 1.6.2
    • Quiz
    • None
    • Linux, PHP 5.0.4, MySQL 4.1.20, Apache 2.0.54, Moodle latest 1.6.2+
    • MOODLE_16_STABLE

      If an apostrophe (ASCII character 39) is entered into a short answer field of a multianswer (cloze) question, and the answer is then either submitted individually (using the adaptive mode) OR saved without submitting with other answers displayed on a quiz page, there is a backslash character inserted in front of the apostrophe each time the quiz page is reloaded.
      Example:
      [SHORTANSWER FIELD]: Boys' Orchestra

      • Save without submitting (1)
        [SHORTANSWER FIELD]: Boys\' Orchestra
      • Save without submitting (2)
        [SHORTANSWER FIELD]: Boys\\\' Orchestra
      • Save without submitting (3)
        [SHORTANSWER FIELD]: Boys\\\\\\\' Orchestra

      What I did was to add a stripslashes() into the question\type\multianswer\questiontype.php file – as shown below. I do not know though whether I should consider this solution systematic or robust enough.

      — ORIGINAL question\type\multianswer\questiontype.php Sat Sep 23 16:52:53 2006
      +++ MODIFIED question\type\multianswer\questiontype.php Sat Sep 23 17:35:33 2006
      @@ -304,7 +304,7 @@
      case 'shortanswer':
      case 'numerical':
      echo " <input $style $readonly $popup name=\"$inputname\"

      • type=\"text\" value=\"$response\" size=\"12\" /> ";
        + type=\"text\" value=\"".stripslashes($response)."\" size=\"12\" /> ";
        break;
        case 'multichoice':
        $outputoptions = '<option></option>'; // Default empty option

            rezeau Joseph Rézeau
            mixik Daniel Miksik (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:

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