mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
MDL-71610 theme_classic: Check whether editing mode is enabled in behat
This commit is contained in:
parent
350797397e
commit
1146c69257
1 changed files with 24 additions and 0 deletions
|
@ -46,4 +46,28 @@ class behat_theme_classic_behat_course extends behat_course {
|
|||
$xpath = "//div[contains(@class,'block')]//li[p/*[string(.)=$coursestr or string(.)=$mycoursestr]]";
|
||||
$this->execute('behat_general::i_click_on_in_the', [get_string('participants'), 'link', $xpath, 'xpath_element']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the user has permission to modify this course.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function is_course_editor(): bool {
|
||||
// If the course is already in editing mode then it will have the class 'editing' on the body.
|
||||
// This is a 'cheap' way of telling if the course is in editing mode.
|
||||
$body = $this->find('css', 'body');
|
||||
if ($body->hasClass('editing')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// If the course is not already in editing mode, then the only real way to find out if the current user may edit
|
||||
// the page is to look for the "Turn editing on" button.
|
||||
// If the button is found then the user is a course editor.
|
||||
try {
|
||||
$this->find('button', get_string('turneditingon'), false, false, 0);
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue