From: mark-nielsen Date: Wed, 23 May 2007 17:48:12 +0000 (+0000) Subject: Merging fixes for MDL-9757, MDL-9619 and MDL-9366 from MOODLE_18_STABLE X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=11bf5b8301b34b737bc9f11b7f844f71a19d52f9;p=moodle.git Merging fixes for MDL-9757, MDL-9619 and MDL-9366 from MOODLE_18_STABLE --- diff --git a/mod/lesson/mod_form.php b/mod/lesson/mod_form.php index 629736b899..5d07a3cf14 100644 --- a/mod/lesson/mod_form.php +++ b/mod/lesson/mod_form.php @@ -7,14 +7,15 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU Public License * @package lesson **/ -require_once ('moodleform_mod.php'); +require_once('moodleform_mod.php'); require_once('locallib.php'); + class mod_lesson_mod_form extends moodleform_mod { function definition() { - global $LESSON_NEXTPAGE_ACTION, $COURSE; + $mform =& $this->_form; //------------------------------------------------------------------------------- @@ -42,7 +43,6 @@ class mod_lesson_mod_form extends moodleform_mod { $mform->setDefault('maxanswers', 4); $mform->setHelpButton('maxanswers', array('maxanswers', get_string('displayformat', 'lesson'), 'lesson')); - //------------------------------------------------------------------------------- $mform->addElement('header', '', get_string('gradeoptions', 'lesson')); @@ -128,14 +128,14 @@ class mod_lesson_mod_form extends moodleform_mod { $mform->setDefault('slideshow', 0); $mform->addElement('text', 'width', get_string('slideshowwidth', 'lesson')); - $mform->setDefault('width', 20); + $mform->setDefault('width', 640); $mform->addRule('width', null, 'required', null, 'client'); $mform->addRule('width', null, 'numeric', null, 'client'); $mform->setHelpButton('width', array('width', get_string('slideshowwidth', 'lesson'), 'lesson')); $mform->setType('width', PARAM_INT); $mform->addElement('text', 'height', get_string('slideshowheight', 'lesson')); - $mform->setDefault('height', 20); + $mform->setDefault('height', 480); $mform->addRule('height', null, 'required', null, 'client'); $mform->addRule('height', null, 'numeric', null, 'client'); $mform->setHelpButton('height', array('height', get_string('slideshowheight', 'lesson'), 'lesson')); @@ -237,7 +237,6 @@ class mod_lesson_mod_form extends moodleform_mod { //------------------------------------------------------------------------------- $mform->addElement('header', '', get_string('other', 'lesson')); - // get the modules if ($mods = get_course_mods($COURSE->id)) { $modinstances = array(); @@ -245,7 +244,7 @@ class mod_lesson_mod_form extends moodleform_mod { // 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 (!empty($this->_cm->id) and $this->_cm->id != $mod->id){ + if (isset($this->_cm->id) and $this->_cm->id != $mod->id){ $modinstances[$mod->id] = $mod->modname.' - '.$module->name; } } @@ -277,9 +276,13 @@ class mod_lesson_mod_form extends moodleform_mod { $this->add_action_buttons(); } - - - function data_preprocessing(&$default_values){ + /** + * Enforce defaults here + * + * @param array $default_values Form defaults + * @return void + **/ + function data_preprocessing(&$default_values) { if (isset($default_values['conditions'])) { $conditions = unserialize($default_values['conditions']); $default_values['timespent'] = $conditions->timespent; @@ -289,6 +292,21 @@ class mod_lesson_mod_form extends moodleform_mod { if (isset($default_values['password'])) { unset($default_values['password']); } + if (isset($default_values['add']) and $defaults = get_record('lesson_default', 'course', $default_values['course'])) { + foreach ($defaults as $fieldname => $default) { + switch ($fieldname) { + case 'conditions': + $conditions = unserialize($default); + $default_values['timespent'] = $conditions->timespent; + $default_values['completed'] = $conditions->completed; + $default_values['gradebetterthan'] = $conditions->gradebetterthan; + break; + default: + $default_values[$fieldname] = $default; + break; + } + } + } } } ?>