Proyectos de Subversion Moodle

Rev

Rev 11 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 11 Rev 1441
Línea 935... Línea 935...
935
                    'course' => $courseid,
935
                    'course' => $courseid,
936
                    'returnto' => 'profile',
936
                    'returnto' => 'profile',
937
                ]);
937
                ]);
938
        }
938
        }
Línea -... Línea 939...
-
 
939
 
-
 
940
        // This next section handles page types starting with an activity name. For example:
939
 
941
        // "forum activity" or "quiz activity editing".
940
        $parts = explode(' ', $type);
942
        $parts = explode(' ', $type);
-
 
943
        if (count($parts) > 1) {
941
        if (count($parts) > 1) {
944
            $modname = $parts[0];
942
            if ($parts[1] === 'activity') {
-
 
943
                $modname = $parts[0];
945
            if ($parts[1] === 'activity') {
Línea 944... Línea 946...
944
                $cm = $this->get_cm_by_activity_name($modname, $identifier);
946
                $cm = $this->get_cm_by_activity_name($modname, $identifier);
945
 
947
 
946
                if (count($parts) == 2) {
948
                if (count($parts) == 2) {
Línea 960... Línea 962...
960
 
962
 
961
                if ($parts[2] === 'permissions') {
963
                if ($parts[2] === 'permissions') {
962
                    // Permissions page.
964
                    // Permissions page.
963
                    return new moodle_url('/admin/roles/permissions.php', ['contextid' => $cm->context->id]);
965
                    return new moodle_url('/admin/roles/permissions.php', ['contextid' => $cm->context->id]);
-
 
966
                }
-
 
967
 
-
 
968
            } else if ($parts[1] === 'index' && count($parts) == 2) {
-
 
969
                $courseid = $this->get_course_id($identifier);
-
 
970
                if (!$courseid) {
-
 
971
                    throw $coursenotfoundexception;
-
 
972
                }
964
                }
973
                return new moodle_url("/mod/$modname/index.php", ['id' => $courseid]);
965
            }
974
            }
Línea 966... Línea 975...
966
        }
975
        }
967
 
976
 
Línea 1157... Línea 1166...
1157
     * @param array $nodelist
1166
     * @param array $nodelist
1158
     */
1167
     */
1159
    protected function select_on_administration_page($nodelist) {
1168
    protected function select_on_administration_page($nodelist) {
1160
        $parentnodes = $nodelist;
1169
        $parentnodes = $nodelist;
1161
        $lastnode = array_pop($parentnodes);
1170
        $lastnode = array_pop($parentnodes);
1162
        $xpath = '//section[@id=\'region-main\']';
1171
        $xpath = '//div[@id=\'region-main\']';
Línea 1163... Línea 1172...
1163
 
1172
 
1164
        // Check if there is a separate tab for this submenu of the page. If found go to it.
1173
        // Check if there is a separate tab for this submenu of the page. If found go to it.
1165
        if ($parentnodes) {
1174
        if ($parentnodes) {
1166
            $tabname = behat_context_helper::escape($parentnodes[0]);
1175
            $tabname = behat_context_helper::escape($parentnodes[0]);
Línea 1284... Línea 1293...
1284
    protected function toggle_page_administration_menu($menuxpath = null) {
1293
    protected function toggle_page_administration_menu($menuxpath = null) {
1285
        if (!$menuxpath) {
1294
        if (!$menuxpath) {
1286
            $menuxpath = $this->find_header_administration_menu() ?: $this->find_page_administration_menu();
1295
            $menuxpath = $this->find_header_administration_menu() ?: $this->find_page_administration_menu();
1287
        }
1296
        }
1288
        if ($menuxpath && $this->running_javascript()) {
1297
        if ($menuxpath && $this->running_javascript()) {
1289
            $node = $this->find('xpath', $menuxpath . '//a[@data-toggle=\'dropdown\']');
1298
            $node = $this->find('xpath', $menuxpath . '//a[@data-bs-toggle=\'dropdown\']');
1290
            if ($node->isVisible()) {
1299
            if ($node->isVisible()) {
1291
                $this->execute('behat_general::i_click_on', [$node, 'NodeElement']);
1300
                $this->execute('behat_general::i_click_on', [$node, 'NodeElement']);
1292
            }
1301
            }
1293
        }
1302
        }
1294
    }
1303
    }
Línea 1533... Línea 1542...
1533
     */
1542
     */
1534
    public function should_exist_in_dropdown(
1543
    public function should_exist_in_dropdown(
1535
        string $item,
1544
        string $item,
1536
        bool $not,
1545
        bool $not,
1537
        string $dropdown,
1546
        string $dropdown,
1538
        string $container = null,
1547
        ?string $container = null,
1539
        string $containertype = null,
1548
        ?string $containertype = null,
1540
    ): void {
1549
    ): void {
1541
        $containernode = null;
1550
        $containernode = null;
1542
        if ($container && $containertype) {
1551
        if ($container && $containertype) {
1543
            $containernode = $this->find(
1552
            $containernode = $this->find(
1544
                selector: $containertype,
1553
                selector: $containertype,
Línea 1626... Línea 1635...
1626
     */
1635
     */
1627
    public function i_keep_block_drawer_closed() {
1636
    public function i_keep_block_drawer_closed() {
1628
        set_user_preference('behat_keep_drawer_closed', 1);
1637
        set_user_preference('behat_keep_drawer_closed', 1);
1629
        $this->i_close_block_drawer_if_open();
1638
        $this->i_close_block_drawer_if_open();
1630
    }
1639
    }
-
 
1640
 
-
 
1641
    /**
-
 
1642
     * Checks if a navigation menu item is active.
-
 
1643
     *
-
 
1644
     * @Then menu item :navigationmenuitem should be active
-
 
1645
     * @param string $navigationmenuitem The navigation menu item name.
-
 
1646
     */
-
 
1647
    public function menu_item_should_be_active(string $navigationmenuitem): void {
-
 
1648
        $elementselector = "//*//a/following-sibling::*//a[contains(text(), '$navigationmenuitem') and @aria-current='true']";
-
 
1649
        $params = [$elementselector, "xpath_element"];
-
 
1650
        $this->execute("behat_general::should_exist", $params);
-
 
1651
    }
-
 
1652
 
-
 
1653
    /**
-
 
1654
     * Checks if a navigation menu item is not active
-
 
1655
     *
-
 
1656
     * @Then menu item :navigationmenuitem should not be active
-
 
1657
     * @param string $navigationmenuitem The navigation menu item name.
-
 
1658
     */
-
 
1659
    public function menu_item_should_not_be_active(string $navigationmenuitem): void {
-
 
1660
        $elementselector = "//*//a/following-sibling::*//a[contains(text(), '$navigationmenuitem') and @aria-current='true']";
-
 
1661
        $params = [$elementselector, "xpath_element"];
-
 
1662
        $this->execute("behat_general::should_not_exist", $params);
-
 
1663
    }
-
 
1664
 
-
 
1665
    /**
-
 
1666
     * Sets a link to no longer navigate when selected.
-
 
1667
     *
-
 
1668
     * @When /^I update the href of the "(?P<locator_string>[^"]*)" "(?P<selector_string>[^"]*)" link to "(?P<href_string>[^"]*)"$/
-
 
1669
     * @param string $locator The locator to use
-
 
1670
     * @param string $selector selector type
-
 
1671
     * @param string $href The value
-
 
1672
     */
-
 
1673
    public function i_update_the_link_to_go_nowhere(
-
 
1674
        string $locator,
-
 
1675
        string $selector,
-
 
1676
        string $href,
-
 
1677
    ): void {
-
 
1678
        $this->require_javascript();
-
 
1679
        $xpath = $this->find(
-
 
1680
            selector: $selector,
-
 
1681
            locator: $locator,
-
 
1682
        )->getXpath();
-
 
1683
        $script = <<<JS
-
 
1684
            var result = document.evaluate("{$xpath}", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
-
 
1685
            var link = result.singleNodeValue;
-
 
1686
 
-
 
1687
            if (link) {
-
 
1688
                link.setAttribute('href', '{$href}');
-
 
1689
            } else {
-
 
1690
                throw new Error('No element found with the XPath: ' + "$selector");
-
 
1691
            }
-
 
1692
        JS;
-
 
1693
 
-
 
1694
        $this->getSession()->executeScript($script);
-
 
1695
    }
1631
}
1696
}