MDL-65056 completion: Hide checkboxes on course page for teachers

This commit is contained in:
Alexander Bias 2019-03-27 21:18:42 +01:00
parent 019004dcc7
commit d6cea5ccd9
5 changed files with 174 additions and 29 deletions

View file

@ -152,4 +152,72 @@ class behat_completion extends behat_base {
array($imgalttext, "icon", $activityxpath, "xpath_element")
);
}
/**
* Checks if the activity with specified name shows a information completion checkbox (i.e. showing the completion tracking
* configuration).
*
* @Given /^the "(?P<activityname_string>(?:[^"]|\\")*)" "(?P<activitytype_string>(?:[^"]|\\")*)" activity with "(manual|auto)" completion shows a configuration completion checkbox/
* @param string $activityname The activity name.
* @param string $activitytype The activity type.
* @param string $completiontype The completion type.
*/
public function activity_has_configuration_completion_checkbox($activityname, $activitytype, $completiontype) {
if ($completiontype == "manual") {
$imgname = 'i/completion-manual-enabled';
} else {
$imgname = 'i/completion-auto-enabled';
}
$iconxpath = "//li[contains(concat(' ', @class, ' '), ' modtype_" . strtolower($activitytype) . " ')]";
$iconxpath .= "[descendant::*[contains(text(), '" . $activityname . "')]]";
$iconxpath .= "/descendant::span[@class='actions']/descendant::img[contains(@src, 'i/completion-')]";
$this->execute("behat_general::the_attribute_of_should_contain",
array("src", $iconxpath, "xpath_element", $imgname)
);
}
/**
* Checks if the activity with specified name shows a tracking completion checkbox (i.e. showing my completion tracking status)
*
* @Given /^the "(?P<activityname_string>(?:[^"]|\\")*)" "(?P<activitytype_string>(?:[^"]|\\")*)" activity with "(manual|auto)" completion shows a status completion checkbox/
* @param string $activityname The activity name.
* @param string $activitytype The activity type.
* @param string $completiontype The completion type.
*/
public function activity_has_status_completion_checkbox($activityname, $activitytype, $completiontype) {
if ($completiontype == "manual") {
$imgname = 'i/completion-manual-';
} else {
$imgname = 'i/completion-auto-';
}
$iconxpath = "//li[contains(concat(' ', @class, ' '), ' modtype_" . strtolower($activitytype) . " ')]";
$iconxpath .= "[descendant::*[contains(text(), '" . $activityname . "')]]";
$iconxpath .= "/descendant::span[@class='actions']/descendant::img[contains(@src, 'i/completion-')]";
$this->execute("behat_general::the_attribute_of_should_contain",
array("src", $iconxpath, "xpath_element", $imgname)
);
$this->execute("behat_general::the_attribute_of_should_not_contain",
array("src", $iconxpath, "xpath_element", '-enabled')
);
}
/**
* Checks if the activity with specified name does not show any completion checkbox.
*
* @Given /^the "(?P<activityname_string>(?:[^"]|\\")*)" "(?P<activitytype_string>(?:[^"]|\\")*)" activity does not show any completion checkbox/
* @param string $activityname The activity name.
* @param string $activitytype The activity type.
*/
public function activity_has_not_any_completion_checkbox($activityname, $activitytype) {
$iconxpath = "//li[contains(concat(' ', @class, ' '), ' modtype_" . strtolower($activitytype) . " ')]";
$iconxpath .= "[descendant::*[contains(text(), '" . $activityname . "')]]";
$iconxpath .= "/descendant::img[contains(@src, 'i/completion-')]";
$this->execute("behat_general::should_not_exist",
array($iconxpath, "xpath_element")
);
}
}