Skip to content

Commit

Permalink
Merge branch 'MDL-71610-master' of git://github.com/andrewnicols/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
abgreeve committed Sep 30, 2021
2 parents 26f7355 + 1146c69 commit 23a5ce9
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions theme/classic/tests/behat/behat_theme_classic_behat_course.php
Expand Up @@ -46,4 +46,28 @@ public function i_navigate_to_course_participants() {
$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;
}
}
}

0 comments on commit 23a5ce9

Please sign in to comment.