ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilFSWebStorageExercise.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2017 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once('./Services/FileSystem/classes/class.ilFileSystemStorage.php');
13{
14 protected $log;
15 protected $ass_id;
16
22 public function __construct($a_container_id = 0, $a_ass_id = 0)
23 {
24 $this->ass_id = $a_ass_id;
25 $this->log = ilLoggerFactory::getLogger("exc");
26 $this->log->debug("ilFSWebStorageExercise construct with a_container_id = " . $a_container_id . " and ass_id =" . $a_ass_id);
27 parent::__construct(self::STORAGE_WEB, true, $a_container_id);
28 }
29
33 public function init()
34 {
35 if (parent::init()) {
36 if ($this->ass_id > 0) {
37 $this->log->debug("parent init() with ass_id =" . $this->ass_id);
38 $this->path .= "/ass_" . $this->ass_id;
39 }
40 } else {
41 $this->log->debug("no parent init() without ass_id");
42 return false;
43 }
44 return true;
45 }
46
47
54 protected function getPathPostfix()
55 {
56 return 'exc';
57 }
58
65 protected function getPathPrefix()
66 {
67 return 'ilExercise';
68 }
69
76 public function create()
77 {
78 $this->log->debug("parent create");
79
80 parent::create();
81
82 return true;
83 }
84
88 public function getFiles()
89 {
90 require_once "./Modules/Exercise/classes/class.ilExAssignment.php";
91
92 $ass = new ilExAssignment($this->ass_id);
93 $files_order = $ass->getInstructionFilesOrder();
94
95 $files = array();
96 if (!is_dir($this->path)) {
97 return $files;
98 }
99
100 $dp = opendir($this->path);
101 while ($file = readdir($dp)) {
102 if (!is_dir($this->path . '/' . $file)) {
103 $files[] = array(
104 'name' => $file,
105 'size' => filesize($this->path . '/' . $file),
106 'ctime' => filectime($this->path . '/' . $file),
107 'fullpath' => $this->path . '/' . $file,
108 'order' => $files_order[$file]["order_nr"] ? $files_order[$file]["order_nr"] : 0
109 );
110 }
111 }
112 closedir($dp);
113 $files = ilUtil::sortArray($files, "order", "asc", true);
114 return $files;
115 }
116
120 public function getAssignmentFilePath($a_file)
121 {
122 return $this->getAbsolutePath() . "/" . $a_file;
123 }
124
130 public function uploadAssignmentFiles($a_files)
131 {
132 if (is_array($a_files["name"])) {
133 foreach ($a_files["name"] as $k => $name) {
134 if ($name != "") {
135 $type = $a_files["type"][$k];
136 $tmp_name = $a_files["tmp_name"][$k];
137 $size = $a_files["size"][$k];
138 ilUtil::moveUploadedFile(
139 $tmp_name,
140 basename($name),
141 $this->path . DIRECTORY_SEPARATOR . basename($name),
142 false
143 );
144 }
145 }
146 }
147 }
148}
$size
Definition: RandomTest.php:84
while(count($oldTaskList) > 0) foreach(array_keys( $newTaskList) as $task) init()
Definition: build.php:77
An exception for terminatinating execution or to throw for unit testing.
Exercise assignment.
__construct($a_container_id=0, $a_ass_id=0)
Constructor.
init()
Append ass_<ass_id> to path (assignment id)
getPathPrefix()
Implementation of abstract method.
uploadAssignmentFiles($a_files)
Upload assignment files (e.g.
getAssignmentFilePath($a_file)
Get path for assignment file.
getPathPostfix()
Implementation of abstract method.
getAbsolutePath()
Get absolute path of storage directory.
static getLogger($a_component_id)
Get component logger.
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
$files
Definition: metarefresh.php:49
$type