Moodle
  1. Moodle
  2. MDL-28457

Grades validation fails for CalculatedMultichoice questions

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Cannot Reproduce
    • Affects Version/s: 2.1
    • Fix Version/s: None
    • Component/s: Questions
    • Labels:
    • Environment:
      Kubuntu 11.04
    • Database:
      PostgreSQL
    • Testing Instructions:
      Hide

      'Create New Question'
      choose Calculated multichoice

      Question name: Test
      Question text: What is 3 *

      {x}?
      One or multiple answers: One answer Only

      Choice 1:
      {={x}

      +..}...:

      {x}
      Grade None

      Choice 2:
      {={x}

      +..}...:

      {x}*1
      Grade None

      Choice 3:
      {={x}

      +..}...:

      {x}*2
      Grade None

      Choice 4:
      {={x}

      +..}...:

      {x}+3
      Grade None

      Choice 5:
      {={x}

      +..}...:

      {x}*3
      Grade 100%

      Save Changes

      Question refuses to be save. Error message in
      Choice 1 says "One of the choices should be 100%, so that it is
      possible to get a full grade for this question."

      Change One or Multiple Answers to Multiple Answers allowed

      Add

      Choice 6:
      {={x}

      +..}...:

      {x}+{x}

      Grade None

      Save Changes

      Now the error message is "The positive grades you have chosen do not add up to 100% Instead, they add up to 0%"

      Show
      'Create New Question' choose Calculated multichoice Question name: Test Question text: What is 3 * {x}? One or multiple answers: One answer Only Choice 1: {={x} +..}...: {x} Grade None Choice 2: {={x} +..}...: {x}*1 Grade None Choice 3: {={x} +..}...: {x}*2 Grade None Choice 4: {={x} +..}...: {x}+3 Grade None Choice 5: {={x} +..}...: {x}*3 Grade 100% Save Changes Question refuses to be save. Error message in Choice 1 says "One of the choices should be 100%, so that it is possible to get a full grade for this question." Change One or Multiple Answers to Multiple Answers allowed Add Choice 6: {={x} +..}...: {x}+{x} Grade None Save Changes Now the error message is "The positive grades you have chosen do not add up to 100% Instead, they add up to 0%"
    • Affected Branches:
      MOODLE_21_STABLE
    • Rank:
      18109

      Description

      The sanity checks for grades on a calculated multichoice question sometimes fail. If you have a number of choices, with exactly one choice marked as 100% grade and all the others as None, and have selected "One Answer Only", you can get the error message: "One of the choices should be 100%, so that it is possible to get a full grade for this question."

      On the other hand, if you select "Multiple Answers Allowed", you can get: "The positive grades you have chosen do not add up to 100% Instead, they add up to 0%". Likewise, if you have exactly 2 choices at 50%.

      Strangely, this only seems to happen when you have a larger number of choices (5 or 6), but that doesn't seem to make sense to me in light of what I think the fix could be.

        Activity

        Hide
        Tim Hunt added a comment -

        You are right, the number of choices should not make a difference. Very weird.

        Show
        Tim Hunt added a comment - You are right, the number of choices should not make a difference. Very weird.
        Hide
        Pierre Pichet added a comment -

        The last choice is not seen by the validating grade code.
        Most probably an index problem.
        Will look to the edit_form_code.

        Show
        Pierre Pichet added a comment - The last choice is not seen by the validating grade code. Most probably an index problem. Will look to the edit_form_code.
        Hide
        Neal Holtz added a comment -

        Ah. That could very well be and I didn't notice that as I tried a lot of
        permutations with not always reproducible effects (seemingly). Though I'm
        almost convinced that I worked through an example, progressively adding one
        more choice each time, with the last choice always being the 100%, and not
        getting a failure till I reached 5 choices. Could have faulty memory (in me) of course.

        Show
        Neal Holtz added a comment - Ah. That could very well be and I didn't notice that as I tried a lot of permutations with not always reproducible effects (seemingly). Though I'm almost convinced that I worked through an example, progressively adding one more choice each time, with the last choice always being the 100%, and not getting a failure till I reached 5 choices. Could have faulty memory (in me) of course.
        Hide
        Pierre Pichet added a comment -

        Thsnk,
        This code was extracted from a more complex project that could edit the question either as regular calculated or as multichoice.
        some more cleaning should be done as removing reference to 'multichoice' as in

        }
                if ($data['multichoice'] == 1) {
                    foreach ($answers as $key => $answer) {
                        $trimmedanswer = trim($answer);
                        if ($trimmedan
        

        The logic of all tests should be verified.

        Show
        Pierre Pichet added a comment - Thsnk, This code was extracted from a more complex project that could edit the question either as regular calculated or as multichoice. some more cleaning should be done as removing reference to 'multichoice' as in } if ($data['multichoice'] == 1) { foreach ($answers as $key => $answer) { $trimmedanswer = trim($answer); if ($trimmedan The logic of all tests should be verified.
        Hide
        Tim Hunt added a comment -

        This seems to have got fixed somewhere along the way. I just re-tesed and could not make this happen.

        Show
        Tim Hunt added a comment - This seems to have got fixed somewhere along the way. I just re-tesed and could not make this happen.

          People

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

            Dates

            • Created:
              Updated:
              Resolved: