diff --git a/course/format/singleactivity/lib.php b/course/format/singleactivity/lib.php
index <HASH>..<HASH> 100644
--- a/course/format/singleactivity/lib.php
+++ b/course/format/singleactivity/lib.php
@@ -181,7 +181,7 @@ class format_singleactivity extends format_base {
                 ),
             );
 
-            if (!isset($availabletypes[$config->activitytype])) {
+            if (!empty($availabletypes) && !isset($availabletypes[$config->activitytype])) {
                 $courseformatoptions['activitytype']['default'] = array_keys($availabletypes)[0];
             }
         }
MDL-<I> format_singleactivity: Make sure available types is not empty