Moodle
  1. Moodle
  2. MDL-28241

Error writing to the database when creating certain cloze question

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 2.1, 2.2
    • Fix Version/s: 2.1.2
    • Component/s: Questions
    • Labels:
    • Database:
      MySQL
    • Testing Instructions:
      Hide

      1. Create a multianswer (Embedded answer) question. There is an example question text that tests all the options in this comment: http://tracker.moodle.org/browse/MDL-28241?focusedCommentId=121358&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-121358

      2. Check that the 'Decode and verify question text' button on the form works without errors.

      3. Check that saving the question works without errors, both when creating a new question and editing an existing one.

      4. Then preview the newly created question and verify it works properly.

      Show
      1. Create a multianswer (Embedded answer) question. There is an example question text that tests all the options in this comment: http://tracker.moodle.org/browse/MDL-28241?focusedCommentId=121358&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-121358 2. Check that the 'Decode and verify question text' button on the form works without errors. 3. Check that saving the question works without errors, both when creating a new question and editing an existing one. 4. Then preview the newly created question and verify it works properly.
    • Affected Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE
    • Fixed Branches:
      MOODLE_21_STABLE
    • Pull from Repository:
    • Pull Master Branch:
    • Rank:
      17939

      Description

      To reproduce:

      Create a new cloze question with this simple HTML code:

      <p>Sub-question 1:

      {2:NUMERICAL:=5E-3:1E-4}

      </p>
      <p>Sub-question 2:

      {1:MULTICHOICE:%100%Yes~%0%No}

      </p>

      Then save it. This leads to the error shown in the image attached. As you can see, Moodle code tries to store a character 'Y' in the 'answerformat' field.

      This character is obviously the first one of the word 'Yes' in the multichoice sub-question (if you change the word
      'Yes' to 'Si' then Moodle tries to store an 'S'), so it seems clearly a problem related to parsing code.

      Note that this bug may pass unnoticed if you upgrade from 1.9 or 2.0 to 2.1 because upgrade works fine. Only when you edit/import the question or add new ones (i.e., when parsing HTML code) this bug appears.

        Issue Links

          Activity

          Hide
          Orestes Mas added a comment -

          Changing the severity to 'critical' because this bug makes certain cloze questions unusable.

          Show
          Orestes Mas added a comment - Changing the severity to 'critical' because this bug makes certain cloze questions unusable.
          Hide
          Orestes Mas added a comment -

          I've tried successfully to reproduce the bug into a fresh installation of Moodle 2.1 (not an upgrade), so problem is totally reproducible.

          Please comment and/or provide hints on how to work around this bug. I'm lost into the code

          Show
          Orestes Mas added a comment - I've tried successfully to reproduce the bug into a fresh installation of Moodle 2.1 (not an upgrade), so problem is totally reproducible. Please comment and/or provide hints on how to work around this bug. I'm lost into the code
          Hide
          Tim Hunt added a comment -

          In PHP, if you use the notation $string[$index] (not $array[$index]) then it will return the ($index)th character of the string, counting from 0. That must be what is going wrong here. At some point the code is getting confused between a string and an array.

          Show
          Tim Hunt added a comment - In PHP, if you use the notation $string [$index] (not $array [$index] ) then it will return the ($index)th character of the string, counting from 0. That must be what is going wrong here. At some point the code is getting confused between a string and an array.
          Hide
          Carl Hodkinson added a comment -

          Looking through the comments, I used a new install too. As I got slightly different vales, I have pasted them below - was for MC-question type by the way).

          Debug info: Incorrect integer value: 'W' for column 'answerformat' at row 1
          UPDATE mdl_question_answers SET question = ?,answer = ?,feedback = ?,answerformat = ?,fraction = ?,feedbackformat = ? WHERE id=?
          [array (
          0 => 71,
          1 => 'W',
          2 => 'Feedback for this wrong answer',
          3 => 'W',
          4 => '0',
          5 => '1',
          6 => 81,
          )]

          Do not know if at all related, but there is no feedback for short answer cloze. Will create a separate ticket.

          Show
          Carl Hodkinson added a comment - Looking through the comments, I used a new install too. As I got slightly different vales, I have pasted them below - was for MC-question type by the way). Debug info: Incorrect integer value: 'W' for column 'answerformat' at row 1 UPDATE mdl_question_answers SET question = ?,answer = ?,feedback = ?,answerformat = ?,fraction = ?,feedbackformat = ? WHERE id=? [array ( 0 => 71, 1 => 'W', 2 => 'Feedback for this wrong answer', 3 => 'W', 4 => '0', 5 => '1', 6 => 81, )] Do not know if at all related, but there is no feedback for short answer cloze. Will create a separate ticket.
          Hide
          Joseph Rézeau added a comment -

          @Carl
          "there is no feedback for short answer cloze. Will create a separate ticket."
          I've already reported this bug as MDL-28259
          "Individual answers Feedback not shown in Cloze questions".
          Joseph

          Show
          Joseph Rézeau added a comment - @Carl "there is no feedback for short answer cloze. Will create a separate ticket." I've already reported this bug as MDL-28259 "Individual answers Feedback not shown in Cloze questions". Joseph
          Hide
          Pierre Pichet added a comment -

          Tim,
          you do some modifications to the regexp analysis.

                          $wrapped->feedback["$answerindex"]['itemid'] = '1';
          
                      }
                      if (!empty($answerregs[ANSWER_REGEX_ANSWER_TYPE_NUMERICAL])
                              && preg_match('~'.NUMERICAL_ALTERNATIVE_REGEX.'~',
                                      $altregs[ANSWER_ALTERNATIVE_REGEX_ANSWER], $numregs)) {
                          $wrapped->answer[] = $numregs[NUMERICAL_CORRECT_ANSWER];
                          if ($numregs[NUMERICAL_ABS_ERROR_MARGIN]) {
                              $wrapped->tolerance["$answerindex"] =
                              $numregs[NUMERICAL_ABS_ERROR_MARGIN];
                          } else {
                              $wrapped->tolerance["$answerindex"] = 0;
                          }
                      } else { // Tolerance can stay undefined for non numerical questions
                          // Undo quoting done by the HTML editor.
                          $answer = html_entity_decode(
                                  $altregs[ANSWER_ALTERNATIVE_REGEX_ANSWER], ENT_QUOTES, 'UTF-8');
                          $answer = str_replace('\}', '}', $answer);
                          $wrapped->answer["$answerindex"] = str_replace('\#', '#', $answer);
                      }
                      $tmp = explode($altregs[0], $remainingalts, 2);
          
          

          I do not understand all your new code as I cannot test it as I am used to do it.
          However your wrapped->answer[...] are not the same in numerical as in other other question type.
          Could this be related to the actual bug ?

          Show
          Pierre Pichet added a comment - Tim, you do some modifications to the regexp analysis. $wrapped->feedback["$answerindex"]['itemid'] = '1'; } if (!empty($answerregs[ANSWER_REGEX_ANSWER_TYPE_NUMERICAL]) && preg_match('~'.NUMERICAL_ALTERNATIVE_REGEX.'~', $altregs[ANSWER_ALTERNATIVE_REGEX_ANSWER], $numregs)) { $wrapped->answer[] = $numregs[NUMERICAL_CORRECT_ANSWER]; if ($numregs[NUMERICAL_ABS_ERROR_MARGIN]) { $wrapped->tolerance["$answerindex"] = $numregs[NUMERICAL_ABS_ERROR_MARGIN]; } else { $wrapped->tolerance["$answerindex"] = 0; } } else { // Tolerance can stay undefined for non numerical questions // Undo quoting done by the HTML editor. $answer = html_entity_decode( $altregs[ANSWER_ALTERNATIVE_REGEX_ANSWER], ENT_QUOTES, 'UTF-8'); $answer = str_replace('\}', '}', $answer); $wrapped->answer["$answerindex"] = str_replace('\#', '#', $answer); } $tmp = explode($altregs[0], $remainingalts, 2); I do not understand all your new code as I cannot test it as I am used to do it. However your wrapped->answer [...] are not the same in numerical as in other other question type. Could this be related to the actual bug ?
          Hide
          Pierre Pichet added a comment -

          I just did try to create the same question in moodle/dem site and i obtain the same error message.
          so this is 2,0 bug not a 2,1 and it could be related to changes done with MDL-24168 that were not correctly tested....

          I can even trace back that I introduce the "$answerindex" to be able to put figures in feedback that were mainly used in multiplechoice questions.

          multianswer/questiontype.php revision 1.90, Mon Sep 20 23:57:22 2010 WST

          However the decode answer function in the edit_form.php which uses the same regexp analysis, decodes correctly the various question parts either in the numerical and in the multiple choice.
          Things get scrumbled when saving??
          However lot of things were changed in the DB calls since september 2010.

          Show
          Pierre Pichet added a comment - I just did try to create the same question in moodle/dem site and i obtain the same error message. so this is 2,0 bug not a 2,1 and it could be related to changes done with MDL-24168 that were not correctly tested.... I can even trace back that I introduce the "$answerindex" to be able to put figures in feedback that were mainly used in multiplechoice questions. multianswer/questiontype.php revision 1.90, Mon Sep 20 23:57:22 2010 WST However the decode answer function in the edit_form.php which uses the same regexp analysis, decodes correctly the various question parts either in the numerical and in the multiple choice. Things get scrumbled when saving?? However lot of things were changed in the DB calls since september 2010.
          Hide
          Pierre Pichet added a comment -

          Sorry, i just noticed that moodle demo site has been updated to 2,1.
          so this remain a 2,1 bug but not related as much to the regexp decoding than to the multiple choice answer saving process.

          Show
          Pierre Pichet added a comment - Sorry, i just noticed that moodle demo site has been updated to 2,1. so this remain a 2,1 bug but not related as much to the regexp decoding than to the multiple choice answer saving process.
          Hide
          Pierre Pichet added a comment -

          The following line defined the
          $wrapped->answer["$answerindex"] = str_replace('#','#',answer);
          This was written before adding image to multiplechoice answers.
          the actual multiplechoice code expect a structure like
          answer['text'] (and the related file and format)

          I think that multianswer should be updated to this new structure.

          there is a tracker issue on this...

          Show
          Pierre Pichet added a comment - The following line defined the $wrapped->answer ["$answerindex"] = str_replace('#','#',answer); This was written before adding image to multiplechoice answers. the actual multiplechoice code expect a structure like answer ['text'] (and the related file and format) I think that multianswer should be updated to this new structure. there is a tracker issue on this...
          Hide
          Pierre Pichet added a comment -

          In the first step to add the necessary answer structure as a first step to integrate image in multiple choice as part of multianswer.(MDL-26511)

          Show
          Pierre Pichet added a comment - In the first step to add the necessary answer structure as a first step to integrate image in multiple choice as part of multianswer.( MDL-26511 )
          Hide
          Pierre Pichet added a comment -

          Following the work done on MDL-26511 the solution could be something like

          ...
          $wrapped->answer["answerindex"] = str_replace('\#','#',$answer);
          if($wrapped->qtype == 'multichoice'){
             $wanswer = array('');
             $wanswer['text']=$wrapped->answer["answerindex"];
             $wanswer['format']='0';
             $wanswer['itemid']='';
             $wrapped->answer["answerindex"]=$wanswer;
          }
          
          Show
          Pierre Pichet added a comment - Following the work done on MDL-26511 the solution could be something like ... $wrapped->answer["answerindex"] = str_replace('\#','#',$answer); if($wrapped->qtype == 'multichoice'){ $wanswer = array(''); $wanswer['text']=$wrapped->answer["answerindex"]; $wanswer['format']='0'; $wanswer['itemid']=''; $wrapped->answer["answerindex"]=$wanswer; }
          Hide
          Pierre Pichet added a comment -

          Tim,
          the "$answerindex" was created to clearly identify the feedback related to a given answer as we cannot use the feedback[]= syntax as the feedback is not always presnt in each answer in a cloze subquestion.
          however this was not corrected for the numerical as shown in

                          $wrapped->answer[] = $numregs[NUMERICAL_CORRECT_ANSWER];
          

          This should be corrected although you could have a better way to do it than the [" $answerindex"].
          The images being allowed in multiplechoice answers have modified the saving_options process and the editor beng used for answers, the $answer['text'] contains now the answer value.
          This is why we need to modify the cloze regexp extraction.

          we could also process a step further and implement images in cloze multichoice i.e. MDL-26511.
          In any cases the saving_options of multichoice expect needs some rewriting as

                  $answercount = 0;
                  foreach ($question->answer as $key => $answer) {
                      if ($answer != '') {
          
          Show
          Pierre Pichet added a comment - Tim, the "$answerindex" was created to clearly identify the feedback related to a given answer as we cannot use the feedback[]= syntax as the feedback is not always presnt in each answer in a cloze subquestion. however this was not corrected for the numerical as shown in $wrapped->answer[] = $numregs[NUMERICAL_CORRECT_ANSWER]; This should be corrected although you could have a better way to do it than the [" $answerindex"] . The images being allowed in multiplechoice answers have modified the saving_options process and the editor beng used for answers, the $answer ['text'] contains now the answer value. This is why we need to modify the cloze regexp extraction. we could also process a step further and implement images in cloze multichoice i.e. MDL-26511 . In any cases the saving_options of multichoice expect needs some rewriting as $answercount = 0; foreach ($question->answer as $key => $answer) { if ($answer != '') {
          Hide
          Pierre Pichet added a comment -

          the decode and subquestion display of the edit_multiasnwer_form.php should be modified to handle the answer[text]form. see MDL-26511

          Show
          Pierre Pichet added a comment - the decode and subquestion display of the edit_multiasnwer_form.php should be modified to handle the answer [text] form. see MDL-26511
          Hide
          Pierre Pichet added a comment -

          Tim,
          just to say that I am begining some work on this to at least suggest a minimal 'tested' solution.

          Show
          Pierre Pichet added a comment - Tim, just to say that I am begining some work on this to at least suggest a minimal 'tested' solution.
          Hide
          Pierre Pichet added a comment -

          Tim,
          just to add that
          line 413 and following of questiontype.php solve the problem.

                          $answer = html_entity_decode(
                                  $altregs[ANSWER_ALTERNATIVE_REGEX_ANSWER], ENT_QUOTES, 'UTF-8');
                          $answer = str_replace('\}', '}', $answer);
                          $wrapped->answer["$answerindex"] = str_replace('\#', '#', $answer);
                          if($wrapped->qtype == 'multichoice'){
                             $wanswer = array('');
                             $wanswer['text']=$wrapped->answer["$answerindex"];
                             $wanswer['format']='0';
                             $wanswer['itemid']='';
                             $wrapped->answer["$answerindex"]=$wanswer;
                          }            
                      }
          

          Unfortunately my wife and me have a more that 25 years rendez-vous with the FFM i.e. Festival des Filns de Monde for the next 10 days

          Given your current tasks, you could rightly conclude that life is not fair for all.
          On the other end, I wish you that at 69 years old, you could have such oppotunities.

          Show
          Pierre Pichet added a comment - Tim, just to add that line 413 and following of questiontype.php solve the problem. $answer = html_entity_decode( $altregs[ANSWER_ALTERNATIVE_REGEX_ANSWER], ENT_QUOTES, 'UTF-8'); $answer = str_replace('\}', '}', $answer); $wrapped->answer["$answerindex"] = str_replace('\#', '#', $answer); if($wrapped->qtype == 'multichoice'){ $wanswer = array(''); $wanswer['text']=$wrapped->answer["$answerindex"]; $wanswer['format']='0'; $wanswer['itemid']=''; $wrapped->answer["$answerindex"]=$wanswer; } } Unfortunately my wife and me have a more that 25 years rendez-vous with the FFM i.e. Festival des Filns de Monde for the next 10 days Given your current tasks, you could rightly conclude that life is not fair for all. On the other end, I wish you that at 69 years old, you could have such oppotunities.
          Hide
          Tim Hunt added a comment -

          That looks plausible. I will try to review it properly later today.

          Show
          Tim Hunt added a comment - That looks plausible. I will try to review it properly later today.
          Hide
          Peter Gravell added a comment -

          Ok I really needed this to work so I've done a quick and dirty fix.

          I'm running 2.1.1+ (Build: 20110817).

          From what I can see the problem resides in question/type/multichoice/questiontype.php

          In particular it is treating $answerdata as an array on lines 84-86:

          $answer->answer = $this->import_or_save_files($answerdata,
          $context, 'question', 'answer', $answer->id);
          $answer->answerformat = $answerdata['format'];

          As a quick fix I just changed this to:
          $answer->answer = $question->answer[$key];
          $answer->answerformat = 1;

          This seemed to work if anyone is in need of multichoice cloze questions and can't wait.

          However after this I have run into several other problems, including:
          1) incorrect parsing of cloze questions with several types (e.g. multichoice and shortanswer) in the same question.
          2) errors when editing questions (like those described above) to remove parts - call to undefined function delete_question() arises.

          Not sure if my changes have caused these problems or whether they exist independently - will test if I have time...

          PS I also note that on line 88 there is another call to "import_or_save_files" which deals with feedback - this may be why feedback isn't working as someone mentioned previously...

          Show
          Peter Gravell added a comment - Ok I really needed this to work so I've done a quick and dirty fix. I'm running 2.1.1+ (Build: 20110817). From what I can see the problem resides in question/type/multichoice/questiontype.php In particular it is treating $answerdata as an array on lines 84-86: $answer->answer = $this->import_or_save_files($answerdata, $context, 'question', 'answer', $answer->id); $answer->answerformat = $answerdata ['format'] ; As a quick fix I just changed this to: $answer->answer = $question->answer [$key] ; $answer->answerformat = 1; This seemed to work if anyone is in need of multichoice cloze questions and can't wait. However after this I have run into several other problems, including: 1) incorrect parsing of cloze questions with several types (e.g. multichoice and shortanswer) in the same question. 2) errors when editing questions (like those described above) to remove parts - call to undefined function delete_question() arises. Not sure if my changes have caused these problems or whether they exist independently - will test if I have time... PS I also note that on line 88 there is another call to "import_or_save_files" which deals with feedback - this may be why feedback isn't working as someone mentioned previously...
          Hide
          Pierre Pichet added a comment -

          Peter,
          The multiple choice has been modified to include files (i.e.) in answer but the cloze decoding has not been changed accordingly.
          What I suggest in my last comment is to modify the cloze decoding although the bug means that multichoice does not handle well old answer structure.
          The final code should be to include images in cloze multichoice answer i.e. MDL-26511 which is more complex to do.
          As for the feedback, the decoding is OK, it was just forgotten in the display (MDL-....)

          Show
          Pierre Pichet added a comment - Peter, The multiple choice has been modified to include files (i.e.) in answer but the cloze decoding has not been changed accordingly. What I suggest in my last comment is to modify the cloze decoding although the bug means that multichoice does not handle well old answer structure. The final code should be to include images in cloze multichoice answer i.e. MDL-26511 which is more complex to do. As for the feedback, the decoding is OK, it was just forgotten in the display (MDL-....)
          Hide
          Toni Soto added a comment -

          I tested this issue an I reproduced the same effects. My version is Moodle 2.1.1+ (Build: 20110817).
          I went a step forward and tested all the formats for Cloze questions and this is what I founded:

          SHORTANSWER & SHORTANSWER_C --> No problem!
          NUMERICAL --> No problem!
          MULTICHOICE (Dropdown menu) & MULTICHOICE_H or MCH --> They don't work (exactely as Orestes Mas described)
          MULTICHOICE_V or MCV --> They are written to the database BUT they show an error when they ared displayed

          As you can see only mutichoices formats show problems. To reproduce what I mentioned I used this code:

          ----------------------------------------------------------

          Shortanswer: (Write: Madrid):

          {1:SHORTANSWER:Barcelona#Feedback for this wrong answer~=Madrid#Feedback for correct answer~%50%madrid#Feedback for half credit answer}

          ShortanswerCase sensitive: (Write moodle in upper case letters)

          {1:SHORTANSWER_C:moodle#Feedback for moodle in lower case ~=MOODLE#Feedback for MOODLE in upper case ~%50%Moodle#Feedback for only first letter in upper case}

          Numerical (Write: 23.8):

          {2:NUMERICAL:=23.8:0.1#Feedback for correct answer 23.8~%50%23.8:2#Feedback for half credit answer in the nearby region of the correct answer}

          .

          Multichoice (Dropdown Menu)

          {1:MULTICHOICE:Wrong answer#Feedback for this wrong answer~Another wrong answer#Feedback for the other wrong answer~=Correct answer#Feedback for correct answer~%50%Answer that gives half the credit#Feedback for half credit answer}

          Multichoice VERTICAL (Dropdown Menu)

          {2:MCV:1. Wrong answer#Feedback for this wrong answer~2. Another wrong answer#Feedback for the other wrong answer~=3. Correct answer#Feedback for correct answer~%50%4. Answer that gives half the credit#Feedback for half credit answer}

          Multichoice HORIZONTAL:

          {2:MCH:a. Wrong answer#Feedback for this wrong answer~b. Another wrong answer#Feedback for the other wrong answer~=c. Correct answer#Feedback for correct answer~%50%d. Answer that gives half the credit#Feedback for half credit answer}

          ----------------------------------------------------------

          Good luck debbuging!

          Show
          Toni Soto added a comment - I tested this issue an I reproduced the same effects. My version is Moodle 2.1.1+ (Build: 20110817). I went a step forward and tested all the formats for Cloze questions and this is what I founded: SHORTANSWER & SHORTANSWER_C --> No problem! NUMERICAL --> No problem! MULTICHOICE (Dropdown menu) & MULTICHOICE_H or MCH --> They don't work (exactely as Orestes Mas described) MULTICHOICE_V or MCV --> They are written to the database BUT they show an error when they ared displayed As you can see only mutichoices formats show problems. To reproduce what I mentioned I used this code: ---------------------------------------------------------- Shortanswer: (Write: Madrid): {1:SHORTANSWER:Barcelona#Feedback for this wrong answer~=Madrid#Feedback for correct answer~%50%madrid#Feedback for half credit answer} ShortanswerCase sensitive: (Write moodle in upper case letters) {1:SHORTANSWER_C:moodle#Feedback for moodle in lower case ~=MOODLE#Feedback for MOODLE in upper case ~%50%Moodle#Feedback for only first letter in upper case} Numerical (Write: 23.8): {2:NUMERICAL:=23.8:0.1#Feedback for correct answer 23.8~%50%23.8:2#Feedback for half credit answer in the nearby region of the correct answer} . Multichoice (Dropdown Menu) {1:MULTICHOICE:Wrong answer#Feedback for this wrong answer~Another wrong answer#Feedback for the other wrong answer~=Correct answer#Feedback for correct answer~%50%Answer that gives half the credit#Feedback for half credit answer} Multichoice VERTICAL (Dropdown Menu) {2:MCV:1. Wrong answer#Feedback for this wrong answer~2. Another wrong answer#Feedback for the other wrong answer~=3. Correct answer#Feedback for correct answer~%50%4. Answer that gives half the credit#Feedback for half credit answer} Multichoice HORIZONTAL: {2:MCH:a. Wrong answer#Feedback for this wrong answer~b. Another wrong answer#Feedback for the other wrong answer~=c. Correct answer#Feedback for correct answer~%50%d. Answer that gives half the credit#Feedback for half credit answer} ---------------------------------------------------------- Good luck debbuging!
          Hide
          Tim Hunt added a comment -

          Thanks Pierre, that showed me the key bit of the fix. Testing it, I found several places in the question editing form that needed to be fixed too.

          I am pretty sure this change I am about to push for integration works.

          Show
          Tim Hunt added a comment - Thanks Pierre, that showed me the key bit of the fix. Testing it, I found several places in the question editing form that needed to be fixed too. I am pretty sure this change I am about to push for integration works.
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Integrated, thanks!

          Show
          Eloy Lafuente (stronk7) added a comment - Integrated, thanks!
          Hide
          Rajesh Taneja added a comment -

          WSD (White screen of Death), while editing "Embedded Question":

          Fatal error: Call to undefined function delete_question() in /usr/local/www/moodle/question/type/multianswer/questiontype.php on line 151 Call Stack: 0.0011 854048 1. {main}() /usr/local/www/moodle/question/question.php:0 0.4490 55037360 2. qtype_multianswer->save_question() /usr/local/www/moodle/question/question.php:264 0.4492 55050896 3. question_type->save_question() /usr/local/www/moodle/question/type/multianswer/questiontype.php:181 0.4753 55121848 4. qtype_multianswer->save_question_options() /usr/local/www/moodle/question/type/questiontypebase.php:424
          

          Steps to reproduce:

          1. Create a new question "Embedded answers (Cloze)"
          2. Type following in "Question text"
            <p>Sub-question 1: {2:NUMERICAL:=5E-3:1E-4}</p>
            <p>Sub-question 2: {1:MULTICHOICE:%100%Yes~%0%No}</p>
            
          3. Click "Decode and verify the question text"
          4. Click save changes
          5. Now edit this question
          6. Replace "Question text" with
            <p>Sub-question 1: {2:NUMERICAL:=5E-3:1E-4}</p>
            
          7. Click "Decode and verify the question text"
          8. Confirm "The question will be saved as edited"
          9. Click "Save Changes"
          10. WSD (White screen of death) with above error msg will be visible.
          Show
          Rajesh Taneja added a comment - WSD (White screen of Death), while editing "Embedded Question": Fatal error: Call to undefined function delete_question() in /usr/local/www/moodle/question/type/multianswer/questiontype.php on line 151 Call Stack: 0.0011 854048 1. {main}() /usr/local/www/moodle/question/question.php:0 0.4490 55037360 2. qtype_multianswer->save_question() /usr/local/www/moodle/question/question.php:264 0.4492 55050896 3. question_type->save_question() /usr/local/www/moodle/question/type/multianswer/questiontype.php:181 0.4753 55121848 4. qtype_multianswer->save_question_options() /usr/local/www/moodle/question/type/questiontypebase.php:424 Steps to reproduce: Create a new question "Embedded answers (Cloze)" Type following in "Question text" <p>Sub-question 1: {2:NUMERICAL:=5E-3:1E-4}</p> <p>Sub-question 2: {1:MULTICHOICE:%100%Yes~%0%No}</p> Click "Decode and verify the question text" Click save changes Now edit this question Replace "Question text" with <p>Sub-question 1: {2:NUMERICAL:=5E-3:1E-4}</p> Click "Decode and verify the question text" Confirm "The question will be saved as edited" Click "Save Changes" WSD (White screen of death) with above error msg will be visible.
          Hide
          Rajesh Taneja added a comment -

          Also, "Question text" being a required field is not defined as required. Probably, it might be nice to have it as required field, so that JS can validate the same.

          Show
          Rajesh Taneja added a comment - Also, "Question text" being a required field is not defined as required. Probably, it might be nice to have it as required field, so that JS can validate the same.
          Hide
          Tim Hunt added a comment -

          Both of these problems are separate issues that are unrelated to this bug. Please can you create new tracker issues?

          People are desperate for a fix to this bug, which has no work-around, while the two problems you found during testing do have work-arounds. So let us not hold up this fix because of side-issues.

          Show
          Tim Hunt added a comment - Both of these problems are separate issues that are unrelated to this bug. Please can you create new tracker issues? People are desperate for a fix to this bug, which has no work-around, while the two problems you found during testing do have work-arounds. So let us not hold up this fix because of side-issues.
          Hide
          Rajesh Taneja added a comment -

          Sure Tim
          Unfortunately I don't have permission to change the status now. Probably Eloy or Aparup can do that
          I will open two new bugs.

          Show
          Rajesh Taneja added a comment - Sure Tim Unfortunately I don't have permission to change the status now. Probably Eloy or Aparup can do that I will open two new bugs.
          Hide
          Eloy Lafuente (stronk7) added a comment -

          re-marking as integrated. Feel free to pass and reference the follow-up issues.

          Show
          Eloy Lafuente (stronk7) added a comment - re-marking as integrated. Feel free to pass and reference the follow-up issues.
          Hide
          Rajesh Taneja added a comment -

          Creating "Embedded answer' works fine
          Thanks for fixing this Tim

          FYI:
          MDL-29062 and MDL-29064 were created to solve related bugs.

          Show
          Rajesh Taneja added a comment - Creating "Embedded answer' works fine Thanks for fixing this Tim FYI: MDL-29062 and MDL-29064 were created to solve related bugs.
          Hide
          Tim Hunt added a comment -

          FYI those two other bugs are already fixed, but probably won't be integrated until next week.

          Show
          Tim Hunt added a comment - FYI those two other bugs are already fixed, but probably won't be integrated until next week.
          Hide
          James Hendricks added a comment -

          Excuse my ignorance. This is the first time that I have tracked a bug with Moodle. Now that the fix appears to be tested, what are the next steps for integrating it into a Moodle release MOODLE_21_STABLE or other version? Is there a place that I could read up on this?

          Thanks for your help.... and all the programming gurus who are a lot smarter than me!

          Show
          James Hendricks added a comment - Excuse my ignorance. This is the first time that I have tracked a bug with Moodle. Now that the fix appears to be tested, what are the next steps for integrating it into a Moodle release MOODLE_21_STABLE or other version? Is there a place that I could read up on this? Thanks for your help.... and all the programming gurus who are a lot smarter than me!
          Hide
          Tim Hunt added a comment -

          See http://docs.moodle.org/dev/Process

          There is one more step. Once all this week's fixes have reached the tested state, the new weekly release is copied to all the servers (git mirrors, cvs mirrors, downloads server) and then all the bugs are marked closed.

          I believe we are in the middle of the copying, so this bug will be closed soon.

          Show
          Tim Hunt added a comment - See http://docs.moodle.org/dev/Process There is one more step. Once all this week's fixes have reached the tested state, the new weekly release is copied to all the servers (git mirrors, cvs mirrors, downloads server) and then all the bugs are marked closed. I believe we are in the middle of the copying, so this bug will be closed soon.
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Many thanks for the hard work, this has been sent upstream and is available in all the git and cvs repositories.

          Show
          Eloy Lafuente (stronk7) added a comment - Many thanks for the hard work, this has been sent upstream and is available in all the git and cvs repositories.

            People

            • Votes:
              19 Vote for this issue
              Watchers:
              22 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: