ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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)
 Get pear review upload path (each peer handled in a separate path) More...
 
 deletePeerReviewUploads ()
 Remove all uploads. More...
 
 create ()
 Create directory. More...
 
 getFiles ()
 Get assignment files. More...
 
 deliverFile ($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...
 
 _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

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

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

Constructor.

Parameters
intexercise id

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

40 {
41 $this->ass_id = $a_ass_id;
42 parent::__construct(self::STORAGE_DATA,true,$a_container_id);
43 }

Member Function Documentation

◆ countFeedbackFiles()

ilFSStorageExercise::countFeedbackFiles (   $a_user_id)

Count number of feedback files for a user.

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

322 {
323 $fbf = $this->getFeedbackFiles($a_user_id);
324 return count($fbf);
325 }
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 173 of file class.ilFSStorageExercise.php.

174 {
175 parent::create();
176 if(!file_exists($this->submission_path))
177 {
178 ilUtil::makeDirParents($this->submission_path);
179 }
180 if(!file_exists($this->tmp_path))
181 {
182 ilUtil::makeDirParents($this->tmp_path);
183 }
184 if(!file_exists($this->feedb_path))
185 {
186 ilUtil::makeDirParents($this->feedb_path);
187 }
188 return true;
189 }
static makeDirParents($a_dir)
Create a new directory and all parent directories.

References ilUtil\makeDirParents().

Referenced by deliverFile().

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

◆ deletePeerReviewUploads()

ilFSStorageExercise::deletePeerReviewUploads ( )

Remove all uploads.

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

163 {
164 $this->deleteDirectory($this->peer_review_upload_path);
165 }
deleteDirectory($a_abs_name)
Delete directory.

References ilFileSystemStorage\deleteDirectory().

+ Here is the call graph for this function:

◆ deliverFile()

ilFSStorageExercise::deliverFile (   $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 231 of file class.ilFSStorageExercise.php.

232 {
233 $this->create();
234
235 // TODO:
236 // CHECK UPLOAD LIMIT
237 //
238 $result = false;
239 if(isset($a_http_post_file) && $a_http_post_file['size'])
240 {
241 $filename = $a_http_post_file['name'];
242 // replace whitespaces with underscores
243 $filename = preg_replace("/\s/", "_", $filename);
244 // remove all special characters
245 $filename = preg_replace("/[^_a-zA-Z0-9\.]/", "", $filename);
246
247 if(!is_dir($savepath = $this->getAbsoluteSubmissionPath()))
248 {
249 ilUtil::makeDir($savepath);
250 }
251 $savepath .= '/' .$user_id;
252 if(!is_dir($savepath))
253 {
254 ilUtil::makeDir($savepath);
255 }
256
257 // CHECK IF FILE PATH EXISTS
258 if (!is_dir($savepath))
259 {
260 require_once "./Services/Utilities/classes/class.ilUtil.php";
261 #ilUtil::makeDirParents($savepath);
262 ilUtil::makeDir($savepath);
263 }
264 $now = getdate();
265 $prefix = sprintf("%04d%02d%02d%02d%02d%02d", $now["year"], $now["mon"], $now["mday"], $now["hours"],
266 $now["minutes"], $now["seconds"]);
267
268 if (!$is_unziped)
269 {
270 //move_uploaded_file($a_http_post_file["tmp_name"], $savepath . $prefix . "_" . $filename);
271 ilUtil::moveUploadedFile($a_http_post_file["tmp_name"], $a_http_post_file["name"],
272 $savepath . "/" . $prefix . "_" . $filename);
273 }
274 else
275 {
276
277 rename($a_http_post_file['tmp_name'],
278 $savepath . "/" . $prefix . "_" . $filename);
279 }
280
281 require_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
282
283 if (is_file($savepath . "/" . $prefix . "_" . $filename))
284 {
285 $result = array(
286 "filename" => $prefix . "_" . $filename,
287 "fullname" => $savepath . "/" . $prefix . "_" . $filename,
288 "mimetype" => ilObjMediaObject::getMimeType($savepath . "/" . $prefix . "_" . $filename)
289 );
290 }
291 }
292 return $result;
293 }
$result
$filename
Definition: buildRTE.php:89
getAbsoluteSubmissionPath()
Get submission path.
static getMimeType($a_file)
get mime type for file
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded 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(), ilUtil\makeDir(), ilUtil\moveUploadedFile(), and ilFileSystemStorage\rename().

+ Here is the call graph for this function:

◆ getAbsoluteSubmissionPath()

ilFSStorageExercise::getAbsoluteSubmissionPath ( )

Get submission path.

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

96 {
97 return $this->submission_path;
98 }

Referenced by deliverFile().

+ Here is the caller graph for this function:

◆ getAssignmentFilePath()

ilFSStorageExercise::getAssignmentFilePath (   $a_file)

Get path for assignment file.

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

331 {
332 return $this->getAbsolutePath()."/".$a_file;
333 }
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 338 of file class.ilFSStorageExercise.php.

339 {
340 $dir = $this->getFeedbackPath($a_user_id);
341 return $dir."/".$a_file;
342 }
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 298 of file class.ilFSStorageExercise.php.

299 {
300 $files = array();
301
302 $dir = $this->getFeedbackPath($a_user_id);
303 if (@is_dir($dir))
304 {
305 $dp = opendir($dir);
306 while($file = readdir($dp))
307 {
308 if(!is_dir($this->path.'/'.$file) && substr($file, 0, 1) != ".")
309 {
310 $files[] = $file;
311 }
312 }
313 }
314
315 return $files;
316 }
print $file

References $file, and 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 111 of file class.ilFSStorageExercise.php.

112 {
113 $path = $this->feedb_path."/".$a_user_id;
114 if(!file_exists($path))
115 {
117 }
118 return $path;
119 }

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 194 of file class.ilFSStorageExercise.php.

195 {
196 $files = array();
197 if (!is_dir($this->path))
198 {
199 return $files;
200 }
201
202 $dp = opendir($this->path);
203 while($file = readdir($dp))
204 {
205 if(!is_dir($this->path.'/'.$file))
206 {
207 $files[] = array(
208 'name' => $file,
209 'size' => filesize($this->path.'/'.$file),
210 'ctime' => ilFormat::formatDate(date('Y-m-d H:i:s',filectime($this->path.'/'.$file))),
211 'fullpath' => $this->path.'/'.$file);
212 }
213 }
214 closedir($dp);
215 $files = ilUtil::sortArray($files, "name", "asc");
216 return $files;
217 }
formatDate($a_date, $a_mode="datetime", $a_omit_seconds=false, $a_relative=TRUE)
format a date according to the user language shortcut for Format::fmtDateTime @access public
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray

References $file, ilFormat\formatDate(), and ilUtil\sortArray().

+ Here is the call graph for this function:

◆ getGlobalFeedbackPath()

ilFSStorageExercise::getGlobalFeedbackPath ( )

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

122 {
123 $path = $this->feedb_path."/0";
124 if(!file_exists($path))
125 {
127 }
128 return $path;
129 }

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 135 of file class.ilFSStorageExercise.php.

136 {
137 $path = $this->multi_feedback_upload_path."/".$a_user_id;
138 if(!file_exists($path))
139 {
141 }
142 return $path;
143 }

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 76 of file class.ilFSStorageExercise.php.

77 {
78 return 'exc';
79 }

◆ getPathPrefix()

ilFSStorageExercise::getPathPrefix ( )
protected

Implementation of abstract method.

@access protected

Reimplemented from ilFileSystemStorage.

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

88 {
89 return 'ilExercise';
90 }

◆ getPeerReviewUploadPath()

ilFSStorageExercise::getPeerReviewUploadPath (   $a_peer_id,
  $a_giver_id 
)

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

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

150 {
151 $path = $this->peer_review_upload_path."/".$a_peer_id."/".$a_giver_id;
152 if(!file_exists($path))
153 {
155 }
156 return $path;
157 }

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

+ Here is the call graph for this function:

◆ getTempPath()

ilFSStorageExercise::getTempPath ( )

Get submission path.

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

104 {
105 return $this->tmp_path;
106 }

◆ init()

ilFSStorageExercise::init ( )

Append ass_<ass_id> to path (assignment id)

Reimplemented from ilFileSystemStorage.

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

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

◆ uploadAssignmentFiles()

ilFSStorageExercise::uploadAssignmentFiles (   $a_files)

Upload assignment files (e.g.

from assignment creation form)

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

349 {
350 if (is_array($a_files["name"]))
351 {
352 foreach ($a_files["name"] as $k => $name)
353 {
354 if ($name != "")
355 {
356 $type = $a_files["type"][$k];
357 $tmp_name = $a_files["tmp_name"][$k];
358 $size = $a_files["size"][$k];
359 ilUtil::moveUploadedFile($tmp_name,
360 basename($name),
361 $this->path.DIRECTORY_SEPARATOR.basename($name),
362 false);
363 }
364 }
365 }
366 }
$size
Definition: RandomTest.php:79

References $size, and ilUtil\moveUploadedFile().

+ Here is the call graph for this function:

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