Category selected defaults to first one available instead of first with studyplans
This commit is contained in:
parent
97552704ce
commit
e092758ff1
|
@ -46,14 +46,11 @@ if ($categoryid > 0) {
|
|||
$studyplancontext = $systemcontext;
|
||||
}
|
||||
} else {
|
||||
// If no context is selected, find the first available one.
|
||||
// If no context is selected, find the first available context for this user.
|
||||
$availablecontexts = courseservice::list_accessible_categories_with_usage("edit");
|
||||
$contextid = 1; // Fallback to system context.
|
||||
foreach ($availablecontexts as $ctx) {
|
||||
if ($ctx->count > 0) {
|
||||
$contextid = $ctx->ctxid;
|
||||
break;
|
||||
}
|
||||
if (count($availablecontexts) > 0) {
|
||||
$contextid = $availablecontexts[0]->ctxid;
|
||||
}
|
||||
// Reload page with selected category.
|
||||
$url = new \moodle_url('/local/treestudyplan/edit-plan.php', ["contextid" => $contextid]);
|
||||
|
|
Loading…
Reference in New Issue
Block a user