added commenting to addDependency method and used new functionality in forum\mod_form.php
This commit is contained in:
@@ -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')){
|
||||
|
||||
+3
-3
@@ -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>';
|
||||
|
||||
@@ -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'));
|
||||
|
||||
Reference in New Issue
Block a user