Moodle
  1. Moodle
  2. MDL-36076

Cannot enter an answer of zero in a multiple choice question

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.2.5
    • Fix Version/s: 2.2.6, 2.3.3
    • Component/s: Questions
    • Labels:
      None
    • Testing Instructions:
      Hide

      1. Turn on the HTML editor in your user profile. (After that you have done that, you will have to log out and log in again for it to take effect. That is probably a bug, but an unrelated one.)

      2. Go to the question bank, and create a multiple choice question with choices 1, 0 and -1, with 0 the right choice. Make sure you can save the form.

      Show
      1. Turn on the HTML editor in your user profile. (After that you have done that, you will have to log out and log in again for it to take effect. That is probably a bug, but an unrelated one.) 2. Go to the question bank, and create a multiple choice question with choices 1, 0 and -1, with 0 the right choice. Make sure you can save the form.
    • Affected Branches:
      MOODLE_22_STABLE
    • Fixed Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE
    • Pull from Repository:
    • Pull Master Branch:
    • Rank:
      44839

      Description

      If you try to use the number 0 as an answer in a multiple-choice question, Moodle will not accept it. Looks like misuse of a comparison operator in the code.

      Steps to reproduce
      ==================
      1. Create a new multiple-choice question. Give it a name and question text.
      2. Insert answers: 2, 1, 0, -1
      3. Insert 100% grade for one of them
      4. Save changes

      Expected result
      ===============
      Question should be created successfully.

      Actual result
      =============
      Moodle returns to the form, and the answer 0 has an error message: "Grade set, but the Answer is blank"

        Activity

        Hide
        Steve Bond added a comment -

        PS this is only true when the field format is "Moodle auto-format". Changing the field to HTML fixes the problem.

        Show
        Steve Bond added a comment - PS this is only true when the field format is "Moodle auto-format". Changing the field to HTML fixes the problem.
        Hide
        Steve Bond added a comment -

        Hmm, my steps to reproduce aren't quite right, since creating a new multiple choice question automatically gives you HTML answer fields, as far as I can see. So really step 1 should read:

        1. Upgrade an existing 1.9 installation to 2.2, then edit an existing multiple-choice question.

        The upgrade process seems to leave certain fields, incuding question answers, in "Moodle auto-format" mode.

        Show
        Steve Bond added a comment - Hmm, my steps to reproduce aren't quite right, since creating a new multiple choice question automatically gives you HTML answer fields, as far as I can see. So really step 1 should read: 1. Upgrade an existing 1.9 installation to 2.2, then edit an existing multiple-choice question. The upgrade process seems to leave certain fields, incuding question answers, in "Moodle auto-format" mode.
        Hide
        Tim Hunt added a comment -

        Doh! typical PHP problem where it things '0' == ''. Fix submitted to integration.

        Show
        Tim Hunt added a comment - Doh! typical PHP problem where it things '0' == ''. Fix submitted to integration.
        Hide
        Aparup Banerjee added a comment -

        The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week.

        TIA and ciao

        Show
        Aparup Banerjee added a comment - The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week. TIA and ciao
        Hide
        Sam Hemelryk added a comment -

        Thanks Tim, nice and simple, has been integrated now

        Show
        Sam Hemelryk added a comment - Thanks Tim, nice and simple, has been integrated now
        Hide
        Ankit Agarwal added a comment -

        I was able to save the form. Although I got this error msg once after the form has been saved. But I cannot replicate it anymore, so passing this test.

        cache definitions reparsed causing cache reset in order to locate definition. You should bump the version number to ensure definitions are reprocessed.
        
            line 294 of /cache/classes/factory.php: call to debugging()
            line 136 of /cache/classes/factory.php: call to cache_factory->create_definition()
            line 169 of /cache/classes/loaders.php: call to cache_factory->create_cache_from_definition()
            line 460 of /question/engine/bank.php: call to cache::make()
            line 469 of /question/engine/bank.php: call to question_finder->get_data_cache()
            line 245 of /question/engine/bank.php: call to question_finder->uncache_question()
            line 285 of /question/question.php: call to question_bank::notify_question_edited()
        
        Skip to main content
        

        Thanks

        Show
        Ankit Agarwal added a comment - I was able to save the form. Although I got this error msg once after the form has been saved. But I cannot replicate it anymore, so passing this test. cache definitions reparsed causing cache reset in order to locate definition. You should bump the version number to ensure definitions are reprocessed. line 294 of /cache/classes/factory.php: call to debugging() line 136 of /cache/classes/factory.php: call to cache_factory->create_definition() line 169 of /cache/classes/loaders.php: call to cache_factory->create_cache_from_definition() line 460 of /question/engine/bank.php: call to cache::make() line 469 of /question/engine/bank.php: call to question_finder->get_data_cache() line 245 of /question/engine/bank.php: call to question_finder->uncache_question() line 285 of /question/question.php: call to question_bank::notify_question_edited() Skip to main content Thanks
        Hide
        Tim Hunt added a comment -

        That error is unrelated. Dan forgot to bump the version number when integration the issue about question definition caching.

        Show
        Tim Hunt added a comment - That error is unrelated. Dan forgot to bump the version number when integration the issue about question definition caching.
        Hide
        Dan Poltawski added a comment -

        Hurray!

        You did it, congratulations! You have on Mojito credit to redeem after the release of Moodle 2.4

        Show
        Dan Poltawski added a comment - Hurray! You did it, congratulations! You have on Mojito credit to redeem after the release of Moodle 2.4

          People

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

            Dates

            • Created:
              Updated:
              Resolved: