]> git.mjollnir.org Git - moodle.git/commitdiff
added commenting to addDependency method and used new functionality in forum\mod_form.php
authorjamiesensei <jamiesensei>
Tue, 21 Nov 2006 09:33:48 +0000 (09:33 +0000)
committerjamiesensei <jamiesensei>
Tue, 21 Nov 2006 09:33:48 +0000 (09:33 +0000)
lib/formslib.php
mod/forum/lib.php
mod/forum/mod_form.php

index d5976e1ae0991de9c654706df9a22261159623b4..b979f59e9a7f2d6d0ed2ddfc1e8d74af6d411410 100644 (file)
@@ -818,6 +818,17 @@ function validate_' . $this->_attributes['id'] . '(frm) {
         $js .='</script>'."\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')){
index 3cc15f0976d5a06fbbca8142b448c8ed439af01a..d86ba7c9aa11dce519374cbbc51a8f42c2414cde 100644 (file)
@@ -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[] =  '<a href="'.$CFG->wwwroot.'/mod/forum/post.php?edit='.$post->id.'">'.$stredit.'</a>';
index 9210724562120e45f70c399f5f739680583cd85e..35eaebb397922c9ded34f43b3628335f1f9f0a1e 100644 (file)
@@ -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'));