mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 09:26:35 +02:00
MDL-48947 course: Section button cleanup
Creates a new method of handling all the section related icons. Including a new method that places these actions in a menu for topic and weeks course formats. (This version replaces "Edit" with "Topic/Week/or Section menu")
This commit is contained in:
parent
cd3a6a78b6
commit
60cf074239
29 changed files with 512 additions and 126 deletions
|
@ -202,6 +202,56 @@ class behat_course extends behat_base {
|
|||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Opens a section edit menu if it is not already opened.
|
||||
*
|
||||
* @Given /^I open section "(?P<section_number>\d+)" edit menu$/
|
||||
* @throws DriverException The step is not available when Javascript is disabled
|
||||
* @param string $sectionnumber
|
||||
*/
|
||||
public function i_open_section_edit_menu($sectionnumber) {
|
||||
if (!$this->running_javascript()) {
|
||||
throw new DriverException('Section edit menu not available when Javascript is disabled');
|
||||
}
|
||||
|
||||
// If it is already opened we do nothing.
|
||||
$xpath = $this->section_exists($sectionnumber);
|
||||
$xpath .= "/descendant::div[contains(@class, 'section-actions')]/descendant::a[contains(@class, 'textmenu')]";
|
||||
|
||||
$exception = new ExpectationException('Section "' . $sectionnumber . '" was not found', $this->getSession());
|
||||
$menu = $this->find('xpath', $xpath, $exception);
|
||||
$menu->click();
|
||||
$this->i_wait_until_section_is_available($sectionnumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes course section.
|
||||
*
|
||||
* @Given /^I delete section "(?P<section_number>\d+)"$/
|
||||
* @param int $sectionnumber The section number
|
||||
* @return Given[]
|
||||
*/
|
||||
public function i_delete_section($sectionnumber) {
|
||||
// Ensures the section exists.
|
||||
$xpath = $this->section_exists($sectionnumber);
|
||||
|
||||
// We need to know the course format as the text strings depends on them.
|
||||
$courseformat = $this->get_course_format();
|
||||
if (get_string_manager()->string_exists('deletesection', $courseformat)) {
|
||||
$strdelete = get_string('deletesection', $courseformat);
|
||||
} else {
|
||||
$strdelete = get_string('deletesection');
|
||||
}
|
||||
|
||||
// If javascript is on, link is inside a menu.
|
||||
if ($this->running_javascript()) {
|
||||
$this->i_open_section_edit_menu($sectionnumber);
|
||||
}
|
||||
|
||||
return new Given('I click on "' . $strdelete . '" "link" in the "' . $this->escape($xpath) . '" "xpath_element"');
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns course section highlighting on.
|
||||
*
|
||||
|
@ -214,6 +264,11 @@ class behat_course extends behat_base {
|
|||
// Ensures the section exists.
|
||||
$xpath = $this->section_exists($sectionnumber);
|
||||
|
||||
// If javascript is on, link is inside a menu.
|
||||
if ($this->running_javascript()) {
|
||||
$this->i_open_section_edit_menu($sectionnumber);
|
||||
}
|
||||
|
||||
return new Given('I click on "' . get_string('markthistopic') . '" "link" in the "' . $this->escape($xpath) . '" "xpath_element"');
|
||||
}
|
||||
|
||||
|
@ -229,6 +284,11 @@ class behat_course extends behat_base {
|
|||
// Ensures the section exists.
|
||||
$xpath = $this->section_exists($sectionnumber);
|
||||
|
||||
// If javascript is on, link is inside a menu.
|
||||
if ($this->running_javascript()) {
|
||||
$this->i_open_section_edit_menu($sectionnumber);
|
||||
}
|
||||
|
||||
return new Given('I click on "' . get_string('markedthistopic') . '" "link" in the "' . $this->escape($xpath) . '" "xpath_element"');
|
||||
}
|
||||
|
||||
|
@ -271,7 +331,20 @@ class behat_course extends behat_base {
|
|||
* @param int $sectionnumber
|
||||
*/
|
||||
public function i_edit_the_section($sectionnumber) {
|
||||
return new Given('I click on "' . get_string('editsummary') . '" "link" in the "#section-' . $sectionnumber . '" "css_element"');
|
||||
// If javascript is on, link is inside a menu.
|
||||
if ($this->running_javascript()) {
|
||||
$this->i_open_section_edit_menu($sectionnumber);
|
||||
}
|
||||
|
||||
// We need to know the course format as the text strings depends on them.
|
||||
$courseformat = $this->get_course_format();
|
||||
if (get_string_manager()->string_exists('editsection', $courseformat)) {
|
||||
$stredit = get_string('editsection', $courseformat);
|
||||
} else {
|
||||
$stredit = get_string('editsection');
|
||||
}
|
||||
|
||||
return new Given('I click on "' . $stredit . '" "link" in the "#section-' . $sectionnumber . '" "css_element"');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -304,7 +377,7 @@ class behat_course extends behat_base {
|
|||
$xpath = $this->section_exists($sectionnumber);
|
||||
|
||||
// The important checking, we can not check the img.
|
||||
$xpath = $xpath . "/descendant::img[@alt='" . get_string('markedthistopic') . "'][contains(@src, 'marked')]";
|
||||
$xpath = $xpath . "/descendant::img[contains(@src, 'marked')]";
|
||||
$exception = new ExpectationException('The "' . $sectionnumber . '" section is not highlighted', $this->getSession());
|
||||
$this->find('xpath', $xpath, $exception);
|
||||
}
|
||||
|
@ -409,9 +482,14 @@ class behat_course extends behat_base {
|
|||
throw new ExpectationException('The section is hidden', $this->getSession());
|
||||
}
|
||||
|
||||
// Hide section button should be visible.
|
||||
// Edit menu should be visible.
|
||||
if ($this->is_course_editor()) {
|
||||
$this->hide_section_icon_exists($sectionnumber);
|
||||
$xpath = $sectionxpath .
|
||||
"/descendant::div[contains(@class, 'section-actions')]" .
|
||||
"/descendant::a[contains(@class, 'textmenu')]";
|
||||
if (!$this->getSession()->getPage()->find('xpath', $xpath)) {
|
||||
throw new ExpectationException('The section edit menu is not available', $this->getSession());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -431,6 +509,11 @@ class behat_course extends behat_base {
|
|||
// Ensures the section exists.
|
||||
$sectionxpath = $this->section_exists($sectionnumber);
|
||||
|
||||
// If javascript is on, link is inside a menu.
|
||||
if ($this->running_javascript()) {
|
||||
$this->i_open_section_edit_menu($sectionnumber);
|
||||
}
|
||||
|
||||
// Follows the link
|
||||
$moveuplink = $this->get_node_in_container('link', get_string('moveup'), 'xpath_element', $sectionxpath);
|
||||
$moveuplink->click();
|
||||
|
@ -452,6 +535,11 @@ class behat_course extends behat_base {
|
|||
// Ensures the section exists.
|
||||
$sectionxpath = $this->section_exists($sectionnumber);
|
||||
|
||||
// If javascript is on, link is inside a menu.
|
||||
if ($this->running_javascript()) {
|
||||
$this->i_open_section_edit_menu($sectionnumber);
|
||||
}
|
||||
|
||||
// Follows the link
|
||||
$movedownlink = $this->get_node_in_container('link', get_string('movedown'), 'xpath_element', $sectionxpath);
|
||||
$movedownlink->click();
|
||||
|
@ -876,10 +964,15 @@ class behat_course extends behat_base {
|
|||
// We need to know the course format as the text strings depends on them.
|
||||
$courseformat = $this->get_course_format();
|
||||
|
||||
// If javascript is on, link is inside a menu.
|
||||
if ($this->running_javascript()) {
|
||||
$this->i_open_section_edit_menu($sectionnumber);
|
||||
}
|
||||
|
||||
// Checking the show button alt text and show icon.
|
||||
$showtext = $this->getSession()->getSelectorsHandler()->xpathLiteral(get_string('showfromothers', $courseformat));
|
||||
$linkxpath = $xpath . "/descendant::a[@title=$showtext]";
|
||||
$imgxpath = $linkxpath . "/descendant::img[@alt=$showtext][contains(@src, 'show')]";
|
||||
$imgxpath = $linkxpath . "/descendant::img[contains(@src, 'show')]";
|
||||
|
||||
$exception = new ElementNotFoundException($this->getSession(), 'Show section icon ');
|
||||
$this->find('xpath', $imgxpath, $exception);
|
||||
|
@ -903,10 +996,15 @@ class behat_course extends behat_base {
|
|||
// We need to know the course format as the text strings depends on them.
|
||||
$courseformat = $this->get_course_format();
|
||||
|
||||
// If javascript is on, link is inside a menu.
|
||||
if ($this->running_javascript()) {
|
||||
$this->i_open_section_edit_menu($sectionnumber);
|
||||
}
|
||||
|
||||
// Checking the hide button alt text and hide icon.
|
||||
$hidetext = $this->getSession()->getSelectorsHandler()->xpathLiteral(get_string('hidefromothers', $courseformat));
|
||||
$linkxpath = $xpath . "/descendant::a[@title=$hidetext]";
|
||||
$imgxpath = $linkxpath . "/descendant::img[@alt=$hidetext][contains(@src, 'hide')]";
|
||||
$imgxpath = $linkxpath . "/descendant::img[contains(@src, 'hide')]";
|
||||
|
||||
$exception = new ElementNotFoundException($this->getSession(), 'Hide section icon ');
|
||||
$this->find('xpath', $imgxpath, $exception);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue