1 |
efrain |
1 |
<?php
|
|
|
2 |
// This file is part of Moodle - http://moodle.org/
|
|
|
3 |
//
|
|
|
4 |
// Moodle is free software: you can redistribute it and/or modify
|
|
|
5 |
// it under the terms of the GNU General Public License as published by
|
|
|
6 |
// the Free Software Foundation, either version 3 of the License, or
|
|
|
7 |
// (at your option) any later version.
|
|
|
8 |
//
|
|
|
9 |
// Moodle is distributed in the hope that it will be useful,
|
|
|
10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
12 |
// GNU General Public License for more details.
|
|
|
13 |
//
|
|
|
14 |
// You should have received a copy of the GNU General Public License
|
|
|
15 |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
16 |
|
|
|
17 |
/**
|
|
|
18 |
* Step definition to generate database fixtures for learning plan system.
|
|
|
19 |
*
|
|
|
20 |
* @package tool_lp
|
|
|
21 |
* @category test
|
|
|
22 |
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
|
|
|
23 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
24 |
*/
|
|
|
25 |
|
|
|
26 |
require_once(__DIR__ . '/../../../../../lib/behat/behat_base.php');
|
|
|
27 |
|
|
|
28 |
/**
|
|
|
29 |
* Step definition for learning plan system.
|
|
|
30 |
*
|
|
|
31 |
* @package tool_lp
|
|
|
32 |
* @category test
|
|
|
33 |
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
|
|
|
34 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
35 |
*/
|
|
|
36 |
class behat_tool_lp extends behat_base {
|
|
|
37 |
|
|
|
38 |
/**
|
|
|
39 |
* Click on an entry in the edit menu.
|
|
|
40 |
*
|
|
|
41 |
* @When /^I click on "([^"]*)" of edit menu in the "([^"]*)" row$/
|
|
|
42 |
*
|
|
|
43 |
* @param string $nodetext
|
|
|
44 |
* @param string $rowname
|
|
|
45 |
*/
|
|
|
46 |
public function click_on_edit_menu_of_the_row($nodetext, $rowname) {
|
|
|
47 |
$xpathtarget = "//ul//li//ul//li[contains(concat(' ', @class, ' '), ' tool-lp-menu-item ')]//a[contains(.,'" . $nodetext . "')]";
|
|
|
48 |
|
|
|
49 |
$this->execute('behat_general::i_click_on_in_the', [get_string('edit'), 'link', $this->escape($rowname), 'table_row']);
|
|
|
50 |
$this->execute('behat_general::i_click_on_in_the', [$xpathtarget, 'xpath_element', $this->escape($rowname), 'table_row']);
|
|
|
51 |
}
|
|
|
52 |
|
|
|
53 |
/**
|
|
|
54 |
* Click on competency in the tree.
|
|
|
55 |
*
|
|
|
56 |
* @Given /^I select "([^"]*)" of the competency tree$/
|
|
|
57 |
*
|
|
|
58 |
* @param string $competencyname
|
|
|
59 |
*/
|
|
|
60 |
public function select_of_the_competency_tree($competencyname) {
|
|
|
61 |
$xpathtarget = "//li[@role='tree-item']//span[contains(.,'" . $competencyname . "')]";
|
|
|
62 |
|
|
|
63 |
$this->execute('behat_general::i_click_on', [$xpathtarget, 'xpath_element']);
|
|
|
64 |
}
|
|
|
65 |
|
|
|
66 |
/**
|
|
|
67 |
* Convert page names to URLs for steps like 'When I am on the "[identifier]" "[page type]" page'.
|
|
|
68 |
*
|
|
|
69 |
* Recognised page names are:
|
|
|
70 |
* | pagetype | name meaning | description |
|
|
|
71 |
* | Course competencies | Course name | The course competencies page |
|
|
|
72 |
*
|
|
|
73 |
* @param string $page identifies which type of page this is, e.g. 'Course competencies'.
|
|
|
74 |
* @param string $identifier identifies the particular page, e.g. 'C1'.
|
|
|
75 |
* @return moodle_url the corresponding URL.
|
|
|
76 |
* @throws Exception with a meaningful error message if the specified page cannot be found.
|
|
|
77 |
*/
|
|
|
78 |
protected function resolve_page_instance_url(string $page, string $identifier): moodle_url {
|
|
|
79 |
switch (strtolower($page)) {
|
|
|
80 |
case 'course competencies':
|
|
|
81 |
$courseid = $this->get_course_id($identifier);
|
|
|
82 |
return new moodle_url('/admin/tool/lp/coursecompetencies.php', [
|
|
|
83 |
'courseid' => $courseid,
|
|
|
84 |
]);
|
|
|
85 |
default:
|
|
|
86 |
throw new Exception("Unrecognised page type '{$page}'");
|
|
|
87 |
}
|
|
|
88 |
}
|
|
|
89 |
|
|
|
90 |
/**
|
|
|
91 |
* Return a list of the exact named selectors for the component.
|
|
|
92 |
*
|
|
|
93 |
* @return behat_component_named_selector[]
|
|
|
94 |
*/
|
|
|
95 |
public static function get_exact_named_selectors(): array {
|
|
|
96 |
return [
|
|
|
97 |
new behat_component_named_selector('competency', [
|
|
|
98 |
"//*[@data-region='coursecompetencies']//table[contains(@class,'managecompetencies')]".
|
|
|
99 |
"//tr[contains(., //a[@title='View details'][contains(., %locator%)])]",
|
|
|
100 |
]),
|
|
|
101 |
new behat_component_named_selector('learning plan', [
|
|
|
102 |
"//*[@data-region='plan-competencies']//table[contains(@class,'managecompetencies')]".
|
|
|
103 |
"//tr[@data-node='user-competency'][contains(., //a[@data-usercompetency='true'][contains(., %locator%)])]",
|
|
|
104 |
]),
|
|
|
105 |
new behat_component_named_selector('competency description', [
|
|
|
106 |
"//td/p[contains(., %locator%)]",
|
|
|
107 |
]),
|
|
|
108 |
new behat_component_named_selector('competency grade', [
|
|
|
109 |
"//span[contains(concat(' ', normalize-space(@class), ' '), ' badge ')][contains(., %locator%)]",
|
|
|
110 |
]),
|
|
|
111 |
new behat_component_named_selector('learning plan rating', [
|
|
|
112 |
"//td[position()=2][contains(., %locator%)]",
|
|
|
113 |
]),
|
|
|
114 |
new behat_component_named_selector('learning plan proficiency', [
|
|
|
115 |
"//td[position()=3][contains(., %locator%)]",
|
|
|
116 |
]),
|
|
|
117 |
new behat_component_named_selector('competency page proficiency', [
|
|
|
118 |
"//dt[contains(., 'Proficient')]/following-sibling::dd[1][contains(., %locator%)]",
|
|
|
119 |
]),
|
|
|
120 |
new behat_component_named_selector('competency page rating', [
|
|
|
121 |
"//dt[contains(., 'Rating')]/following-sibling::dd[1][contains(., %locator%)]",
|
|
|
122 |
]),
|
|
|
123 |
new behat_component_named_selector('competency page related competency', [
|
|
|
124 |
"//*[@data-region='relatedcompetencies']//a[contains(., %locator%)]",
|
|
|
125 |
]),
|
|
|
126 |
];
|
|
|
127 |
}
|
|
|
128 |
|
|
|
129 |
}
|