Moodle
  1. Moodle
  2. MDL-3481

wildcard problem in cloze question

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.6
    • Fix Version/s: None
    • Component/s: Questions
    • Labels:
      None
    • Environment:
      All
    • Affected Branches:
      MOODLE_16_STABLE
    • Rank:
      8477

      Description

      See http://moodle.org/mod/forum/discuss.php?d=25431.

      Probably a * needs to be escaped somewhere, search for REG_BADRPT on http://uk2.php.net/eregi_replace

        Activity

        Hide
        Martin Dougiamas added a comment -

        From Julian Sedding (jps502 at york.ac.uk) Monday, 13 June 2005, 05:39 PM:

        Yes, the escaping was done, but it was assigned to the wrong variable. That's now corrected.

        From Joseph R?zeau (joseph.rezeau at uhb.fr) Thursday, 17 August 2006, 06:15 PM:

        Just found out that there is still a problem with the wildcard (asterisk) in cloze/embedded questions, SHORTANSWER sub-question type.

        Example:

        An abbreviation, such as NATO, laser, and ABC, written as the initial letter or letters of words, and pronounced on the basis of this abbreviated written form.

        {:SHORTANSWER:=acronym#correct~acro*#You've got the first part of the word right~nym#You've got the second part of the word right~#all wrong}

        In Moodle 1.6

        Student types: acro or nym -> Program does not recognize these answers, and proceeds to the catch-all asterisk and ouputs feedback message all wrong.

        Fix:

        in file question/type/multianswer/questiontype.php around line 260, a break command must be added in order to stop analysis at the first asterisk it meets.

        case 'shortanswer':

        [...]

        $raw_grade = $answer->fraction;

        }

        break; //JR

        }

        }

        break;

        In Moodle 1.7, the asterisk does not work at all, which is curious, since the file question/type/multianswer/questiontype.php is almost identical.

        Joseph

        From Tim Hunt (T.J.Hunt at open.ac.uk) Thursday, 17 August 2006, 07:18 PM:

        In 1.6:

        Obviously, we should make the corresponding change to the numerical question type too.

        And if we are putting in the break, then we don't need the inner if statement or the $raw_grade variable.

        I'll attach a patch in a moment. Can you see if it looks right.

        In 1.7 I made the shortanswer question type work properly. Question types are supposed to provide two functions: compare_responses, which checks if two different answers provided by the student are equivalent, and test_response to see whether the student's answer matches one of the predefined answers.

        shortanswer was using compare_responses instead of test_response, and had an implementation of compare_responses that was just wrong. So I fixed it. I had not realised the multianswer depended so much on the inner workings of the other question types. Yet another reason for me to hate CLOZE

        Now that shortanswer is fixed, the multianswer code can be simplified a lot more. See the second patch I am about to attach.

        If both of these look right, and if you can test them and they seem OK, I'll check them in.

        From Tim Hunt (T.J.Hunt at open.ac.uk) Thursday, 17 August 2006, 07:21 PM:

        By the way, you might want to look at the changes to shortanswer, and make the same chages to your ragexp question type.

        From Joseph R?zeau (joseph.rezeau at uhb.fr) Friday, 18 August 2006, 01:21 AM:

        Tim > By the way, you might want to look at the changes to shortanswer, and make the same changes to your regexp question type.

        Yes, of course, I must do that. Do you mean in 1.6 or 1.7dev (or both)?

        Joseph

        From Joseph R?zeau (joseph.rezeau at uhb.fr) Friday, 18 August 2006, 01:23 AM:

        Tim,

        I will test both your patches either tonight or tomorrow.

        Joseph

        From Joseph R?zeau (joseph.rezeau at uhb.fr) Friday, 18 August 2006, 05:52 PM:

        cloze 1.6 patch = tested, OK

        cloze 1.7 patch = tested, OK

        I guess you can check them in,

        Thanks,

        Joseph

        From Tim Hunt (T.J.Hunt at open.ac.uk) Friday, 18 August 2006, 06:31 PM:

        Thanks for testing. Fix now in HEAD and MOODLE_16_STABLE.

        Show
        Martin Dougiamas added a comment - From Julian Sedding (jps502 at york.ac.uk) Monday, 13 June 2005, 05:39 PM: Yes, the escaping was done, but it was assigned to the wrong variable. That's now corrected. From Joseph R?zeau (joseph.rezeau at uhb.fr) Thursday, 17 August 2006, 06:15 PM: Just found out that there is still a problem with the wildcard (asterisk) in cloze/embedded questions, SHORTANSWER sub-question type. Example: An abbreviation, such as NATO, laser, and ABC, written as the initial letter or letters of words, and pronounced on the basis of this abbreviated written form. {:SHORTANSWER:=acronym#correct~acro*#You've got the first part of the word right~ nym#You've got the second part of the word right~ #all wrong} In Moodle 1.6 Student types: acro or nym -> Program does not recognize these answers, and proceeds to the catch-all asterisk and ouputs feedback message all wrong. Fix: in file question/type/multianswer/questiontype.php around line 260, a break command must be added in order to stop analysis at the first asterisk it meets. case 'shortanswer': [...] $raw_grade = $answer->fraction; } break; //JR } } break; In Moodle 1.7, the asterisk does not work at all, which is curious, since the file question/type/multianswer/questiontype.php is almost identical. Joseph From Tim Hunt (T.J.Hunt at open.ac.uk) Thursday, 17 August 2006, 07:18 PM: In 1.6: Obviously, we should make the corresponding change to the numerical question type too. And if we are putting in the break, then we don't need the inner if statement or the $raw_grade variable. I'll attach a patch in a moment. Can you see if it looks right. In 1.7 I made the shortanswer question type work properly. Question types are supposed to provide two functions: compare_responses, which checks if two different answers provided by the student are equivalent, and test_response to see whether the student's answer matches one of the predefined answers. shortanswer was using compare_responses instead of test_response, and had an implementation of compare_responses that was just wrong. So I fixed it. I had not realised the multianswer depended so much on the inner workings of the other question types. Yet another reason for me to hate CLOZE Now that shortanswer is fixed, the multianswer code can be simplified a lot more. See the second patch I am about to attach. If both of these look right, and if you can test them and they seem OK, I'll check them in. From Tim Hunt (T.J.Hunt at open.ac.uk) Thursday, 17 August 2006, 07:21 PM: By the way, you might want to look at the changes to shortanswer, and make the same chages to your ragexp question type. From Joseph R?zeau (joseph.rezeau at uhb.fr) Friday, 18 August 2006, 01:21 AM: Tim > By the way, you might want to look at the changes to shortanswer, and make the same changes to your regexp question type. Yes, of course, I must do that. Do you mean in 1.6 or 1.7dev (or both)? Joseph From Joseph R?zeau (joseph.rezeau at uhb.fr) Friday, 18 August 2006, 01:23 AM: Tim, I will test both your patches either tonight or tomorrow. Joseph From Joseph R?zeau (joseph.rezeau at uhb.fr) Friday, 18 August 2006, 05:52 PM: cloze 1.6 patch = tested, OK cloze 1.7 patch = tested, OK I guess you can check them in, Thanks, Joseph From Tim Hunt (T.J.Hunt at open.ac.uk) Friday, 18 August 2006, 06:31 PM: Thanks for testing. Fix now in HEAD and MOODLE_16_STABLE.

          People

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

            Dates

            • Created:
              Updated:
              Resolved: