Add-ons
  1. Add-ons
  2. CONTRIB-2162

Questionnaire not allowing students to see results

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor 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
    • Rank:
      21774

      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.

        Activity

        Hide
        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
        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
        Caroline Moore added a comment -

        Patch to make the resp_view option functional.

        Show
        Caroline Moore added a comment - Patch to make the resp_view option functional.
        Hide
        Kathryn Fortin added a comment -

        We have a client site with the same issue on 1.9.10

        Show
        Kathryn Fortin added a comment - We have a client site with the same issue on 1.9.10
        Hide
        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
        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
        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
        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
        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
        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; }

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development