diff --git a/course/format/singleactivity/lib.php b/course/format/singleactivity/lib.php index 02795d1ee21..6e5a4f209ff 100644 --- a/course/format/singleactivity/lib.php +++ b/course/format/singleactivity/lib.php @@ -154,7 +154,7 @@ class format_singleactivity extends format_base { ); } if ($foreditform && !isset($courseformatoptions['activitytype']['label'])) { - $availabletypes = get_module_types_names(); + $availabletypes = $this->get_supported_activities(); $courseformatoptionsedit = array( 'activitytype' => array( 'label' => new lang_string('activitytype', 'format_singleactivity'), @@ -270,7 +270,7 @@ class format_singleactivity extends format_base { */ protected function get_activitytype() { $options = $this->get_format_options(); - $availabletypes = get_module_types_names(); + $availabletypes = $this->get_supported_activities(); if (!empty($options['activitytype']) && array_key_exists($options['activitytype'], $availabletypes)) { return $options['activitytype']; @@ -291,6 +291,23 @@ class format_singleactivity extends format_base { return $this->activity; } + /** + * Get the activities supported by the format. + * + * Here we ignore the modules that do not have a page of their own, like the label. + * + * @return array array($module => $name of the module). + */ + public static function get_supported_activities() { + $availabletypes = get_module_types_names(); + foreach ($availabletypes as $module => $name) { + if (plugin_supports('mod', $module, FEATURE_NO_VIEW_LINK, false)) { + unset($availabletypes[$module]); + } + } + return $availabletypes; + } + /** * Checks if the current user can add the activity of the specified type to this course. * diff --git a/course/format/singleactivity/settingslib.php b/course/format/singleactivity/settingslib.php index 75494fc00b7..4846c58dee7 100644 --- a/course/format/singleactivity/settingslib.php +++ b/course/format/singleactivity/settingslib.php @@ -42,11 +42,11 @@ class format_singleactivity_admin_setting_activitytype extends admin_setting_con */ public function load_choices() { global $CFG; - require_once($CFG->dirroot. '/course/lib.php'); + require_once($CFG->dirroot. '/course/format/singleactivity/lib.php'); if (is_array($this->choices)) { return true; } - $this->choices = get_module_types_names(); + $this->choices = format_singleactivity::get_supported_activities(); return true; } }