mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-46503 behat: cohort generator allows to create cohort in category
This commit is contained in:
parent
40f0ad21a3
commit
5f079af450
2 changed files with 41 additions and 0 deletions
|
@ -217,6 +217,25 @@ class behat_data_generators extends behat_base {
|
|||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* If contextlevel and reference are specified for cohort, transform them to the contextid.
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function preprocess_cohort($data) {
|
||||
if (isset($data['contextlevel'])) {
|
||||
if (!isset($data['reference'])) {
|
||||
throw new Exception('If field contextlevel is specified, field reference must also be present');
|
||||
}
|
||||
$context = $this->get_context($data['contextlevel'], $data['reference']);
|
||||
unset($data['contextlevel']);
|
||||
unset($data['reference']);
|
||||
$data['contextid'] = $context->id;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adapter to modules generator
|
||||
* @throws Exception Custom exception for test writers
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue