$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')){
$forum->assessed = 0;
}
- if (!empty($forum->ratingtime)) {
+ if (empty($forum->ratingtime)) {
$forum->assesstimestart = 0;
$forum->assesstimefinish = 0;
}
}
$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>';
$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'));