ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilFSStorageExercise Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilFSStorageExercise:
+ Collaboration diagram for ilFSStorageExercise:

Public Member Functions

 __construct (int $a_container_id=0, int $a_ass_id=0)
 
 init ()
 Append ass_<ass_id> to path (assignment id) More...
 
 getAbsoluteSubmissionPath ()
 
 getTempPath ()
 
 getFeedbackPath (string $a_user_id)
 
 getGlobalFeedbackPath ()
 
 getMultiFeedbackUploadPath (int $a_user_id)
 Get multi feedback upload path (each uploader handled in a separate path) More...
 
 getPeerReviewUploadPath (int $a_peer_id, int $a_giver_id, ?int $a_crit_id=null)
 Get pear review upload path (each peer handled in a separate path) More...
 
 create ()
 Create directory. More...
 
 getFiles ()
 
 uploadFile (array $a_http_post_file, int $user_id, bool $is_unziped=false)
 store delivered file in filesystem More...
 
 addFileUpload (\ILIAS\FileUpload\DTO\UploadResult $result, int $user_id)
 store delivered file in filesystem More...
 
 getFeedbackFiles (string $a_user_id)
 
 countFeedbackFiles (string $a_user_id)
 
 getAssignmentFilePath (string $a_file)
 
 getFeedbackFilePath (string $a_user_id, string $a_file)
 
 uploadAssignmentFiles (array $a_files)
 
- Public Member Functions inherited from ilFileSystemAbstractionStorage
 __construct (int $a_storage_type, bool $a_path_conversion, int $a_container_id)
 Constructor. More...
 
 fileExists (string $a_absolute_path)
 
 getContainerId ()
 
 writeToFile (string $a_data, $a_absolute_path)
 
 copyFile (string $a_from, string $a_to)
 
 create ()
 
 getAbsolutePath ()
 Calculates the full path on the filesystem. More...
 
 delete ()
 
 deleteDirectory (string $a_abs_name)
 
 deleteFile (string $a_abs_name)
 
 appendToPath (string $a_appendix)
 
 getStorageType ()
 
 getPath ()
 

Protected Member Functions

 getRelativeSubmissionPath ()
 
 getPathPostfix ()
 
 getPathPrefix ()
 
 getStorageFilename (string $filename)
 
- Protected Member Functions inherited from ilFileSystemAbstractionStorage
 getLegacyFullAbsolutePath (string $relative_path)
 
 getFileSystemService ()
 
 getPathPrefix ()
 Get path prefix. More...
 
 getPathPostfix ()
 Get directory name. More...
 
 getLegacyAbsolutePath ()
 Calculates the absolute filesystem storage location. More...
 
 init ()
 

Protected Attributes

string $relative_submission_path
 
ILIAS FileUpload FileUpload $upload
 
int $ass_id
 
string $submission_path
 
string $tmp_path
 
string $feedb_path
 
string $multi_feedback_upload_path
 
string $peer_review_upload_path
 
- Protected Attributes inherited from ilFileSystemAbstractionStorage
string $path = null
 
ILIAS Filesystem Filesystems $file_system_service
 

Additional Inherited Members

- Static Public Member Functions inherited from ilFileSystemAbstractionStorage
static createPathFromId (int $a_container_id, string $a_name)
 
static _copyDirectory (string $a_sdir, string $a_tdir)
 
- Data Fields inherited from ilFileSystemAbstractionStorage
const STORAGE_WEB = 1
 
const STORAGE_DATA = 2
 
const STORAGE_SECURED = 3
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

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

Constructor & Destructor Documentation

◆ __construct()

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

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

References $DIC, ILIAS\MetaData\Repository\Validation\Data\__construct(), and ILIAS\Repository\upload().

36  {
37  global $DIC;
38 
39  $this->ass_id = $a_ass_id;
40  parent::__construct(self::STORAGE_DATA, true, $a_container_id);
41  $this->upload = $DIC->upload();
42  }
global $DIC
Definition: feed.php:28
__construct(VocabulariesInterface $vocabularies)
+ Here is the call graph for this function:

Member Function Documentation

◆ addFileUpload()

ilFSStorageExercise::addFileUpload ( \ILIAS\FileUpload\DTO\UploadResult  $result,
int  $user_id 
)

store delivered file in filesystem

Parameters
array$a_http_post_file
int$user_id
bool$is_unziped
Returns
?array result array with filename and mime type of the saved file
Exceptions
ilException
ilFileUtilsException

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

References $filename, create(), getRelativeSubmissionPath(), getStorageFilename(), and ILIAS\Repository\upload().

