Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.1, 2.2, 2.3.7, 2.4.4, 2.5
    • Fix Version/s: STABLE backlog
    • Component/s: Feedback
    • Labels:
    • Affected Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE, MOODLE_23_STABLE, MOODLE_24_STABLE, MOODLE_25_STABLE
    • Rank:
      38668

      Description

      Tested with Moodle 2.1.4 and Moodle Moodle 2.2.1+ (Build: 20120301)

      Feedback with depend item does not work as expected.

      Q1 (owncar) do you own a car?*
      yes
      no
      Page break----------------------------
      Q2 (carcolor) what color is your car?* (owncar->yes)
      blue
      black
      red
      Page break----------------------------
      Q3 (label) Survey is finished, you can now submit it.

      scenario #1
      Q1: yes
      Q2: blue (or any other color)
      Q3: Survey is finished, you can now submit it.
      Submit: OK

      scenario #2
      Q2: no
      next screen: no question text is shown, only the Previous page and Next page buttons and a Cancel button.
      Press Next page OR Previous button: error message "Saving failed because missing or false values"

        Activity

        Hide
        Joseph Rézeau added a comment -

        I think I've found the bug. The problem happens because Q2 is marked as "required" AND it's also marked as "depend" (on Q1 owncar->yes).
        It seems that these 2 options are incompatible and lead to the error I have found.

        Moreover, once a question marked as "depending" on another question has been marked as "required", it's impossible when you edit it to remove the "required" parameter.

        I think the bug is somewhere in feedback/lib.php in function feedback_check_values($firstitem, $lastitem).

        Joseph

        Show
        Joseph Rézeau added a comment - I think I've found the bug. The problem happens because Q2 is marked as "required" AND it's also marked as "depend" (on Q1 owncar->yes). It seems that these 2 options are incompatible and lead to the error I have found. Moreover, once a question marked as "depending" on another question has been marked as "required", it's impossible when you edit it to remove the "required" parameter. I think the bug is somewhere in feedback/lib.php in function feedback_check_values($firstitem, $lastitem). Joseph
        Hide
        Michael de Raadt added a comment -

        Thanks for reporting this, Joseph.

        Andreas, perhaps you could tell us if this is working as expected or if it is a bug.

        Show
        Michael de Raadt added a comment - Thanks for reporting this, Joseph. Andreas, perhaps you could tell us if this is working as expected or if it is a bug.
        Hide
        Andreas Grabs added a comment -

        Hi Michael,

        I am not sure what is the definition of a bug.
        It is so as Joseph said.
        This behavior is unexpected.
        But there are some unmerged fixes for the feedback-module so I will wait until these fixes are integrated before I do a fix here. It is no a security issue.
        Sorry for my bad english

        Best regards
        Andreas

        Show
        Andreas Grabs added a comment - Hi Michael, I am not sure what is the definition of a bug. It is so as Joseph said. This behavior is unexpected. But there are some unmerged fixes for the feedback-module so I will wait until these fixes are integrated before I do a fix here. It is no a security issue. Sorry for my bad english Best regards Andreas
        Hide
        Pau Ferrer Ocaña (crazyserver) added a comment -

        Hi, I made a patch for this situation:

        On mod/feedback/lib.php Function feedback_check_values Arround line 2220

                         [...]
                           $value = optional_param($formvalname, null, PARAM_RAW);
                         }
                         $value = $itemobj->clean_input_value($value);
        
                        //ADD THIS: Check if depending is correct and discard required if isn't
        		if($item->dependitem > 0 AND $item->required == 1){
        			if (!isset($feedbackcompletedtmp->id)){
        				$feedbackcompletedtmp = feedback_get_current_completed($item->feedback, true);
        			}
        			$fb_compare_value = true;
        			if (isset($feedbackcompletedtmp->id)){
        				$fb_compare_value = feedback_compare_item_value($feedbackcompletedtmp->id,
                                                                            $item->dependitem,
                                                                            $item->dependvalue,
                                                                            true);
        			}
        			
        			if (!isset($feedbackcompletedtmp->id) OR !$fb_compare_value) {
        				$item->required	= 0;
        			}
        		}
                        //END
                       //check if the value is set
                       if (is_null($value) AND $item->required == 1) {
                          return false;
                        }
                        [...]
        		

        It ensures that if the question is required but it does not needed to be shown, the required value falls to 0 and the show can go on!

        Pau

        Show
        Pau Ferrer Ocaña (crazyserver) added a comment - Hi, I made a patch for this situation: On mod/feedback/lib.php Function feedback_check_values Arround line 2220 [...] $value = optional_param($formvalname, null , PARAM_RAW); } $value = $itemobj->clean_input_value($value); //ADD THIS: Check if depending is correct and discard required if isn't if ($item->dependitem > 0 AND $item->required == 1){ if (!isset($feedbackcompletedtmp->id)){ $feedbackcompletedtmp = feedback_get_current_completed($item->feedback, true ); } $fb_compare_value = true ; if (isset($feedbackcompletedtmp->id)){ $fb_compare_value = feedback_compare_item_value($feedbackcompletedtmp->id, $item->dependitem, $item->dependvalue, true ); } if (!isset($feedbackcompletedtmp->id) OR !$fb_compare_value) { $item->required = 0; } } //END //check if the value is set if (is_null($value) AND $item->required == 1) { return false ; } [...] It ensures that if the question is required but it does not needed to be shown, the required value falls to 0 and the show can go on! Pau
        Hide
        Andreas Grabs added a comment -

        Hi Pau,
        thank you for this fix. I'll try this soon.
        Best regards
        Andreas

        Show
        Andreas Grabs added a comment - Hi Pau, thank you for this fix. I'll try this soon. Best regards Andreas
        Hide
        Christian Rojas added a comment -

        Hi,

        I just added the code of Pau in version 2.6.1 and it works perfectly. Each branch is completely isolated and does not give error submitting the form.

        It would be great to be integrated this solution into the production version.

        Sorry for my english.

        Best regards

        Christian Rojas

        Show
        Christian Rojas added a comment - Hi, I just added the code of Pau in version 2.6.1 and it works perfectly. Each branch is completely isolated and does not give error submitting the form. It would be great to be integrated this solution into the production version. Sorry for my english. Best regards Christian Rojas
        Hide
        Joe Amatrucola added a comment -

        I ran into this same problem today, and the patch above resolved the issue for us. I, too, request that this code be integrated into the production version.

        Joe

        Show
        Joe Amatrucola added a comment - I ran into this same problem today, and the patch above resolved the issue for us. I, too, request that this code be integrated into the production version. Joe
        Hide
        Paul Vaughan added a comment -

        Can anyone confirm use of and success with the above patch on 2.6?

        Show
        Paul Vaughan added a comment - Can anyone confirm use of and success with the above patch on 2.6?
        Hide
        Joe Amatrucola added a comment -

        I am running Moodle 2.6.1+ (Build: 20140131)
        I should follow-up from my previous post by saying that after implementing the fix above, it seemed to solve the problem involving dependent and required questions. However, within 2 days, folks were still reporting difficulty, which I then verified. Not having much more time to troubleshoot, I just changed the dependent question to not be required.

        Show
        Joe Amatrucola added a comment - I am running Moodle 2.6.1+ (Build: 20140131) I should follow-up from my previous post by saying that after implementing the fix above, it seemed to solve the problem involving dependent and required questions. However, within 2 days, folks were still reporting difficulty, which I then verified. Not having much more time to troubleshoot, I just changed the dependent question to not be required.

          People

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

            Dates

            • Created:
              Updated: