mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-74332 mod_survey: Critical incidents dont require summary and scales
Do not show summary and scales for the survey with critical incidents. So critical incidents survey would have questions and participants only under response reports. Also corrected the heading for the Questions page.
This commit is contained in:
parent
b5f51883f0
commit
bfb4c2797a
@ -70,36 +70,36 @@ class actionbar implements renderable, templatable {
|
||||
* @return url_select url_select object.
|
||||
*/
|
||||
private function create_select_menu(): url_select {
|
||||
$summarylink = new moodle_url('/mod/survey/report.php', ['id' => $this->id, 'action' => 'summary']);
|
||||
$scaleslink = new moodle_url('/mod/survey/report.php', ['id' => $this->id, 'action' => 'scales']);
|
||||
$questionslink = new moodle_url('/mod/survey/report.php', ['id' => $this->id, 'action' => 'questions']);
|
||||
$participantslink = new moodle_url('/mod/survey/report.php', ['id' => $this->id, 'action' => 'students']);
|
||||
$menu = [];
|
||||
$actions = $this->get_available_reports();
|
||||
|
||||
$menu = [
|
||||
$summarylink->out(false) => get_string('summary', 'survey'),
|
||||
$scaleslink->out(false) => get_string('scales', 'survey'),
|
||||
$questionslink->out(false) => get_string('questions', 'survey'),
|
||||
$participantslink->out(false) => get_string('participants'),
|
||||
];
|
||||
|
||||
switch ($this->action) {
|
||||
case 'summary':
|
||||
$activeurl = $summarylink;
|
||||
break;
|
||||
case 'scales':
|
||||
$activeurl = $scaleslink;
|
||||
break;
|
||||
case 'questions':
|
||||
$activeurl = $questionslink;
|
||||
break;
|
||||
case 'students':
|
||||
$activeurl = $participantslink;
|
||||
break;
|
||||
default:
|
||||
$activeurl = $this->currenturl;
|
||||
foreach ($actions as $action => $straction) {
|
||||
$url = new moodle_url($this->currenturl, ['id' => $this->id, 'action' => $action]);
|
||||
$menu[$url->out(false)] = $straction;
|
||||
}
|
||||
return new url_select($menu, $this->currenturl->out(false), null, 'surveyresponseselect');
|
||||
}
|
||||
|
||||
return new url_select($menu, $activeurl->out(false), null, 'surveyresponseselect');
|
||||
/**
|
||||
* Generate available reports list
|
||||
*
|
||||
* @return array The list of available action => action string.
|
||||
*/
|
||||
private function get_available_reports(): array {
|
||||
global $DB;
|
||||
|
||||
$cm = get_coursemodule_from_id('survey', $this->id);
|
||||
$survey = $DB->get_record("survey", ["id" => $cm->instance]);
|
||||
|
||||
$actions = [];
|
||||
if ($survey && ($survey->template != SURVEY_CIQ)) {
|
||||
$actions['summary'] = get_string('summary', 'survey');
|
||||
$actions['scales'] = get_string('scales', 'survey');
|
||||
}
|
||||
$actions['questions'] = get_string('questions', 'survey');
|
||||
$actions['students'] = get_string('participants');
|
||||
|
||||
return $actions;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,2 +1,3 @@
|
||||
clicktocontinue,mod_survey
|
||||
viewsurveyresponses,mod_survey
|
||||
allquestions,mod_survey
|
||||
|
@ -26,7 +26,6 @@
|
||||
$string['actual'] = 'Actual';
|
||||
$string['actualclass'] = 'Class actual';
|
||||
$string['actualstudent'] = '{$a} actual';
|
||||
$string['allquestions'] = 'All questions in order, all students';
|
||||
$string['allscales'] = 'All scales, all students';
|
||||
$string['alreadysubmitted'] = 'You have already submitted this survey';
|
||||
$string['analysisof'] = 'Analysis of {$a}';
|
||||
@ -286,3 +285,4 @@ $string['allquestionrequireanswer'] = 'All questions are required and must be an
|
||||
// Deprecated since Moodle 4.0.
|
||||
$string['clicktocontinue'] = 'Click here to continue';
|
||||
$string['viewsurveyresponses'] = 'View {$a} survey responses';
|
||||
$string['allquestions'] = 'All questions in order, all students';
|
||||
|
@ -811,9 +811,16 @@ function survey_supports($feature) {
|
||||
* @param navigation_node $surveynode
|
||||
*/
|
||||
function survey_extend_settings_navigation(settings_navigation $settings, navigation_node $surveynode) {
|
||||
global $DB;
|
||||
if (has_capability('mod/survey:readresponses', $settings->get_page()->cm->context)) {
|
||||
$url = new moodle_url('/mod/survey/report.php', array('id' => $settings->get_page()->cm->id,
|
||||
'action' => 'summary'));
|
||||
$cm = get_coursemodule_from_id('survey', $settings->get_page()->cm->id);
|
||||
$survey = $DB->get_record("survey", ["id" => $cm->instance]);
|
||||
$url = new moodle_url('/mod/survey/report.php', ['id' => $settings->get_page()->cm->id]);
|
||||
if ($survey && ($survey->template != SURVEY_CIQ)) {
|
||||
$url->param('action', 'summary');
|
||||
} else {
|
||||
$url->param('action', 'questions');
|
||||
}
|
||||
$surveynode->add(get_string("responsereports", "survey"), $url);
|
||||
}
|
||||
}
|
||||
|
@ -87,7 +87,6 @@
|
||||
$strquestions = get_string("questions", "survey");
|
||||
$strdownload = get_string("download", "survey");
|
||||
$strallscales = get_string("allscales", "survey");
|
||||
$strallquestions = get_string("allquestions", "survey");
|
||||
$strselectedquestions = get_string("selectedquestions", "survey");
|
||||
$strseemoredetail = get_string("seemoredetail", "survey");
|
||||
$strnotes = get_string("notes", "survey");
|
||||
@ -148,6 +147,10 @@
|
||||
switch ($action) {
|
||||
|
||||
case "summary":
|
||||
// If survey type is Critical incidents then we don't show summary report.
|
||||
if ($survey->template == SURVEY_CIQ) {
|
||||
throw new moodle_exception('cannotviewreport');
|
||||
}
|
||||
echo $OUTPUT->heading($strsummary, 3);
|
||||
|
||||
if ($groupsactivitymenu) {
|
||||
@ -164,6 +167,10 @@
|
||||
break;
|
||||
|
||||
case "scales":
|
||||
// If survey type is Critical incidents then we don't show scales report.
|
||||
if ($survey->template == SURVEY_CIQ) {
|
||||
throw new moodle_exception('cannotviewreport');
|
||||
}
|
||||
echo $OUTPUT->heading($strscales, 3);
|
||||
|
||||
if ($groupsactivitymenu) {
|
||||
@ -218,7 +225,7 @@
|
||||
$questions = $DB->get_records_list("survey_questions", "id", explode(',',$survey->questions));
|
||||
$questionorder = explode(",", $survey->questions);
|
||||
|
||||
echo $OUTPUT->heading($strallquestions, 3);
|
||||
echo $OUTPUT->heading($strquestions, 3);
|
||||
}
|
||||
|
||||
if ($groupsactivitymenu) {
|
||||
@ -506,5 +513,8 @@
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new moodle_exception('cannotviewreport');
|
||||
|
||||
}
|
||||
echo $OUTPUT->footer();
|
||||
|
54
mod/survey/tests/behat/survey_critical_incidents.feature
Normal file
54
mod/survey/tests/behat/survey_critical_incidents.feature
Normal file
@ -0,0 +1,54 @@
|
||||
@mod @mod_survey @javascript
|
||||
Feature: A teacher navigates to response reports of students
|
||||
If survey activity is configured for critical students
|
||||
Only questions and particiats pages should be visible under response reports
|
||||
|
||||
Background:
|
||||
Given the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| teacher1 | Teacher | 1 | teacher1@example.com |
|
||||
| student1 | Student | 1 | student1@example.com |
|
||||
| student2 | Student | 1 | student2@example.com |
|
||||
And the following "courses" exist:
|
||||
| fullname | shortname | category | enablecompletion |
|
||||
| Course 1 | C1 | 0 | 1 |
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
| student1 | C1 | student |
|
||||
| student2 | C1 | student |
|
||||
And the following "activities" exist:
|
||||
| activity | name | intro | course | idnumber | section |
|
||||
| survey | Test survey name | Test survey description | C1 | survey1 | 1 |
|
||||
|
||||
Scenario: Only questions and participants page should be available under response reports as teacher
|
||||
Given I am on the "Test survey name" "survey activity" page logged in as teacher1
|
||||
And I navigate to "Settings" in current page administration
|
||||
And I set the following fields to these values:
|
||||
| Survey type | Critical incidents |
|
||||
And I press "Save and return to course"
|
||||
And I log out
|
||||
And I am on the "Test survey name" "survey activity" page logged in as student1
|
||||
And I set the field "At what moment in class were you most engaged as a learner?" to "most engaged as student1"
|
||||
And I set the field "At what moment in class were you most distanced as a learner?" to "most distanced as student1"
|
||||
And I set the field "What action from anyone in the forums did you find most affirming or helpful?" to "most helpful student1"
|
||||
And I set the field "What action from anyone in the forums did you find most puzzling or confusing?" to "most confusing student1"
|
||||
And I set the field "What event surprised you most?" to "most surprised student1"
|
||||
And I press "Submit"
|
||||
And I press "Continue"
|
||||
And I log out
|
||||
And I am on the "Test survey name" "survey activity" page logged in as student2
|
||||
And I set the field "At what moment in class were you most engaged as a learner?" to "most engaged as student2"
|
||||
And I set the field "At what moment in class were you most distanced as a learner?" to "most distanced as student2"
|
||||
And I set the field "What action from anyone in the forums did you find most affirming or helpful?" to "most helpful student2"
|
||||
And I set the field "What action from anyone in the forums did you find most puzzling or confusing?" to "most confusing student2"
|
||||
And I set the field "What event surprised you most?" to "most surprised student1"
|
||||
And I press "Submit"
|
||||
And I press "Continue"
|
||||
And I log out
|
||||
When I am on the "Test survey name" "survey activity" page logged in as teacher1
|
||||
And I navigate to "Response reports" in current page administration
|
||||
Then I should not see "Summary"
|
||||
And I should not see "Scales"
|
||||
And I should see "Questions"
|
||||
And I should see "Participants"
|
Loading…
x
Reference in New Issue
Block a user