mirror of
https://github.com/moodle/moodle.git
synced 2025-05-31 13:09:25 +02:00
MDL-37490 mod_assign: Add setting to show the due date on the course page.
This commit is contained in:
parent
b3be471f52
commit
ef8a6dfb33
@ -52,6 +52,7 @@ class backup_assign_activity_structure_step extends backup_activity_structure_st
|
||||
'sendnotifications',
|
||||
'sendlatenotifications',
|
||||
'duedate',
|
||||
'displayduedate',
|
||||
'cutoffdate',
|
||||
'allowsubmissionsfromdate',
|
||||
'grade',
|
||||
|
@ -17,6 +17,7 @@
|
||||
<FIELD NAME="sendnotifications" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Allows the disabling of email notifications in the assign module."/>
|
||||
<FIELD NAME="sendlatenotifications" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Allows separate enabling of notifications for late assignment submissions."/>
|
||||
<FIELD NAME="duedate" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="The due date for the assignment. Displayed to students."/>
|
||||
<FIELD NAME="displayduedate" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="If true the due date will be displayed."/>
|
||||
<FIELD NAME="allowsubmissionsfromdate" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="If set, submissions will only be accepted after this date."/>
|
||||
<FIELD NAME="grade" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="The maximum grade for this assignment. Can be negative to indicate the use of a scale."/>
|
||||
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="The time the settings for this assign module instance were last modified."/>
|
||||
|
@ -207,6 +207,17 @@ function xmldb_assign_upgrade($oldversion) {
|
||||
|
||||
// Moodle v2.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
if ($oldversion < 2012112902) {
|
||||
// Define field displayduedate to be added to assign.
|
||||
$table = new xmldb_table('assign');
|
||||
$field = new xmldb_field('displayduedate', XMLDB_TYPE_INTEGER, '2', null, null, null, '0', 'duedate');
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Assign savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2012112902, 'assign');
|
||||
}
|
||||
|
||||
if ($oldversion < 2013030600) {
|
||||
upgrade_set_timeout(60*20);
|
||||
|
@ -115,6 +115,8 @@ $string['deletepluginareyousure'] = 'Delete assignment plugin {$a}: are you sure
|
||||
$string['deletepluginareyousuremessage'] = 'You are about to completely delete the assignment plugin {$a}. This will completely delete everything in the database associated with this assignment plugin. Are you SURE you want to continue?';
|
||||
$string['deletingplugin'] = 'Deleting plugin {$a}.';
|
||||
$string['description'] = 'Description';
|
||||
$string['displayduedate'] = 'Display due date';
|
||||
$string['displayduedate_help'] = "If enabled the due date will be displayed on the course page if one has been set and enabled.";
|
||||
$string['downloadall'] = 'Download all submissions';
|
||||
$string['download all submissions'] = 'Download all submissions in a zip file.';
|
||||
$string['duedate'] = 'Due date';
|
||||
|
@ -257,7 +257,7 @@ function assign_get_coursemodule_info($coursemodule) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbparams = array('id'=>$coursemodule->instance);
|
||||
$fields = 'id, name, alwaysshowdescription, allowsubmissionsfromdate, intro, introformat';
|
||||
$fields = 'id, name, alwaysshowdescription, allowsubmissionsfromdate, intro, introformat, duedate, displayduedate';
|
||||
if (! $assignment = $DB->get_record('assign', $dbparams, $fields)) {
|
||||
return false;
|
||||
}
|
||||
@ -270,6 +270,14 @@ function assign_get_coursemodule_info($coursemodule) {
|
||||
$result->content = format_module_intro('assign', $assignment, $coursemodule->id, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (($assignment->duedate > 0) && ($assignment->displayduedate)) {
|
||||
if (empty($result->content)){
|
||||
$result->content = '';
|
||||
}
|
||||
$result->content .= html_writer::tag('p', get_string('duedate', 'assign') . ': ' . userdate($assignment->duedate));
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
@ -524,7 +524,16 @@ class assign {
|
||||
$update->requiresubmissionstatement = $formdata->requiresubmissionstatement;
|
||||
$update->sendnotifications = $formdata->sendnotifications;
|
||||
$update->sendlatenotifications = $formdata->sendlatenotifications;
|
||||
$update->duedate = $formdata->duedate;
|
||||
if (empty($formdata->duedateenable)) {
|
||||
$update->duedate = 0;
|
||||
} else {
|
||||
$update->duedate = $formdata->duedate;
|
||||
}
|
||||
if (empty($formdata->displayduedate)) {
|
||||
$update->displayduedate = 0;
|
||||
} else {
|
||||
$update->displayduedate = $formdata->displayduedate;
|
||||
}
|
||||
$update->cutoffdate = $formdata->cutoffdate;
|
||||
$update->allowsubmissionsfromdate = $formdata->allowsubmissionsfromdate;
|
||||
$update->grade = $formdata->grade;
|
||||
@ -845,7 +854,16 @@ class assign {
|
||||
$update->requiresubmissionstatement = $formdata->requiresubmissionstatement;
|
||||
$update->sendnotifications = $formdata->sendnotifications;
|
||||
$update->sendlatenotifications = $formdata->sendlatenotifications;
|
||||
$update->duedate = $formdata->duedate;
|
||||
if (empty($formdata->duedateenable)) {
|
||||
$update->duedate = 0;
|
||||
} else {
|
||||
$update->duedate = $formdata->duedate;
|
||||
}
|
||||
if (empty($formdata->displayduedate)) {
|
||||
$update->displayduedate = 0;
|
||||
} else {
|
||||
$update->displayduedate = $formdata->displayduedate;
|
||||
}
|
||||
$update->cutoffdate = $formdata->cutoffdate;
|
||||
$update->allowsubmissionsfromdate = $formdata->allowsubmissionsfromdate;
|
||||
$update->grade = $formdata->grade;
|
||||
|
@ -42,7 +42,7 @@ class mod_assign_mod_form extends moodleform_mod {
|
||||
* @return void
|
||||
*/
|
||||
public function definition() {
|
||||
global $CFG, $DB, $PAGE;
|
||||
global $CFG, $DB, $PAGE, $OUTPUT;
|
||||
$mform = $this->_form;
|
||||
|
||||
$mform->addElement('header', 'general', get_string('general', 'form'));
|
||||
@ -83,10 +83,28 @@ class mod_assign_mod_form extends moodleform_mod {
|
||||
$mform->addHelpButton('allowsubmissionsfromdate', 'allowsubmissionsfromdate', 'assign');
|
||||
$mform->setDefault('allowsubmissionsfromdate', time());
|
||||
|
||||
$name = get_string('duedate', 'assign');
|
||||
$mform->addElement('date_time_selector', 'duedate', $name, array('optional'=>true));
|
||||
$mform->addHelpButton('duedate', 'duedate', 'assign');
|
||||
$mform->setDefault('duedate', time()+7*24*3600);
|
||||
$name = get_string('duedate', 'assign').$OUTPUT->help_icon('duedate', 'assign');
|
||||
$duedateelements[] = $mform->createElement('date_time_selector', 'duedate', $name);
|
||||
$duedateelements[] = $mform->createElement('checkbox', 'duedateenable', null, get_string('enable'));
|
||||
try {
|
||||
$duedate = $assignment->get_instance()->duedate;
|
||||
} catch (Exception $e) {
|
||||
$duedate = 0;
|
||||
}
|
||||
if ($duedate > 0) {
|
||||
$mform->setDefault('duedate', $duedate);
|
||||
$mform->setDefault('duedateenable', 1);
|
||||
} else {
|
||||
$mform->setDefault('duedate', time()+7*24*3600);
|
||||
$mform->setDefault('duedateenable', 0);
|
||||
}
|
||||
|
||||
$dddname = get_string('displayduedate', 'assign').$OUTPUT->help_icon('displayduedate', 'assign');
|
||||
$duedateelements[] = $mform->createElement('checkbox', 'displayduedate', null, $dddname);
|
||||
$mform->setDefault('displayduedate', 0);
|
||||
|
||||
$mform->addGroup($duedateelements, 'duedategrp', $name, null, false);
|
||||
$mform->disabledIf('duedategrp', 'duedateenable');
|
||||
|
||||
$name = get_string('cutoffdate', 'assign');
|
||||
$mform->addElement('date_time_selector', 'cutoffdate', $name, array('optional'=>true));
|
||||
|
@ -56,6 +56,7 @@ class mod_assign_generator extends testing_module_generator {
|
||||
'sendnotifications' => 0,
|
||||
'sendlatenotifications' => 0,
|
||||
'duedate' => 0,
|
||||
'displayduedate' => 0,
|
||||
'allowsubmissionsfromdate' => 0,
|
||||
'grade' => 100,
|
||||
'cutoffdate' => 0,
|
||||
|
@ -86,6 +86,7 @@ class assign_upgrade_manager {
|
||||
$data->sendnotifications = $oldassignment->emailteachers;
|
||||
$data->sendlatenotifications = $oldassignment->emailteachers;
|
||||
$data->duedate = $oldassignment->timedue;
|
||||
$data->displayduedate = 0;
|
||||
$data->allowsubmissionsfromdate = $oldassignment->timeavailable;
|
||||
$data->grade = $oldassignment->grade;
|
||||
$data->submissiondrafts = $oldassignment->resubmit;
|
||||
|
Loading…
x
Reference in New Issue
Block a user