Skip to content
Permalink
Browse files

Better handling of dates when timedue isn't set

  • Loading branch information...
moodler
moodler committed May 31, 2005
1 parent 98823d2 commit 0d4a2139436fee3b77be6795a464aeb3eb73f08c
Showing with 27 additions and 23 deletions.
  1. +27 −23 mod/assignment/lib.php
@@ -245,7 +245,7 @@ function submittedlink() {
if (isset($USER->id)) {
if ($submission = $this->get_submission($USER->id)) {
if ($submission->timemodified) {
if ($submission->timemodified <= $this->assignment->timedue) {
if ($submission->timemodified <= $this->assignment->timedue || empty($this->assignment->timedue)) {
$submitted = '<span class="early">'.userdate($submission->timemodified).'</span>';
} else {
$submitted = '<span class="late">'.userdate($submission->timemodified).'</span>';
@@ -344,19 +344,21 @@ function add_instance($assignment) {
if ($returnid = insert_record("assignment", $assignment)) {
$event = NULL;
$event->name = $assignment->name;
$event->description = $assignment->description;
$event->courseid = $assignment->course;
$event->groupid = 0;
$event->userid = 0;
$event->modulename = 'assignment';
$event->instance = $returnid;
$event->eventtype = 'due';
$event->timestart = $assignment->timedue;
$event->timeduration = 0;
if ($assignment->timedue) {
$event = NULL;
$event->name = $assignment->name;
$event->description = $assignment->description;
$event->courseid = $assignment->course;
$event->groupid = 0;
$event->userid = 0;
$event->modulename = 'assignment';
$event->instance = $returnid;
$event->eventtype = 'due';
$event->timestart = $assignment->timedue;
$event->timeduration = 0;
add_event($event);
add_event($event);
}
}
return $returnid;
@@ -408,15 +410,17 @@ function update_instance($assignment) {
if ($returnid = update_record('assignment', $assignment)) {
$event = NULL;
if ($assignment->timedue) {
$event = NULL;
if ($event->id = get_field('event', 'id', 'modulename', 'assignment', 'instance', $assignment->id)) {
if ($event->id = get_field('event', 'id', 'modulename', 'assignment', 'instance', $assignment->id)) {
$event->name = $assignment->name;
$event->description = $assignment->description;
$event->timestart = $assignment->timedue;
$event->name = $assignment->name;
$event->description = $assignment->description;
$event->timestart = $assignment->timedue;
update_event($event);
update_event($event);
}
}
}
@@ -1047,7 +1051,7 @@ function file_area($userid) {
function isopen() {
$time = time();
if ($this->assignment->preventlate) {
if ($this->assignment->preventlate && $this->assignment->timedue) {
return ($this->assignment->timeavailable <= $time && $time <= $this->assignment->timedue);
} else {
return ($this->assignment->timeavailable <= $time);
@@ -1100,6 +1104,9 @@ function user_complete($user) {
}
function display_lateness($timesubmitted) {
if (!$this->assignment->timedue) {
return '';
}
$time = $this->assignment->timedue - $timesubmitted;
if ($time < 0) {
$timetext = get_string('late', 'assignment', format_time($time));
@@ -1111,9 +1118,6 @@ function display_lateness($timesubmitted) {
}
} ////// End of the assignment_base class

0 comments on commit 0d4a213

Please sign in to comment.
You can’t perform that action at this time.