ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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

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

162 {
163 parent::create();
164 if (!file_exists($this->submission_path)) {
165 ilUtil::makeDirParents($this->submission_path);
166 }
167 if (!file_exists($this->tmp_path)) {
168 ilUtil::makeDirParents($this->tmp_path);
169 }
170 if (!file_exists($this->feedb_path)) {
171 ilUtil::makeDirParents($this->feedb_path);
172 }
173 return true;
174 }
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 91 of file class.ilFSStorageExercise.php.

92 {
93 return $this->submission_path;
94 }

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

285 {
286 $files = array();
287
288 $dir = $this->getFeedbackPath($a_user_id);
289 if (@is_dir($dir)) {
290 $dp = opendir($dir);
291 while ($file = readdir($dp)) {
292 if (!is_dir($this->path . '/' . $file) && substr($file, 0, 1) != ".") {
293 $files[] = $file;
294 }
295 }
296 }
297
298 return $files;
299 }
$files
Definition: add-vimline.php:18
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file

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

108 {
109 $path = $this->feedb_path . "/" . $a_user_id;
110 if (!file_exists($path)) {
112 }
113 return $path;
114 }

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

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

References $file, $files, and ilUtil\sortArray().

+ Here is the call graph for this function:

◆ getGlobalFeedbackPath()

ilFSStorageExercise::getGlobalFeedbackPath ( )

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

117 {
118 $path = $this->feedb_path . "/0";
119 if (!file_exists($path)) {
121 }
122 return $path;
123 }

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

130 {
131 $path = $this->multi_feedback_upload_path . "/" . $a_user_id;
132 if (!file_exists($path)) {
134 }
135 return $path;
136 }

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

73 {
74 return 'exc';
75 }

◆ getPathPrefix()

ilFSStorageExercise::getPathPrefix ( )
protected

Implementation of abstract method.

@access protected

Reimplemented from ilFileSystemStorage.

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

84 {
85 return 'ilExercise';
86 }

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

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

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

+ Here is the call graph for this function:

◆ getTempPath()

ilFSStorageExercise::getTempPath ( )

Get submission path.

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

100 {
101 return $this->tmp_path;
102 }

◆ 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 if ($this->ass_id > 0) {
52 $this->submission_path = $this->path . "/subm_" . $this->ass_id;
53 $this->tmp_path = $this->path . "/tmp_" . $this->ass_id;
54 $this->feedb_path = $this->path . "/feedb_" . $this->ass_id;
55 $this->multi_feedback_upload_path = $this->path . "/mfb_up_" . $this->ass_id;
56 $this->peer_review_upload_path = $this->path . "/peer_up_" . $this->ass_id;
57 $this->path.= "/ass_" . $this->ass_id;
58 }
59 } else {
60 return false;
61 }
62 return true;
63 }

◆ 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];
339 ilUtil::moveUploadedFile(
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
if($format !==null) $name
Definition: metadata.php:146
$type

References $name, $size, and $type.

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

214 {
215 $this->create();
216 // TODO:
217 // CHECK UPLOAD LIMIT
218
219
220 //
221 $result = false;
222 if (isset($a_http_post_file) && $a_http_post_file['size']) {
223 $filename = $a_http_post_file['name'];
224
225 include_once("./Services/Utilities/classes/class.ilFileUtils.php");
227
228 // replace whitespaces with underscores
229 $filename = preg_replace("/\s/", "_", $filename);
230 // remove all special characters
231 $filename = preg_replace("/[^_a-zA-Z0-9\.]/", "", $filename);
232
233 if (!is_dir($savepath = $this->getAbsoluteSubmissionPath())) {
234 ilUtil::makeDir($savepath);
235 }
236 $savepath .= '/' . $user_id;
237 if (!is_dir($savepath)) {
238 ilUtil::makeDir($savepath);
239 }
240
241 // CHECK IF FILE PATH EXISTS
242 if (!is_dir($savepath)) {
243 ilUtil::makeDir($savepath);
244 }
245 $now = getdate();
246 $prefix = sprintf(
247 "%04d%02d%02d%02d%02d%02d",
248 $now["year"],
249 $now["mon"],
250 $now["mday"],
251 $now["hours"],
252 $now["minutes"],
253 $now["seconds"]
254 );
255
256 if (!$is_unziped) {
257 ilUtil::moveUploadedFile(
258 $a_http_post_file["tmp_name"],
259 $prefix . "_" . $filename,
260 $savepath . "/" . $prefix . "_" . $filename
261 );
262 } else {
263 rename(
264 $a_http_post_file['tmp_name'],
265 $savepath . "/" . $prefix . "_" . $filename
266 );
267 }
268
269 require_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
270 if (is_file($savepath . "/" . $prefix . "_" . $filename)) {
271 $result = array(
272 "filename" => $prefix . "_" . $filename,
273 "fullname" => $savepath . "/" . $prefix . "_" . $filename,
274 "mimetype" => ilObjMediaObject::getMimeType($savepath . "/" . $prefix . "_" . $filename)
275 );
276 }
277 }
278 return $result;
279 }
sprintf('%.4f', $callTime)
$result
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(), ilFileSystemStorage\rename(), and sprintf.

+ Here is the call graph for this function:

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