From a6736504775d9fe3234448e98b0bba8ceac1894f Mon Sep 17 00:00:00 2001 From: Paul Nicholls Date: Fri, 26 Jun 2015 12:05:49 +1200 Subject: [PATCH] MDL-50699 Lesson: "Link to next activity" empty until Lesson saved Due to a logic bug, the "Link to next activity" dropdown was empty (only contains the "None" option) until the Lesson had been saved. This minor change allows a "next activity" to be specified when initially creating the Lesson whilst still preventing the user from choosing the Lesson as its own next activity. --- mod/lesson/mod_form.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mod/lesson/mod_form.php b/mod/lesson/mod_form.php index d64cfe64f05..fa70507b258 100644 --- a/mod/lesson/mod_form.php +++ b/mod/lesson/mod_form.php @@ -146,15 +146,15 @@ class mod_lesson_mod_form extends moodleform_mod { if ($mods = get_course_mods($COURSE->id)) { $modinstances = array(); foreach ($mods as $mod) { - - // get the module name and then store it in a new array + // Get the module name and then store it in a new array. if ($module = get_coursemodule_from_instance($mod->modname, $mod->instance, $COURSE->id)) { - if (isset($this->_cm->id) and $this->_cm->id != $mod->id){ + // Exclude this lesson, if it's already been saved. + if (!isset($this->_cm->id) || $this->_cm->id != $mod->id) { $modinstances[$mod->id] = $mod->modname.' - '.$module->name; } } } - asort($modinstances); // sort by module name + asort($modinstances); // Sort by module name. $modinstances=array(0=>get_string('none'))+$modinstances; $mform->addElement('select', 'activitylink', get_string('activitylink', 'lesson'), $modinstances);