Skip to content
Browse files

MDL-39870 correctly determine whether activity is resource or module

  • Loading branch information...
1 parent 836dab7 commit f85cb076aaf165d25f6133638b83d01b0b6849ad @marinaglancy marinaglancy committed with danpoltawski May 29, 2013
Showing with 15 additions and 6 deletions.
  1. +15 −6 course/renderer.php
View
21 course/renderer.php
@@ -369,9 +369,7 @@ function course_section_add_cm_control($course, $section, $sectionreturn = null,
$activities = array(MOD_CLASS_ACTIVITY => array(), MOD_CLASS_RESOURCE => array());
foreach ($modules as $module) {
- if (!array_key_exists($module->archetype, $activities)) {
- // System modules cannot be added by user, do not add to dropdown
- } else if (isset($module->types)) {
+ if (isset($module->types)) {
// This module has a subtype
// NOTE: this is legacy stuff, module subtypes are very strongly discouraged!!
$subtypes = array();
@@ -381,17 +379,28 @@ function course_section_add_cm_control($course, $section, $sectionreturn = null,
}
// Sort module subtypes into the list
+ $activityclass = MOD_CLASS_ACTIVITY;
+ if ($module->archetype == MOD_CLASS_RESOURCE) {
+ $activityclass = MOD_CLASS_RESOURCE;
+ }
if (!empty($module->title)) {
// This grouping has a name
- $activities[$module->archetype][] = array($module->title => $subtypes);
+ $activities[$activityclass][] = array($module->title => $subtypes);
} else {
// This grouping does not have a name
- $activities[$module->archetype] = array_merge($activities[$module->archetype], $subtypes);
+ $activities[$activityclass] = array_merge($activities[$activityclass], $subtypes);
}
} else {
// This module has no subtypes
+ $activityclass = MOD_CLASS_ACTIVITY;
+ if ($module->archetype == MOD_ARCHETYPE_RESOURCE) {
+ $activityclass = MOD_CLASS_RESOURCE;
+ } else if ($module->archetype === MOD_ARCHETYPE_SYSTEM) {
+ // System modules cannot be added by user, do not add to dropdown
+ continue;
+ }
$link = $module->link->out(true, $urlparams);
- $activities[$module->archetype][$link] = $module->title;
+ $activities[$activityclass][$link] = $module->title;
}
}

0 comments on commit f85cb07

Please sign in to comment.
Something went wrong with that request. Please try again.