Skip to content

Commit

Permalink
Fixed MDL-9619
Browse files Browse the repository at this point in the history
Fixed MDL-9366
Fixed MDL-9757
Converted tabs to spaces
Cleaned up white space
  • Loading branch information
mark-nielsen committed May 23, 2007
1 parent a335226 commit 16ba216
Showing 1 changed file with 48 additions and 30 deletions.
78 changes: 48 additions & 30 deletions mod/lesson/mod_form.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,22 +7,23 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package lesson * @package lesson
**/ **/
require_once ('moodleform_mod.php');


require_once('moodleform_mod.php');
require_once('locallib.php'); require_once('locallib.php');

class mod_lesson_mod_form extends moodleform_mod { class mod_lesson_mod_form extends moodleform_mod {


function definition() { function definition() {
global $LESSON_NEXTPAGE_ACTION, $COURSE;


global $LESSON_NEXTPAGE_ACTION, $COURSE; $mform =& $this->_form;
$mform =& $this->_form;


//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
$mform->addElement('header', 'general', get_string('general', 'form')); $mform->addElement('header', 'general', get_string('general', 'form'));


$mform->addElement('text', 'name', get_string('name'), array('size'=>'64')); $mform->addElement('text', 'name', get_string('name'), array('size'=>'64'));
$mform->setType('name', PARAM_TEXT); $mform->setType('name', PARAM_TEXT);
$mform->addRule('name', null, 'required', null, 'client'); $mform->addRule('name', null, 'required', null, 'client');


$mform->addElement('selectyesno', 'timed', get_string('timed', 'lesson')); $mform->addElement('selectyesno', 'timed', get_string('timed', 'lesson'));
$mform->setDefault('timed', 0); $mform->setDefault('timed', 0);
Expand All @@ -32,7 +33,7 @@ function definition() {
$mform->setDefault('maxtime', 20); $mform->setDefault('maxtime', 20);
$mform->addRule('maxtime', null, 'required', null, 'client'); $mform->addRule('maxtime', null, 'required', null, 'client');
$mform->addRule('maxtime', null, 'numeric', null, 'client'); $mform->addRule('maxtime', null, 'numeric', null, 'client');
$mform->setType('maxtime', PARAM_INT); $mform->setType('maxtime', PARAM_INT);


$numbers = array(); $numbers = array();
for ($i=20; $i>1; $i--) { for ($i=20; $i>1; $i--) {
Expand All @@ -42,7 +43,6 @@ function definition() {
$mform->setDefault('maxanswers', 4); $mform->setDefault('maxanswers', 4);
$mform->setHelpButton('maxanswers', array('maxanswers', get_string('displayformat', 'lesson'), 'lesson')); $mform->setHelpButton('maxanswers', array('maxanswers', get_string('displayformat', 'lesson'), 'lesson'));



//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
$mform->addElement('header', '', get_string('gradeoptions', 'lesson')); $mform->addElement('header', '', get_string('gradeoptions', 'lesson'));


Expand Down Expand Up @@ -128,24 +128,24 @@ function definition() {
$mform->setDefault('slideshow', 0); $mform->setDefault('slideshow', 0);


$mform->addElement('text', 'width', get_string('slideshowwidth', 'lesson')); $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, 'required', null, 'client');
$mform->addRule('width', null, 'numeric', null, 'client'); $mform->addRule('width', null, 'numeric', null, 'client');
$mform->setHelpButton('width', array('width', get_string('slideshowwidth', 'lesson'), 'lesson')); $mform->setHelpButton('width', array('width', get_string('slideshowwidth', 'lesson'), 'lesson'));
$mform->setType('width', PARAM_INT); $mform->setType('width', PARAM_INT);


$mform->addElement('text', 'height', get_string('slideshowheight', 'lesson')); $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, 'required', null, 'client');
$mform->addRule('height', null, 'numeric', null, 'client'); $mform->addRule('height', null, 'numeric', null, 'client');
$mform->setHelpButton('height', array('height', get_string('slideshowheight', 'lesson'), 'lesson')); $mform->setHelpButton('height', array('height', get_string('slideshowheight', 'lesson'), 'lesson'));
$mform->setType('height', PARAM_INT); $mform->setType('height', PARAM_INT);


$mform->addElement('text', 'bgcolor', get_string('slideshowbgcolor', 'lesson')); $mform->addElement('text', 'bgcolor', get_string('slideshowbgcolor', 'lesson'));
$mform->setDefault('bgcolor', '#FFFFFF'); $mform->setDefault('bgcolor', '#FFFFFF');
$mform->addRule('bgcolor', null, 'required', null, 'client'); $mform->addRule('bgcolor', null, 'required', null, 'client');
$mform->setHelpButton('bgcolor', array('bgcolor', get_string('slideshowbgcolor', 'lesson'), 'lesson')); $mform->setHelpButton('bgcolor', array('bgcolor', get_string('slideshowbgcolor', 'lesson'), 'lesson'));
$mform->setType('bgcolor', PARAM_TEXT); $mform->setType('bgcolor', PARAM_TEXT);


$mform->addElement('selectyesno', 'displayleft', get_string('displayleftmenu', 'lesson')); $mform->addElement('selectyesno', 'displayleft', get_string('displayleftmenu', 'lesson'));
$mform->setHelpButton('displayleft', array('displayleft', get_string('displayleftmenu', 'lesson'), 'lesson')); $mform->setHelpButton('displayleft', array('displayleft', get_string('displayleftmenu', 'lesson'), 'lesson'));
Expand Down Expand Up @@ -174,15 +174,15 @@ function definition() {
$mform->setHelpButton('password', array('password', get_string('password', 'lesson'), 'lesson')); $mform->setHelpButton('password', array('password', get_string('password', 'lesson'), 'lesson'));
$mform->setDefault('password', ''); $mform->setDefault('password', '');
//never displayed converted to md5 //never displayed converted to md5
$mform->setType('password', PARAM_RAW); $mform->setType('password', PARAM_RAW);


$mform->addElement('date_time_selector', 'available', get_string('available', 'lesson')); $mform->addElement('date_time_selector', 'available', get_string('available', 'lesson'));
$mform->setDefault('available', 0); $mform->setDefault('available', 0);


$mform->addElement('date_time_selector', 'deadline', get_string('deadline', 'lesson')); $mform->addElement('date_time_selector', 'deadline', get_string('deadline', 'lesson'));
$mform->setDefault('deadline', 0); $mform->setDefault('deadline', 0);


//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
$mform->addElement('header', '', get_string('dependencyon', 'lesson')); $mform->addElement('header', '', get_string('dependencyon', 'lesson'));


$options = array(0=>get_string('none')); $options = array(0=>get_string('none'));
Expand All @@ -200,22 +200,22 @@ function definition() {


$mform->addElement('text', 'timespent', get_string('timespentminutes', 'lesson')); $mform->addElement('text', 'timespent', get_string('timespentminutes', 'lesson'));
$mform->setDefault('timespent', 0); $mform->setDefault('timespent', 0);
$mform->setType('timespent', PARAM_INT); $mform->setType('timespent', PARAM_INT);


$mform->addElement('checkbox', 'completed', get_string('completed', 'lesson')); $mform->addElement('checkbox', 'completed', get_string('completed', 'lesson'));
$mform->setDefault('completed', 0); $mform->setDefault('completed', 0);


$mform->addElement('text', 'gradebetterthan', get_string('gradebetterthan', 'lesson')); $mform->addElement('text', 'gradebetterthan', get_string('gradebetterthan', 'lesson'));
$mform->setDefault('gradebetterthan', 0); $mform->setDefault('gradebetterthan', 0);
$mform->setType('gradebetterthan', PARAM_INT); $mform->setType('gradebetterthan', PARAM_INT);


//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
$mform->addElement('header', '', get_string('mediafile', 'lesson')); $mform->addElement('header', '', get_string('mediafile', 'lesson'));


$mform->addElement('choosecoursefile', 'mediafile', get_string('mediafile', 'lesson'), array('courseid'=>$COURSE->id)); $mform->addElement('choosecoursefile', 'mediafile', get_string('mediafile', 'lesson'), array('courseid'=>$COURSE->id));
$mform->setHelpButton('mediafile', array('mediafile', get_string('mediafile', 'lesson'), 'lesson')); $mform->setHelpButton('mediafile', array('mediafile', get_string('mediafile', 'lesson'), 'lesson'));
$mform->setDefault('mediafile', ''); $mform->setDefault('mediafile', '');
$mform->setType('mediafile', PARAM_PATH); $mform->setType('mediafile', PARAM_PATH);


$mform->addElement('selectyesno', 'mediaclose', get_string('mediaclose', 'lesson')); $mform->addElement('selectyesno', 'mediaclose', get_string('mediaclose', 'lesson'));
$mform->setDefault('mediaclose', 0); $mform->setDefault('mediaclose', 0);
Expand All @@ -225,27 +225,26 @@ function definition() {
$mform->setDefault('mediaheight', 100); $mform->setDefault('mediaheight', 100);
$mform->addRule('mediaheight', null, 'required', null, 'client'); $mform->addRule('mediaheight', null, 'required', null, 'client');
$mform->addRule('mediaheight', null, 'numeric', null, 'client'); $mform->addRule('mediaheight', null, 'numeric', null, 'client');
$mform->setType('mediaheight', PARAM_INT); $mform->setType('mediaheight', PARAM_INT);


$mform->addElement('text', 'mediawidth', get_string('mediawidth', 'lesson')); $mform->addElement('text', 'mediawidth', get_string('mediawidth', 'lesson'));
$mform->setHelpButton('mediawidth', array('mediawidth', get_string('mediawidth', 'lesson'), 'lesson')); $mform->setHelpButton('mediawidth', array('mediawidth', get_string('mediawidth', 'lesson'), 'lesson'));
$mform->setDefault('mediawidth', 650); $mform->setDefault('mediawidth', 650);
$mform->addRule('mediawidth', null, 'required', null, 'client'); $mform->addRule('mediawidth', null, 'required', null, 'client');
$mform->addRule('mediawidth', null, 'numeric', null, 'client'); $mform->addRule('mediawidth', null, 'numeric', null, 'client');
$mform->setType('mediawidth', PARAM_INT); $mform->setType('mediawidth', PARAM_INT);


//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
$mform->addElement('header', '', get_string('other', 'lesson')); $mform->addElement('header', '', get_string('other', 'lesson'));



// get the modules // get the modules
if ($mods = get_course_mods($COURSE->id)) { if ($mods = get_course_mods($COURSE->id)) {
$modinstances = array(); $modinstances = array();
foreach ($mods as $mod) { 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 ($module = get_coursemodule_from_instance($mod->modname, $mod->instance, $COURSE->id)) {
if ($this->_cm->id != $mod->id){ if (isset($this->_cm->id) and $this->_cm->id != $mod->id){
$modinstances[$mod->id] = $mod->modname.' - '.$module->name; $modinstances[$mod->id] = $mod->modname.' - '.$module->name;
} }
} }
Expand All @@ -264,22 +263,26 @@ function definition() {
$mform->setDefault('maxhighscores', 10); $mform->setDefault('maxhighscores', 10);
$mform->addRule('maxhighscores', null, 'required', null, 'client'); $mform->addRule('maxhighscores', null, 'required', null, 'client');
$mform->addRule('maxhighscores', null, 'numeric', null, 'client'); $mform->addRule('maxhighscores', null, 'numeric', null, 'client');
$mform->setType('maxhighscores', PARAM_INT); $mform->setType('maxhighscores', PARAM_INT);


$mform->addElement('selectyesno', 'lessondefault', get_string('lessondefault', 'lesson')); $mform->addElement('selectyesno', 'lessondefault', get_string('lessondefault', 'lesson'));
$mform->setHelpButton('lessondefault', array('lessondefault', get_string('lessondefault', 'lesson'), 'lesson')); $mform->setHelpButton('lessondefault', array('lessondefault', get_string('lessondefault', 'lesson'), 'lesson'));
$mform->setDefault('lessondefault', 0); $mform->setDefault('lessondefault', 0);


//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
$this->standard_coursemodule_elements(false); $this->standard_coursemodule_elements(false);
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
// buttons // buttons
$this->add_action_buttons(); $this->add_action_buttons();
} }



/**

* Enforce defaults here
function data_preprocessing(&$default_values){ *
* @param array $default_values Form defaults
* @return void
**/
function data_preprocessing(&$default_values) {
if (isset($default_values['conditions'])) { if (isset($default_values['conditions'])) {
$conditions = unserialize($default_values['conditions']); $conditions = unserialize($default_values['conditions']);
$default_values['timespent'] = $conditions->timespent; $default_values['timespent'] = $conditions->timespent;
Expand All @@ -289,6 +292,21 @@ function data_preprocessing(&$default_values){
if (isset($default_values['password'])) { if (isset($default_values['password'])) {
unset($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;
}
}
}
}
} }
?> ?>

0 comments on commit 16ba216

Please sign in to comment.