diff --git a/build.php b/build.php
index 10d5505..39115f9 100644
--- a/build.php
+++ b/build.php
@@ -39,8 +39,9 @@ if(!is_dir($builddir)){
}
}
-if(is_file($zipfile)){
- unlink($zipfile);
+if(file_exists($zipfile)){
+ print("Zip file '{$zipfile}' already exists. Exiting...\n");
+ exit(1);
}
$cwd = getcwd();
diff --git a/view-plan.php b/view-plan.php
index ae8c283..6f34042 100644
--- a/view-plan.php
+++ b/view-plan.php
@@ -1,6 +1,8 @@
libdir.'/weblib.php');
$systemcontext = context_system::instance();
@@ -29,8 +31,19 @@ elseif($contextid > 0)
}
else
{
- $categoryid = 0;
- $studyplancontext = $systemcontext;
+ // If no context is selected, find the first available one
+ $available_contexts = courseservice::list_used_categories("view");
+ $contextid=1; // fallback to system context
+ foreach($available_contexts as $ctx){
+ if($ctx["studyplancount"] > 0){
+ $contextid = $ctx["context_id"];
+ break;
+ }
+ }
+ // reload page with selected category
+ $url = new \moodle_url('/local/treestudyplan/view-plan.php',["contextid" => $contextid]);
+ header('Location: '.$url->out(false), true, 302);
+ exit;
}
require_capability('local/treestudyplan:viewuserreports',$studyplancontext);
@@ -72,7 +85,6 @@ print $OUTPUT->header();
:active="ctx.context_id == contextid" :class="(ctx.studyplancount > 0)?'font-weight-bold':''"
> / {{ p }} ({{ ctx.studyplancount }})
-