MDL-31355 mod_forum: Add duedate and cutoffdate to form

AMOS BEGIN
CPY [availability,mod_assign],[availability,mod_forum]
CPY [cutoffdate,mod_assign],[cutoffdate,mod_forum]
CPY [cutoffdatevalidation,mod_assign],[cutoffdatevalidation,mod_forum]
CPY [duedate,mod_assign],[duedate,mod_forum]
AMOS END
This commit is contained in:
Shamim Rezaie 2019-04-04 00:21:09 +11:00
parent f6b07fedde
commit ceea2d2618
2 changed files with 29 additions and 0 deletions

View File

@ -43,6 +43,7 @@ $string['attachment_help'] = 'You can optionally attach one or more files to a f
$string['attachmentnopost'] = 'You cannot export attachments without a post id';
$string['attachments'] = 'Attachments';
$string['attachmentswordcount'] = 'Attachments and word count';
$string['availability'] = 'Availability';
$string['blockafter'] = 'Post threshold for blocking';
$string['blockafter_help'] = 'This setting specifies the maximum number of posts which a user can post in the given time period. Users with the capability mod/forum:postwithoutthrottling are exempt from post limits.';
$string['blockperiod'] = 'Time period for blocking';
@ -122,6 +123,9 @@ $string['couldnotadd'] = 'Could not add your post due to an unknown error';
$string['couldnotdeletereplies'] = 'Sorry, that cannot be deleted as people have already responded to it';
$string['couldnotupdate'] = 'Could not update your post due to an unknown error';
$string['crontask'] = 'Forum mailings and maintenance jobs';
$string['cutoffdate'] = 'Cut-off date';
$string['cutoffdate_help'] = 'If set, the forum will not accept posts after this date.';
$string['cutoffdatevalidation'] = 'The cut-off date cannot be earlier than the due date.';
$string['delete'] = 'Delete';
$string['deleteddiscussion'] = 'The discussion topic has been deleted';
$string['deletedpost'] = 'The post has been deleted';
@ -170,6 +174,9 @@ $string['displaystart'] = 'Display start';
$string['displaystart_help'] = 'This setting specifies whether a forum post should be displayed from a certain date. Note that administrators can always view forum posts.';
$string['displaywordcount'] = 'Display word count';
$string['displaywordcount_help'] = 'This setting specifies whether the word count of each post should be displayed or not.';
$string['duedate'] = 'Due date';
$string['duedate_help'] = 'This is when the forum is due. Although this date is displayed on the calendar as the due date for the forum, posting to the forum will still be allowed after this date. To prevent posting to the forum after a certain date - set the forum cut off date.';
$string['duedatetodisplayincalendar'] = 'Due date to display in calendar';
$string['eachuserforum'] = 'Each person posts one discussion';
$string['edit'] = 'Edit';
$string['editedby'] = 'Edited by {$a->name} - original submission {$a->date}';

View File

@ -54,6 +54,16 @@ class mod_forum_mod_form extends moodleform_mod {
$mform->addHelpButton('type', 'forumtype', 'forum');
$mform->setDefault('type', 'general');
$mform->addElement('header', 'availability', get_string('availability', 'forum'));
$name = get_string('duedate', 'forum');
$mform->addElement('date_time_selector', 'duedate', $name, array('optional' => true));
$mform->addHelpButton('duedate', 'duedate', 'forum');
$name = get_string('cutoffdate', 'forum');
$mform->addElement('date_time_selector', 'cutoffdate', $name, array('optional' => true));
$mform->addHelpButton('cutoffdate', 'cutoffdate', 'forum');
// Attachments and word count.
$mform->addElement('header', 'attachmentswordcounthdr', get_string('attachmentswordcount', 'forum'));
@ -229,6 +239,18 @@ class mod_forum_mod_form extends moodleform_mod {
}
public function validation($data, $files) {
$errors = parent::validation($data, $files);
if ($data['duedate'] && $data['cutoffdate']) {
if ($data['duedate'] > $data['cutoffdate']) {
$errors['cutoffdate'] = get_string('cutoffdatevalidation', 'forum');
}
}
return $errors;
}
function data_preprocessing(&$default_values) {
parent::data_preprocessing($default_values);