From: jamiesensei Date: Tue, 21 Nov 2006 11:02:13 +0000 (+0000) Subject: more fixes for lockoptions behaviour; changes to forum/mod_form.php; removed forum... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=9c03bbaa0433820a255ddcbc3a8a7b507ee33975;p=moodle.git more fixes for lockoptions behaviour; changes to forum/mod_form.php; removed forum/mod.html --- diff --git a/lib/formslib.php b/lib/formslib.php index b979f59e9a..4a882c9826 100644 --- a/lib/formslib.php +++ b/lib/formslib.php @@ -820,7 +820,8 @@ function validate_' . $this->_attributes['id'] . '(frm) { } /** * 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 + * If $condition='notchecked' (default) then the condition is that the $dependentOn element + * is not checked. If $condition='checked' 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. * @@ -829,7 +830,7 @@ function validate_' . $this->_attributes['id'] . '(frm) { * condition * @param string $condition the condition to check */ - function addDependency($elementName, $dependentOn, $condition='checked'){ + function addDependency($elementName, $dependentOn, $condition='notchecked'){ $el=$this->getElement($elementName); if (is_a($el, 'HTML_QuickForm_group')){ $group=$el; diff --git a/lib/javascript-static.js b/lib/javascript-static.js index 5914f78b8c..2f8ed11951 100644 --- a/lib/javascript-static.js +++ b/lib/javascript-static.js @@ -65,10 +65,12 @@ function lockoptionsall(formid) { for (var master in items){ var subitems=items[master].dependents; var thislock; - if (items[master].condition=='checked'){ + if (items[master].condition=='notchecked'){ thislock=!form.elements[master].checked; - }else{ - thislock=!(form.elements[master].value==items[master].condition); + } else if (items[master].condition=='checked'){ + thislock=form.elements[master].checked; + } else { + thislock=(form.elements[master].value==items[master].condition); } for (var i=0; idirroot.'/mod/forum/lib.php'); - - if (!isset($form->name)) { - $form->name = ''; - } - if (!isset($form->type)) { - $form->type = ''; - } - if (!isset($form->intro)) { - $form->intro = ''; - } - if (!isset($form->open)) { - $form->open = 2; - } - if (!isset($form->assessed)) { - $form->assessed = 0; - } - if (!isset($form->forcesubscribe)) { - $form->forcesubscribe = 0; - } - if (!isset($form->maxbytes)) { - $form->maxbytes = $CFG->forum_maxbytes; - } - if (!isset($form->rsstype)) { - $form->rsstype = 0; - } - if (!isset($form->rssarticles)) { - $form->rssarticles = 0; - } - if (!isset($form->scale)) { - $form->scale = 0; - } - if (!isset($form->assesstimestart)) { - $form->assesstimestart = 0; - } - if (!isset($form->assesstimefinish)) { - $form->assesstimefinish = 0; - } - if (!isset($form->trackingtype)) { - $form->trackingtype = FORUM_TRACKING_OPTIONAL; - } - if (!isset($form->warnafter)) { - $form->warnafter = 0; - } - if (!isset($form->blockafter)) { - $form->blockafter = 0; - } - if (!isset($form->blockperiod)) { - $form->blockperiod = 0; - } - -?> -
- - - - - - - - - - - - - - - - - -forum_trackreadposts) { ?> - - - - - - - - - -enablerssfeeds - && isset($CFG->forum_enablerssfeeds) - && $CFG->forum_enablerssfeeds) { - echo ''; - echo ''; - echo ''; - echo ''; - - echo ''; - echo ''; - echo ''; - echo ''; - } -?> - - - - - - - - - - - - - - - - - -
: - -
: - student; - require_once("$CFG->dirroot/mod/forum/lib.php"); - asort($FORUM_TYPES); - if (! $form->type) { - $form->type = 'general'; - } - if ($form->type == 'news') { - print_string('namenews', 'forum'); - echo ''; - } else if ($form->type == 'social') { - print_string('namesocial', 'forum'); - echo ''; - } else { - choose_from_menu($FORUM_TYPES, 'type', $form->type, ''); - helpbutton('forumtype', get_string('forumtype', 'forum'), 'forum'); - } - ?> - -
:

- '; - helpbutton('questions', get_string('helpquestions'), 'moodle', true, true); - echo '
'; - if ($usehtmleditor) { - helpbutton('richtext', get_string('helprichtext'), 'moodle', true, true); - } else { - emoticonhelpbutton('form', 'intro'); - } - echo '
'; - ?> -
- intro); ?> -
: - forcesubscribe, ''); - helpbutton('subscription2', get_string('forcesubscribeq', 'forum'), 'forum'); - ?> -
: - trackingtype, ''); - helpbutton('trackingtype', get_string('trackingtype', 'forum'), 'forum'); - ?> -
: - maxbytes, $course->maxbytes); - $choices[1] = get_string("uploadnotallowed"); - $choices[0] = get_string("courseuploadlimit") . " (".display_size($course->maxbytes).")"; - choose_from_menu ($choices, "maxbytes", $form->maxbytes, ""); - helpbutton("maxattachmentsize", get_string("maxattachmentsize", "forum"), "forum"); - ?> -
'.get_string('rsstype').':'; - unset($choices); - $choices[0] = get_string('none'); - $choices[1] = get_string('discussions', 'forum'); - $choices[2] = get_string('posts', 'forum'); - choose_from_menu ($choices, 'rsstype', $form->rsstype, ''); - helpbutton('rsstype', get_string('rsstype'), 'forum'); - echo '
'.get_string('rssarticles').':'; - unset($choices); - $choices[0] = '0'; - $choices[1] = '1'; - $choices[2] = '2'; - $choices[3] = '3'; - $choices[4] = '4'; - $choices[5] = '5'; - $choices[10] = '10'; - $choices[15] = '15'; - $choices[20] = '20'; - $choices[25] = '25'; - $choices[30] = '30'; - $choices[40] = '40'; - $choices[50] = '50'; - choose_from_menu ($choices, 'rssarticles', $form->rssarticles, ''); - helpbutton('rssarticles', get_string('rssarticles'), 'forum'); - echo '
: - - - '; - - echo ''; - - echo ''; - echo '
- '; - echo " var subitemstime = ['startday','startmonth','startyear','starthour', 'startminute',". - "'finishday','finishmonth','finishyear','finishhour','finishminute'];"; - - echo " var subitemsall = ['ratingtime', 'scale', ". - "'startday','startmonth','startyear','starthour', 'startminute',". - "'finishday','finishmonth','finishyear','finishhour','finishminute'];"; - echo ''; - - echo 'assessed) { - echo ' checked="checked" '; - } - echo ' />'; - echo ' '.get_string('ratingsuse', 'forum').':'; - echo '
'; - echo get_string('grade').': '; - echo ''; - print_grade_menu($course->id, 'scale', $form->scale, false); - echo '
'; - echo 'assesstimestart and $form->assesstimefinish and $form->assessed) { - $form->ratingtime = 1; - echo ' checked="checked" '; - } - echo ' /> '; - print_string('ratingtime', 'forum'); - - echo '
 '; - - echo '
