ILIAS  release_7 Revision v7.30-3-g800a261c036
ilFSStorageExercise Class Reference
+ Inheritance diagram for ilFSStorageExercise:
+ Collaboration diagram for ilFSStorageExercise:

Public Member Functions

 __construct ($a_container_id=0, $a_ass_id=0)
 Constructor. More...
 
 init ()
 Append ass_<ass_id> to path (assignment id) More...
 
 getAbsoluteSubmissionPath ()
 Get submission path. More...
 
 getTempPath ()
 Get submission path. More...
 
 getFeedbackPath ($a_user_id)
 Get feedback path. More...
 
 getGlobalFeedbackPath ()
 
 getMultiFeedbackUploadPath ($a_user_id)
 Get multi feedback upload path (each uploader handled in a separate path) More...
 
 getPeerReviewUploadPath ($a_peer_id, $a_giver_id, $a_crit_id)
 Get pear review upload path (each peer handled in a separate path) More...
 
 create ()
 Create directory. More...
 
 getFiles ()
 Get assignment files. More...
 
 uploadFile ($a_http_post_file, $user_id, $is_unziped=false)
 store delivered file in filesystem More...
 
 getFeedbackFiles ($a_user_id)
 Get number of feedback files. More...
 
 countFeedbackFiles ($a_user_id)
 Count number of feedback files for a user. More...
 
 getAssignmentFilePath ($a_file)
 Get path for assignment file. More...
 
 getFeedbackFilePath ($a_user_id, $a_file)
 Get path for feedback file. More...
 
 uploadAssignmentFiles ($a_files)
 Upload assignment files (e.g. More...
 
- Public Member Functions inherited from ilFileSystemStorage
 __construct ($a_storage_type, $a_path_conversion, $a_container_id)
 Constructor. More...
 
 getContainerId ()
 
 create ()
 Create directory. More...
 
 getAbsolutePath ()
 Get absolute path of storage directory. More...
 
 writeToFile ($a_data, $a_absolute_path)
 Write data to file. More...
 
 deleteFile ($a_abs_name)
 Delete file. More...
 
 deleteDirectory ($a_abs_name)
 Delete directory. More...
 
 delete ()
 Delete complete directory. More...
 
 copyFile ($a_from, $a_to)
 Copy files. More...
 
 appendToPath ($a_appendix)
 
 getStorageType ()
 
 getPath ()
 Get path. More...
 
 __construct ($a_storage_type, $a_path_conversion, $a_container_id)
 Constructor. More...
 
 create ()
 Create directory. More...
 
 getAbsolutePath ()
 Get absolute path of storage directory. More...
 
 getShortPath ()
 
 rename ($from, $to)
 

Protected Member Functions

 getPathPostfix ()
 Implementation of abstract method. More...
 
 getPathPrefix ()
 Implementation of abstract method. More...
 
 getPathPrefix ()
 Get path prefix. More...
 
 getPathPostfix ()
 Get directory name. More...
 
 init ()
 Read path info. More...
 
 getPathPrefix ()
 Get path prefix. More...
 
 getPathPostfix ()
 Get directory name. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from ilFileSystemStorage
static _createPathFromId ($a_container_id, $a_name)
 Create a path from an id: e.g 12345 will be converted to 12/34/<name>_5. More...
 
static _copyDirectory ($a_source, $a_target)
 Copy directory and all contents. More...
 
static _createPathFromId ($a_container_id, $a_name)
 Create a path from an id: e.g 12345 will be converted to 12/34/<name>_5. More...
 
- Data Fields inherited from ilFileSystemStorage
const STORAGE_WEB = 1
 
const STORAGE_DATA = 2
 
const STORAGE_SECURED = 3
 
const FACTOR = 100
 
const MAX_EXPONENT = 3
 
const SECURED_DIRECTORY = "sec"
 
- Protected Attributes inherited from ilFileSystemStorage
 $path
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilFSStorageExercise::__construct (   $a_container_id = 0,
  $a_ass_id = 0 
)

Constructor.

Parameters
intexercise id

Definition at line 37 of file class.ilFSStorageExercise.php.

38 {
39 $this->ass_id = $a_ass_id;
40 parent::__construct(self::STORAGE_DATA, true, $a_container_id);
41 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

Member Function Documentation

◆ countFeedbackFiles()

ilFSStorageExercise::countFeedbackFiles (   $a_user_id)

Count number of feedback files for a user.

Definition at line 304 of file class.ilFSStorageExercise.php.

305 {
306 $fbf = $this->getFeedbackFiles($a_user_id);
307 return count($fbf);
308 }
getFeedbackFiles($a_user_id)
Get number of feedback files.

References getFeedbackFiles().

+ Here is the call graph for this function:

◆ create()

ilFSStorageExercise::create ( )

Create directory.

@access public

Reimplemented from ilFileSystemStorage.

Definition at line 159 of file class.ilFSStorageExercise.php.

160 {
161 parent::create();
162 if (!file_exists($this->submission_path)) {
163 ilUtil::makeDirParents($this->submission_path);
164 }
165 if (!file_exists($this->tmp_path)) {
166 ilUtil::makeDirParents($this->tmp_path);
167 }
168 if (!file_exists($this->feedb_path)) {
169 ilUtil::makeDirParents($this->feedb_path);
170 }
171 return true;
172 }
static makeDirParents($a_dir)
Create a new directory and all parent directories.

References ilUtil\makeDirParents().

Referenced by uploadFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAbsoluteSubmissionPath()

ilFSStorageExercise::getAbsoluteSubmissionPath ( )

Get submission path.

Definition at line 89 of file class.ilFSStorageExercise.php.

90 {
91 return $this->submission_path;
92 }

Referenced by uploadFile().

+ Here is the caller graph for this function:

◆ getAssignmentFilePath()

ilFSStorageExercise::getAssignmentFilePath (   $a_file)

Get path for assignment file.

Definition at line 313 of file class.ilFSStorageExercise.php.

314 {
315 return $this->getAbsolutePath() . "/" . $a_file;
316 }
getAbsolutePath()
Get absolute path of storage directory.

References ilFileSystemStorage\getAbsolutePath().

+ Here is the call graph for this function:

◆ getFeedbackFilePath()

ilFSStorageExercise::getFeedbackFilePath (   $a_user_id,
  $a_file 
)

Get path for feedback file.

Definition at line 321 of file class.ilFSStorageExercise.php.

322 {
323 $dir = $this->getFeedbackPath($a_user_id);
324 return $dir . "/" . $a_file;
325 }
getFeedbackPath($a_user_id)
Get feedback path.

References getFeedbackPath().

+ Here is the call graph for this function:

◆ getFeedbackFiles()

ilFSStorageExercise::getFeedbackFiles (   $a_user_id)

Get number of feedback files.

Definition at line 280 of file class.ilFSStorageExercise.php.

281 {
282 $files = array();
283
284 if ($a_user_id === "t") { // team assignment without team, see #36253
285 return[];
286 }
287
288 $dir = $this->getFeedbackPath($a_user_id);
289
290 if (@is_dir($dir)) {
291 $dp = opendir($dir);
292 while ($file = readdir($dp)) {
293 if (!is_dir($this->path . '/' . $file) && substr($file, 0, 1) != ".") {
294 $files[] = $file;
295 }
296 }
297 }
298 return $files;
299 }

References getFeedbackPath().

Referenced by countFeedbackFiles().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFeedbackPath()

ilFSStorageExercise::getFeedbackPath (   $a_user_id)

Get feedback path.

Definition at line 105 of file class.ilFSStorageExercise.php.

106 {
107 $path = $this->feedb_path . "/" . $a_user_id;
108 if (!file_exists($path)) {
110 }
111 return $path;
112 }

References ilFileSystemStorage\$path, and ilUtil\makeDirParents().

Referenced by getFeedbackFilePath(), and getFeedbackFiles().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFiles()

ilFSStorageExercise::getFiles ( )

Get assignment files.

Definition at line 177 of file class.ilFSStorageExercise.php.

178 {
179 $files = array();
180 if (!is_dir($this->path)) {
181 return $files;
182 }
183
184 $dp = opendir($this->path);
185 while ($file = readdir($dp)) {
186 if (!is_dir($this->path . '/' . $file)) {
187 $files[] = array(
188 'name' => $file,
189 'size' => filesize($this->path . '/' . $file),
190 'ctime' => filectime($this->path . '/' . $file),
191 'fullpath' => $this->path . '/' . $file);
192 }
193 }
194 closedir($dp);
195 $files = ilUtil::sortArray($files, "name", "asc");
196 return $files;
197 }
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray

References ilUtil\sortArray().

+ Here is the call graph for this function:

◆ getGlobalFeedbackPath()

ilFSStorageExercise::getGlobalFeedbackPath ( )

Definition at line 114 of file class.ilFSStorageExercise.php.

115 {
116 $path = $this->feedb_path . "/0";
117 if (!file_exists($path)) {
119 }
120 return $path;
121 }

References ilFileSystemStorage\$path, and ilUtil\makeDirParents().

+ Here is the call graph for this function:

◆ getMultiFeedbackUploadPath()

ilFSStorageExercise::getMultiFeedbackUploadPath (   $a_user_id)

Get multi feedback upload path (each uploader handled in a separate path)

Definition at line 127 of file class.ilFSStorageExercise.php.

128 {
129 $path = $this->multi_feedback_upload_path . "/" . $a_user_id;
130 if (!file_exists($path)) {
132 }
133 return $path;
134 }

References ilFileSystemStorage\$path, and ilUtil\makeDirParents().

+ Here is the call graph for this function:

◆ getPathPostfix()

ilFSStorageExercise::getPathPostfix ( )
protected

Implementation of abstract method.

@access protected

Reimplemented from ilFileSystemStorage.

Definition at line 70 of file class.ilFSStorageExercise.php.

71 {
72 return 'exc';
73 }

◆ getPathPrefix()

ilFSStorageExercise::getPathPrefix ( )
protected

Implementation of abstract method.

@access protected

Reimplemented from ilFileSystemStorage.

Definition at line 81 of file class.ilFSStorageExercise.php.

82 {
83 return 'ilExercise';
84 }

◆ getPeerReviewUploadPath()

ilFSStorageExercise::getPeerReviewUploadPath (   $a_peer_id,
  $a_giver_id,
  $a_crit_id 
)

Get pear review upload path (each peer handled in a separate path)

Definition at line 140 of file class.ilFSStorageExercise.php.

141 {
142 $path = $this->peer_review_upload_path . "/" . $a_peer_id . "/" . $a_giver_id . "/";
143
144 if ((int) $a_crit_id) {
145 $path .= (int) $a_crit_id . "/";
146 }
147 if (!file_exists($path)) {
149 }
150 return $path;
151 }

References ilFileSystemStorage\$path, and ilUtil\makeDirParents().

+ Here is the call graph for this function:

◆ getTempPath()

ilFSStorageExercise::getTempPath ( )

Get submission path.

Definition at line 97 of file class.ilFSStorageExercise.php.

98 {
99 return $this->tmp_path;
100 }

◆ init()

ilFSStorageExercise::init ( )

Append ass_<ass_id> to path (assignment id)

Reimplemented from ilFileSystemStorage.

Definition at line 46 of file class.ilFSStorageExercise.php.

47 {
48 if (parent::init()) {
49 if ($this->ass_id > 0) {
50 $this->submission_path = $this->path . "/subm_" . $this->ass_id;
51 $this->tmp_path = $this->path . "/tmp_" . $this->ass_id;
52 $this->feedb_path = $this->path . "/feedb_" . $this->ass_id;
53 $this->multi_feedback_upload_path = $this->path . "/mfb_up_" . $this->ass_id;
54 $this->peer_review_upload_path = $this->path . "/peer_up_" . $this->ass_id;
55 $this->path .= "/ass_" . $this->ass_id;
56 }
57 } else {
58 return false;
59 }
60 return true;
61 }

◆ uploadAssignmentFiles()

ilFSStorageExercise::uploadAssignmentFiles (   $a_files)

Upload assignment files (e.g.

from assignment creation form)

Definition at line 331 of file class.ilFSStorageExercise.php.

332 {
333 if (is_array($a_files["name"])) {
334 foreach ($a_files["name"] as $k => $name) {
335 if ($name != "") {
336 $type = $a_files["type"][$k];
337 $tmp_name = $a_files["tmp_name"][$k];
338 $size = $a_files["size"][$k];
340 $tmp_name,
341 basename($name),
342 $this->path . DIRECTORY_SEPARATOR . basename($name),
343 false
344 );
345 }
346 }
347 }
348 }
$size
Definition: RandomTest.php:84
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
if($format !==null) $name
Definition: metadata.php:230
$type

References $name, $size, $type, and ilUtil\moveUploadedFile().

+ Here is the call graph for this function:

◆ uploadFile()

ilFSStorageExercise::uploadFile (   $a_http_post_file,
  $user_id,
  $is_unziped = false 
)

store delivered file in filesystem

Parameters
arrayHTTP_POST_FILES
numericdatabase id of the user who delivered the file @access public
Returns
mixed Returns a result array with filename and mime type of the saved file, otherwise false

Definition at line 211 of file class.ilFSStorageExercise.php.

212 {
213 $this->create();
214 // TODO:
215 // CHECK UPLOAD LIMIT
216
217
218 //
219 $result = false;
220 if (isset($a_http_post_file) && $a_http_post_file['size']) {
221 $filename = $a_http_post_file['name'];
222
224
225 // replace whitespaces with underscores
226 $filename = preg_replace("/\s/", "_", $filename);
227 // remove all special characters
228 $filename = preg_replace("/[^_a-zA-Z0-9\.]/", "", $filename);
229
230 if (!is_dir($savepath = $this->getAbsoluteSubmissionPath())) {
231 ilUtil::makeDir($savepath);
232 }
233 $savepath .= '/' . $user_id;
234 if (!is_dir($savepath)) {
235 ilUtil::makeDir($savepath);
236 }
237
238 // CHECK IF FILE PATH EXISTS
239 if (!is_dir($savepath)) {
240 ilUtil::makeDir($savepath);
241 }
242 $now = getdate();
243 $prefix = sprintf(
244 "%04d%02d%02d%02d%02d%02d",
245 $now["year"],
246 $now["mon"],
247 $now["mday"],
248 $now["hours"],
249 $now["minutes"],
250 $now["seconds"]
251 );
252
253 if (!$is_unziped) {
255 $a_http_post_file["tmp_name"],
256 $prefix . "_" . $filename,
257 $savepath . "/" . $prefix . "_" . $filename
258 );
259 } else {
260 rename(
261 $a_http_post_file['tmp_name'],
262 $savepath . "/" . $prefix . "_" . $filename
263 );
264 }
265
266 if (is_file($savepath . "/" . $prefix . "_" . $filename)) {
267 $result = array(
268 "filename" => $prefix . "_" . $filename,
269 "fullname" => $savepath . "/" . $prefix . "_" . $filename,
270 "mimetype" => ilObjMediaObject::getMimeType($savepath . "/" . $prefix . "_" . $filename)
271 );
272 }
273 }
274 return $result;
275 }
$result
$filename
Definition: buildRTE.php:89
getAbsoluteSubmissionPath()
Get submission path.
static getValidFilename($a_filename)
Get valid filename.
static getMimeType($a_file, $a_external=null)
get mime type for file
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...

References $filename, $result, create(), getAbsoluteSubmissionPath(), ilObjMediaObject\getMimeType(), ilFileUtils\getValidFilename(), ilUtil\makeDir(), ilUtil\moveUploadedFile(), and ilFileSystemStorage\rename().

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: