ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilIndividualAssessmentFileStorage.php
Go to the documentation of this file.
1<?php
2
4
5require_once("Modules/IndividualAssessment/interfaces/FileStorage/interface.IndividualAssessmentFileStorage.php");
6include_once('Services/FileSystem/classes/class.ilFileSystemStorage.php');
14{
15 public static function getInstance($a_container_id = 0)
16 {
17 return new self(self::STORAGE_WEB, true, $a_container_id);
18 }
19
25 protected function getPathPostfix()
26 {
27 return 'iass';
28 }
29
35 protected function getPathPrefix()
36 {
37 return 'IASS';
38 }
39
45 public function isEmpty()
46 {
47 $files = $this->readDir();
48
49 return (count($files) == 0) ? true : false;
50 }
51
57 public function setUserId($user_id)
58 {
59 $this->user_id = $user_id;
60 }
61
67 public function create()
68 {
69 if (!file_exists($this->getAbsolutePath())) {
71 }
72 return true;
73 }
74
80 public function getAbsolutePath()
81 {
82 $path = parent::getAbsolutePath();
83
84 if ($this->user_id) {
85 $path .= "/user_" . $this->user_id;
86 }
87
88 return $path;
89 }
90
96 public function readDir()
97 {
98 if (!is_dir($this->getAbsolutePath())) {
99 $this->create();
100 }
101
102 $fh = opendir($this->getAbsolutePath());
103 $files = array();
104 while ($file = readdir($fh)) {
105 if ($file != "." && $file != ".." && !is_dir($this->getAbsolutePath() . "/" . $file)) {
106 $files[] = $file;
107 }
108 }
109 closedir($fh);
110
111 return $files;
112 }
113
123 {
124 $path = $this->getAbsolutePath();
125
126 $clean_name = preg_replace("/[^a-zA-Z0-9\_\.\-]/", "", $result->getName());
127 $new_file = $path . "/" . $clean_name;
128
130 $result->getPath(),
131 $clean_name, // This parameter does not do a thing
132 $new_file
133 );
134
135 return true;
136 }
137
141 public function deleteCurrentFile()
142 {
143 $this->deleteFile($this->getFilePath());
144 }
145
151 public function getFilePath()
152 {
153 return $this->getAbsolutePath() . "/" . $this->getFileName();
154 }
155
161 public function getFileName()
162 {
163 $files = $this->readDir();
164 return $files[0];
165 }
166
172 public function deleteFileByName($file_name)
173 {
174 $this->deleteFile($this->getAbsolutePath() . "/" . $file_name);
175 }
176}
$result
An exception for terminatinating execution or to throw for unit testing.
return true
Flag indicating whether or not HTTP headers will be sent when outputting captcha image/audio.
deleteFile($a_abs_name)
Delete file.
Handles the fileupload and folder creation for files uploaded in grading form.
getPathPostfix()
part of the folder structure in ILIAS webdir.
isEmpty()
Is the webdir folder for this IA empty.
getPathPrefix()
part of the folder structure in ILIAS webdir.
setUserId($user_id)
Set the user id for an extra folder of each participant in the IA.
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
static makeDirParents($a_dir)
Create a new directory and all parent directories.