ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilIndividualAssessmentFileStorage Class Reference

Handles the file upload and folder creation for files uploaded in grading form. More...

+ Inheritance diagram for ilIndividualAssessmentFileStorage:
+ Collaboration diagram for ilIndividualAssessmentFileStorage:

Public Member Functions

 setUserId (int $user_id)
 Set the user id for an extra folder of each participant in the IA. More...
 
 create ()
 creates the folder structure More...
 
 getAbsolutePath ()
 Get the absolute path for files. More...
 
 readDir ()
 Read the dir. More...
 
 uploadFile (UploadResult $file)
 Upload the file. More...
 
 deleteAllFilesBut (?string $filename)
 Delete the existing file. More...
 
- 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 ()
 
- Public Member Functions inherited from IndividualAssessmentFileStorage
 deleteAllFilesBut (string $file)
 

Static Public Member Functions

static getInstance (int $container_id=0)
 
- 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

const PATH_POSTFIX = "iass"
 
const PATH_PREFIX = "IASS"
 
- Data Fields inherited from ilFileSystemAbstractionStorage
const STORAGE_WEB = 1
 
const STORAGE_DATA = 2
 
const STORAGE_SECURED = 3
 

Protected Member Functions

 getPathPostfix ()
 part of the folder structure in ILIAS webdir. More...
 
 getPathPrefix ()
 part of the folder structure in ILIAS webdir. More...
 
- 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 $user_id = null
 
- Protected Attributes inherited from ilFileSystemAbstractionStorage
string $path = null
 
ILIAS Filesystem Filesystems $file_system_service
 

Detailed Description

Handles the file upload and folder creation for files uploaded in grading form.

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

Member Function Documentation

◆ create()

ilIndividualAssessmentFileStorage::create ( )

creates the folder structure

Implements IndividualAssessmentFileStorage.

Definition at line 65 of file class.ilIndividualAssessmentFileStorage.php.

References getAbsolutePath(), and ilFileUtils\makeDirParents().

Referenced by readDir().

65  : void
66  {
67  if (!file_exists($this->getAbsolutePath())) {
69  }
70  }
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:

◆ deleteAllFilesBut()

ilIndividualAssessmentFileStorage::deleteAllFilesBut ( ?string  $filename)

Delete the existing file.

Definition at line 131 of file class.ilIndividualAssessmentFileStorage.php.

References ilFileSystemAbstractionStorage\deleteFile(), getAbsolutePath(), and readDir().

131  : void
132  {
133  $files = $this->readDir();
134  foreach ($files as $file) {
135  if ($file === $filename) {
136  continue;
137  }
138  $this->deleteFile($this->getAbsolutePath() . "/" . $file);
139  }
140  }
$filename
Definition: buildRTE.php:78
+ Here is the call graph for this function:

◆ getAbsolutePath()

ilIndividualAssessmentFileStorage::getAbsolutePath ( )

Get the absolute path for files.

Definition at line 75 of file class.ilIndividualAssessmentFileStorage.php.

References ilFileSystemAbstractionStorage\$path, and $user_id.

Referenced by create(), deleteAllFilesBut(), readDir(), and uploadFile().

75  : string
76  {
77  $path = parent::getAbsolutePath();
78 
79  if ($this->user_id) {
80  $path .= "/user_" . $this->user_id;
81  }
82 
83  return $path;
84  }
+ Here is the caller graph for this function:

◆ getInstance()

static ilIndividualAssessmentFileStorage::getInstance ( int  $container_id = 0)
static

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

References ilFileSystemAbstractionStorage\$container_id.

Referenced by ilObjIndividualAssessment\getFileStorage().

34  {
35  return new self(self::STORAGE_WEB, true, $container_id);
36  }
Handles the file upload and folder creation for files uploaded in grading form.
+ Here is the caller graph for this function:

◆ getPathPostfix()

ilIndividualAssessmentFileStorage::getPathPostfix ( )
protected

part of the folder structure in ILIAS webdir.

Definition at line 41 of file class.ilIndividualAssessmentFileStorage.php.

41  : string
42  {
43  return self::PATH_POSTFIX;
44  }

◆ getPathPrefix()

ilIndividualAssessmentFileStorage::getPathPrefix ( )
protected

part of the folder structure in ILIAS webdir.

Definition at line 49 of file class.ilIndividualAssessmentFileStorage.php.

49  : string
50  {
51  return self::PATH_PREFIX;
52  }

◆ readDir()

ilIndividualAssessmentFileStorage::readDir ( )

Read the dir.

Returns
string[]

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

References create(), and getAbsolutePath().

Referenced by deleteAllFilesBut().

91  : array
92  {
93  if (!is_dir($this->getAbsolutePath())) {
94  $this->create();
95  }
96 
97  $fh = opendir($this->getAbsolutePath());
98  $files = array();
99  while ($file = readdir($fh)) {
100  if ($file != "." && $file != ".." && !is_dir($this->getAbsolutePath() . "/" . $file)) {
101  $files[] = $file;
102  }
103  }
104  closedir($fh);
105 
106  return $files;
107  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setUserId()

ilIndividualAssessmentFileStorage::setUserId ( int  $user_id)

Set the user id for an extra folder of each participant in the IA.

Implements IndividualAssessmentFileStorage.

Definition at line 57 of file class.ilIndividualAssessmentFileStorage.php.

References $user_id.

57  : void
58  {
59  $this->user_id = $user_id;
60  }

◆ uploadFile()

ilIndividualAssessmentFileStorage::uploadFile ( UploadResult  $file)

Upload the file.

Implements IndividualAssessmentFileStorage.

Definition at line 112 of file class.ilIndividualAssessmentFileStorage.php.

References ilFileSystemAbstractionStorage\$path, getAbsolutePath(), ILIAS\FileUpload\DTO\UploadResult\getName(), ILIAS\FileUpload\DTO\UploadResult\getPath(), ilFileUtils\getValidFilename(), and ilFileUtils\moveUploadedFile().

112  : string
113  {
114  $path = $this->getAbsolutePath();
115 
116  $clean_name = ilFileUtils::getValidFilename($file->getName());
117  $new_file = $path . "/" . $clean_name;
118 
120  $file->getPath(),
121  $clean_name, // This parameter does not do a thing
122  $new_file
123  );
124 
125  return $clean_name;
126  }
static getValidFilename(string $a_filename)
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file
+ Here is the call graph for this function:

Field Documentation

◆ $user_id

int ilIndividualAssessmentFileStorage::$user_id = null
protected

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

Referenced by getAbsolutePath(), and setUserId().

◆ PATH_POSTFIX

const ilIndividualAssessmentFileStorage::PATH_POSTFIX = "iass"

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

◆ PATH_PREFIX

const ilIndividualAssessmentFileStorage::PATH_PREFIX = "IASS"

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


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