From 72d890d2d2bf4d3f83486d273d00634ec0fbb6ee Mon Sep 17 00:00:00 2001 From: Henning Bostelmann Date: Tue, 17 Apr 2012 18:51:58 +0100 Subject: [PATCH] MDL-32490 Offline assignment: do not display lateness information --- mod/assignment/lib.php | 10 ++++++++-- mod/assignment/mod_form.php | 6 ++++-- mod/assignment/type/offline/assignment.class.php | 4 ++++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/mod/assignment/lib.php b/mod/assignment/lib.php index 08144b601c4..c6fa42250d3 100644 --- a/mod/assignment/lib.php +++ b/mod/assignment/lib.php @@ -408,6 +408,12 @@ class assignment_base { return $submitted; } + /** + * @return Whether this assignment type supports lateness information - true by default + */ + function supports_lateness() { + return true; + } /** * @todo Document this function @@ -1374,8 +1380,8 @@ class assignment_base { if ($auser->timemodified > 0) { $studentmodifiedcontent = $this->print_student_answer($auser->id) . userdate($auser->timemodified); - if ($assignment->timedue && $auser->timemodified > $assignment->timedue) { - $studentmodifiedcontent .= assignment_display_lateness($auser->timemodified, $assignment->timedue); + if ($assignment->timedue && $auser->timemodified > $assignment->timedue && $this->supports_lateness()) { + $studentmodifiedcontent .= $this->display_lateness($auser->timemodified); $rowclass = 'late'; } } else { diff --git a/mod/assignment/mod_form.php b/mod/assignment/mod_form.php index 1c5cf3195aa..f31ceb8dfa7 100644 --- a/mod/assignment/mod_form.php +++ b/mod/assignment/mod_form.php @@ -55,8 +55,10 @@ class mod_assignment_mod_form extends moodleform_mod { $ynoptions = array( 0 => get_string('no'), 1 => get_string('yes')); - $mform->addElement('select', 'preventlate', get_string('preventlate', 'assignment'), $ynoptions); - $mform->setDefault('preventlate', 0); + if ($assignmentinstance->supports_lateness()) { + $mform->addElement('select', 'preventlate', get_string('preventlate', 'assignment'), $ynoptions); + $mform->setDefault('preventlate', 0); + } // hack to support pluggable assignment type titles if (get_string_manager()->string_exists('type'.$type, 'assignment')) { diff --git a/mod/assignment/type/offline/assignment.class.php b/mod/assignment/type/offline/assignment.class.php index 04097dc8b7f..b975d5955a9 100644 --- a/mod/assignment/type/offline/assignment.class.php +++ b/mod/assignment/type/offline/assignment.class.php @@ -11,6 +11,10 @@ class assignment_offline extends assignment_base { $this->type = 'offline'; } + function supports_lateness() { + return false; + } + function display_lateness($timesubmitted) { return ''; }