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

Invalid cloze-questions saved to question bank

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.2.6, 3.3.1, 3.4, 3.5.2, 3.6
    • Fix Version/s: 3.4.6, 3.5.3
    • Component/s: Questions
    • Labels:
    • Testing Instructions:
      Hide
      Single answer
      1. Go to a course's question bank page.
      2. Create a new "Embedded answers (Cloze)" question.
      3. Enter a question name.
      4. Enter the following question text:

        Please select the fruits {1:MULTICHOICE:=Apple#Correct}
        

      5. Save the changes.
      6. Confirm that the question is decoded correctly (there will be a new "Question {#1}" section in the form.
      7. Check the decoded question's section.
      8. Confirm that it has a validation error that says "This type of question requires at least 2 choices"
      No answer
      1. Create another "Embedded answers (Cloze)" question.
      2. Enter a question name.
      3. Enter the following question text:

        The capital of France is {1:SHORTANSWER:=    }
        

        Note: If you're using the atto/TinyMCE, you might need to use the HTML editor view and remove the  's and replace them with spaces.

      1. Save the changes.
      2. Confirm that the question is decoded correctly (there will be a new "Question XX" section in the form.
      3. Check the decoded question's section.
      4. Confirm that it has a validation error that says "This type of question requires at least 1 answers"
      Valid question
      1. Create another Embedded answers question.
      2. On the question text, enter the following:

        Match the following cities with the correct state:
        * San Francisco: {1:MULTICHOICE:=California#OK~Arizona#Wrong}
        * Tucson: {1:MULTICHOICE:California#Wrong~%100%Arizona#OK}
        * Los Angeles: {1:MULTICHOICE:=California#OK~Arizona#Wrong}
        * Phoenix: {1:MULTICHOICE:%0%California#Wrong~=Arizona#OK}
        The capital of France is {1:SHORTANSWER:%100%Paris#Congratulations!
        ~%50%Marseille#No, that is the second largest city in France (after
        Paris).~*#Wrong answer. The capital of France is Paris, of course.}.
        

      3. Click "Decode and verify the question text"
      4. Confirm that you get 4 multiple choice questions and 1 short answer question.
      5. Save the changes.
      6. Confirm that the question is successfully saved.
      Show
      Single answer Go to a course's question bank page. Create a new " Embedded answers (Cloze) " question. Enter a question name. Enter the following question text: Please select the fruits {1:MULTICHOICE:=Apple#Correct} Save the changes. Confirm that the question is decoded correctly (there will be a new "Question {#1}" section in the form. Check the decoded question's section. Confirm that it has a validation error that says " This type of question requires at least 2 choices " No answer Create another " Embedded answers (Cloze) " question. Enter a question name. Enter the following question text: The capital of France is {1:SHORTANSWER:= } Note: If you're using the atto/TinyMCE, you might need to use the HTML editor view and remove the   's and replace them with spaces. Save the changes. Confirm that the question is decoded correctly (there will be a new "Question XX" section in the form. Check the decoded question's section. Confirm that it has a validation error that says " This type of question requires at least 1 answers " Valid question Create another Embedded answers question. On the question text, enter the following: Match the following cities with the correct state: * San Francisco: {1:MULTICHOICE:=California#OK~Arizona#Wrong} * Tucson: {1:MULTICHOICE:California#Wrong~%100%Arizona#OK} * Los Angeles: {1:MULTICHOICE:=California#OK~Arizona#Wrong} * Phoenix: {1:MULTICHOICE:%0%California#Wrong~=Arizona#OK} The capital of France is {1:SHORTANSWER:%100%Paris#Congratulations! ~%50%Marseille#No, that is the second largest city in France (after Paris).~*#Wrong answer. The capital of France is Paris, of course.}. Click " Decode and verify the question text " Confirm that you get 4 multiple choice questions and 1 short answer question. Save the changes. Confirm that the question is successfully saved.
    • Affected Branches:
      MOODLE_32_STABLE, MOODLE_33_STABLE, MOODLE_34_STABLE, MOODLE_35_STABLE, MOODLE_36_STABLE
    • Fixed Branches:
      MOODLE_34_STABLE, MOODLE_35_STABLE
    • Pull 3.5 Branch:
    • Pull Master Branch:
      MDL-60897-master

      Description

      On Moodle 3.3.x and 3.2.x (and probably earlier versions), we regularly notice an error that prevents us from exporting questions from the question bank / copying courses / importing quizzes into other courses. After going through all questions in the question bank, we found out that a couple of the cloze-questions were corrupted and therefore prevented the export / copying / importing from working properly. Unlike other issues here in the tracker which suggest that the questions were corrupted in an earlier ID-mapping during restore (e.g. https://tracker.moodle.org/browse/MDL-54724), our cloze-questions were corrupted from the beginning.

      We could reproduce the issue by doing the following :

      1. Create new Cloze question (Multichoice) and fill in ONLY ONE choice, then save the question
      2. Moodle announces that at least two options need to be given
      3. When continuing, however, we do not get the possibility to fix the problem, but « error/question/missingcourseorcmid » appears instead and we eventually get back to the dashboard
      4. When we go back to the quiz, the question does not appear as part of the quiz, it does however, appear in the question bank.
      5. When we now try to export the question bank, the export will fail because of the corrupted cloze-question. There is also a problem when we try to copy the course or try to import the quiz into another course:

       

      ERROR: invalid input syntax for integer: ""
      SELECT * FROM mdl_question WHERE id = $1 ORDER BY id ASC
      [array (
      0 => '
      )]
      Error code: dmlreadexception

       

      To avoid this error, Moodle should not save invalid cloze-questions at all, but should instead force the user to enter a correct cloze-question (or abort the saving of the invalid cloze question in the question bank).

        Attachments

          Activity

            People

            • Votes:
              12 Vote for this issue
              Watchers:
              10 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                12/Nov/18

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 45 minutes
                45m