ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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...
 
 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

 getPathPostfix ()
 
 getPathPrefix ()
 
- 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

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

References ILIAS\GlobalScreen\Provider\__construct().

34  {
35  $this->ass_id = $a_ass_id;
36  parent::__construct(self::STORAGE_DATA, true, $a_container_id);
37  }
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ countFeedbackFiles()

ilFSStorageExercise::countFeedbackFiles ( string  $a_user_id)

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

References getFeedbackFiles().

Referenced by ilExAssignmentGUI\addSubmissionFeedback(), and ilExerciseSubmissionTableGUI\parseColumns().

277  : int {
278  $fbf = $this->getFeedbackFiles($a_user_id);
279  return count($fbf);
280  }
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 135 of file class.ilFSStorageExercise.php.

References ilFileUtils\makeDirParents().

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

135  : void
136  {
137  parent::create();
138  if (!file_exists($this->submission_path)) {
139  ilFileUtils::makeDirParents($this->submission_path);
140  }
141  if (!file_exists($this->tmp_path)) {
142  ilFileUtils::makeDirParents($this->tmp_path);
143  }
144  if (!file_exists($this->feedb_path)) {
145  ilFileUtils::makeDirParents($this->feedb_path);
146  }
147  }
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 69 of file class.ilFSStorageExercise.php.

References $submission_path.

Referenced by uploadFile().

69  : string
70  {
72  }
+ Here is the caller graph for this function:

◆ getAssignmentFilePath()

ilFSStorageExercise::getAssignmentFilePath ( string  $a_file)

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

References ilFileSystemAbstractionStorage\getAbsolutePath().

282  : string
283  {
284  return $this->getAbsolutePath() . "/" . $a_file;
285  }
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 287 of file class.ilFSStorageExercise.php.

References getFeedbackPath().

290  : string {
291  $dir = $this->getFeedbackPath($a_user_id);
292  return $dir . "/" . $a_file;
293  }
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 254 of file class.ilFSStorageExercise.php.

References getFeedbackPath().

Referenced by countFeedbackFiles(), and ilExSubmissionGUI\downloadFeedbackFileObject().

256  : array {
257  $files = array();
258 
259  if ($a_user_id === "t") { // team assignment without team, see #36253
260  return[];
261  }
262 
263  $dir = $this->getFeedbackPath($a_user_id);
264  if (is_dir($dir)) {
265  $dp = opendir($dir);
266  while ($file = readdir($dp)) {
267  if (!is_dir($this->path . '/' . $file) && substr($file, 0, 1) != ".") {
268  $files[] = $file;
269  }
270  }
271  }
272  return $files;
273  }
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 79 of file class.ilFSStorageExercise.php.

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

Referenced by getFeedbackFilePath(), and getFeedbackFiles().

81  : string {
82  $path = $this->feedb_path . "/" . $a_user_id;
83  if (!file_exists($path)) {
85  }
86  return $path;
87  }
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 149 of file class.ilFSStorageExercise.php.

References ilArrayUtil\sortArray().

Referenced by ilObjExercise\update().

149  : array
150  {
151  $files = array();
152  if (!is_dir($this->path)) {
153  return $files;
154  }
155 
156  $dp = opendir($this->path);
157  while ($file = readdir($dp)) {
158  if (!is_dir($this->path . '/' . $file)) {
159  $files[] = array(
160  'name' => $file,
161  'size' => filesize($this->path . '/' . $file),
162  'ctime' => filectime($this->path . '/' . $file),
163  'fullpath' => $this->path . '/' . $file);
164  }
165  }
166  closedir($dp);
167  return ilArrayUtil::sortArray($files, "name", "asc");
168  }
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 89 of file class.ilFSStorageExercise.php.

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

Referenced by ilExAssignment\cloneAssignmentsOfExercise().

89  : string
90  {
91  $path = $this->feedb_path . "/0";
92  if (!file_exists($path)) {
94  }
95  return $path;
96  }
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:

◆ getMultiFeedbackUploadPath()

ilFSStorageExercise::getMultiFeedbackUploadPath ( int  $a_user_id)

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

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

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

104  : string {
105  $path = $this->multi_feedback_upload_path . "/" . $a_user_id;
106  if (!file_exists($path)) {
108  }
109  return $path;
110  }
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 59 of file class.ilFSStorageExercise.php.

59  : string
60  {
61  return 'exc';
62  }

◆ getPathPrefix()

ilFSStorageExercise::getPathPrefix ( )
protected

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

64  : string
65  {
66  return 'ilExercise';
67  }

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

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

Referenced by ilExcCriteriaFile\initStorage().

