Moodle
  1. Moodle
  2. MDL-29569

Impossible to create Matching type questions inside Lessons without response text

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.4, 2.1.1
    • Fix Version/s: 2.0.6, 2.1.3
    • Component/s: Lesson
    • Labels:
    • Testing Instructions:
      Hide

      1)Create a lesson
      2)Add a page with matching question
      3)select following options
      ->Correct answer jump: next page
      ->Correct score: 10
      ->Wrong answer jump: next page
      ->Wrong score: 0
      4)Make sure response texts are empty.
      5)add couple of matching and answer pairs
      6) Save the question
      7) edit the question by changing the following:
      ->Correct answer jump: this page
      ->Correct score: 1
      ->Wrong answer jump: this page
      ->Wrong score: 0
      8) make sure the new values are stored properly.
      9) Retry above texts with "response text" filled in. Everything works as expected.
      10)make sure to check the expanded mode and make sure it displays the correct info.

      Show
      1)Create a lesson 2)Add a page with matching question 3)select following options ->Correct answer jump: next page ->Correct score: 10 ->Wrong answer jump: next page ->Wrong score: 0 4)Make sure response texts are empty. 5)add couple of matching and answer pairs 6) Save the question 7) edit the question by changing the following: ->Correct answer jump: this page ->Correct score: 1 ->Wrong answer jump: this page ->Wrong score: 0 8) make sure the new values are stored properly. 9) Retry above texts with "response text" filled in. Everything works as expected. 10)make sure to check the expanded mode and make sure it displays the correct info.
    • Workaround:
      Hide

      always use response text in such situations

      Show
      always use response text in such situations
    • Affected Branches:
      MOODLE_20_STABLE, MOODLE_21_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE, MOODLE_21_STABLE
    • Pull from Repository:
    • Pull Master Branch:
    • Rank:
      19086

      Description

      Matching type Questions heavily breaks if there is no response text associated with it.
      Follow these instructions for an better idea:-
      1)Create a lesson
      2)Add a page with matching question
      3)select following options
      ->Correct answer jump - next page
      ->Correct score -10
      ->Wrong answer jump -next page
      ->Wrong score -2
      4)Make sure response texts are empty.
      5) Save the question and open the question again.
      6) Settings are automatically changed to following (Without any error)
      ->Correct answer jump - this page
      ->Correct score -0
      ->Wrong answer jump -this page
      ->Wrong score -0
      7) Retry above texts with "response text" filled in. Everything works as expected.

      Possible solutions:-
      1)Resolve the issue to allow empty response texts.
      2)Make response text fields required.

      attached screenshots of what it was configured to be and what it automatically changes to.

      1. less-1.PNG
        46 kB
      2. less-2.PNG
        47 kB

        Issue Links

          Activity

          Hide
          Ankit Agarwal added a comment -

          Hi Rosie,
          A few things you might want to consider before pushing it to integration:-

          • Lesson>Edit>Expanded is still broken and shows invalid information
          • If we are using a default value of 0 for wrong answer and correct answer fields, the fields should be made required and auto-filled with 0 perhaps
          • The first two conditions of if can be combined together
                        if (isset($answer->answer) && $answer->answer != '') {
                            $answer->id = $DB->insert_record("lesson_answers", $answer);
                            $answers[$answer->id] = new lesson_page_answer($answer);
                        } else if ($i < 2) {
                            $answer->id = $DB->insert_record("lesson_answers", $answer);
                            $answers[$answer->id] = new lesson_page_answer($answer);
                        } else {
                            break;
                        }
            

            Same can be done to the other if condition present :-

            if ($this->answers[$i]->answer != '') {
                            if (!isset($this->answers[$i]->id)) {
                                $this->answers[$i]->id =  $DB->insert_record("lesson_answers", $this->answers[$i]);
                            } else {
                                $DB->update_record("lesson_answers", $this->answers[$i]->properties());
                            }
            
                        } else if ($i < 2) {
                            if (!isset($this->answers[$i]->id)) {
                                $this->answers[$i]->id =  $DB->insert_record("lesson_answers", $this->answers[$i]);
                            } else {
                                $DB->update_record("lesson_answers", $this->answers[$i]->properties());
                            }
            
                        } else if (isset($this->answers[$i]->id)) {
                            $DB->delete_records('lesson_answers', array('id'=>$this->answers[$i]->id));
                            unset($this->answers[$i]);
                        }
            

            Rest stuff looks good to me!
            Thanks

          Show
          Ankit Agarwal added a comment - Hi Rosie, A few things you might want to consider before pushing it to integration:- Lesson>Edit>Expanded is still broken and shows invalid information If we are using a default value of 0 for wrong answer and correct answer fields, the fields should be made required and auto-filled with 0 perhaps The first two conditions of if can be combined together if (isset($answer->answer) && $answer->answer != '') { $answer->id = $DB->insert_record( "lesson_answers" , $answer); $answers[$answer->id] = new lesson_page_answer($answer); } else if ($i < 2) { $answer->id = $DB->insert_record( "lesson_answers" , $answer); $answers[$answer->id] = new lesson_page_answer($answer); } else { break ; } Same can be done to the other if condition present :- if ($ this ->answers[$i]->answer != '') { if (!isset($ this ->answers[$i]->id)) { $ this ->answers[$i]->id = $DB->insert_record( "lesson_answers" , $ this ->answers[$i]); } else { $DB->update_record( "lesson_answers" , $ this ->answers[$i]->properties()); } } else if ($i < 2) { if (!isset($ this ->answers[$i]->id)) { $ this ->answers[$i]->id = $DB->insert_record( "lesson_answers" , $ this ->answers[$i]); } else { $DB->update_record( "lesson_answers" , $ this ->answers[$i]->properties()); } } else if (isset($ this ->answers[$i]->id)) { $DB->delete_records('lesson_answers', array('id'=>$ this ->answers[$i]->id)); unset($ this ->answers[$i]); } Rest stuff looks good to me! Thanks
          Hide
          Rossiani Wijaya added a comment -

          Hi Ankit,

          Thanks for noticing the expand section and default values for correct and wrong answers. I will make changes to those two items.

          As for combining the if statement, each if statement actually use differently. In matching question, correct and wrong responses are stored in answer table. These values are allowed to have empty string, which will be catch by the second if(i<2). The actual matching pairs will be inserted by the first if.

          After having a discussion with Ankit, it would be better to have the jumpto and score fixed located on the second if.

          I will make changes to the patch according to the above statement.

          Show
          Rossiani Wijaya added a comment - Hi Ankit, Thanks for noticing the expand section and default values for correct and wrong answers. I will make changes to those two items. As for combining the if statement, each if statement actually use differently. In matching question, correct and wrong responses are stored in answer table. These values are allowed to have empty string, which will be catch by the second if(i<2). The actual matching pairs will be inserted by the first if. After having a discussion with Ankit, it would be better to have the jumpto and score fixed located on the second if. I will make changes to the patch according to the above statement.
          Hide
          Rossiani Wijaya added a comment -

          Hi Ankit,

          I updated the patch for all branches. When you have a chance, could you re-review this?

          Thanks

          Show
          Rossiani Wijaya added a comment - Hi Ankit, I updated the patch for all branches. When you have a chance, could you re-review this? Thanks
          Hide
          Ankit Agarwal added a comment -

          Hi Rossie,
          Things looking good to me!
          Thanks

          Show
          Ankit Agarwal added a comment - Hi Rossie, Things looking good to me! Thanks
          Hide
          Rossiani Wijaya added a comment -

          Thanks Ankit for reviewing.

          submitting for integration review.

          Show
          Rossiani Wijaya added a comment - Thanks Ankit for reviewing. submitting for integration review.
          Hide
          Sam Hemelryk added a comment -

          Hi Rosie,

          This needs more work presently.
          If you create a new matching question and give it both positive and negative feedback you will notice that the score and jumpto are not saved.

          Cheers
          Sam

          Show
          Sam Hemelryk added a comment - Hi Rosie, This needs more work presently. If you create a new matching question and give it both positive and negative feedback you will notice that the score and jumpto are not saved. Cheers Sam
          Hide
          Rossiani Wijaya added a comment -

          Thanks sam for spotting that.

          fixed all patches and re-submitting for integration.

          Show
          Rossiani Wijaya added a comment - Thanks sam for spotting that. fixed all patches and re-submitting for integration.
          Hide
          Sam Hemelryk added a comment -

          Thanks Rosie - this has been integrated now

          Show
          Sam Hemelryk added a comment - Thanks Rosie - this has been integrated now
          Hide
          Jason Fowler added a comment -

          All good

          Show
          Jason Fowler added a comment - All good
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Done, your delicious hacks have been sent upstream, many thanks!

          Closing as fixed, ciao

          Show
          Eloy Lafuente (stronk7) added a comment - Done, your delicious hacks have been sent upstream, many thanks! Closing as fixed, ciao

            People

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

              Dates

              • Created:
                Updated:
                Resolved: