Moodle

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

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor 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

Issue Links

Activity

Hide
Daniel Miksik added a comment -

If the answer containing an apostrophe is simply submitted for the first time (wihout using adaptive mode or saving it without submitting), then a backslash appears in front of the apostrophe on the review page.

Show
Daniel Miksik added a comment - If the answer containing an apostrophe is simply submitted for the first time (wihout using adaptive mode or saving it without submitting), then a backslash appears in front of the apostrophe on the review page.
Hide
Tim Hunt added a comment -

And another one for you to look at Joseph. Didn't we fix this one already? I am sure I remember something like this. Thanks.

Show
Tim Hunt added a comment - And another one for you to look at Joseph. Didn't we fix this one already? I am sure I remember something like this. Thanks.
Hide
Daniel Miksik added a comment -

The MDL-6386 issue has been fixed in 1.7 , 1.6.4 , 1.8, so this one can be closed too.

Show
Daniel Miksik added a comment - The MDL-6386 issue has been fixed in 1.7 , 1.6.4 , 1.8, so this one can be closed too.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: