Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.9.3
-
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.
With respect to the comments regarding the class names.
I have been looking further into the use of style sheets and now understand how the intended classes are being used (i.e. separate classes for response, correct and incorrect). I can see that this is more flexible but at present it is resulting in some inconsistent markup.
Once the change from "or" to "and" referred to above is made, the processing of ++ and – answers can take place. However the use of classes in the way these answers are handled is inconsistent. If the ++ response is matched then the user answer is returned wrapped in a class "incorrect matches", which results in both the answer and the response text being returned to the user styled as incorrect.
However all other processing of the short answer question fails to wrap the answer in either a correct or incorrect class.
It might be useful to have correct and incorrect answers wrapped in appropriate classes, but if so would it not be better to be consistent in its application?
Kind regards
Johnathan