ILIAS  release_4-4 Revision
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...
 
 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...
 
- 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...
 
 _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 FACTOR = 100
 
const MAX_EXPONENT = 3
 
- 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 299 of file class.ilFSStorageExercise.php.

References getFeedbackFiles().

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

◆ create()

ilFSStorageExercise::create ( )

Create directory.

public

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

References ilUtil\makeDirParents().

Referenced by ilExAssignment\cloneAssignmentsOfExercise(), deliverFile(), ilExerciseXMLParser\ilExerciseXMLParser(), and ilExerciseDataSet\importRecord().

152  {
153  parent::create();
154  if(!file_exists($this->submission_path))
155  {
156  ilUtil::makeDirParents($this->submission_path);
157  }
158  if(!file_exists($this->tmp_path))
159  {
160  ilUtil::makeDirParents($this->tmp_path);
161  }
162  if(!file_exists($this->feedb_path))
163  {
164  ilUtil::makeDirParents($this->feedb_path);
165  }
166  return true;
167  }
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:

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

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

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

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

◆ getAbsoluteSubmissionPath()

ilFSStorageExercise::getAbsoluteSubmissionPath ( )

Get submission path.

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

Referenced by deliverFile().

95  {
96  return $this->submission_path;
97  }
+ Here is the caller graph for this function:

◆ getAssignmentFilePath()

ilFSStorageExercise::getAssignmentFilePath (   $a_file)

Get path for assignment file.

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

References ilFileSystemStorage\getAbsolutePath().

309  {
310  return $this->getAbsolutePath()."/".$a_file;
311  }
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 316 of file class.ilFSStorageExercise.php.

References getFeedbackPath().

317  {
318  $dir = $this->getFeedbackPath($a_user_id);
319  return $dir."/".$a_file;
320  }
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 276 of file class.ilFSStorageExercise.php.

References $file, and getFeedbackPath().

Referenced by countFeedbackFiles().

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

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

Referenced by getFeedbackFilePath(), and getFeedbackFiles().

111  {
112  $path = $this->feedb_path."/".$a_user_id;
113  if(!file_exists($path))
114  {
116  }
117  return $path;
118  }
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 172 of file class.ilFSStorageExercise.php.

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

173  {
174  $files = array();
175  if (!is_dir($this->path))
176  {
177  return $files;
178  }
179 
180  $dp = opendir($this->path);
181  while($file = readdir($dp))
182  {
183  if(!is_dir($this->path.'/'.$file))
184  {
185  $files[] = array(
186  'name' => $file,
187  'size' => filesize($this->path.'/'.$file),
188  'ctime' => ilFormat::formatDate(date('Y-m-d H:i:s',filectime($this->path.'/'.$file))),
189  'fullpath' => $this->path.'/'.$file);
190  }
191  }
192  closedir($dp);
193  $files = ilUtil::sortArray($files, "name", "asc");
194  return $files;
195  }
print $file
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
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 public ...
+ Here is the call graph for this function:

◆ getGlobalFeedbackPath()

ilFSStorageExercise::getGlobalFeedbackPath ( )

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

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

121  {
122  $path = $this->feedb_path."/0";
123  if(!file_exists($path))
124  {
126  }
127  return $path;
128  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
+ 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 134 of file class.ilFSStorageExercise.php.

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

135  {
136  $path = $this->multi_feedback_upload_path."/".$a_user_id;
137  if(!file_exists($path))
138  {
140  }
141  return $path;
142  }
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 75 of file class.ilFSStorageExercise.php.

76  {
77  return 'exc';
78  }

◆ getPathPrefix()

ilFSStorageExercise::getPathPrefix ( )
protected

Implementation of abstract method.

protected

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

87  {
88  return 'ilExercise';
89  }

◆ getTempPath()

ilFSStorageExercise::getTempPath ( )

Get submission path.

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

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

◆ init()

ilFSStorageExercise::init ( )

Append ass_<ass_id> to path (assignment id)

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->path.= "/ass_".$this->ass_id;
59  }
60  }
61  else
62  {
63  return false;
64  }
65  return true;
66  }

◆ uploadAssignmentFiles()

ilFSStorageExercise::uploadAssignmentFiles (   $a_files)

Upload assignment files (e.g.

from assignment creation form)

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

References $size, and ilUtil\moveUploadedFile().

327  {
328  if (is_array($a_files["name"]))
329  {
330  foreach ($a_files["name"] as $k => $name)
331  {
332  if ($name != "")
333  {
334  $type = $a_files["type"][$k];
335  $tmp_name = $a_files["tmp_name"][$k];
336  $size = $a_files["size"][$k];
337  ilUtil::moveUploadedFile($tmp_name,
338  basename($name),
339  $this->path.DIRECTORY_SEPARATOR.basename($name),
340  false);
341  }
342  }
343  }
344  }
$size
Definition: RandomTest.php:79
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:

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