'; - echo get_string('from').': '; - print_date_selector('startday', 'startmonth', 'startyear', $form->assesstimestart); - print_time_selector('starthour', 'startminute', $form->assesstimestart); - echo '
'; - echo get_string('to').': '; - print_date_selector('finishday', 'finishmonth', 'finishyear', $form->assesstimefinish); - print_time_selector('finishhour', 'finishminute', $form->assesstimefinish); - echo '
'; - echo '
'; - - echo '
'; - - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - - echo ''; - - if (empty($form->ratingtime)) { - echo ''; - } - ?> -
: -
: -
:blockperiod,''); - helpbutton('manageposts', get_string('blockperiod', 'forum'),'forum'); ?> -
-
- - - - - - - - - -" /> -" /> -
-
diff --git a/mod/forum/mod_form.php b/mod/forum/mod_form.php index 35eaebb397..38de1b4af4 100644 --- a/mod/forum/mod_form.php +++ b/mod/forum/mod_form.php @@ -95,20 +95,6 @@ class forum_mod_form extends moodleform_mod { //------------------------------------------------------------------------------- $mform->addElement('header', '', get_string('blockafter', 'forum')); - $mform->addElement('text', 'warnafter', get_string('warnafter', 'forum')); - $mform->setType('warnafter', PARAM_INT); - $mform->setDefault('warnafter', '0'); - $mform->addRule('warnafter', null, 'required', null, 'client'); - $mform->addRule('warnafter', null, 'numeric', null, 'client'); - $mform->setHelpButton('warnafter', array('manageposts', get_string('warnafter', 'forum'),'forum')); - - $mform->addElement('text', 'blockafter', get_string('blockafter', 'forum')); - $mform->setType('blockafter', PARAM_INT); - $mform->setDefault('blockafter', '0'); - $mform->addRule('blockafter', null, 'required', null, 'client'); - $mform->addRule('blockafter', null, 'numeric', null, 'client'); - $mform->setHelpButton('blockafter', array('manageposts', get_string('blockafter', 'forum'),'forum')); - $options = array(); $options[0] = get_string('blockperioddisabled','forum'); $options[60*60*24] = '1 '.get_string('day'); @@ -121,6 +107,21 @@ class forum_mod_form extends moodleform_mod { $mform->addElement('select', 'blockperiod', get_string("blockperiod", "forum") , $options); $mform->setHelpButton('blockperiod', array('manageposts', get_string('blockperiod', 'forum'),'forum')); + $mform->addElement('text', 'blockafter', get_string('blockafter', 'forum')); + $mform->setType('blockafter', PARAM_INT); + $mform->setDefault('blockafter', '0'); + $mform->addRule('blockafter', null, 'numeric', null, 'client'); + $mform->setHelpButton('blockafter', array('manageposts', get_string('blockafter', 'forum'),'forum')); + $mform->addDependency('blockafter', 'blockperiod', 0); + + + $mform->addElement('text', 'warnafter', get_string('warnafter', 'forum')); + $mform->setType('warnafter', PARAM_INT); + $mform->setDefault('warnafter', '0'); + $mform->addRule('warnafter', null, 'numeric', null, 'client'); + $mform->setHelpButton('warnafter', array('manageposts', get_string('warnafter', 'forum'),'forum')); + $mform->addDependency('warnafter', 'blockperiod', 0); + //------------------------------------------------------------------------------- $this->standard_coursemodule_elements(); @@ -147,6 +148,14 @@ class forum_mod_form extends moodleform_mod { $type->freeze(); $type->setPersistantFreeze(true); } + $assesstimestartvalue=is_array($mform->getElementValue('assesstimestart')); + $assesstimefinishvalue=is_array($mform->getElementValue('assesstimefinish')); + $ratingtime=&$mform->getElement('ratingtime'); + if ($assesstimestartvalue && $assesstimefinishvalue){ + $ratingtime->setValue(true); + } else { + $ratingtime->setValue(false); + } }