From fde4592c9ff8e021bd5035fba726a9ca43ff72a1 Mon Sep 17 00:00:00 2001 From: Damyon Wiese Date: Thu, 21 Mar 2019 14:00:13 +0800 Subject: [PATCH] MDL-52828 competencies: Breakdown report Add behat test for the breakdown report, including the activity filter. --- .../classes/output/user_course_navigation.php | 4 ++ report/competency/templates/report.mustache | 24 ++++++++ .../templates/user_course_navigation.mustache | 24 ++++++++ .../tests/behat/breakdown_by_activity.feature | 61 +++++++++++++++++++ 4 files changed, 113 insertions(+) create mode 100644 report/competency/tests/behat/breakdown_by_activity.feature diff --git a/report/competency/classes/output/user_course_navigation.php b/report/competency/classes/output/user_course_navigation.php index 536d96376b8..57735788ede 100644 --- a/report/competency/classes/output/user_course_navigation.php +++ b/report/competency/classes/output/user_course_navigation.php @@ -82,6 +82,10 @@ class user_course_navigation implements renderable, templatable { $data->userid = $this->userid; $data->courseid = $this->courseid; $data->moduleid = $this->moduleid; + if (empty($data->moduleid)) { + // Moduleid is optional. + $data->moduleid = 0; + } $data->baseurl = $this->baseurl; $data->groupselector = ''; diff --git a/report/competency/templates/report.mustache b/report/competency/templates/report.mustache index e1e2191d7f1..24622d7f346 100644 --- a/report/competency/templates/report.mustache +++ b/report/competency/templates/report.mustache @@ -1,3 +1,27 @@ +{{! + This file is part of Moodle - http://moodle.org/ + + Moodle is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Moodle is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Moodle. If not, see . +}} +{{! + @template report_competency/report + + Moodle template competency breakdown report. + + Example context (json): + { "pushratingstouserplans": false, "usercompetencies": []} +}}
{{#pushratingstouserplans}} diff --git a/report/competency/templates/user_course_navigation.mustache b/report/competency/templates/user_course_navigation.mustache index e48f434c8e6..ad430a6ac5b 100644 --- a/report/competency/templates/user_course_navigation.mustache +++ b/report/competency/templates/user_course_navigation.mustache @@ -1,3 +1,27 @@ +{{! + This file is part of Moodle - http://moodle.org/ + + Moodle is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Moodle is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Moodle. If not, see . +}} +{{! + @template report_competency/user_course_navigation + + Moodle navigation control allowing to jump to a user or filter to an activity. + + Example context (json): + { "hasusers": false, "hasmodules": false} +}}

{{{groupselector}}}

diff --git a/report/competency/tests/behat/breakdown_by_activity.feature b/report/competency/tests/behat/breakdown_by_activity.feature new file mode 100644 index 00000000000..dfa0876a6b9 --- /dev/null +++ b/report/competency/tests/behat/breakdown_by_activity.feature @@ -0,0 +1,61 @@ +@report @javascript @report_competency +Feature: See the competencies for an activity + As a competency grader + In order to perform mark all competencies for an activity + I need to see the competencies linked to one activity in the breakdown report. + + Background: + Given the following lp "frameworks" exist: + | shortname | idnumber | + | Test-Framework | ID-FW1 | + And the following lp "competencies" exist: + | shortname | framework | + | Test-Comp1 | ID-FW1 | + | Test-Comp2 | ID-FW1 | + Given the following "courses" exist: + | shortname | fullname | + | C1 | Course 1 | + And the following "users" exist: + | username | firstname | lastname | email | + | student1 | Student | 1 | student1@example.com | + And the following "course enrolments" exist: + | user | course | role | + | student1 | C1 | student | + And the following "activities" exist: + | activity | name | intro | course | idnumber | + | page | PageName1 | PageDesc1 | C1 | PAGE1 | + And I log in as "admin" + And I am on site homepage + And I follow "Course 1" + And I follow "Competencies" + And I press "Add competencies to course" + And "Competency picker" "dialogue" should be visible + And I select "Test-Comp1" of the competency tree + And I click on "Add" "button" in the "Competency picker" "dialogue" + And I press "Add competencies to course" + And "Competency picker" "dialogue" should be visible + And I select "Test-Comp2" of the competency tree + And I click on "Add" "button" in the "Competency picker" "dialogue" + And I am on "Course 1" course homepage + And I follow "PageName1" + And I navigate to "Edit settings" in current page administration + And I follow "Expand all" + And I set the field "Course competencies" to "Test-Comp1" + And I press "Save and return to course" + + @javascript + Scenario: Go to the competency breakdown report + When I navigate to "Reports > Competency breakdown" in current page administration + And I set the field "Filter competencies by resource or activity" to "PageName1" + And I press key "13" in the field "Filter competencies by resource or activity" + Then I should see "Test-Comp1" + And I should not see "Test-Comp2" + And I click on "Not rated" "link" + And I click on "Rate" "button" + And I set the field "Rating" to "A" + And I click on "Rate" "button" in the ".competency-grader" "css_element" + And I click on "Close" "button" + And I set the field "Filter competencies by resource or activity" to "No filters applied" + And I press key "13" in the field "Filter competencies by resource or activity" + And I should see "Test-Comp1" + And I should see "Test-Comp2"