From b4f4f09ca8716ed26e4faf4fbb8d9bd81668e763 Mon Sep 17 00:00:00 2001 From: michaelpenne Date: Fri, 13 Jan 2006 21:57:42 +0000 Subject: [PATCH] [Fixed] Fails gracefully when no course modules are found. [Fixed] Does not remove other modules from the activity link options due to same ids. --- mod/lesson/mod.html | 65 ++++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/mod/lesson/mod.html b/mod/lesson/mod.html index 9164c70ca85..8effa61ceab 100644 --- a/mod/lesson/mod.html +++ b/mod/lesson/mod.html @@ -544,40 +544,43 @@ if ($form->mode == "add") { course); - $modinstances = array(); - foreach ($mods as $mod) { - if ($mod->instance == $form->instance) { // don't add this lesson - continue; - } - // get the module name and then store it in a new array - if ($module = get_coursemodule_from_instance($mod->modname, $mod->instance, $form->course)) { - $modinstances[$mod->modname][$module->id] = $module->name; - } - } - ksort($modinstances); // sort by module name - - // print out a select dropdown with optgroups - echo ''; + if ($form->activitylink == 0) { + echo '\n"; + } else { + echo '\n"; + } + foreach ($modinstances as $module => $instances) { + echo ''."\n"; + + asort($instances); + foreach ($instances as $modid => $instance) { + if ($form->activitylink == $modid) { // check for being selected + echo '\n"; + } else { + echo '\n"; + } + } + echo "\n"; + } + echo "\n"; + } else { + print_string('nocoursemods', 'lesson'); } - echo "\n"; helpbutton("activitylink", get_string("activitylink", "lesson"), "lesson"); ?>