Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-30957 Adding a new method "is_complete" to assignment lib for

testing if a submission has actually been submitted and then adding a
call to it before displaying the the assignment submission date header

As recommended I've simplified the functions and split the logic out into appropriate upload classes.
  • Loading branch information...
commit d773f373ef33840655c2c22135124b6f861a44fc 1 parent e0d5a17
Gerard (Gerry) Caulfield authored
View
15 mod/assignment/lib.php
@@ -393,7 +393,8 @@ function submittedlink($allgroups=false) {
} else {
if (isloggedin()) {
if ($submission = $this->get_submission($USER->id)) {
- if ($submission->timemodified) {
+ // If the submission has been completed
+ if ($this->is_submitted_with_required_data($submission)) {
if ($submission->timemodified <= $this->assignment->timedue || empty($this->assignment->timedue)) {
$submitted = '<span class="early">'.userdate($submission->timemodified).'</span>';
} else {
@@ -1695,6 +1696,18 @@ function get_submission($userid=0, $createnew=false, $teachermodified=false) {
}
/**
+ * Check the given submission is complete. Preliminary rows are often created in the assignment_submissions
+ * table before a submission actually takes place. This function checks to see if the given submission has actually
+ * been submitted.
+ *
+ * @param stdClass $submission The submission we want to check for completion
+ * @return bool Indicates if the submission was found to be complete
+ */
+ public function is_submitted_with_required_data($submission) {
+ return $submission->timemodified;
+ }
+
+ /**
* Instantiates a new submission object for a given user
*
* Sets the assignment, userid and times, everything else is set to default values.
View
12 mod/assignment/type/upload/assignment.class.php
@@ -1135,6 +1135,18 @@ public function download_submissions() {
send_temp_file($zipfile, $filename); //send file and delete after sending.
}
}
+
+ /**
+ * Check the given submission is complete. Preliminary rows are often created in the assignment_submissions
+ * table before a submission actually takes place. This function checks to see if the given submission has actually
+ * been submitted.
+ *
+ * @param stdClass $submission The submission we want to check for completion
+ * @return bool Indicates if the submission was found to be complete
+ */
+ public function is_submitted_with_required_data($submission) {
+ return ($submission->timemodified AND $submission->data2);
+ }
}
class mod_assignment_upload_notes_form extends moodleform {
View
12 mod/assignment/type/uploadsingle/assignment.class.php
@@ -393,6 +393,18 @@ function download_submissions() {
send_temp_file($zipfile, $filename); //send file and delete after sending.
}
}
+
+ /**
+ * Check the given submission is complete. Preliminary rows are often created in the assignment_submissions
+ * table before a submission actually takes place. This function checks to see if the given submission has actually
+ * been submitted.
+ *
+ * @param stdClass $submission The submission we want to check for completion
+ * @return bool Indicates if the submission was found to be complete
+ */
+ public function is_submitted_with_required_data($submission) {
+ return ($submission->timemodified AND $submission->numfiles > 0);
+ }
}
class mod_assignment_uploadsingle_response_form extends moodleform {
Please sign in to comment.
Something went wrong with that request. Please try again.