From 6e372b2591168a063301f504f90e11a4a12e3d84 Mon Sep 17 00:00:00 2001 From: jamiesensei Date: Tue, 21 Nov 2006 09:33:48 +0000 Subject: [PATCH] added commenting to addDependency method and used new functionality in forum\mod_form.php --- lib/formslib.php | 11 +++++++++++ mod/forum/lib.php | 6 +++--- mod/forum/mod_form.php | 9 +++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/lib/formslib.php b/lib/formslib.php index d5976e1ae0..b979f59e9a 100644 --- a/lib/formslib.php +++ b/lib/formslib.php @@ -818,6 +818,17 @@ function validate_' . $this->_attributes['id'] . '(frm) { $js .=''."\n"; return $js; } + /** + * Adds a dependency for $elementName which will be disabled if $condition is met. + * If $condition='checked' (default) then the condition is that the $dependentOn element + * is checked. If $condition is something else then it is checked to see if the value + * of the $dependentOn element is equal to $condition. + * + * @param string $elementName the name of the element which will be disabled + * @param string $dependentOn the name of the element whose state will be checked for + * condition + * @param string $condition the condition to check + */ function addDependency($elementName, $dependentOn, $condition='checked'){ $el=$this->getElement($elementName); if (is_a($el, 'HTML_QuickForm_group')){ diff --git a/mod/forum/lib.php b/mod/forum/lib.php index 3cc15f0976..d86ba7c9aa 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -146,7 +146,7 @@ function forum_update_instance($forum) { $forum->assessed = 0; } - if (!empty($forum->ratingtime)) { + if (empty($forum->ratingtime)) { $forum->assesstimestart = 0; $forum->assesstimefinish = 0; } @@ -2044,8 +2044,8 @@ function forum_print_post(&$post, $courseid, $ownpost=false, $reply=false, $link } $editanypost = has_capability('mod/forum:editanypost', $modcontext); - - + + if ($ownpost or $editanypost) { if (($age < $CFG->maxeditingtime) or $editanypost) { $commands[] = ''.$stredit.''; diff --git a/mod/forum/mod_form.php b/mod/forum/mod_form.php index 9210724562..35eaebb397 100644 --- a/mod/forum/mod_form.php +++ b/mod/forum/mod_form.php @@ -79,10 +79,19 @@ class forum_mod_form extends moodleform_mod { $mform->addElement('checkbox', 'assessed', get_string('allowratings', 'forum') , get_string('ratingsuse', 'forum')); $mform->addElement('modgrade', 'scale', get_string('grade'), false); + $mform->addDependency('scale', 'assessed'); + + $mform->addElement('checkbox', 'ratingtime', get_string('ratingtime', 'forum')); + $mform->addDependency('ratingtime', 'assessed'); $mform->addElement('date_time_selector', 'assesstimestart', get_string('from')); + $mform->addDependency('assesstimestart', 'assessed'); + $mform->addDependency('assesstimestart', 'ratingtime'); $mform->addElement('date_time_selector', 'assesstimefinish', get_string('to')); + $mform->addDependency('assesstimefinish', 'assessed'); + $mform->addDependency('assesstimefinish', 'ratingtime'); + //------------------------------------------------------------------------------- $mform->addElement('header', '', get_string('blockafter', 'forum')); -- 2.39.5