285  : ?array {
286  $this->create();
287 
288  $filename = $result->getName();
290 
291  $savepath = $this->getRelativeSubmissionPath();
292  $savepath .= '/' . $user_id;
293 
294  $now = getdate();
295  $prefix = sprintf(
296  "%04d%02d%02d%02d%02d%02d",
297  $now["year"],
298  $now["mon"],
299  $now["mday"],
300  $now["hours"],
301  $now["minutes"],
302  $now["seconds"]
303  );
304 
305  $this->upload->moveOneFileTo(
306  $result,
307  $savepath,
308  \ILIAS\FileUpload\Location::STORAGE,
309  $prefix . "_" . $filename,
310  true
311  );
312 
313  $result = array(
314  "filename" => $prefix . "_" . $filename,
315  "fullname" => $savepath . "/" . $prefix . "_" . $filename,
316  "mimetype" => $result->getMimeType()
317  );
318 
319  return $result;
320  }
getStorageFilename(string $filename)
Class ChatMainBarProvider .
$filename
Definition: buildRTE.php:78
+ Here is the call graph for this function:

◆ countFeedbackFiles()

ilFSStorageExercise::countFeedbackFiles ( string  $a_user_id)

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

References getFeedbackFiles().

Referenced by ilExerciseSubmissionTableGUI\parseColumns().

