Moodle
  1. Moodle
  2. MDL-26714

Summary of attempt page in a cloze multi-answer quiz question

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.2
    • Fix Version/s: 2.0.3
    • Component/s: Quiz
    • Testing Instructions:
      Hide

      Create a Cloze question with numerical subquestions (ideally create a wide range of Cloze questions).

      Add them to a quiz.

      Attempt the quiz, and ensure that the responses are saved and graded correctly, and that the navigation updates correctly.

      Show
      Create a Cloze question with numerical subquestions (ideally create a wide range of Cloze questions). Add them to a quiz. Attempt the quiz, and ensure that the responses are saved and graded correctly, and that the navigation updates correctly.
    • Affected Branches:
      MOODLE_20_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-26714_master
    • Rank:
      16598

      Description

      On the Summary of attempt page in a cloze multi-answer quiz: Shows Answered for questions on pages viewed but not necessarily questions that have been answered/attempted.

        Activity

        Hide
        Tim Hunt added a comment -

        Cloze, so -> Pierre in the first instance.

        Pierre, when this happened with other question types, the problem was caused by the compare_responses function not working properly when the response was blank.

        Show
        Tim Hunt added a comment - Cloze, so -> Pierre in the first instance. Pierre, when this happened with other question types, the problem was caused by the compare_responses function not working properly when the response was blank.
        Hide
        Pierre Pichet added a comment -

        As I am already on Cloze code (MDL-26511) , I will take look.

        Show
        Pierre Pichet added a comment - As I am already on Cloze code ( MDL-26511 ) , I will take look.
        Hide
        Pierre Pichet added a comment -

        There is no specific multianswer compare_responses function.
        It uses the default_questiontype.
        I have to check with multianswer_questions having the different questiontypes to see where the test is not good...

        Show
        Pierre Pichet added a comment - There is no specific multianswer compare_responses function. It uses the default_questiontype. I have to check with multianswer_questions having the different questiontypes to see where the test is not good...
        Hide
        Pierre Pichet added a comment -

        I suspect the numerical as the code have changed and somehow an input element set as a numerical always send back a 0 as an empty value...

        Show
        Pierre Pichet added a comment - I suspect the numerical as the code have changed and somehow an input element set as a numerical always send back a 0 as an empty value...
        Hide
        Tieku Bortei-Doku added a comment -

        Will this be difficult to correct/fix?

        Show
        Tieku Bortei-Doku added a comment - Will this be difficult to correct/fix?
        Hide
        Pierre Pichet added a comment -

        The problem is with multiple choice V or H as there is no response if no radio button element is chosen so the number of responses array() is different i.e in a five sub questions (MCV, MC, SW,SW,NUM)
        the state
        responses array =( [2],[3],[4],[5] )
        and teststate =([1], [2],[3],[4],[5] )

        if the user click on one radiobutton i.e. id 220
        responses array =([1]=>220, [2],[3],[4],[5] )
        and teststate =([1], [2],[3],[4],[5] )

        So this can be solved by creating a new multianswer compare_responses that will handle this using the compare functions of the subquestion types..
        On normal multiple choice the problem is not the same as the
        the state
        responses array =() is empty if nothing is selected and this is clearly identified as empty.

        So let's do the code and testing.

        Show
        Pierre Pichet added a comment - The problem is with multiple choice V or H as there is no response if no radio button element is chosen so the number of responses array() is different i.e in a five sub questions (MCV, MC, SW,SW,NUM) the state responses array =( [2] , [3] , [4] , [5] ) and teststate =( [1] , [2] , [3] , [4] , [5] ) if the user click on one radiobutton i.e. id 220 responses array =( [1] =>220, [2] , [3] , [4] , [5] ) and teststate =( [1] , [2] , [3] , [4] , [5] ) So this can be solved by creating a new multianswer compare_responses that will handle this using the compare functions of the subquestion types.. On normal multiple choice the problem is not the same as the the state responses array =() is empty if nothing is selected and this is clearly identified as empty. So let's do the code and testing.
        Hide
        Pierre Pichet added a comment -

        The compare code being the same in 1,9, this could implied that unanswered questions having the multiplechoice v or h option could be handled as being answered even if they were not.
        However the quiz steps are not the same.

        Tim,

        have seen reports on this possible problem for 1,9 ?

        Show
        Pierre Pichet added a comment - The compare code being the same in 1,9, this could implied that unanswered questions having the multiplechoice v or h option could be handled as being answered even if they were not. However the quiz steps are not the same. Tim, have seen reports on this possible problem for 1,9 ?
        Hide
        Pierre Pichet added a comment - - edited

        Tim,
        The solution could be the following
        in multinaswer/questiontype.php

            function compare_responses(&$question, $state, $teststate) {
                global $QTYPES ;
                $result = false;
                foreach($question->options->questions as $key => $wrapped) {
                    if (!empty($wrapped)){
                        $stateforquestion = clone($state);
                        if(isset($state->responses[$key])){
                            $stateforquestion->responses[''] = $state->responses[$key];
                        } else {
                            $stateforquestion->responses[''] = '' ;    
                        }                    
                        $teststateforquestion = clone($teststate);
                        if(isset($teststate->responses[$key])){                
                            $teststateforquestion->responses[''] = $teststate->responses[$key];
                        } else {
                            $teststateforquestion->responses[''] = '' ;    
                        }                    
                        if (  $QTYPES[$wrapped->qtype]->compare_responses(&$wrapped, $stateforquestion, $teststateforquestion)) {
                            $result = true ;
                        }else {
                            $result = false ;
                            break ;
                        }
                    }
                }
           return result ;
        

        The logic being is one of the subquestion is false the retour is false .

        I test it , seems Ok but you have perhaps a better code.
        Feel free to create the commit, my Git need some cleaning and rebasing ...

        Show
        Pierre Pichet added a comment - - edited Tim, The solution could be the following in multinaswer/questiontype.php function compare_responses(&$question, $state, $teststate) { global $QTYPES ; $result = false; foreach($question->options->questions as $key => $wrapped) { if (!empty($wrapped)){ $stateforquestion = clone($state); if(isset($state->responses[$key])){ $stateforquestion->responses[''] = $state->responses[$key]; } else { $stateforquestion->responses[''] = '' ; } $teststateforquestion = clone($teststate); if(isset($teststate->responses[$key])){ $teststateforquestion->responses[''] = $teststate->responses[$key]; } else { $teststateforquestion->responses[''] = '' ; } if ( $QTYPES[$wrapped->qtype]->compare_responses(&$wrapped, $stateforquestion, $teststateforquestion)) { $result = true ; }else { $result = false ; break ; } } } return result ; The logic being is one of the subquestion is false the retour is false . I test it , seems Ok but you have perhaps a better code. Feel free to create the commit, my Git need some cleaning and rebasing ...
        Hide
        Tieku Bortei-Doku added a comment -

        Hello Tim, Pierre, how soon can you finalize testing and commit the changes? Thanks

        Show
        Tieku Bortei-Doku added a comment - Hello Tim, Pierre, how soon can you finalize testing and commit the changes? Thanks
        Hide
        Tieku Bortei-Doku added a comment -

        Any progress on this? Thanks

        Show
        Tieku Bortei-Doku added a comment - Any progress on this? Thanks
        Hide
        Pierre Pichet added a comment -

        the actual process of testing and commit is more structured than last year and more reliable.
        Steps that are under direct control of Tim has been done as this bug was triaged for further processing.

        Show
        Pierre Pichet added a comment - the actual process of testing and commit is more structured than last year and more reliable. Steps that are under direct control of Tim has been done as this bug was triaged for further processing.
        Hide
        Tim Hunt added a comment -

        OK, cleaned up version of the code at https://github.com/timhunt/moodle/compare/master...MDL-26714

        It would be really great to have some help testing this fully. If we can get some confirmation that this fix works, and does not cause any problems, before Friday, then I can do a pull request and it can be included in the next weekly build.

        Instructions for testing:

        1. Create a quiz with some multianswer questions.
        2. Go through the quiz without answering any questions, and check that when you get to the summary page, this question is shown as not being answered.
        3. Do the same test, but with the other setting for Adaptive mode.
        4. Now test putting in some answers and moving on to the next page, then going back and forwards sometimes changing the answer, and sometimes not. When you get to the review page, make sure there are just the right number of save events in the history of responses table under each question.
        5. Repeat 4. in adaptive mode, and include clicking Check in the testing as well as navigating backwards and forwards to save.

        Show
        Tim Hunt added a comment - OK, cleaned up version of the code at https://github.com/timhunt/moodle/compare/master...MDL-26714 It would be really great to have some help testing this fully. If we can get some confirmation that this fix works, and does not cause any problems, before Friday, then I can do a pull request and it can be included in the next weekly build. Instructions for testing: 1. Create a quiz with some multianswer questions. 2. Go through the quiz without answering any questions, and check that when you get to the summary page, this question is shown as not being answered. 3. Do the same test, but with the other setting for Adaptive mode. 4. Now test putting in some answers and moving on to the next page, then going back and forwards sometimes changing the answer, and sometimes not. When you get to the review page, make sure there are just the right number of save events in the history of responses table under each question. 5. Repeat 4. in adaptive mode, and include clicking Check in the testing as well as navigating backwards and forwards to save.
        Hide
        Tieku Bortei-Doku added a comment -

        Is there a way I can help with testing? Where do I go to download? Or do I modify my existing code for question/type/multianswer/questiontype.php?

        Show
        Tieku Bortei-Doku added a comment - Is there a way I can help with testing? Where do I go to download? Or do I modify my existing code for question/type/multianswer/questiontype.php?
        Hide
        Tim Hunt added a comment -

        Well, if you know how to use the git version-control system, you can get the changes from what I said above.

        Alternatively, if you know http://docs.moodle.org/en/Development:How_to_apply_a_patch then you can use the file I just attached.

        Or you can just manually make those changes to the code in question/type/multianswer/questiontype.php

        Show
        Tim Hunt added a comment - Well, if you know how to use the git version-control system, you can get the changes from what I said above. Alternatively, if you know http://docs.moodle.org/en/Development:How_to_apply_a_patch then you can use the file I just attached. Or you can just manually make those changes to the code in question/type/multianswer/questiontype.php
        Hide
        Tieku Bortei-Doku added a comment -

        Tim I have tested in both adaptive and non-adaptive mode it looks like it is working. I realized there is no "Previous" button (only a "Next" button) in Moodle 2.0.2 to navigate back and forth between quiz pages. Is that a quiz setting? There is also no way to choose not to answer a question, after you answer it (i.e. un-select the radio button)

        Show
        Tieku Bortei-Doku added a comment - Tim I have tested in both adaptive and non-adaptive mode it looks like it is working. I realized there is no "Previous" button (only a "Next" button) in Moodle 2.0.2 to navigate back and forth between quiz pages. Is that a quiz setting? There is also no way to choose not to answer a question, after you answer it (i.e. un-select the radio button)
        Hide
        Tim Hunt added a comment -

        You can jump to any question by clicking the icon in the navigation block, or you can jump back to any question from the summary page.

        We decided that most of the time people move forwards through quizzes, so it was better to keep the UI simple with only a next button - and let people use the navigation for everything else.

        There is no way to un-select a radio button in Moodle, but that is a separate issue.

        Show
        Tim Hunt added a comment - You can jump to any question by clicking the icon in the navigation block, or you can jump back to any question from the summary page. We decided that most of the time people move forwards through quizzes, so it was better to keep the UI simple with only a next button - and let people use the navigation for everything else. There is no way to un-select a radio button in Moodle, but that is a separate issue.
        Hide
        Tieku Bortei-Doku added a comment -

        I did not realize the omission of the Previous button was deliberate. Now I know.
        Well then I will say my testing is done.Who else has to test?
        I guess where there are multiple MCH responses per question, there is no way of indicating partially answered questions (on the Summary of attempt page).

        Show
        Tieku Bortei-Doku added a comment - I did not realize the omission of the Previous button was deliberate. Now I know. Well then I will say my testing is done.Who else has to test? I guess where there are multiple MCH responses per question, there is no way of indicating partially answered questions (on the Summary of attempt page).
        Hide
        Pierre Pichet added a comment -

        I have done the testing and everything seem OK.
        The number of save events stored does not increase if the answer is the same like repeating submit on empty response.
        In this case however as there are submits an empty response is seen as answered.

        By the way, I just commented the Tieku post on forum...

        Show
        Pierre Pichet added a comment - I have done the testing and everything seem OK. The number of save events stored does not increase if the answer is the same like repeating submit on empty response. In this case however as there are submits an empty response is seen as answered. By the way, I just commented the Tieku post on forum...
        Hide
        Tim Hunt added a comment -

        Thanks for the testing. PULL request done.

        Show
        Tim Hunt added a comment - Thanks for the testing. PULL request done.
        Hide
        Tieku Bortei-Doku added a comment -

        When does this make it to Moodle download? Downloaded today but not there. Thanks.

        Show
        Tieku Bortei-Doku added a comment - When does this make it to Moodle download? Downloaded today but not there. Thanks.
        Hide
        Eloy Lafuente (stronk7) added a comment - - edited

        The change has been integrated and if it passes integration tests next Tuesday, will be sent upstream on Wednesday and available in next weekly version (Thursday).

        Thanks Pierre, Tim & Tieku, ciao

        Show
        Eloy Lafuente (stronk7) added a comment - - edited The change has been integrated and if it passes integration tests next Tuesday, will be sent upstream on Wednesday and available in next weekly version (Thursday). Thanks Pierre, Tim & Tieku, ciao
        Hide
        Helen Foster added a comment -

        Thanks everyone. As Eloy mentioned, the fix is now available in the latest 2.0.2+.

        Show
        Helen Foster added a comment - Thanks everyone. As Eloy mentioned, the fix is now available in the latest 2.0.2+.
        Hide
        Pierre Pichet added a comment -

        Numerical cloze does not respond correctly i.e. the response is not seen as answered if it is the only one that is answered.

        See http://moodle.org/mod/forum/discuss.php?d=172474
        and
        http://moodle.org/mod/forum/discuss.php?d=172170.

        Show
        Pierre Pichet added a comment - Numerical cloze does not respond correctly i.e. the response is not seen as answered if it is the only one that is answered. See http://moodle.org/mod/forum/discuss.php?d=172474 and http://moodle.org/mod/forum/discuss.php?d=172170 .
        Hide
        Pierre Pichet added a comment -

        The problem is related to changes done in numerical when adding the unit element.
        The compare response wait for an answer element.
        This was not seen in cloze as cloze does not call the numerical compare_response before this new cloze compare_response .
        If the test is good for at least one other sub question that is not numerical then question appears as attempted and is graded correctly .
        Although there was one numerical in the 5 question cloze that I use fortesting, I did not test the numerical as the only one answered.

        The simplest way to solve this is probably to do the compare response for numerical locally in the cloze question code.
        So back to work

        Show
        Pierre Pichet added a comment - The problem is related to changes done in numerical when adding the unit element. The compare response wait for an answer element. This was not seen in cloze as cloze does not call the numerical compare_response before this new cloze compare_response . If the test is good for at least one other sub question that is not numerical then question appears as attempted and is graded correctly . Although there was one numerical in the 5 question cloze that I use fortesting, I did not test the numerical as the only one answered. The simplest way to solve this is probably to do the compare response for numerical locally in the cloze question code. So back to work
        Hide
        Pierre Pichet added a comment -

        One solution is to use the shortanswer compare function

                    if ($wrapped->qtype == 'numerical'){
                        // use shortanswer                 
                        if (!$QTYPES['shortanswer']->compare_responses($wrapped,
                                $stateforquestion, $teststateforquestion)) {
                            return false;
                        }
                    }else {
                        if (!$QTYPES[$wrapped->qtype]->compare_responses($wrapped,
                            $stateforquestion, $teststateforquestion)) {
                            return false;
                        }
                    }                
        

        First tests seem OK but???

        The shortanswer is not waiting for a given 'answer' element.

        There are other solutions one of these is to modify the numerical compare_responses but as we are changing all these codes for 2,1, the proposed solution appears the lowest cost patch

        Show
        Pierre Pichet added a comment - One solution is to use the shortanswer compare function if ($wrapped->qtype == 'numerical'){ // use shortanswer if (!$QTYPES['shortanswer']->compare_responses($wrapped, $stateforquestion, $teststateforquestion)) { return false; } }else { if (!$QTYPES[$wrapped->qtype]->compare_responses($wrapped, $stateforquestion, $teststateforquestion)) { return false; } } First tests seem OK but??? The shortanswer is not waiting for a given 'answer' element. There are other solutions one of these is to modify the numerical compare_responses but as we are changing all these codes for 2,1, the proposed solution appears the lowest cost patch
        Hide
        Orestes Mas added a comment -

        I think it's not a minor bug, but a major one. Quizzes that include cloze question with numerical sub-questions will not work, and this could pass unnoticed to teachers and problem will explode in the middle of a quiz (like it happened to me)

        Show
        Orestes Mas added a comment - I think it's not a minor bug, but a major one. Quizzes that include cloze question with numerical sub-questions will not work, and this could pass unnoticed to teachers and problem will explode in the middle of a quiz (like it happened to me)
        Hide
        Pierre Pichet added a comment -

        The solution applied create a major bug !!!
        Cloze numerical questions answers are not saved correctly

        Show
        Pierre Pichet added a comment - The solution applied create a major bug !!! Cloze numerical questions answers are not saved correctly
        Hide
        Tim Hunt added a comment -

        Note to integrators:

        I am aware that the latest pull request is a god-awful ugly hack. However, it is the simplest solution at this stage. Roll-on the new question engine.

        Show
        Tim Hunt added a comment - Note to integrators: I am aware that the latest pull request is a god-awful ugly hack. However, it is the simplest solution at this stage. Roll-on the new question engine.
        Hide
        Eloy Lafuente (stronk7) added a comment -

        Integrated, thanks!

        Show
        Eloy Lafuente (stronk7) added a comment - Integrated, thanks!
        Hide
        Aparup Banerjee added a comment - - edited

        :-| an importable question set that tests the wide range of Cloze questions would be awesome for testing.

        Show
        Aparup Banerjee added a comment - - edited :-| an importable question set that tests the wide range of Cloze questions would be awesome for testing.
        Hide
        Aparup Banerjee added a comment -

        yup works for me, marks are saved and grade show up appropriately.

        Show
        Aparup Banerjee added a comment - yup works for me, marks are saved and grade show up appropriately.
        Hide
        Eloy Lafuente (stronk7) added a comment -

        Closing as fixed. Many thanks!

        Show
        Eloy Lafuente (stronk7) added a comment - Closing as fixed. Many thanks!

          People

          • Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: