ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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...
 
- Protected Member Functions inherited from ilFileSystemStorage
 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

Constructor & Destructor Documentation

◆ __construct()

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

Constructor.

Parameters
intexercise id

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

References ILIAS\GlobalScreen\Provider\__construct().

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

Member Function Documentation

◆ countFeedbackFiles()

ilFSStorageExercise::countFeedbackFiles (   $a_user_id)

Count number of feedback files for a user.

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

References getFeedbackFiles().

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

301  {
302  $fbf = $this->getFeedbackFiles($a_user_id);
303  return count($fbf);
304  }
getFeedbackFiles($a_user_id)
Get number of feedback files.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ create()

ilFSStorageExercise::create ( )

Create directory.

public

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

References ilUtil\makeDirParents().

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

160  {
161  parent::create();
162  if (!file_exists($this->submission_path)) {
163  ilUtil::makeDirParents($this->submission_path);
164  }
165  if (!file_exists($this->tmp_path)) {
166  ilUtil::makeDirParents($this->tmp_path);
167  }
168  if (!file_exists($this->feedb_path)) {
169  ilUtil::makeDirParents($this->feedb_path);
170  }
171  return true;
172  }
static makeDirParents($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 ( )

Get submission path.

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

Referenced by uploadFile().

90  {
91  return $this->submission_path;
92  }
+ Here is the caller graph for this function:

◆ getAssignmentFilePath()

ilFSStorageExercise::getAssignmentFilePath (   $a_file)

Get path for assignment file.

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

References ilFileSystemStorage\getAbsolutePath().

310  {
311  return $this->getAbsolutePath() . "/" . $a_file;
312  }
getAbsolutePath()
Get absolute path of storage directory.
+ Here is the call graph for this function:

◆ getFeedbackFilePath()

ilFSStorageExercise::getFeedbackFilePath (   $a_user_id,
  $a_file 
)

Get path for feedback file.

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

References getFeedbackPath().

318  {
319  $dir = $this->getFeedbackPath($a_user_id);
320  return $dir . "/" . $a_file;
321  }
getFeedbackPath($a_user_id)
Get feedback path.
+ Here is the call graph for this function:

◆ getFeedbackFiles()

ilFSStorageExercise::getFeedbackFiles (   $a_user_id)

Get number of feedback files.

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

References getFeedbackPath().

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

281  {
282  $files = array();
283 
284  $dir = $this->getFeedbackPath($a_user_id);
285  if (@is_dir($dir)) {
286  $dp = opendir($dir);
287  while ($file = readdir($dp)) {
288  if (!is_dir($this->path . '/' . $file) && substr($file, 0, 1) != ".") {
289  $files[] = $file;
290  }
291  }
292  }
293 
294  return $files;
295  }
getFeedbackPath($a_user_id)
Get feedback path.
+ 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 105 of file class.ilFSStorageExercise.php.

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

Referenced by getFeedbackFilePath(), and getFeedbackFiles().

106  {
107  $path = $this->feedb_path . "/" . $a_user_id;
108  if (!file_exists($path)) {
110  }
111  return $path;
112  }
static makeDirParents($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 ( )

Get assignment files.

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

References ilUtil\sortArray().

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

◆ getGlobalFeedbackPath()

ilFSStorageExercise::getGlobalFeedbackPath ( )

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

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

Referenced by ilExAssignment\cloneAssignmentsOfExercise().

115  {
116  $path = $this->feedb_path . "/0";
117  if (!file_exists($path)) {
119  }
120  return $path;
121  }
static makeDirParents($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 (   $a_user_id)

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

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

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

128  {
129  $path = $this->multi_feedback_upload_path . "/" . $a_user_id;
130  if (!file_exists($path)) {
132  }
133  return $path;
134  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
+ Here is the call graph for this function:

◆ getPathPostfix()

ilFSStorageExercise::getPathPostfix ( )
protected

Implementation of abstract method.

protected

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

71  {
72  return 'exc';
73  }

◆ getPathPrefix()

ilFSStorageExercise::getPathPrefix ( )
protected

Implementation of abstract method.

protected

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

82  {
83  return 'ilExercise';
84  }

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

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

Referenced by ilExcCriteriaFile\initStorage().

141  {
142  $path = $this->peer_review_upload_path . "/" . $a_peer_id . "/" . $a_giver_id . "/";
143 
144  if ((int) $a_crit_id) {
145  $path .= (int) $a_crit_id . "/";
146  }
147  if (!file_exists($path)) {
149  }
150  return $path;
151  }
static makeDirParents($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 ( )

Get submission path.

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

98  {
99  return $this->tmp_path;
100  }

◆ init()

ilFSStorageExercise::init ( )

Append ass_<ass_id> to path (assignment id)

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

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

◆ uploadAssignmentFiles()

ilFSStorageExercise::uploadAssignmentFiles (   $a_files)

Upload assignment files (e.g.

from assignment creation form)

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

References $name, $size, $type, and ilUtil\moveUploadedFile().

328  {
329  if (is_array($a_files["name"])) {
330  foreach ($a_files["name"] as $k => $name) {
331  if ($name != "") {
332  $type = $a_files["type"][$k];
333  $tmp_name = $a_files["tmp_name"][$k];
334  $size = $a_files["size"][$k];
336  $tmp_name,
337  basename($name),
338  $this->path . DIRECTORY_SEPARATOR . basename($name),
339  false
340  );
341  }
342  }
343  }
344  }
$size
Definition: RandomTest.php:84
$type
if($format !==null) $name
Definition: metadata.php:230
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
+ Here is the call graph for this function:

◆ 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 public
Returns
mixed Returns a result array with filename and mime type of the saved file, otherwise false

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

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

212  {
213  $this->create();
214  // TODO:
215  // CHECK UPLOAD LIMIT
216 
217 
218  //
219  $result = false;
220  if (isset($a_http_post_file) && $a_http_post_file['size']) {
221  $filename = $a_http_post_file['name'];
222 
224 
225  // replace whitespaces with underscores
226  $filename = preg_replace("/\s/", "_", $filename);
227  // remove all special characters
228  $filename = preg_replace("/[^_a-zA-Z0-9\.]/", "", $filename);
229 
230  if (!is_dir($savepath = $this->getAbsoluteSubmissionPath())) {
231  ilUtil::makeDir($savepath);
232  }
233  $savepath .= '/' . $user_id;
234  if (!is_dir($savepath)) {
235  ilUtil::makeDir($savepath);
236  }
237 
238  // CHECK IF FILE PATH EXISTS
239  if (!is_dir($savepath)) {
240  ilUtil::makeDir($savepath);
241  }
242  $now = getdate();
243  $prefix = sprintf(
244  "%04d%02d%02d%02d%02d%02d",
245  $now["year"],
246  $now["mon"],
247  $now["mday"],
248  $now["hours"],
249  $now["minutes"],
250  $now["seconds"]
251  );
252 
253  if (!$is_unziped) {
255  $a_http_post_file["tmp_name"],
256  $prefix . "_" . $filename,
257  $savepath . "/" . $prefix . "_" . $filename
258  );
259  } else {
260  rename(
261  $a_http_post_file['tmp_name'],
262  $savepath . "/" . $prefix . "_" . $filename
263  );
264  }
265 
266  if (is_file($savepath . "/" . $prefix . "_" . $filename)) {
267  $result = array(
268  "filename" => $prefix . "_" . $filename,
269  "fullname" => $savepath . "/" . $prefix . "_" . $filename,
270  "mimetype" => ilObjMediaObject::getMimeType($savepath . "/" . $prefix . "_" . $filename)
271  );
272  }
273  }
274  return $result;
275  }
getAbsoluteSubmissionPath()
Get submission path.
static getMimeType($a_file, $a_external=null)
get mime type for file
$result
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
$filename
Definition: buildRTE.php:89
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
static getValidFilename($a_filename)
Get valid filename.
+ Here is the call graph for this function:

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