mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-30121 Assignment 2.2: Draft submission files will not be included in zip, if activity is open
This commit is contained in:
parent
d71c486507
commit
c517046e4d
1 changed files with 12 additions and 1 deletions
|
@ -1150,7 +1150,7 @@ class assignment_upload extends assignment_base {
|
||||||
require_once($CFG->libdir.'/filelib.php');
|
require_once($CFG->libdir.'/filelib.php');
|
||||||
$submissions = $this->get_submissions('','');
|
$submissions = $this->get_submissions('','');
|
||||||
if (empty($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();
|
$filesforzipping = array();
|
||||||
$fs = get_file_storage();
|
$fs = get_file_storage();
|
||||||
|
@ -1164,6 +1164,11 @@ class assignment_upload extends assignment_base {
|
||||||
}
|
}
|
||||||
$filename = str_replace(' ', '_', clean_filename($this->course->shortname.'-'.$this->assignment->name.'-'.$groupname.$this->assignment->id.".zip")); //name of new zip file.
|
$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) {
|
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
|
$a_userid = $submission->userid; //get userid
|
||||||
if ((groups_is_member($groupid,$a_userid)or !$groupmode or !$groupid)) {
|
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.
|
$a_assignid = $submission->assignment; //get name of this assignment for use in the file names.
|
||||||
|
@ -1180,6 +1185,12 @@ class assignment_upload extends assignment_base {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // end of foreach loop
|
} // 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)) {
|
if ($zipfile = assignment_pack_files($filesforzipping)) {
|
||||||
send_temp_file($zipfile, $filename); //send file and delete after sending.
|
send_temp_file($zipfile, $filename); //send file and delete after sending.
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue