From 780765ff79a3770e6adb713a32c3b5318cf265ea Mon Sep 17 00:00:00 2001 From: PMKuipers Date: Fri, 16 Jun 2023 13:49:05 +0200 Subject: [PATCH] Auto get first available context on viewing --- view-plan.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/view-plan.php b/view-plan.php index 6f34042..6a3d8b0 100644 --- a/view-plan.php +++ b/view-plan.php @@ -32,11 +32,11 @@ elseif($contextid > 0) else { // If no context is selected, find the first available one - $available_contexts = courseservice::list_used_categories("view"); + $available_contexts = courseservice::list_accessible_categories_with_usage("view"); $contextid=1; // fallback to system context foreach($available_contexts as $ctx){ - if($ctx["studyplancount"] > 0){ - $contextid = $ctx["context_id"]; + if($ctx->count > 0){ + $contextid = $ctx->ctxid; break; } }