ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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
122 {
123 $path = $this->getAbsolutePath();
124
125 $clean_name = preg_replace("/[^a-zA-Z0-9\_\.\-]/", "", $result->getName());
126 $new_file = $path . "/" . $clean_name;
127
129 $result->getPath(),
130 $clean_name, // This parameter does not do a thing
131 $new_file
132 );
133
134 return true;
135 }
136
140 public function deleteCurrentFile()
141 {
142 $files = $this->readDir();
143 $this->deleteFile($this->getAbsolutePath() . "/" . $files[0]);
144 }
145
151 public function getFilePath()
152 {
153 $files = $this->readDir();
154 return $this->getAbsolutePath() . "/" . $files[0];
155 }
156
162 public function deleteFileByName($file_name)
163 {
164 $this->deleteFile($this->getAbsolutePath() . "/" . $file_name);
165 }
166}
$result
An exception for terminatinating execution or to throw for unit testing.
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.