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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.6.2
    • Fix Version/s: None
    • Component/s: Quiz
    • Labels:
      None
    • Environment:
      Linux, PHP 5.0.4, MySQL 4.1.20, Apache 2.0.54, Moodle latest 1.6.2+
    • Affected Branches:
      MOODLE_16_STABLE

      Description

      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

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              rezeau Joseph Rézeau
              Reporter:
              mixik Daniel Miksik
              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: