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

errors in continue.php cause failure to correctly process regular expressions and to display correct classes for responses

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.9.3
    • Fix Version/s: 1.9.4, 2.0
    • Component/s: Lesson
    • Labels:
      None
    • Environment:
      Windows 2000, apache 2.2.8, php 5.2.5, postgresql 8.3.4, Moodle 1.9.3 build 20081027
    • Affected Branches:
      MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_19_STABLE, MOODLE_20_STABLE

      Description

      In the lesson module it is possible to specify incorrect answers with their own response, with scores of 0 or less, and to set them to jump to a page other than "this page".

      However even with the following settings for the lesson (there appears to be a known problem with incorrect answers failing to display their response text if review is enabled)

      allow student review = no
      display review button = no
      display default feedback = no

      The use of regular expressions to evaluate the lesson fails as line 125 of moodle/mod/lesson/action/continue.php treats all pages that jump to somewhere other than "this page" as possible correct responses.

      if (lesson_iscorrect($pageid, $answer->jumpto) or ($lesson->custom && $answer->score > 0) ) {

      The result is that responses that include the use of ++ to define words that must not appear or – to identify words that must appear are processed without any testing for the use of ++ or – and a php error is generated.

      preg_match() [function preg-match]: compilation failed: nothing to repeat at offset 1 in ...

      The solution to this appears to be to change the "or" operator to an "and" operator in line 125, after which the test performs correctly.

      if (lesson_iscorrect($pageid, $answer->jumpto) and ($lesson->custom && $answer->score > 0) ) {

      Further down in continue.php, on line 688 a class for correct responses is defined.

      $class = 'response correct'; //CSS over-ride this if they exist (!important)

      I don't know a lot about style sheets but in my tests the use of a class name with a space resulted in the class "response correct" being recognised as "response", with the result that all responses were displayed in the class response.

      Changing the class name in line 688 to response-correct and in line 692 to response-incorrect will resolve this.

        Attachments

          Activity

            People

            Assignee:
            howardsmiller Howard Miller
            Reporter:
            johnathankemp Johnathan Kemp
            Tester:
            Tim Hunt Tim Hunt
            Participants:
            Component watchers:
            Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Sujith Haridasan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              28/Jan/09