Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-30121 Assignment 2.2: Draft submission files will not be included…

… in zip, if activity is open
  • Loading branch information...
commit c517046e4d04c5222decb774fd4db79e50c38185 1 parent d71c486
@rajeshtaneja rajeshtaneja authored
Showing with 12 additions and 1 deletion.
  1. +12 −1 mod/assignment/type/upload/assignment.class.php
View
13 mod/assignment/type/upload/assignment.class.php
@@ -1150,7 +1150,7 @@ public function download_submissions() {
require_once($CFG->libdir.'/filelib.php');
$submissions = $this->get_submissions('','');
if (empty($submissions)) {
- print_error('errornosubmissions', 'assignment');
+ print_error('errornosubmissions', 'assignment', new moodle_url('/mod/assignment/submissions.php', array('id'=>$this->cm->id)));
}
$filesforzipping = array();
$fs = get_file_storage();
@@ -1164,6 +1164,11 @@ public function download_submissions() {
}
$filename = str_replace(' ', '_', clean_filename($this->course->shortname.'-'.$this->assignment->name.'-'.$groupname.$this->assignment->id.".zip")); //name of new zip file.
foreach ($submissions as $submission) {
+ // If assignment is open and submission is not finalized then don't add it to zip.
+ $submissionstatus = $this->is_finalized($submission);
+ if ($this->isopen() && empty($submissionstatus)) {
+ continue;
+ }
$a_userid = $submission->userid; //get userid
if ((groups_is_member($groupid,$a_userid)or !$groupmode or !$groupid)) {
$a_assignid = $submission->assignment; //get name of this assignment for use in the file names.
@@ -1180,6 +1185,12 @@ public function download_submissions() {
}
}
} // end of foreach loop
+
+ // Throw error if no files are added.
+ if (empty($filesforzipping)) {
+ print_error('errornosubmissions', 'assignment', new moodle_url('/mod/assignment/submissions.php', array('id'=>$this->cm->id)));
+ }
+
if ($zipfile = assignment_pack_files($filesforzipping)) {
send_temp_file($zipfile, $filename); //send file and delete after sending.
}
Please sign in to comment.
Something went wrong with that request. Please try again.