ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilFSWebStorageExercise 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 ilFSWebStorageExercise:
+ Collaboration diagram for ilFSWebStorageExercise:

Public Member Functions

 __construct (int $a_container_id=0, int $a_ass_id=0)
 
 deleteUserSubmissionDirectory (int $user_id)
 
 getFiles ()
 Get assignment files. More...
 
 getAssignmentFilePath (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

 init ()
 
 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

ilLogger $log
 
int $ass_id
 
string $submissions_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
Jesús López lopez.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 23 of file class.ilFSWebStorageExercise.php.

Constructor & Destructor Documentation

◆ __construct()

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

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

References ILIAS\GlobalScreen\Provider\__construct(), and ilLoggerFactory\getLogger().

32  {
33  $this->ass_id = $a_ass_id;
34  $this->log = ilLoggerFactory::getLogger("exc");
35  $this->log->debug("ilFSWebStorageExercise construct with a_container_id = " . $a_container_id . " and ass_id =" . $a_ass_id);
36  parent::__construct(self::STORAGE_WEB, true, $a_container_id);
37  }
static getLogger(string $a_component_id)
Get component logger.
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ deleteUserSubmissionDirectory()

ilFSWebStorageExercise::deleteUserSubmissionDirectory ( int  $user_id)

Definition at line 66 of file class.ilFSWebStorageExercise.php.

Referenced by ilExerciseManagementGUI\removeUserSubmissionFilesFromWebDir().

68  : void {
69  $internal_dir = $this->submissions_path . "/" . $user_id;
70 
71  //remove first dot from (./data/client/ilExercise/3/exc_318/subm_21/6)
72  $internal_dir_without_dot = substr($internal_dir, 1);
73 
74  $absolute_path = ILIAS_ABSOLUTE_PATH . $internal_dir_without_dot;
75 
76  if (is_dir($absolute_path)) {
77  parent::deleteDirectory($absolute_path);
78  $this->log->debug("Removed = " . $absolute_path);
79  }
80  }
+ Here is the caller graph for this function:

◆ getAssignmentFilePath()

ilFSWebStorageExercise::getAssignmentFilePath ( string  $a_file)

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

References ilFileSystemAbstractionStorage\getAbsolutePath().

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

◆ getFiles()

ilFSWebStorageExercise::getFiles ( )

Get assignment files.

Exceptions
ilExcUnknownAssignmentTypeException

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

References ilFileSystemAbstractionStorage\$path, CLIENT_ID, ilFileSystemAbstractionStorage\getPath(), ILIAS_WEB_DIR, and ilArrayUtil\sortArray().

86  : array
87  {
88  $ass = new ilExAssignment($this->ass_id);
89  $files_order = $ass->getInstructionFilesOrder();
90  $files = array();
91 
92  $path = "./" . ILIAS_WEB_DIR . "/" . CLIENT_ID . "/" . $this->getPath();
93 
94  if (!is_dir($path)) {
95  return $files;
96  }
97 
98  $dp = opendir($path);
99  while ($file = readdir($dp)) {
100  if (!is_dir($path . '/' . $file)) {
101  $files[] = array(
102  'name' => $file,
103  'size' => filesize($path . '/' . $file),
104  'ctime' => filectime($path . '/' . $file),
105  'fullpath' => $path . '/' . $file,
106  'order' => $files_order[$file]["order_nr"] ?? 0
107  );
108  }
109  }
110  closedir($dp);
111  return ilArrayUtil::sortArray($files, "order", "asc", true);
112  }
Exercise assignment.
const CLIENT_ID
Definition: constants.php:41
const ILIAS_WEB_DIR
Definition: constants.php:45
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:

◆ getPathPostfix()

ilFSWebStorageExercise::getPathPostfix ( )
protected

Definition at line 55 of file class.ilFSWebStorageExercise.php.

55  : string
56  {
57  return 'exc';
58  }

◆ getPathPrefix()

ilFSWebStorageExercise::getPathPrefix ( )
protected

Definition at line 60 of file class.ilFSWebStorageExercise.php.

60  : string
61  {
62  return 'ilExercise';
63  }

◆ init()

ilFSWebStorageExercise::init ( )
protected

Definition at line 39 of file class.ilFSWebStorageExercise.php.

References $ass_id.

39  : bool
40  {
41  if (parent::init()) {
42  if ($this->ass_id > 0) {
43  $this->submissions_path = $this->path . "/subm_" . $this->ass_id;
44 
45  $this->log->debug("parent init() with ass_id =" . $this->ass_id);
46  $this->path .= "/ass_" . $this->ass_id;
47  }
48  } else {
49  $this->log->debug("no parent init() without ass_id");
50  return false;
51  }
52  return true;
53  }

◆ uploadAssignmentFiles()

ilFSWebStorageExercise::uploadAssignmentFiles ( array  $a_files)
Exceptions
ilException

Definition at line 123 of file class.ilFSWebStorageExercise.php.

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

125  : void {
126  if (is_array($a_files["name"])) {
127  foreach ($a_files["name"] as $k => $name) {
128  if ($name != "") {
129  $tmp_name = $a_files["tmp_name"][$k];
131  $tmp_name,
132  basename($name),
133  $this->getAbsolutePath() . DIRECTORY_SEPARATOR . basename($name),
134  false
135  );
136  }
137  }
138  }
139  }
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:

Field Documentation

◆ $ass_id

int ilFSWebStorageExercise::$ass_id
protected

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

Referenced by init().

◆ $log

ilLogger ilFSWebStorageExercise::$log
protected

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

◆ $submissions_path

string ilFSWebStorageExercise::$submissions_path
protected

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


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