| Línea 57... |
Línea 57... |
| 57 |
new behat_component_named_selector(
|
57 |
new behat_component_named_selector(
|
| 58 |
'Activity chooser tab', [
|
58 |
'Activity chooser tab', [
|
| 59 |
"%core_course/activityChooser%//*[@data-region=%locator%][contains(concat(' ', @class, ' '), ' tab-pane ')]"
|
59 |
"%core_course/activityChooser%//*[@data-region=%locator%][contains(concat(' ', @class, ' '), ' tab-pane ')]"
|
| 60 |
]
|
60 |
]
|
| 61 |
),
|
61 |
),
|
| - |
|
62 |
new behat_component_named_selector(
|
| - |
|
63 |
'initials bar',
|
| - |
|
64 |
[".//*[contains(concat(' ', @class, ' '), ' initialbar ')]//span[contains(., %locator%)]/parent::div"]
|
| - |
|
65 |
),
|
| 62 |
];
|
66 |
];
|
| 63 |
}
|
67 |
}
|
| Línea 64... |
Línea 68... |
| 64 |
|
68 |
|
| 65 |
/**
|
69 |
/**
|
| Línea 176... |
Línea 180... |
| 176 |
* @param string $identifier
|
180 |
* @param string $identifier
|
| 177 |
* @return moodle_url
|
181 |
* @return moodle_url
|
| 178 |
*/
|
182 |
*/
|
| 179 |
protected function resolve_page_instance_url(string $type, string $identifier): moodle_url {
|
183 |
protected function resolve_page_instance_url(string $type, string $identifier): moodle_url {
|
| 180 |
$type = strtolower($type);
|
184 |
$type = strtolower($type);
|
| - |
|
185 |
|
| - |
|
186 |
// Some selectors can have a sub selector divided by >.
|
| - |
|
187 |
$subtype = null;
|
| - |
|
188 |
$parts = explode('>', $type);
|
| - |
|
189 |
if (count($parts) > 1) {
|
| - |
|
190 |
$type = trim($parts[0]);
|
| - |
|
191 |
$subtype = trim($parts[1]);
|
| - |
|
192 |
}
|
| - |
|
193 |
|
| - |
|
194 |
$sectionpage = 'section.php';
|
| 181 |
switch ($type) {
|
195 |
switch ($type) {
|
| - |
|
196 |
case 'section settings':
|
| - |
|
197 |
$sectionpage = 'editsection.php';
|
| 182 |
case 'section':
|
198 |
case 'section':
|
| 183 |
$identifiers = explode('>', $identifier);
|
199 |
$identifiers = explode('>', $identifier);
|
| 184 |
$identifiers = array_map('trim', $identifiers);
|
200 |
$identifiers = array_map('trim', $identifiers);
|
| 185 |
if (count($identifiers) < 2) {
|
201 |
if (count($identifiers) < 2) {
|
| 186 |
throw new Exception("The specified section $identifier is not valid and should be coursename > section.");
|
202 |
throw new Exception("The specified section $identifier is not valid and should be coursename > section.");
|
| Línea 194... |
Línea 210... |
| 194 |
$section = $this->get_section_and_course_by_sectionnum($courseidentifier, (int) $sectionno);
|
210 |
$section = $this->get_section_and_course_by_sectionnum($courseidentifier, (int) $sectionno);
|
| 195 |
}
|
211 |
}
|
| 196 |
if (!$section) {
|
212 |
if (!$section) {
|
| 197 |
throw new Exception("The specified section $identifier does not exist.");
|
213 |
throw new Exception("The specified section $identifier does not exist.");
|
| 198 |
}
|
214 |
}
|
| 199 |
return new moodle_url('/course/section.php', ['id' => $section->id]);
|
215 |
return new moodle_url('/course/' . $sectionpage, ['id' => $section->id]);
|
| - |
|
216 |
case 'activities':
|
| - |
|
217 |
$params = ['id' => $this->get_course_id($identifier)];
|
| - |
|
218 |
if ($subtype !== null) {
|
| - |
|
219 |
$params['expand[]'] = $subtype;
|
| - |
|
220 |
}
|
| - |
|
221 |
return new moodle_url('/course/overview.php', $params);
|
| 200 |
}
|
222 |
}
|
| 201 |
throw new Exception('Unrecognised core page type "' . $type . '."');
|
223 |
throw new Exception('Unrecognised core page type "' . $type . '."');
|
| 202 |
}
|
224 |
}
|
| Línea 203... |
Línea 225... |
| 203 |
|
225 |
|
| Línea 265... |
Línea 287... |
| 265 |
*/
|
287 |
*/
|
| 266 |
public function i_add_to_section_using_the_activity_chooser($activityname, $sectionnum) {
|
288 |
public function i_add_to_section_using_the_activity_chooser($activityname, $sectionnum) {
|
| Línea 267... |
Línea 289... |
| 267 |
|
289 |
|
| Línea -... |
Línea 290... |
| - |
|
290 |
$this->require_javascript('Please use the \'the following "activity" exists:\' data generator instead.');
|
| 268 |
$this->require_javascript('Please use the \'the following "activity" exists:\' data generator instead.');
|
291 |
|
| 269 |
|
292 |
$infrontpage = false;
|
| - |
|
293 |
if ($this->getSession()->getPage()->find('css', 'body#page-site-index') && (int) $sectionnum <= 1) {
|
| 270 |
if ($this->getSession()->getPage()->find('css', 'body#page-site-index') && (int) $sectionnum <= 1) {
|
294 |
// We are on the frontpage.
|
| 271 |
// We are on the frontpage.
|
295 |
$infrontpage = true;
|
| 272 |
if ($sectionnum) {
|
296 |
if ($sectionnum) {
|
| 273 |
// Section 1 represents the contents on the frontpage.
|
297 |
// Section 1 represents the contents on the frontpage.
|
| 274 |
$sectionxpath = "//body[@id='page-site-index']" .
|
298 |
$sectionxpath = "//body[@id='page-site-index']" .
|
| Línea 282... |
Línea 306... |
| 282 |
$sectionxpath = "//li[@id='section-" . $sectionnum . "']";
|
306 |
$sectionxpath = "//li[@id='section-" . $sectionnum . "']";
|
| 283 |
}
|
307 |
}
|
| Línea 284... |
Línea 308... |
| 284 |
|
308 |
|
| 285 |
// Clicks add activity or resource section link.
|
309 |
// Clicks add activity or resource section link.
|
| - |
|
310 |
$sectionnode = $this->find('xpath', $sectionxpath);
|
| - |
|
311 |
if (!$infrontpage) {
|
| - |
|
312 |
$this->execute('behat_general::i_click_on_in_the', [
|
| - |
|
313 |
"//button[@data-action='open-addingcontent' and not(@data-beforemod)]",
|
| - |
|
314 |
'xpath',
|
| - |
|
315 |
$sectionnode,
|
| - |
|
316 |
'NodeElement',
|
| - |
|
317 |
]);
|
| 286 |
$sectionnode = $this->find('xpath', $sectionxpath);
|
318 |
}
|
| 287 |
$this->execute('behat_general::i_click_on_in_the', [
|
319 |
$this->execute('behat_general::i_click_on_in_the', [
|
| 288 |
"//button[@data-action='open-chooser' and not(@data-beforemod)]",
|
320 |
"//button[@data-action='open-chooser' and not(@data-beforemod)]",
|
| 289 |
'xpath',
|
321 |
'xpath',
|
| 290 |
$sectionnode,
|
322 |
$sectionnode,
|
| Línea 303... |
Línea 335... |
| 303 |
}
|
335 |
}
|
| Línea 304... |
Línea 336... |
| 304 |
|
336 |
|
| 305 |
/**
|
337 |
/**
|
| 306 |
* Opens a section edit menu if it is not already opened.
|
338 |
* Opens a section edit menu if it is not already opened.
|
| 307 |
*
|
339 |
*
|
| 308 |
* @Given /^I open section "(?P<section_number>\d+)" edit menu$/
|
340 |
* @Given /^I open section "(?P<section>(?:[^"]|\\")*)" edit menu$/
|
| 309 |
* @throws DriverException The step is not available when Javascript is disabled
|
341 |
* @throws DriverException The step is not available when Javascript is disabled
|
| 310 |
* @param string $sectionnumber
|
342 |
* @param string|int $section
|
| 311 |
*/
|
343 |
*/
|
| 312 |
public function i_open_section_edit_menu($sectionnumber) {
|
344 |
public function i_open_section_edit_menu($section) {
|
| 313 |
if (!$this->running_javascript()) {
|
345 |
if (!$this->running_javascript()) {
|
| 314 |
throw new DriverException('Section edit menu not available when Javascript is disabled');
|
346 |
throw new DriverException('Section edit menu not available when Javascript is disabled');
|
| Línea 315... |
Línea 347... |
| 315 |
}
|
347 |
}
|
| 316 |
|
348 |
|
| Línea 317... |
Línea 349... |
| 317 |
// Wait for section to be available, before clicking on the menu.
|
349 |
// Wait for section to be available, before clicking on the menu.
|
| 318 |
$this->i_wait_until_section_is_available($sectionnumber);
|
350 |
$this->i_wait_until_section_is_available($section);
|
| 319 |
|
351 |
|
| Línea 320... |
Línea 352... |
| 320 |
// If it is already opened we do nothing.
|
352 |
// If it is already opened we do nothing.
|
| 321 |
$xpath = $this->section_exists($sectionnumber);
|
353 |
$xpath = $this->section_exists($section);
|
| 322 |
$xpath .= "/descendant::div[contains(@class, 'section-actions')]/descendant::a[contains(@data-toggle, 'dropdown')]";
|
354 |
$xpath .= "/descendant::div[contains(@class, 'section-actions')]/descendant::a[@data-bs-toggle='dropdown']";
|
| 323 |
|
355 |
|
| 324 |
$exception = new ExpectationException('Section "' . $sectionnumber . '" was not found', $this->getSession());
|
356 |
$exception = new ExpectationException('Section "' . $section . '" was not found', $this->getSession());
|
| Línea 325... |
Línea 357... |
| 325 |
$menu = $this->find('xpath', $xpath, $exception);
|
357 |
$menu = $this->find('xpath', $xpath, $exception);
|
| 326 |
$menu->click();
|
358 |
$menu->click();
|
| 327 |
$this->i_wait_until_section_is_available($sectionnumber);
|
359 |
$this->i_wait_until_section_is_available($section);
|
| Línea 402... |
Línea 434... |
| 402 |
}
|
434 |
}
|
| Línea 403... |
Línea 435... |
| 403 |
|
435 |
|
| 404 |
/**
|
436 |
/**
|
| 405 |
* Shows the specified hidden section. You need to be in the course page and on editing mode.
|
437 |
* Shows the specified hidden section. You need to be in the course page and on editing mode.
|
| 406 |
*
|
438 |
*
|
| 407 |
* @Given /^I show section "(?P<section_number>\d+)"$/
|
439 |
* @Given /^I show section "(?P<section>(?:[^"]|\\")*)"$/
|
| 408 |
* @param int $sectionnumber
|
440 |
* @param int|string $section
|
| 409 |
*/
|
441 |
*/
|
| - |
|
442 |
public function i_show_section($section) {
|
| 410 |
public function i_show_section($sectionnumber) {
|
443 |
// Ensures the section exists.
|
| - |
|
444 |
$xpath = $this->section_exists($section);
|
| - |
|
445 |
// We need to know the course format as the text strings depends on them.
|
| - |
|
446 |
$courseformat = $this->get_course_format();
|
| - |
|
447 |
$strshow = get_string('showfromothers', $courseformat);
|
| Línea 411... |
Línea 448... |
| 411 |
$showlink = $this->show_section_link_exists($sectionnumber);
|
448 |
|
| 412 |
|
449 |
|
| 413 |
// Ensure section edit menu is open before interacting with it.
|
450 |
// If javascript is on, link is inside a menu.
|
| 414 |
if ($this->running_javascript()) {
|
451 |
if ($this->running_javascript()) {
|
| - |
|
452 |
$this->i_open_section_edit_menu($section);
|
| - |
|
453 |
}
|
| - |
|
454 |
|
| - |
|
455 |
// Ensure the click is using the action menu and not the visibility badge.
|
| 415 |
$this->i_open_section_edit_menu($sectionnumber);
|
456 |
$xpath .= "//*[@role='menu']";
|
| - |
|
457 |
|
| - |
|
458 |
// Click on hide link.
|
| - |
|
459 |
$this->execute('behat_general::i_click_on_in_the',
|
| Línea 416... |
Línea 460... |
| 416 |
}
|
460 |
[$strshow, "link", $this->escape($xpath), "xpath_element"]
|
| 417 |
$showlink->click();
|
461 |
);
|
| 418 |
|
462 |
|
| 419 |
if ($this->running_javascript()) {
|
463 |
if ($this->running_javascript()) {
|
| 420 |
$this->getSession()->wait(self::get_timeout() * 1000, self::PAGE_READY_JS);
|
464 |
$this->getSession()->wait(self::get_timeout() * 1000, self::PAGE_READY_JS);
|
| Línea 421... |
Línea 465... |
| 421 |
$this->i_wait_until_section_is_available($sectionnumber);
|
465 |
$this->i_wait_until_section_is_available($section);
|
| 422 |
}
|
466 |
}
|
| 423 |
}
|
467 |
}
|
| 424 |
|
468 |
|
| 425 |
/**
|
469 |
/**
|
| 426 |
* Hides the specified visible section. You need to be in the course page and on editing mode.
|
470 |
* Hides the specified visible section. You need to be in the course page and on editing mode.
|
| 427 |
*
|
471 |
*
|
| 428 |
* @Given /^I hide section "(?P<section_number>\d+)"$/
|
472 |
* @Given /^I hide section "(?P<section>(?:[^"]|\\")*)"$/
|
| 429 |
* @param int $sectionnumber
|
473 |
* @param int|string $section
|
| 430 |
*/
|
- |
|
| 431 |
public function i_hide_section($sectionnumber) {
|
474 |
*/
|
| 432 |
// Ensures the section exists.
|
475 |
public function i_hide_section($section) {
|
| 433 |
$xpath = $this->section_exists($sectionnumber);
|
476 |
// Ensures the section exists.
|
| 434 |
|
477 |
$xpath = $this->section_exists($section);
|
| 435 |
// We need to know the course format as the text strings depends on them.
|
478 |
// We need to know the course format as the text strings depends on them.
|
| 436 |
$courseformat = $this->get_course_format();
|
479 |
$courseformat = $this->get_course_format();
|
| 437 |
if (get_string_manager()->string_exists('hidefromothers', $courseformat)) {
|
480 |
if (get_string_manager()->string_exists('hidefromothers', $courseformat)) {
|
| Línea 438... |
Línea 481... |
| 438 |
$strhide = get_string('hidefromothers', $courseformat);
|
481 |
$strhide = get_string('hidefromothers', $courseformat);
|
| 439 |
} else {
|
482 |
} else {
|
| 440 |
$strhide = get_string('hidesection');
|
483 |
$strhide = get_string('hidesection');
|
| 441 |
}
|
484 |
}
|
| Línea 442... |
Línea 485... |
| 442 |
|
485 |
|
| 443 |
// If javascript is on, link is inside a menu.
|
486 |
// If javascript is on, link is inside a menu.
|
| 444 |
if ($this->running_javascript()) {
|
487 |
if ($this->running_javascript()) {
|
| 445 |
$this->i_open_section_edit_menu($sectionnumber);
|
488 |
$this->i_open_section_edit_menu($section);
|
| Línea 446... |
Línea 489... |
| 446 |
}
|
489 |
}
|
| 447 |
|
490 |
|
| 448 |
// Click on delete link.
|
491 |
// Click on hide link.
|
| 449 |
$this->execute('behat_general::i_click_on_in_the',
|
492 |
$this->execute('behat_general::i_click_on_in_the',
|
| 450 |
array($strhide, "link", $this->escape($xpath), "xpath_element")
|
493 |
array($strhide, "link", $this->escape($xpath), "xpath_element")
|
| Línea 451... |
Línea 494... |
| 451 |
);
|
494 |
);
|
| 452 |
|
495 |
|
| Línea 620... |
Línea 663... |
| 620 |
|
663 |
|
| 621 |
// Edit menu should be visible.
|
664 |
// Edit menu should be visible.
|
| 622 |
if ($this->is_course_editor()) {
|
665 |
if ($this->is_course_editor()) {
|
| 623 |
$xpath = $sectionxpath .
|
666 |
$xpath = $sectionxpath .
|
| 624 |
"/descendant::div[contains(@class, 'section-actions')]" .
|
667 |
"/descendant::div[contains(@class, 'section-actions')]" .
|
| 625 |
"/descendant::a[contains(@data-toggle, 'dropdown')]";
|
668 |
"/descendant::a[contains(@data-bs-toggle, 'dropdown')]";
|
| 626 |
if (!$this->getSession()->getPage()->find('xpath', $xpath)) {
|
669 |
if (!$this->getSession()->getPage()->find('xpath', $xpath)) {
|
| 627 |
throw new ExpectationException('The section edit menu is not available', $this->getSession());
|
670 |
throw new ExpectationException('The section edit menu is not available', $this->getSession());
|
| 628 |
}
|
671 |
}
|
| 629 |
}
|
672 |
}
|
| Línea 830... |
Línea 873... |
| 830 |
* @Given /^I move "(?P<activity_name_string>(?:[^"]|\\")*)" activity to section "(?P<section_number>\d+)"$/
|
873 |
* @Given /^I move "(?P<activity_name_string>(?:[^"]|\\")*)" activity to section "(?P<section_number>\d+)"$/
|
| 831 |
* @param string $activityname The activity name
|
874 |
* @param string $activityname The activity name
|
| 832 |
* @param int $sectionnumber The number of section
|
875 |
* @param int $sectionnumber The number of section
|
| 833 |
*/
|
876 |
*/
|
| 834 |
public function i_move_activity_to_section($activityname, $sectionnumber): void {
|
877 |
public function i_move_activity_to_section($activityname, $sectionnumber): void {
|
| - |
|
878 |
$this->require_javascript('Moving activities requires javascript.');
|
| - |
|
879 |
|
| 835 |
// Ensure the destination is valid.
|
880 |
// Ensure the destination is valid.
|
| 836 |
$sectionxpath = $this->section_exists($sectionnumber);
|
881 |
$sectionxpath = $this->section_exists($sectionnumber);
|
| Línea -... |
Línea 882... |
| - |
|
882 |
|
| 837 |
|
883 |
// TODO: remove this if clause as part of MDL-83627 when YUI is removed from course.
|
| 838 |
// Not all formats are compatible with the move tool.
|
884 |
// Not all formats are compatible with the move tool.
|
| 839 |
$activitynode = $this->get_activity_node($activityname);
|
885 |
$activitynode = $this->get_activity_node($activityname);
|
| 840 |
if (!$activitynode->find('css', "[data-action='moveCm']", false, false, 0)) {
|
886 |
if (!$activitynode->find('css', "[data-action='moveCm']", false, false, 0)) {
|
| 841 |
// Execute the legacy YUI move option.
|
887 |
// Execute the legacy YUI move option.
|
| 842 |
$this->i_move_activity_to_section_yui($activityname, $sectionnumber);
|
888 |
$this->i_move_activity_to_section_yui($activityname, $sectionnumber);
|
| 843 |
return;
|
889 |
return;
|
| Línea 844... |
Línea -... |
| 844 |
}
|
- |
|
| 845 |
|
- |
|
| 846 |
// JS enabled.
|
890 |
}
|
| 847 |
if ($this->running_javascript()) {
|
891 |
|
| 848 |
$this->i_open_actions_menu($activityname);
|
892 |
$this->i_open_actions_menu($activityname);
|
| 849 |
$this->execute(
|
893 |
$this->execute(
|
| 850 |
'behat_course::i_click_on_in_the_activity',
|
894 |
'behat_course::i_click_on_in_the_activity',
|
| 851 |
[get_string('move'), "link", $this->escape($activityname)]
|
895 |
[get_string('move'), "link", $this->escape($activityname)]
|
| 852 |
);
|
896 |
);
|
| 853 |
$this->execute("behat_general::i_click_on_in_the", [
|
897 |
$this->execute("behat_general::i_click_on_in_the", [
|
| 854 |
"[data-for='section'][data-number='$sectionnumber']",
|
898 |
"[data-for='section'][data-number='$sectionnumber']",
|
| 855 |
'css_element',
|
899 |
'css_element',
|
| 856 |
"[data-region='modal-container']",
|
- |
|
| 857 |
'css_element'
|
- |
|
| 858 |
]);
|
- |
|
| 859 |
} else {
|
- |
|
| 860 |
$this->execute(
|
- |
|
| 861 |
'behat_course::i_click_on_in_the_activity',
|
- |
|
| 862 |
[get_string('move'), "link", $this->escape($activityname)]
|
- |
|
| 863 |
);
|
- |
|
| 864 |
$this->execute(
|
- |
|
| 865 |
'behat_general::i_click_on_in_the',
|
- |
|
| 866 |
["li.movehere a", "css_element", $this->escape($sectionxpath), "xpath_element"]
|
900 |
"[data-region='modal-container']",
|
| 867 |
);
|
901 |
'css_element',
|
| Línea 868... |
Línea 902... |
| 868 |
}
|
902 |
]);
|
| 869 |
}
|
903 |
}
|
| 870 |
|
904 |
|
| 871 |
/**
|
905 |
/**
|
| 872 |
* Moves the specified activity to the first slot of a section using the YUI course format.
|
906 |
* Moves the specified activity to the first slot of a section using the YUI course format.
|
| - |
|
907 |
*
|
| 873 |
*
|
908 |
* This step is experimental when using it in Javascript tests. Editing mode should be on.
|
| 874 |
* This step is experimental when using it in Javascript tests. Editing mode should be on.
|
909 |
*
|
| 875 |
*
|
910 |
* @todo remove this module as part of MDL-83627.
|
| 876 |
* @param string $activityname The activity name
|
911 |
* @param string $activityname The activity name
|
| 877 |
* @param int $sectionnumber The number of section
|
912 |
* @param int $sectionnumber The number of section
|
| Línea 937... |
Línea 972... |
| 937 |
|
972 |
|
| 938 |
// If it is already opened we do nothing.
|
973 |
// If it is already opened we do nothing.
|
| Línea 939... |
Línea 974... |
| 939 |
$activitynode = $this->get_activity_node($activityname);
|
974 |
$activitynode = $this->get_activity_node($activityname);
|
| 940 |
|
975 |
|
| 941 |
// Find the menu.
|
976 |
// Find the menu.
|
| 942 |
$menunode = $activitynode->find('css', 'a[data-toggle=dropdown]');
|
977 |
$menunode = $activitynode->find('css', 'a[data-bs-toggle=dropdown]');
|
| 943 |
if (!$menunode) {
|
978 |
if (!$menunode) {
|
| 944 |
throw new ExpectationException(sprintf('Could not find actions menu for the activity "%s"', $activityname),
|
979 |
throw new ExpectationException(sprintf('Could not find actions menu for the activity "%s"', $activityname),
|
| 945 |
$this->getSession());
|
980 |
$this->getSession());
|
| 946 |
}
|
981 |
}
|
| 947 |
$expanded = $menunode->getAttribute('aria-expanded');
|
982 |
$expanded = $menunode->getAttribute('aria-expanded');
|
| 948 |
if ($expanded == 'true') {
|
983 |
if ($expanded == 'true') {
|
| Línea 949... |
Línea 984... |
| 949 |
return;
|
984 |
return;
|
| 950 |
}
|
985 |
}
|
| 951 |
|
986 |
|
| Línea 952... |
Línea 987... |
| 952 |
$this->execute('behat_course::i_click_on_in_the_activity',
|
987 |
$this->execute('behat_course::i_click_on_in_the_activity',
|
| 953 |
array("a[data-toggle='dropdown']", "css_element", $this->escape($activityname))
|
988 |
["a[data-bs-toggle='dropdown']", "css_element", $this->escape($activityname)]
|
| Línea 970... |
Línea 1005... |
| 970 |
}
|
1005 |
}
|
| Línea 971... |
Línea 1006... |
| 971 |
|
1006 |
|
| 972 |
// If it is already closed we do nothing.
|
1007 |
// If it is already closed we do nothing.
|
| 973 |
$activitynode = $this->get_activity_node($activityname);
|
1008 |
$activitynode = $this->get_activity_node($activityname);
|
| 974 |
// Find the menu.
|
1009 |
// Find the menu.
|
| 975 |
$menunode = $activitynode->find('css', 'a[data-toggle=dropdown]');
|
1010 |
$menunode = $activitynode->find('css', 'a[data-bs-toggle=dropdown]');
|
| 976 |
if (!$menunode) {
|
1011 |
if (!$menunode) {
|
| 977 |
throw new ExpectationException(sprintf('Could not find actions menu for the activity "%s"', $activityname),
|
1012 |
throw new ExpectationException(sprintf('Could not find actions menu for the activity "%s"', $activityname),
|
| 978 |
$this->getSession());
|
1013 |
$this->getSession());
|
| 979 |
}
|
1014 |
}
|
| 980 |
$expanded = $menunode->getAttribute('aria-expanded');
|
1015 |
$expanded = $menunode->getAttribute('aria-expanded');
|
| 981 |
if ($expanded != 'true') {
|
1016 |
if ($expanded != 'true') {
|
| 982 |
return;
|
1017 |
return;
|
| Línea 983... |
Línea 1018... |
| 983 |
}
|
1018 |
}
|
| 984 |
|
1019 |
|
| 985 |
$this->execute('behat_course::i_click_on_in_the_activity',
|
1020 |
$this->execute('behat_course::i_click_on_in_the_activity',
|
| 986 |
array("a[data-toggle='dropdown']", "css_element", $this->escape($activityname))
|
1021 |
["a[data-bs-toggle='dropdown']", "css_element", $this->escape($activityname)]
|
| Línea 987... |
Línea 1022... |
| 987 |
);
|
1022 |
);
|
| 988 |
}
|
1023 |
}
|
| Línea 1000... |
Línea 1035... |
| 1000 |
throw new DriverException('Activities actions menu not available when Javascript is disabled');
|
1035 |
throw new DriverException('Activities actions menu not available when Javascript is disabled');
|
| 1001 |
}
|
1036 |
}
|
| Línea 1002... |
Línea 1037... |
| 1002 |
|
1037 |
|
| 1003 |
$activitynode = $this->get_activity_node($activityname);
|
1038 |
$activitynode = $this->get_activity_node($activityname);
|
| 1004 |
// Find the menu.
|
1039 |
// Find the menu.
|
| 1005 |
$menunode = $activitynode->find('css', 'a[data-toggle=dropdown]');
|
1040 |
$menunode = $activitynode->find('css', 'a[data-bs-toggle=dropdown]');
|
| 1006 |
if (!$menunode) {
|
1041 |
if (!$menunode) {
|
| 1007 |
throw new ExpectationException(sprintf('Could not find actions menu for the activity "%s"', $activityname),
|
1042 |
throw new ExpectationException(sprintf('Could not find actions menu for the activity "%s"', $activityname),
|
| 1008 |
$this->getSession());
|
1043 |
$this->getSession());
|
| 1009 |
}
|
1044 |
}
|
| Línea 1130... |
Línea 1165... |
| 1130 |
get_string('cmdelete_title', 'core_courseformat'),
|
1165 |
get_string('cmdelete_title', 'core_courseformat'),
|
| 1131 |
"dialogue"
|
1166 |
"dialogue"
|
| 1132 |
]
|
1167 |
]
|
| 1133 |
);
|
1168 |
);
|
| 1134 |
} else {
|
1169 |
} else {
|
| 1135 |
$this->execute("behat_forms::press_button", get_string('yes'));
|
1170 |
$this->execute("behat_forms::press_button", get_string('delete'));
|
| 1136 |
}
|
1171 |
}
|
| Línea 1137... |
Línea 1172... |
| 1137 |
|
1172 |
|
| 1138 |
return $steps;
|
1173 |
return $steps;
|
| Línea 1139... |
Línea 1174... |
| 1139 |
}
|
1174 |
}
|
| - |
|
1175 |
|
| - |
|
1176 |
/**
|
| - |
|
1177 |
* Deletes a course.
|
| - |
|
1178 |
*
|
| - |
|
1179 |
* @Given the course :coursefullname is deleted
|
| - |
|
1180 |
* @param string $coursefullname
|
| - |
|
1181 |
*/
|
| - |
|
1182 |
#[\core\attribute\example('And the course "Course test" is deleted')]
|
| - |
|
1183 |
public function the_course_is_deleted($coursefullname) {
|
| - |
|
1184 |
delete_course($this->get_course_id($coursefullname), false);
|
| - |
|
1185 |
fix_course_sortorder();
|
| - |
|
1186 |
}
|
| 1140 |
|
1187 |
|
| 1141 |
/**
|
1188 |
/**
|
| 1142 |
* Duplicates the activity or resource specified by it's name. You should be in the course page with editing mode on.
|
1189 |
* Duplicates the activity or resource specified by it's name. You should be in the course page with editing mode on.
|
| 1143 |
*
|
1190 |
*
|
| 1144 |
* @Given /^I duplicate "(?P<activity_name_string>(?:[^"]|\\")*)" activity$/
|
1191 |
* @Given /^I duplicate "(?P<activity_name_string>(?:[^"]|\\")*)" activity$/
|
| Línea 1171... |
Línea 1218... |
| 1171 |
$this->execute("behat_course::i_duplicate_activity", $activity);
|
1218 |
$this->execute("behat_course::i_duplicate_activity", $activity);
|
| Línea 1172... |
Línea 1219... |
| 1172 |
|
1219 |
|
| 1173 |
// Determine the future new activity xpath from the former one.
|
1220 |
// Determine the future new activity xpath from the former one.
|
| 1174 |
$duplicatedxpath = "//li[contains(concat(' ', normalize-space(@class), ' '), ' activity ')]" .
|
1221 |
$duplicatedxpath = "//li[contains(concat(' ', normalize-space(@class), ' '), ' activity ')]" .
|
| 1175 |
"[contains(., $activityliteral)]/following-sibling::li";
|
1222 |
"[contains(., $activityliteral)]/following-sibling::li";
|
| Línea 1176... |
Línea 1223... |
| 1176 |
$duplicatedactionsmenuxpath = $duplicatedxpath . "/descendant::a[@data-toggle='dropdown']";
|
1223 |
$duplicatedactionsmenuxpath = $duplicatedxpath . "/descendant::a[@data-bs-toggle='dropdown']";
|
| 1177 |
|
1224 |
|
| 1178 |
if ($this->running_javascript()) {
|
1225 |
if ($this->running_javascript()) {
|
| 1179 |
// We wait until the AJAX request finishes and the section is visible again.
|
1226 |
// We wait until the AJAX request finishes and the section is visible again.
|
| 1180 |
$hiddenlightboxxpath = "//li[contains(concat(' ', normalize-space(@class), ' '), ' activity ')]" .
|
1227 |
$hiddenlightboxxpath = "//li[contains(concat(' ', normalize-space(@class), ' '), ' activity ')]" .
|
| 1181 |
"[contains(., $activityliteral)]" .
|
1228 |
"[contains(., $activityliteral)]" .
|
| Línea 1182... |
Línea 1229... |
| 1182 |
"/ancestor::li[contains(concat(' ', normalize-space(@class), ' '), ' section ')]" .
|
1229 |
"/ancestor::li[contains(concat(' ', normalize-space(@class), ' '), ' section ')]" .
|
| 1183 |
"/descendant::div[contains(concat(' ', @class, ' '), ' lightbox ')][contains(@style, 'display: none')]";
|
1230 |
"/descendant::div[contains(concat(' ', @class, ' '), ' lightbox ')][contains(@style, 'display: none')]";
|
| 1184 |
|
1231 |
|
| Línea 1185... |
Línea 1232... |
| 1185 |
// Component based courses do not use lightboxes anymore but js depending.
|
1232 |
// Component based courses do not use lightboxes anymore but js depending.
|
| 1186 |
$sectionreadyxpath = "//*[contains(@id,'page-content')]" .
|
1233 |
$sectionreadyxpath = "//*[contains(@id,'page')]" .
|
| 1187 |
"/descendant::*[contains(concat(' ', normalize-space(@class), ' '), ' stateready ')]";
|
1234 |
"/descendant::*[contains(concat(' ', normalize-space(@class), ' '), ' stateready ')]";
|
| Línea 1221... |
Línea 1268... |
| 1221 |
* be executed if it returns another step.
|
1268 |
* be executed if it returns another step.
|
| 1222 |
*
|
1269 |
*
|
| 1223 |
* Hopefully we would not require test writers to use this step
|
1270 |
* Hopefully we would not require test writers to use this step
|
| 1224 |
* and we will manage it from other step definitions.
|
1271 |
* and we will manage it from other step definitions.
|
| 1225 |
*
|
1272 |
*
|
| 1226 |
* @Given /^I wait until section "(?P<section_number>\d+)" is available$/
|
1273 |
* @Given /^I wait until section "(?P<section>(?:[^"]|\\")*)" is available$/
|
| 1227 |
* @param int $sectionnumber
|
1274 |
* @param int|string $section
|
| 1228 |
* @return void
|
1275 |
* @return void
|
| 1229 |
*/
|
1276 |
*/
|
| 1230 |
public function i_wait_until_section_is_available($sectionnumber) {
|
1277 |
public function i_wait_until_section_is_available($section) {
|
| Línea 1231... |
Línea 1278... |
| 1231 |
|
1278 |
|
| 1232 |
// Looks for a hidden lightbox or a non-existent lightbox in that section.
|
1279 |
// Looks for a hidden lightbox or a non-existent lightbox in that section.
|
| 1233 |
$sectionxpath = $this->section_exists($sectionnumber);
|
1280 |
$sectionxpath = $this->section_exists($section);
|
| 1234 |
$hiddenlightboxxpath = $sectionxpath . "/descendant::div[contains(concat(' ', @class, ' '), ' lightbox ')][contains(@style, 'display: none')]" .
|
1281 |
$hiddenlightboxxpath = $sectionxpath . "/descendant::div[contains(concat(' ', @class, ' '), ' lightbox ')][contains(@style, 'display: none')]" .
|
| 1235 |
" | " .
|
1282 |
" | " .
|
| Línea 1236... |
Línea 1283... |
| 1236 |
$sectionxpath . "[count(child::div[contains(@class, 'lightbox')]) = 0]";
|
1283 |
$sectionxpath . "[count(child::div[contains(@class, 'lightbox')]) = 0]";
|
| Línea 1269... |
Línea 1316... |
| 1269 |
|
1316 |
|
| 1270 |
/**
|
1317 |
/**
|
| 1271 |
* Checks if the course section exists.
|
1318 |
* Checks if the course section exists.
|
| 1272 |
*
|
1319 |
*
|
| - |
|
1320 |
* @throws ElementNotFoundException Thrown by behat_base::find
|
| - |
|
1321 |
* @param int|string $section Section number or name to look for.
|
| - |
|
1322 |
* @return string The xpath of the section.
|
| - |
|
1323 |
*/
|
| - |
|
1324 |
protected function section_exists($section) {
|
| - |
|
1325 |
|
| - |
|
1326 |
if (is_numeric($section)) {
|
| - |
|
1327 |
return $this->section_number_exists($section);
|
| - |
|
1328 |
}
|
| - |
|
1329 |
|
| - |
|
1330 |
return $this->section_name_exists($section);
|
| - |
|
1331 |
}
|
| - |
|
1332 |
|
| - |
|
1333 |
/**
|
| - |
|
1334 |
* Checks if the course section number exists.
|
| - |
|
1335 |
*
|
| 1273 |
* @throws ElementNotFoundException Thrown by behat_base::find
|
1336 |
* @throws ElementNotFoundException Thrown by behat_base::find
|
| 1274 |
* @param int $sectionnumber
|
1337 |
* @param int $sectionnumber
|
| 1275 |
* @return string The xpath of the section.
|
1338 |
* @return string The xpath of the section.
|
| 1276 |
*/
|
1339 |
*/
|
| Línea 1277... |
Línea 1340... |
| 1277 |
protected function section_exists($sectionnumber) {
|
1340 |
protected function section_number_exists(int $sectionnumber): string {
|
| 1278 |
|
1341 |
|
| 1279 |
// Just to give more info in case it does not exist.
|
1342 |
// Just to give more info in case it does not exist.
|
| 1280 |
$xpath = "//li[@id='section-" . $sectionnumber . "']";
|
1343 |
$xpath = "//li[@id='section-" . $sectionnumber . "']";
|
| Línea 1281... |
Línea 1344... |
| 1281 |
$exception = new ElementNotFoundException($this->getSession(), "Section $sectionnumber ");
|
1344 |
$exception = new ElementNotFoundException($this->getSession(), "Section $sectionnumber ");
|
| 1282 |
$this->find('xpath', $xpath, $exception);
|
1345 |
$this->find('xpath', $xpath, $exception);
|
| Línea 1283... |
Línea 1346... |
| 1283 |
|
1346 |
|
| - |
|
1347 |
return $xpath;
|
| - |
|
1348 |
}
|
| - |
|
1349 |
|
| - |
|
1350 |
/**
|
| - |
|
1351 |
* Checks if the section name exists.
|
| - |
|
1352 |
*
|
| - |
|
1353 |
* @throws ElementNotFoundException Thrown by behat_base::find
|
| - |
|
1354 |
* @param string $sectionname
|
| - |
|
1355 |
* @return string The xpath of the section.
|
| - |
|
1356 |
*/
|
| - |
|
1357 |
protected function section_name_exists(string $sectionname): string {
|
| - |
|
1358 |
// Let's try to find section or subsection in course page.
|
| - |
|
1359 |
$xpath = "//li[@data-for='section']//*[@data-for='section_title' and contains(normalize-space(.), '" . $sectionname ."')]";
|
| - |
|
1360 |
$exception = new ElementNotFoundException($this->getSession(), "Section $sectionname ");
|
| - |
|
1361 |
try {
|
| - |
|
1362 |
$this->find('xpath', $xpath, $exception);
|
| - |
|
1363 |
} catch (ElementNotFoundException $e) {
|
| - |
|
1364 |
// Let's try to find section in section page.
|
| - |
|
1365 |
$xpath = "//header[@id='page-header' and contains(normalize-space(.), '" . $sectionname ."')]";
|
| - |
|
1366 |
$this->find('xpath', $xpath, $exception);
|
| - |
|
1367 |
}
|
| - |
|
1368 |
|
| 1284 |
return $xpath;
|
1369 |
return $xpath;
|
| 1285 |
}
|
1370 |
}
|
| 1286 |
|
1371 |
|
| 1287 |
/**
|
1372 |
/**
|
| 1288 |
* Returns the show section icon or throws an exception.
|
1373 |
* Returns the show section icon or throws an exception.
|
| 1289 |
*
|
1374 |
*
|
| 1290 |
* @throws ElementNotFoundException Thrown by behat_base::find
|
1375 |
* @throws ElementNotFoundException Thrown by behat_base::find
|
| Línea 1291... |
Línea 1376... |
| 1291 |
* @param int $sectionnumber
|
1376 |
* @param int|string $section Section number or name to look for.
|
| 1292 |
* @return NodeElement
|
1377 |
* @return NodeElement
|
| Línea 1293... |
Línea 1378... |
| 1293 |
*/
|
1378 |
*/
|
| 1294 |
protected function show_section_link_exists($sectionnumber) {
|
1379 |
protected function show_section_link_exists($section) {
|
| Línea 1295... |
Línea 1380... |
| 1295 |
|
1380 |
|
| Línea 1311... |
Línea 1396... |
| 1311 |
|
1396 |
|
| 1312 |
/**
|
1397 |
/**
|
| 1313 |
* Returns the hide section icon link if it exists or throws exception.
|
1398 |
* Returns the hide section icon link if it exists or throws exception.
|
| 1314 |
*
|
1399 |
*
|
| 1315 |
* @throws ElementNotFoundException Thrown by behat_base::find
|
1400 |
* @throws ElementNotFoundException Thrown by behat_base::find
|
| 1316 |
* @param int $sectionnumber
|
1401 |
* @param int|string $section Section number or name to look for.
|
| 1317 |
* @return NodeElement
|
1402 |
* @return NodeElement
|
| 1318 |
*/
|
1403 |
*/
|
| Línea 1319... |
Línea 1404... |
| 1319 |
protected function hide_section_link_exists($sectionnumber) {
|
1404 |
protected function hide_section_link_exists($section) {
|
| 1320 |
|
1405 |
|
| Línea 1321... |
Línea 1406... |
| 1321 |
// Gets the section xpath and ensure it exists.
|
1406 |
// Gets the section xpath and ensure it exists.
|
| 1322 |
$xpath = $this->section_exists($sectionnumber);
|
1407 |
$xpath = $this->section_exists($section);
|
| Línea 1323... |
Línea 1408... |
| 1323 |
|
1408 |
|
| Línea 1357... |
Línea 1442... |
| 1357 |
|
1442 |
|
| 1358 |
if (strstr($bodyid, 'page-course-view-') === false) {
|
1443 |
if (strstr($bodyid, 'page-course-view-') === false) {
|
| 1359 |
throw $exception;
|
1444 |
throw $exception;
|
| Línea -... |
Línea 1445... |
| - |
|
1445 |
}
|
| - |
|
1446 |
|
| - |
|
1447 |
if (strstr($bodyid, 'page-course-view-section-') !== false) {
|
| - |
|
1448 |
return 'format_' . str_replace('page-course-view-section-', '', $bodyid);
|
| 1360 |
}
|
1449 |
}
|
| 1361 |
|
1450 |
|
| Línea 1362... |
Línea 1451... |
| 1362 |
return 'format_' . str_replace('page-course-view-', '', $bodyid);
|
1451 |
return 'format_' . str_replace('page-course-view-', '', $bodyid);
|
| 1363 |
}
|
1452 |
}
|
| Línea 1956... |
Línea 2045... |
| 1956 |
$actionnode = $actionsnode->find('css', '.action-'.$action);
|
2045 |
$actionnode = $actionsnode->find('css', '.action-'.$action);
|
| 1957 |
if (!$actionnode) {
|
2046 |
if (!$actionnode) {
|
| 1958 |
throw new ExpectationException("Expected action was not available or not found ($action)", $this->getSession());
|
2047 |
throw new ExpectationException("Expected action was not available or not found ($action)", $this->getSession());
|
| 1959 |
}
|
2048 |
}
|
| 1960 |
if ($this->running_javascript() && !$actionnode->isVisible()) {
|
2049 |
if ($this->running_javascript() && !$actionnode->isVisible()) {
|
| 1961 |
$actionsnode->find('css', 'a[data-toggle=dropdown]')->click();
|
2050 |
$actionsnode->find('css', 'a[data-bs-toggle=dropdown]')->click();
|
| 1962 |
$actionnode = $actionsnode->find('css', '.action-'.$action);
|
2051 |
$actionnode = $actionsnode->find('css', '.action-'.$action);
|
| 1963 |
}
|
2052 |
}
|
| 1964 |
$actionnode->click();
|
2053 |
$actionnode->click();
|
| 1965 |
}
|
2054 |
}
|
| Línea 1982... |
Línea 2071... |
| 1982 |
*
|
2071 |
*
|
| 1983 |
* @param string $name The name of the category as it is displayed in the management interface.
|
2072 |
* @param string $name The name of the category as it is displayed in the management interface.
|
| 1984 |
*/
|
2073 |
*/
|
| 1985 |
public function i_open_the_action_menu_for_item_in_management_category_listing($name) {
|
2074 |
public function i_open_the_action_menu_for_item_in_management_category_listing($name) {
|
| 1986 |
$node = $this->get_management_category_listing_node_by_name($name);
|
2075 |
$node = $this->get_management_category_listing_node_by_name($name);
|
| 1987 |
$node->find('xpath', "//*[contains(@class, 'category-item-actions')]//a[@data-toggle='dropdown']")->click();
|
2076 |
$node->find('xpath', "//*[contains(@class, 'category-item-actions')]//a[@data-bs-toggle='dropdown']")->click();
|
| 1988 |
}
|
2077 |
}
|
| Línea 1989... |
Línea 2078... |
| 1989 |
|
2078 |
|
| 1990 |
/**
|
2079 |
/**
|
| 1991 |
* Checks that the specified category actions menu contains an item.
|
2080 |
* Checks that the specified category actions menu contains an item.
|
| Línea 2082... |
Línea 2171... |
| 2082 |
* Open the activity chooser in a course.
|
2171 |
* Open the activity chooser in a course.
|
| 2083 |
*
|
2172 |
*
|
| 2084 |
* @Given /^I open the activity chooser$/
|
2173 |
* @Given /^I open the activity chooser$/
|
| 2085 |
*/
|
2174 |
*/
|
| 2086 |
public function i_open_the_activity_chooser() {
|
2175 |
public function i_open_the_activity_chooser() {
|
| - |
|
2176 |
// Open the "Activity or resource and Subsection" dropdown first.
|
| - |
|
2177 |
$this->execute('behat_general::i_click_on',
|
| - |
|
2178 |
['//button[@data-action="open-addingcontent"]', 'xpath_element']);
|
| 2087 |
$this->execute('behat_general::i_click_on',
|
2179 |
$this->execute('behat_general::i_click_on',
|
| 2088 |
array('//button[@data-action="open-chooser"]', 'xpath_element'));
|
2180 |
['//button[@data-action="open-chooser"]', 'xpath_element']);
|
| Línea 2089... |
Línea 2181... |
| 2089 |
|
2181 |
|
| 2090 |
$node = $this->get_selected_node('xpath_element', '//div[@data-region="modules"]');
|
2182 |
$node = $this->get_selected_node('xpath_element', '//div[@data-region="modules"]');
|
| 2091 |
$this->ensure_node_is_visible($node);
|
2183 |
$this->ensure_node_is_visible($node);
|