Permalink
Browse files

Merge branch 'wip-mdl-30121-m22' of git://github.com/rajeshtaneja/moo…

…dle into MOODLE_22_STABLE
  • Loading branch information...
2 parents 12f57ec + e0b1515 commit 06606caf718d532db04f89051b82228bc01084f4 @stronk7 stronk7 committed Aug 29, 2012
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
@@ -1148,7 +1148,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();
@@ -1162,6 +1162,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.
@@ -1178,6 +1183,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.
}

0 comments on commit 06606ca

Please sign in to comment.