120  : string {
121  $path = $this->peer_review_upload_path . "/" . $a_peer_id . "/" . $a_giver_id . "/";
122 
123  if ((int) $a_crit_id !== 0) {
124  $path .= (int) $a_crit_id . "/";
125  }
126  if (!file_exists($path)) {
128  }
129  return $path;
130  }
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:

◆ getTempPath()

ilFSStorageExercise::getTempPath ( )

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

References $tmp_path.

74  : string
75  {
76  return $this->tmp_path;
77  }

◆ init()

ilFSStorageExercise::init ( )

Append ass_<ass_id> to path (assignment id)

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

References $ass_id, and ilFileSystemAbstractionStorage\getAbsolutePath().

42  : bool
43  {
44  if (parent::init()) {
45  if ($this->ass_id > 0) {
46  $this->submission_path = $this->getAbsolutePath() . "/subm_" . $this->ass_id;
47  $this->tmp_path = $this->getAbsolutePath() . "/tmp_" . $this->ass_id;
48  $this->feedb_path = $this->getAbsolutePath() . "/feedb_" . $this->ass_id;
49  $this->multi_feedback_upload_path = $this->getAbsolutePath() . "/mfb_up_" . $this->ass_id;
50  $this->peer_review_upload_path = $this->getAbsolutePath() . "/peer_up_" . $this->ass_id;
51  $this->path .= "/ass_" . $this->ass_id;
52  }
53  } else {
54  return false;
55  }
56  return true;
57  }
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 298 of file class.ilFSStorageExercise.php.

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

300  : void {
301  if (is_array($a_files["name"])) {
302  foreach ($a_files["name"] as $k => $name) {
303  if ($name != "") {
304  $tmp_name = $a_files["tmp_name"][$k];
306  $tmp_name,
307  basename($name),
308  $this->getAbsolutePath() . DIRECTORY_SEPARATOR . basename($name),
309  false
310  );
311  }
312  }
313  }
314  }
if($format !==null) $name
Definition: metadata.php:247
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

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

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

188  : ?array {
189  $this->create();
190  // TODO:
191  // CHECK UPLOAD LIMIT
192 
193  //
194  $result = null;
195  if (isset($a_http_post_file) && $a_http_post_file['size']) {
196  $filename = $a_http_post_file['name'];
197 
199  // replace whitespaces with underscores
200  $filename = preg_replace("/\s/", "_", $filename);
201  // remove all special characters
202  $filename = preg_replace("/[^_a-zA-Z0-9\.]/", "", $filename);
203 
204  if (!is_dir($savepath = $this->getAbsoluteSubmissionPath())) {
205  ilFileUtils::makeDir($savepath);
206  }
207  $savepath .= '/' . $user_id;
208  if (!is_dir($savepath)) {
209  ilFileUtils::makeDir($savepath);
210  }
211 
212  // CHECK IF FILE PATH EXISTS
213  if (!is_dir($savepath)) {
214  ilFileUtils::makeDir($savepath);
215  }
216  $now = getdate();
217  $prefix = sprintf(
218  "%04d%02d%02d%02d%02d%02d",
219  $now["year"],
220  $now["mon"],
221  $now["mday"],
222  $now["hours"],
223  $now["minutes"],
224  $now["seconds"]
225  );
226 
227  if (!$is_unziped) {
229  $a_http_post_file["tmp_name"],
230  $prefix . "_" . $filename,
231  $savepath . "/" . $prefix . "_" . $filename
232  );
233  } else {
235  $a_http_post_file['tmp_name'],
236  $savepath . "/" . $prefix . "_" . $filename
237  );
238  }
239 
240  if (is_file($savepath . "/" . $prefix . "_" . $filename)) {
241  $result = array(
242  "filename" => $prefix . "_" . $filename,
243  "fullname" => $savepath . "/" . $prefix . "_" . $filename,
244  "mimetype" => ilObjMediaObject::getMimeType($savepath . "/" . $prefix . "_" . $filename)
245  );
246  }
247  }
248  return $result;
249  }
static getValidFilename(string $a_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 24 of file class.ilFSStorageExercise.php.

Referenced by init().

◆ $feedb_path

string ilFSStorageExercise::$feedb_path
protected

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

◆ $multi_feedback_upload_path

string ilFSStorageExercise::$multi_feedback_upload_path
protected

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

◆ $peer_review_upload_path

string ilFSStorageExercise::$peer_review_upload_path
protected

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

◆ $submission_path

string ilFSStorageExercise::$submission_path
protected

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

Referenced by getAbsoluteSubmissionPath().

◆ $tmp_path

string ilFSStorageExercise::$tmp_path
protected

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

Referenced by getTempPath().


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