Moodle
  1. Moodle
  2. MDL-6386

Apostrophe problem in SHORTANSWER question embedded inside CLOZE question

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.6.1
    • Fix Version/s: 1.6.4, 1.6.5, 1.7, 1.7.2, 1.8, 1.9
    • Component/s: Questions
    • Labels:
      None
    • Affected Branches:
      MOODLE_16_STABLE
    • Fixed Branches:
      MOODLE_16_STABLE, MOODLE_17_STABLE, MOODLE_18_STABLE, MOODLE_19_STABLE
    • Rank:
      28383

      Description

      There is an apostrophe problem in the display of a SHORTANSWER question embedded inside CLOZE question, e.g.

      Rewrite "the book of John" using a genitive

      {1:SHORTANSWER:~%100%John's book#ok}

      When student enters "John's book", the displayed output is "John\'s book", with an added unwanted backslash. And each subsequent click on the Submit page button adds more backslashes: "John
      's book", "John\\\'s book", "John\\\\'s book", etc.

      Joseph

        Issue Links

          Activity

          Hide
          Joseph Rézeau added a comment -

          Suggested bug fix:
          simply add a stripslashes command:

          RCS file: /cvsroot/moodle/moodle/question/type/multianswer/questiontype.php,v
          retrieving revision 1.7.2.5
          diff -u -r1.7.2.5 questiontype.php
          — question/type/multianswer/questiontype.php 18 Aug 2006 10:28:15 -0000 1.7.2.5
          +++ question/type/multianswer/questiontype.php 29 Aug 2006 21:00:22 -0000
          @@ -225,6 +225,7 @@
          $inputname = $nameprefix.$positionkey;
          $response = isset($state->responses[$positionkey])
          ? $state->responses[$positionkey] : null;
          + $response = stripslashes($state->responses[$positionkey]);

          // Determine feedback popup if any

          Tim, can you please check this? Thanks.

          Show
          Joseph Rézeau added a comment - Suggested bug fix: simply add a stripslashes command: RCS file: /cvsroot/moodle/moodle/question/type/multianswer/questiontype.php,v retrieving revision 1.7.2.5 diff -u -r1.7.2.5 questiontype.php — question/type/multianswer/questiontype.php 18 Aug 2006 10:28:15 -0000 1.7.2.5 +++ question/type/multianswer/questiontype.php 29 Aug 2006 21:00:22 -0000 @@ -225,6 +225,7 @@ $inputname = $nameprefix.$positionkey; $response = isset($state->responses [$positionkey] ) ? $state->responses [$positionkey] : null; + $response = stripslashes($state->responses [$positionkey] ); // Determine feedback popup if any Tim, can you please check this? Thanks.
          Hide
          Joseph Rézeau added a comment -

          Bug still there in 1.6.2... How about implementing my simple fix?
          Thanks
          Joseph

          Show
          Joseph Rézeau added a comment - Bug still there in 1.6.2... How about implementing my simple fix? Thanks Joseph
          Hide
          Tim Hunt added a comment -

          Fix checked in to Moodle 1.6.3+, 1.7beta and 1.8dev. Sorry it took so long.

          Show
          Tim Hunt added a comment - Fix checked in to Moodle 1.6.3+, 1.7beta and 1.8dev. Sorry it took so long.
          Hide
          Nicolas Martignoni added a comment -

          Verified, closing.

          Show
          Nicolas Martignoni added a comment - Verified, closing.
          Hide
          Joseph Rézeau added a comment -

          I provided a fix for this problem on 30/Aug/06.

          On 18/Oct/06 Tim wrote: Fix checked in to Moodle 1.6.3+, 1.7beta and 1.8dev. Sorry it took so long.

          Now I see that the fix has disappeared from all current versions of Moodle (from 1.6 to 1.9). That's weird. The bug is still there and my fix is still needed. Tim, can you check it please?

          Joseph

          Show
          Joseph Rézeau added a comment - I provided a fix for this problem on 30/Aug/06. On 18/Oct/06 Tim wrote: Fix checked in to Moodle 1.6.3+, 1.7beta and 1.8dev. Sorry it took so long. Now I see that the fix has disappeared from all current versions of Moodle (from 1.6 to 1.9). That's weird. The bug is still there and my fix is still needed. Tim, can you check it please? Joseph
          Hide
          Joseph Rézeau added a comment -

          Here is the patch for current Moodle 1.8 version, shoud be about the same for other versions:

          Index: questiontype.php
          ===================================================================
          RCS file: /cvsroot/moodle/moodle/question/type/multianswer/questiontype.php,v
          retrieving revision 1.26.2.1
          diff -u -r1.26.2.1 questiontype.php
          — questiontype.php 15 Mar 2007 12:59:15 -0000 1.26.2.1
          +++ questiontype.php 17 Mar 2007 12:57:43 -0000
          @@ -232,7 +232,7 @@

          $inputname = $nameprefix.$positionkey;
          if (isset($state->responses[$positionkey]))

          { - $response = $state->responses[$positionkey]; + $response = stripslashes($state->responses[$positionkey]); }

          else

          { $response = null; }
          Show
          Joseph Rézeau added a comment - Here is the patch for current Moodle 1.8 version, shoud be about the same for other versions: Index: questiontype.php =================================================================== RCS file: /cvsroot/moodle/moodle/question/type/multianswer/questiontype.php,v retrieving revision 1.26.2.1 diff -u -r1.26.2.1 questiontype.php — questiontype.php 15 Mar 2007 12:59:15 -0000 1.26.2.1 +++ questiontype.php 17 Mar 2007 12:57:43 -0000 @@ -232,7 +232,7 @@ $inputname = $nameprefix.$positionkey; if (isset($state->responses [$positionkey] )) { - $response = $state->responses[$positionkey]; + $response = stripslashes($state->responses[$positionkey]); } else { $response = null; }
          Hide
          Dan Poltawski added a comment -

          This looks to be a regression from this changeset: http://moodle.cvs.sourceforge.net/moodle/moodle/question/type/multianswer/questiontype.php?r1=1.7.2.8&r2=1.7.2.9

          stripslashes fix from above was lost.

          Show
          Dan Poltawski added a comment - This looks to be a regression from this changeset: http://moodle.cvs.sourceforge.net/moodle/moodle/question/type/multianswer/questiontype.php?r1=1.7.2.8&r2=1.7.2.9 stripslashes fix from above was lost.
          Hide
          Dan Poltawski added a comment -

          Hi, thanks for your attention to this issue. I've refixed this in CVS for versions 1.6 and above.

          Show
          Dan Poltawski added a comment - Hi, thanks for your attention to this issue. I've refixed this in CVS for versions 1.6 and above.
          Hide
          Tim Hunt added a comment -

          This 'fix' you applied is just wrong. Did you actually test it thoroughly before committing it? By thorough testing, I mean including in your test question the string

          ' \ \'
          " & < > & < >

          After your change, this string gets mangled to

          ' ' \ " & < > & < >

          Show
          Tim Hunt added a comment - This 'fix' you applied is just wrong. Did you actually test it thoroughly before committing it? By thorough testing, I mean including in your test question the string ' \ \' " & < > & < > After your change, this string gets mangled to ' ' \ " & < > & < >
          Hide
          Tim Hunt added a comment -

          Proper fix checked in.

          Tested cloze question containing a shortanswer question with

          ' \
          \' & < > & < >

          as both the answer to an embedded shortanswer question and its feedback.

          Checked both fill with correct, and submitting right and wrong answers.

          Show
          Tim Hunt added a comment - Proper fix checked in. Tested cloze question containing a shortanswer question with ' \ \' & < > & < > as both the answer to an embedded shortanswer question and its feedback. Checked both fill with correct, and submitting right and wrong answers.
          Hide
          Joseph Rézeau added a comment -

          Hi Tim, thanks for fixing this issue, including a fair number of "special characters"...
          Just tested your fixes in
          1.7.1+ OK
          1.8 Beta OK
          -------------------
          In 1.9, if I type in a cloze question Moodle is an

          {1:SHORTANSWER:=excellent}

          CMS.
          In question preview mode, if I click the Fill with correct button, the input field is filled with:
          </angle>excellent<angle></angle><angle>
          Very strange...

          Joseph

          Show
          Joseph Rézeau added a comment - Hi Tim, thanks for fixing this issue, including a fair number of "special characters"... Just tested your fixes in 1.7.1+ OK 1.8 Beta OK ------------------- In 1.9, if I type in a cloze question Moodle is an {1:SHORTANSWER:=excellent} CMS. In question preview mode, if I click the Fill with correct button, the input field is filled with: </angle>excellent<angle></angle><angle> Very strange... Joseph
          Hide
          Tim Hunt added a comment -

          I don't get that in 1.9 dev - I just tried it.

          Show
          Tim Hunt added a comment - I don't get that in 1.9 dev - I just tried it.
          Hide
          Dan Poltawski added a comment -

          Apologies for that bad commit. I shall be more careful in future.

          Show
          Dan Poltawski added a comment - Apologies for that bad commit. I shall be more careful in future.
          Hide
          Joseph Rézeau added a comment -

          Tim,
          just did a clean install of current Moodle 1.9 dev (HEAD) in CVS and now everything works as expected. Maybe my previous version had got corrupted.
          Sorry!
          Joseph

          Show
          Joseph Rézeau added a comment - Tim, just did a clean install of current Moodle 1.9 dev (HEAD) in CVS and now everything works as expected. Maybe my previous version had got corrupted. Sorry! Joseph
          Hide
          Nicolas Martignoni added a comment -

          Closing, thanks.

          Show
          Nicolas Martignoni added a comment - Closing, thanks.

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: