mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-22779 fixing add instance to show only cohorts from parent contexts
This commit is contained in:
parent
b31f126a2a
commit
d675887bc0
1 changed files with 6 additions and 2 deletions
|
@ -37,9 +37,13 @@ class enrol_cohort_addinstance_form extends moodleform {
|
||||||
|
|
||||||
$enrol = enrol_get_plugin('cohort');
|
$enrol = enrol_get_plugin('cohort');
|
||||||
|
|
||||||
//TODO: add only cohorts from parent contexts of this course
|
|
||||||
$cohorts = array('' => get_string('choosedots'));
|
$cohorts = array('' => get_string('choosedots'));
|
||||||
$rs = $DB->get_recordset('cohort', array(), 'name ASC', 'id, name, contextid');
|
list($sqlparents, $params) = $DB->get_in_or_equal(get_parent_contexts($coursecontext));
|
||||||
|
$sql = "SELECT id, name, contextid
|
||||||
|
FROM {cohort}
|
||||||
|
WHERE contextid $sqlparents
|
||||||
|
ORDER BY name ASC";
|
||||||
|
$rs = $DB->get_recordset_sql($sql, $params);
|
||||||
foreach ($rs as $c) {
|
foreach ($rs as $c) {
|
||||||
$context = get_context_instance_by_id($c->contextid);
|
$context = get_context_instance_by_id($c->contextid);
|
||||||
if (!has_capability('moodle/cohort:view', $context)) {
|
if (!has_capability('moodle/cohort:view', $context)) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue