ILIAS  release_8 Revision v8.24
class.ilFSWebStorageExercise.php
Go to the documentation of this file.
1<?php
2
24{
25 protected ilLogger $log;
26 protected int $ass_id;
27 protected string $submissions_path;
28
29 public function __construct(
30 int $a_container_id = 0,
31 int $a_ass_id = 0
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 }
38
39 protected function init(): 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 }
54
55 protected function getPathPostfix(): string
56 {
57 return 'exc';
58 }
59
60 protected function getPathPrefix(): string
61 {
62 return 'ilExercise';
63 }
64
65
67 int $user_id
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 }
81
86 public function getFiles(): 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 }
113
114 public function getAssignmentFilePath(
115 string $a_file
116 ): string {
117 return $this->getAbsolutePath() . "/" . $a_file;
118 }
119
123 public function uploadAssignmentFiles(
124 array $a_files
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 }
140}
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
Exercise assignment.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(int $a_container_id=0, int $a_ass_id=0)
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file
static getLogger(string $a_component_id)
Get component logger.
Component logger with individual log levels by component id.
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: confirmReg.php:20
const CLIENT_ID
Definition: constants.php:41
const ILIAS_WEB_DIR
Definition: constants.php:45
return['3gp', '7z', 'ai', 'aif', 'aifc', 'aiff', 'au', 'arw', 'avi', 'backup', 'bak', 'bas', 'bpmn', 'bpmn2', 'bmp', 'bib', 'bibtex', 'bz', 'bz2', 'c', 'c++', 'cc', 'cct', 'cdf', 'cer', 'class', 'cls', 'conf', 'cpp', 'crt', 'crs', 'crw', 'cr2', 'css', 'cst', 'csv', 'cur', 'db', 'dcr', 'des', 'dng', 'doc', 'docx', 'dot', 'dotx', 'dtd', 'dvi', 'el', 'eps', 'epub', 'f', 'f77', 'f90', 'flv', 'for', 'g3', 'gif', 'gl', 'gan', 'ggb', 'gsd', 'gsm', 'gtar', 'gz', 'gzip', 'h', 'hpp', 'htm', 'html', 'htmls', 'ibooks', 'ico', 'ics', 'ini', 'ipynb', 'java', 'jbf', 'jpeg', 'jpg', 'js', 'jsf', 'jso', 'json', 'latex', 'lang', 'less', 'log', 'lsp', 'ltx', 'm1v', 'm2a', 'm2v', 'm3u', 'm4a', 'm4v', 'markdown', 'm', 'mat', 'md', 'mdl', 'mdown', 'mid', 'min', 'midi', 'mobi', 'mod', 'mov', 'movie', 'mp2', 'mp3', 'mp4', 'mpa', 'mpeg', 'mpg', 'mph', 'mpga', 'mpp', 'mpt', 'mpv', 'mpx', 'mv', 'mw', 'mv4', 'nb', 'nbp', 'nef', 'nif', 'niff', 'obj', 'obm', 'odt', 'ods', 'odp', 'odg', 'odf', 'oga', 'ogg', 'ogv', 'old', 'p', 'pas', 'pbm', 'pcl', 'pct', 'pcx', 'pdf', 'pgm', 'pic', 'pict', 'png', 'por', 'pov', 'project', 'properties', 'ppa', 'ppm', 'pps', 'ppsx', 'ppt', 'pptx', 'ppz', 'ps', 'psd', 'pwz', 'qt', 'qtc', 'qti', 'qtif', 'r', 'ra', 'ram', 'rar', 'rast', 'rda', 'rev', 'rexx', 'ris', 'rf', 'rgb', 'rm', 'rmd', 'rmi', 'rmm', 'rmp', 'rt', 'rtf', 'rtx', 'rv', 's', 's3m', 'sav', 'sbs', 'sec', 'sdml', 'sgm', 'sgml', 'smi', 'smil', 'srt', 'sps', 'spv', 'stl', 'svg', 'swa', 'swf', 'swz', 'tar', 'tex', 'texi', 'texinfo', 'text', 'tgz', 'tif', 'tiff', 'ttf', 'txt', 'tmp', 'uvproj', 'vdf', 'vimeo', 'viv', 'vivo', 'vrml', 'vsdx', 'wav', 'webm', 'wmv', 'wmx', 'wmz', 'woff', 'wwd', 'xhtml', 'xif', 'xls', 'xlsx', 'xmind', 'xml', 'xsl', 'xsd', 'zip']
$path
Definition: ltiservices.php:32
if($format !==null) $name
Definition: metadata.php:247
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc