-
Notifications
You must be signed in to change notification settings - Fork 197
Description
Responses are not visible in some circumstances.
This may happen, when a new questionnaire is created in a course and a global pubic form is selected where the questions are taken from.
Apparently submitting responses is not an issue. However, the results of all responsed cannot be viewed, not even by the siteadmin.
The reason is that inside of \questionnaire::can_view_all_responses() the call to $this->is_survey_owner(); which is implicit done in the return statement, always evaluates to false. The current course is not the course where the question survey belongs to, even though the realm is public.
As a quick hack I inserted into \questionnaire::can_view_all_responses() the following lines at some place:
if (is_siteadmin() || has_capability('moodle/course:changecategory', $this->context)) {
return true; // Siteadmin or capability that usually requires the manager role.
}
that, at least allows the site admin and the course manager to view the results.
I guess the change inside is_survey_owner() must be adapted in a way like:
return (
(!empty($this->survey->courseid)) && ($this->course->id == $this->survey->courseid)) ||
$this->survey->realm === 'public'
):
I don't have a deeper knowledge of the data model to be confident to handle it that way. Also changing the content of the method should probably also change the name, because the check is actually doing something different then.
Best regards, Stephan