348  : int {
349  $fbf = $this->getFeedbackFiles($a_user_id);
350  return count($fbf);
351  }
getFeedbackFiles(string $a_user_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ create()

ilFSStorageExercise::create ( )

Create directory.

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

References ilFileUtils\makeDirParents().

Referenced by ilExAssignmentPeerReviewTableGUI\__construct(), ilExerciseXMLParser\__construct(), addFileUpload(), ilExSubmission\downloadAllAssignmentFiles(), ilExPeerReviewGUI\executeCommand(), ilExerciseManagementGUI\executeCommand(), ilExPeerReviewGUI\getPeerReviewReceiverPanel(), ilExerciseDataSet\importRecord(), and uploadFile().

147  : void
148  {
149  parent::create();
150  if (!file_exists($this->submission_path)) {
151  ilFileUtils::makeDirParents($this->submission_path);
152  }
153  if (!file_exists($this->tmp_path)) {
154  ilFileUtils::makeDirParents($this->tmp_path);
155  }
156  if (!file_exists($this->feedb_path)) {
157  ilFileUtils::makeDirParents($this->feedb_path);
158  }
159  }
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAbsoluteSubmissionPath()

ilFSStorageExercise::getAbsoluteSubmissionPath ( )

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

References $submission_path.

Referenced by uploadFile().

81  : string
82  {
84  }
+ Here is the caller graph for this function:

◆ getAssignmentFilePath()

ilFSStorageExercise::getAssignmentFilePath ( string  $a_file)

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

References ilFileSystemAbstractionStorage\getAbsolutePath().

353  : string
354  {
355  return $this->getAbsolutePath() . "/" . $a_file;
356  }
getAbsolutePath()
Calculates the full path on the filesystem.
+ Here is the call graph for this function:

◆ getFeedbackFilePath()

ilFSStorageExercise::getFeedbackFilePath ( string  $a_user_id,
string  $a_file 
)

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

References getFeedbackPath().

361  : string {
362  $dir = $this->getFeedbackPath($a_user_id);
363  return $dir . "/" . $a_file;
364  }
getFeedbackPath(string $a_user_id)
+ Here is the call graph for this function:

◆ getFeedbackFiles()

ilFSStorageExercise::getFeedbackFiles ( string  $a_user_id)
Returns
string[]

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

References getFeedbackPath().

Referenced by countFeedbackFiles().

327  : array {
328  $files = array();
329 
330  if ($a_user_id === "t") { // team assignment without team, see #36253
331  return[];
332  }
333 
334  $dir = $this->getFeedbackPath($a_user_id);
335  if (is_dir($dir)) {
336  $dp = opendir($dir);
337  while ($file = readdir($dp)) {
338  if (!is_dir($this->path . '/' . $file) && substr($file, 0, 1) != ".") {
339  $files[] = $file;
340  }
341  }
342  }
343  return $files;
344  }
getFeedbackPath(string $a_user_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFeedbackPath()

ilFSStorageExercise::getFeedbackPath ( string  $a_user_id)

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

References ilFileSystemAbstractionStorage\$path, and ilFileUtils\makeDirParents().

Referenced by getFeedbackFilePath(), and getFeedbackFiles().

93  : string {
94  $path = $this->feedb_path . "/" . $a_user_id;
95  if (!file_exists($path)) {
97  }
98  return $path;
99  }
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFiles()

ilFSStorageExercise::getFiles ( )

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

References ilArrayUtil\sortArray().

Referenced by ilObjExercise\update().

161  : array
162  {
163  $files = array();
164  if (!is_dir($this->path)) {
165  return $files;
166  }
167 
168  $dp = opendir($this->path);
169  while ($file = readdir($dp)) {
170  if (!is_dir($this->path . '/' . $file)) {
171  $files[] = array(
172  'name' => $file,
173  'size' => filesize($this->path . '/' . $file),
174  'ctime' => filectime($this->path . '/' . $file),
175  'fullpath' => $this->path . '/' . $file);
176  }
177  }
178  closedir($dp);
179  return ilArrayUtil::sortArray($files, "name", "asc");
180  }
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getGlobalFeedbackPath()

ilFSStorageExercise::getGlobalFeedbackPath ( )

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

References ilFileSystemAbstractionStorage\$path, and ilFileUtils\makeDirParents().

101  : string
102  {
103  $path = $this->feedb_path . "/0";
104  if (!file_exists($path)) {
106  }
107  return $path;
108  }
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
+ Here is the call graph for this function:

◆ getMultiFeedbackUploadPath()

ilFSStorageExercise::getMultiFeedbackUploadPath ( int  $a_user_id)

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

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

References ilFileSystemAbstractionStorage\$path, and ilFileUtils\makeDirParents().

116  : string {
117  $path = $this->multi_feedback_upload_path . "/" . $a_user_id;
118  if (!file_exists($path)) {
120  }
121  return $path;
122  }
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
+ Here is the call graph for this function:

◆ getPathPostfix()

ilFSStorageExercise::getPathPostfix ( )
protected

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

71  : string
72  {
73  return 'exc';
74  }

◆ getPathPrefix()

ilFSStorageExercise::getPathPrefix ( )
protected

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

76  : string
77  {
78  return 'ilExercise';
79  }

◆ getPeerReviewUploadPath()

ilFSStorageExercise::getPeerReviewUploadPath ( int  $a_peer_id,
int  $a_giver_id,
?int  $a_crit_id = null 
)

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

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

References ilFileSystemAbstractionStorage\$path, ILIAS\Repository\int(), and ilFileUtils\makeDirParents().

Referenced by ilExPeerReviewGUI\executeCommand(), and ilExcCriteriaFile\initStorage().

132  : string {
133  $path = $this->peer_review_upload_path . "/" . $a_peer_id . "/" . $a_giver_id . "/";
134 
135  if ((int) $a_crit_id !== 0) {
136  $path .= (int) $a_crit_id . "/";
137  }
138  if (!file_exists($path)) {
140  }
141  return $path;
142  }
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRelativeSubmissionPath()

ilFSStorageExercise::getRelativeSubmissionPath ( )
protected

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

References $relative_submission_path.

Referenced by addFileUpload().

44  : string
45  {
47  }
+ Here is the caller graph for this function:

◆ getStorageFilename()

ilFSStorageExercise::getStorageFilename ( string  $filename)
protected

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

References $DIC, $filename, and ilFileUtils\getValidFilename().

Referenced by addFileUpload(), and uploadFile().

260  : string
261  {
262  global $DIC;
263 
265  // replace whitespaces with underscores
266  $filename = preg_replace("/\s/", "_", $filename);
267  $filename = (new \ilFileServicesPolicy($DIC->fileServiceSettings()))->ascii($filename);
268  // remove all special characters
269  $filename = preg_replace("/[^_a-zA-Z0-9\.]/", "", $filename);
270  return $filename;
271  }
static getValidFilename(string $a_filename)
global $DIC
Definition: feed.php:28
$filename
Definition: buildRTE.php:78
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTempPath()

ilFSStorageExercise::getTempPath ( )

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

References $tmp_path.

86  : string
87  {
88  return $this->tmp_path;
89  }

◆ init()

ilFSStorageExercise::init ( )

Append ass_<ass_id> to path (assignment id)

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

References $ass_id, ilFileSystemAbstractionStorage\getAbsolutePath(), and init().

52  : bool
53  {
54  if (parent::init()) {
55  if ($this->ass_id > 0) {
56  $this->submission_path = $this->getAbsolutePath() . "/subm_" . $this->ass_id;
57  $this->relative_submission_path = $this->path . "/subm_" . $this->ass_id;
58  ;
59  $this->tmp_path = $this->getAbsolutePath() . "/tmp_" . $this->ass_id;
60  $this->feedb_path = $this->getAbsolutePath() . "/feedb_" . $this->ass_id;
61  $this->multi_feedback_upload_path = $this->getAbsolutePath() . "/mfb_up_" . $this->ass_id;
62  $this->peer_review_upload_path = $this->getAbsolutePath() . "/peer_up_" . $this->ass_id;
63  $this->path .= "/ass_" . $this->ass_id;
64  }
65  } else {
66  return false;
67  }
68  return true;
69  }
getAbsolutePath()
Calculates the full path on the filesystem.
+ Here is the call graph for this function:

◆ uploadAssignmentFiles()

ilFSStorageExercise::uploadAssignmentFiles ( array  $a_files)
Exceptions
ilException

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

References ilFileSystemAbstractionStorage\getAbsolutePath(), and ilFileUtils\moveUploadedFile().

371  : void {
372  if (is_array($a_files["name"])) {
373  foreach ($a_files["name"] as $k => $name) {
374  if ($name != "") {
375  $tmp_name = $a_files["tmp_name"][$k];
377  $tmp_name,
378  basename($name),
379  $this->getAbsolutePath() . DIRECTORY_SEPARATOR . basename($name),
380  false
381  );
382  }
383  }
384  }
385  }
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file
getAbsolutePath()
Calculates the full path on the filesystem.
+ Here is the call graph for this function:

◆ uploadFile()

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

store delivered file in filesystem

Parameters
array$a_http_post_file
int$user_id
bool$is_unziped
Returns
?array result array with filename and mime type of the saved file
Exceptions
ilException
ilFileUtilsException
Deprecated:
use addFileUpload instead

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

References $filename, create(), getAbsoluteSubmissionPath(), ilObjMediaObject\getMimeType(), getStorageFilename(), ilFileUtils\makeDir(), ilFileUtils\moveUploadedFile(), and ilFileUtils\rename().

201  : ?array {
202  $this->create();
203  // TODO:
204  // CHECK UPLOAD LIMIT
205 
206  //
207  $result = null;
208  if (isset($a_http_post_file) && $a_http_post_file['size']) {
209  $filename = $a_http_post_file['name'];
210 
212 
213  if (!is_dir($savepath = $this->getAbsoluteSubmissionPath())) {
214  ilFileUtils::makeDir($savepath);
215  }
216  $savepath .= '/' . $user_id;
217  if (!is_dir($savepath)) {
218  ilFileUtils::makeDir($savepath);
219  }
220 
221  // CHECK IF FILE PATH EXISTS
222  if (!is_dir($savepath)) {
223  ilFileUtils::makeDir($savepath);
224  }
225  $now = getdate();
226  $prefix = sprintf(
227  "%04d%02d%02d%02d%02d%02d",
228  $now["year"],
229  $now["mon"],
230  $now["mday"],
231  $now["hours"],
232  $now["minutes"],
233  $now["seconds"]
234  );
235 
236  if (!$is_unziped) {
238  $a_http_post_file["tmp_name"],
239  $prefix . "_" . $filename,
240  $savepath . "/" . $prefix . "_" . $filename
241  );
242  } else {
244  $a_http_post_file['tmp_name'],
245  $savepath . "/" . $prefix . "_" . $filename
246  );
247  }
248 
249  if (is_file($savepath . "/" . $prefix . "_" . $filename)) {
250  $result = array(
251  "filename" => $prefix . "_" . $filename,
252  "fullname" => $savepath . "/" . $prefix . "_" . $filename,
253  "mimetype" => ilObjMediaObject::getMimeType($savepath . "/" . $prefix . "_" . $filename)
254  );
255  }
256  }
257  return $result;
258  }
getStorageFilename(string $filename)
static getMimeType(string $a_file, bool $a_external=false)
get mime type for file
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file
$filename
Definition: buildRTE.php:78
static rename(string $a_source, string $a_target)
static makeDir(string $a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
+ Here is the call graph for this function:

Field Documentation

◆ $ass_id

int ilFSStorageExercise::$ass_id
protected

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

Referenced by init().

◆ $feedb_path

string ilFSStorageExercise::$feedb_path
protected

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

◆ $multi_feedback_upload_path

string ilFSStorageExercise::$multi_feedback_upload_path
protected

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

◆ $peer_review_upload_path

string ilFSStorageExercise::$peer_review_upload_path
protected

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

◆ $relative_submission_path

string ilFSStorageExercise::$relative_submission_path
protected

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

Referenced by getRelativeSubmissionPath().

◆ $submission_path

string ilFSStorageExercise::$submission_path
protected

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

Referenced by getAbsoluteSubmissionPath().

◆ $tmp_path

string ilFSStorageExercise::$tmp_path
protected

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

Referenced by getTempPath().

◆ $upload

ILIAS FileUpload FileUpload ilFSStorageExercise::$upload
protected

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


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