Uploaded image for project: 'Plugins'
  1. Plugins
  2. CONTRIB-2162

Questionnaire not allowing students to see results

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Won't Fix
    • Affects Version/s: 1.9.8, 1.9.9
    • Fix Version/s: None
    • Component/s: Module: Questionnaire
    • Labels:
      None
    • Affected Branches:
      MOODLE_19_STABLE

      Description

      The Questionnaire module has a setting where instructors can choose whether students can see all responses Never, After answering the questionnaire, After the questionnaire is closed, or Always.

      No matter which option is selected, students can only see their own responses, not those of other students.

      This is happening on my production 1.9.8 server and also on a clean 1.9.9 instance with the latest Questionnaire code.

        Gliffy Diagrams

          Attachments

            Activity

            carolinemoore Caroline Moore created issue -
            Hide
            carolinemoore Caroline Moore added a comment -

            Ok, I think I've figured this out. The elseif statement in tabs.php around line 153 should be:

            } else if (($questionnaire->resp_view == $QUESTIONNAIRE_STUDENTVIEWRESPONSES_ALWAYS ||
            ($questionnaire->resp_view == $QUESTIONNAIRE_STUDENTVIEWRESPONSES_WHENCLOSED
            && $questionnaire->is_closed()) ||
            ($questionnaire->resp_view == $QUESTIONNAIRE_STUDENTVIEWRESPONSES_WHENANSWERED
            && !$questionnaire->user_can_take($USER->id))) &&
            $questionnaire->is_survey_owner()) {

            The other pieces cause this to work incorrectly.

            $questionnaire->capabilities->readallresponses checks for the mod/questionnaire:readallresponses capability ("Read response summaries, subject to open times") looks like it should be part of the elseif (i.e. users should have this capability in order to view all responses). However, this capability is Not Set for students by default, which makes this whole drop-down menu of options for when students can view all responses moot, not to mention confusing to instructors. We could keep this line in the elseif, but we'd probably also want to set this capability to Allow for students by default, which would require seeing where else in the code this capability comes into play. (We don't want students viewing all responses when they shouldn't!)

            The second part of the elseif, ($numresp > 0) , is problematic because if the resp_view variable is set to allow students to see all responses Always, they should not be required to have > 0 responses in order to see all responses. (Actually, should this statement be part of the "WHENANSWERED" portion of the elseif?)

            I'll attach the patch file momentarily.

            Show
            carolinemoore Caroline Moore added a comment - Ok, I think I've figured this out. The elseif statement in tabs.php around line 153 should be: } else if (($questionnaire->resp_view == $QUESTIONNAIRE_STUDENTVIEWRESPONSES_ALWAYS || ($questionnaire->resp_view == $QUESTIONNAIRE_STUDENTVIEWRESPONSES_WHENCLOSED && $questionnaire->is_closed()) || ($questionnaire->resp_view == $QUESTIONNAIRE_STUDENTVIEWRESPONSES_WHENANSWERED && !$questionnaire->user_can_take($USER->id))) && $questionnaire->is_survey_owner()) { The other pieces cause this to work incorrectly. $questionnaire->capabilities->readallresponses checks for the mod/questionnaire:readallresponses capability ("Read response summaries, subject to open times") looks like it should be part of the elseif (i.e. users should have this capability in order to view all responses). However, this capability is Not Set for students by default, which makes this whole drop-down menu of options for when students can view all responses moot, not to mention confusing to instructors. We could keep this line in the elseif, but we'd probably also want to set this capability to Allow for students by default, which would require seeing where else in the code this capability comes into play. (We don't want students viewing all responses when they shouldn't!) The second part of the elseif, ($numresp > 0) , is problematic because if the resp_view variable is set to allow students to see all responses Always, they should not be required to have > 0 responses in order to see all responses. (Actually, should this statement be part of the "WHENANSWERED" portion of the elseif?) I'll attach the patch file momentarily.
            Hide
            carolinemoore Caroline Moore added a comment -

            Patch to make the resp_view option functional.

            Show
            carolinemoore Caroline Moore added a comment - Patch to make the resp_view option functional.
            carolinemoore Caroline Moore made changes -
            Field Original Value New Value
            Attachment questionnaire.diff [ 20540 ]
            Hide
            kfortin Kathryn Fortin added a comment -

            We have a client site with the same issue on 1.9.10

            Show
            kfortin Kathryn Fortin added a comment - We have a client site with the same issue on 1.9.10
            Hide
            fsainsbu Frank Sainsbury added a comment -

            I need to provide admins with a patched code for questionaire mod (http://tracker.moodle.org/browse/CONTRIB-3182), but $questionnaire->capabilities->readallresponses capability is Not Set for students by default, How would this be done in the installer?

            Show
            fsainsbu Frank Sainsbury added a comment - I need to provide admins with a patched code for questionaire mod ( http://tracker.moodle.org/browse/CONTRIB-3182 ), but $questionnaire->capabilities->readallresponses capability is Not Set for students by default, How would this be done in the installer?
            Hide
            fsainsbu Frank Sainsbury added a comment -

            in
            db/access.php add 'student' => CAP_ALLOW to readallresponses:
            ie:

            // Ability to read others' previous responses to questionnaires.
            // Subject to constraints on whether responses can be viewed whilst
            // questionnaire still open or user has not yet responded themselves.
            'mod/questionnaire:readallresponses' => array(

            'captype' => 'read',
            'contextlevel' => CONTEXT_MODULE,
            'legacy' => array(
            'manager' => CAP_ALLOW,
            'teacher' => CAP_ALLOW,
            'editingteacher' => CAP_ALLOW
            'student' => CAP_ALLOW
            )
            ),

            Show
            fsainsbu Frank Sainsbury added a comment - in db/access.php add 'student' => CAP_ALLOW to readallresponses: ie: // Ability to read others' previous responses to questionnaires. // Subject to constraints on whether responses can be viewed whilst // questionnaire still open or user has not yet responded themselves. 'mod/questionnaire:readallresponses' => array( 'captype' => 'read', 'contextlevel' => CONTEXT_MODULE, 'legacy' => array( 'manager' => CAP_ALLOW, 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW 'student' => CAP_ALLOW ) ),
            Hide
            fsainsbu Frank Sainsbury added a comment -

            But this does not clear up what other things a student might be able to do with this value set to true.
            in lib.php and locallib.php it always looks like this. so in effect the issue is that the default is restrictive, which is not obvious from the flow of the always, when closed, or answered. I feel that the change above ie add 'student' => CAP_ALLOW to readallresponses would be helpful with an explanation that if you wish to restrict then set the value off? Happy to be told otherwise.

            /// If you are allowed to view this response for another user.
            if ($this->capabilities->readallresponses &&
            ($this->resp_view == $QUESTIONNAIRE_STUDENTVIEWRESPONSES_ALWAYS ||
            ($this->resp_view == $QUESTIONNAIRE_STUDENTVIEWRESPONSES_WHENCLOSED && $this->is_closed()) ||
            ($this->resp_view == $QUESTIONNAIRE_STUDENTVIEWRESPONSES_WHENANSWERED && !$this->user_can_take($USER->id))))

            { return true; }
            Show
            fsainsbu Frank Sainsbury added a comment - But this does not clear up what other things a student might be able to do with this value set to true. in lib.php and locallib.php it always looks like this. so in effect the issue is that the default is restrictive, which is not obvious from the flow of the always, when closed, or answered. I feel that the change above ie add 'student' => CAP_ALLOW to readallresponses would be helpful with an explanation that if you wish to restrict then set the value off? Happy to be told otherwise. /// If you are allowed to view this response for another user. if ($this->capabilities->readallresponses && ($this->resp_view == $QUESTIONNAIRE_STUDENTVIEWRESPONSES_ALWAYS || ($this->resp_view == $QUESTIONNAIRE_STUDENTVIEWRESPONSES_WHENCLOSED && $this->is_closed()) || ($this->resp_view == $QUESTIONNAIRE_STUDENTVIEWRESPONSES_WHENANSWERED && !$this->user_can_take($USER->id)))) { return true; }
            rezeau Joseph Rézeau made changes -
            Status Open [ 1 ] Resolved [ 5 ]
            Resolution Won't Fix [ 2 ]
            Hide
            hanna123 hanna edelman added a comment -

            Hi, I would suggest adding the option (that was in older versions)
            resp_view == $QUESTIONNAIRE_STUDENTVIEWRESPONSES__NEVER
            since it seems like teachers, when adding any activity, like to edit the settings without having to deal with capabilities

            Show
            hanna123 hanna edelman added a comment - Hi, I would suggest adding the option (that was in older versions) resp_view == $QUESTIONNAIRE_STUDENTVIEWRESPONSES__NEVER since it seems like teachers, when adding any activity, like to edit the settings without having to deal with capabilities
            Hide
            mchurch Mike Churchward added a comment -

            Hi hanna edelman... This issue was a bug report with the old 1.9 questionnaire. The newest one is now at 2.8. Moodle's way of controlling who can access activity functions is through roles and capabilities. The questionnaire settings only determine timing, if the students are allowed to see the responses at all.
            This is all defined here - https://docs.moodle.org/27/en/Adding/editing_a_questionnaire#ALL_Responses_viewing

            If you wish to request a new feature or improvement, I would recommend opening a new issue with your request. This particular issue is not going to be re-opened.

            Show
            mchurch Mike Churchward added a comment - Hi hanna edelman ... This issue was a bug report with the old 1.9 questionnaire. The newest one is now at 2.8. Moodle's way of controlling who can access activity functions is through roles and capabilities. The questionnaire settings only determine timing, if the students are allowed to see the responses at all. This is all defined here - https://docs.moodle.org/27/en/Adding/editing_a_questionnaire#ALL_Responses_viewing If you wish to request a new feature or improvement, I would recommend opening a new issue with your request. This particular issue is not going to be re-opened.
            mchurch Mike Churchward made changes -
            Status Resolved [ 5 ] Closed [ 6 ]

              People

              • Votes:
                18 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: