~ubuntu-branches/ubuntu/utopic/moodle/utopic

« back to all changes in this revision

Viewing changes to mod/assign/feedback/file/importziplib.php

  • Committer: Package Import Robot
  • Author(s): Thijs Kinkhorst
  • Date: 2014-05-12 16:10:38 UTC
  • mfrom: (36.1.3 sid)
  • Revision ID: package-import@ubuntu.com-20140512161038-puyqf65k4e0s8ytz
Tags: 2.6.3-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
194
194
                                          $USER->id,
195
195
                                          '/import/');
196
196
 
 
197
        $keys = array_keys($files);
 
198
        if (count($files) == 1 && $files[$keys[0]]->is_directory()) {
 
199
            // An entire folder was zipped, rather than its contents.
 
200
            // We need to return the contents of the folder instead, so the import can continue.
 
201
            $files = $fs->get_directory_files($contextid,
 
202
                                              'assignfeedback_file',
 
203
                                              ASSIGNFEEDBACK_FILE_IMPORT_FILEAREA,
 
204
                                              $USER->id,
 
205
                                              $files[$keys[0]]->get_filepath());
 
206
        }
 
207
 
197
208
        return $files;
198
209
    }
199
210
 
205
216
     * @return string - The html response
206
217
     */
207
218
    public function import_zip_files($assignment, $fileplugin) {
208
 
        global $USER, $CFG, $PAGE, $DB;
 
219
        global $CFG, $PAGE, $DB;
209
220
 
210
221
        @set_time_limit(ASSIGNFEEDBACK_FILE_MAXFILEUNZIPTIME);
211
222
        $packer = get_file_packer('application/zip');
216
227
        $contextid = $assignment->get_context()->id;
217
228
 
218
229
        $fs = get_file_storage();
219
 
        $files = $fs->get_directory_files($contextid,
220
 
                                          'assignfeedback_file',
221
 
                                          ASSIGNFEEDBACK_FILE_IMPORT_FILEAREA,
222
 
                                          $USER->id,
223
 
                                          '/import/');
 
230
        $files = $this->get_import_files($contextid);
224
231
 
225
232
        $currentgroup = groups_get_activity_group($assignment->get_course_module(), true);
226
233
        $allusers = $assignment->list_participants($currentgroup, false);
246
253
                                                 '/',
247
254
                                                 $filename)) {
248
255
                        // Update existing feedback file.
249
 
                        $oldfile->replace_content_with($unzippedfile);
 
256
                        $oldfile->replace_file_with($unzippedfile);
250
257
                        $feedbackfilesupdated++;
251
258
                    } else {
252
259
                        // Create a new feedback file.