ILIAS  release_8 Revision v8.24
ilAssFileUploadUploadsExporter Class Reference
+ Collaboration diagram for ilAssFileUploadUploadsExporter:

Public Member Functions

 __construct (ilDBInterface $db, ilLanguage $lng)
 
 getRefId ()
 
 setRefId ($refId)
 
 getTestId ()
 
 setTestId ($testId)
 
 getTestTitle ()
 
 setTestTitle ($testTitle)
 
 getQuestion ()
 
 setQuestion ($question)
 
 build ()
 
 getFinalZipFilePath ()
 
 getDispoZipFileName ()
 
 getZipFileMimeType ()
 

Data Fields

const ZIP_FILE_MIME_TYPE = 'application/zip'
 
const ZIP_FILE_EXTENSION = '.zip'
 

Protected Attributes

 $db
 
 $lng
 
 $refId
 

Private Member Functions

 initFilenames ()
 
 getFileUploadSolutionData ()
 
 getParticipantData ($solutionData)
 
 collectUploadedFiles ($solutionData, ilTestParticipantData $participantData)
 
 getPassSubDirName ($pass)
 
 createFileUploadCollectionZipFile ()
 
 removeFileUploadCollection ()
 

Private Attributes

 $testId
 
 $testTitle
 
 $question
 
 $finalZipFilePath
 
 $tempZipFilePath
 
 $tempDirPath
 
 $mainFolderName
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilAssFileUploadUploadsExporter::__construct ( ilDBInterface  $db,
ilLanguage  $lng 
)

Member Function Documentation

◆ build()

ilAssFileUploadUploadsExporter::build ( )

Definition at line 153 of file class.ilAssFileUploadUploadsExporter.php.

153 : void
154 {
155 $this->initFilenames();
156
157 $solutionData = $this->getFileUploadSolutionData();
158
159 $participantData = $this->getParticipantData($solutionData);
160
161 $this->collectUploadedFiles($solutionData, $participantData);
162
164
166 }
collectUploadedFiles($solutionData, ilTestParticipantData $participantData)

References collectUploadedFiles(), createFileUploadCollectionZipFile(), getFileUploadSolutionData(), getParticipantData(), initFilenames(), and removeFileUploadCollection().

+ Here is the call graph for this function:

◆ collectUploadedFiles()

ilAssFileUploadUploadsExporter::collectUploadedFiles (   $solutionData,
ilTestParticipantData  $participantData 
)
private

Definition at line 234 of file class.ilAssFileUploadUploadsExporter.php.

234 : void
235 {
236 foreach ($solutionData as $activeId => $passes) {
237 if (!in_array($activeId, $participantData->getActiveIds())) {
238 continue;
239 }
240
241 foreach ($passes as $pass => $files) {
242 foreach ($files as $file) {
243 $uploadedFileDir = $this->question->getFileUploadPath(
244 $this->getTestId(),
245 $activeId,
246 $this->question->getId()
247 );
248
249 // #20317
250 if (!is_file($uploadedFileDir . $file['value1'])) {
251 continue;
252 }
253
254 $destinationDir = $this->tempDirPath . '/' . $this->mainFolderName . '/';
255 $destinationDir .= $participantData->getFileSystemCompliantFullnameByActiveId($activeId) . '/';
256 $destinationDir .= $this->getPassSubDirName($file['pass']) . '/';
257
258 ilFileUtils::makeDirParents($destinationDir);
259
260 copy($uploadedFileDir . $file['value1'], $destinationDir . $file['value2']);
261 }
262 }
263 }
264 }
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.

References ilTestParticipantData\getActiveIds(), ilTestParticipantData\getFileSystemCompliantFullnameByActiveId(), getPassSubDirName(), getTestId(), and ilFileUtils\makeDirParents().

Referenced by build().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createFileUploadCollectionZipFile()

ilAssFileUploadUploadsExporter::createFileUploadCollectionZipFile ( )
private

Definition at line 271 of file class.ilAssFileUploadUploadsExporter.php.

271 : void
272 {
273 ilFileUtils::zip($this->tempDirPath . '/' . $this->mainFolderName, $this->tempZipFilePath);
274
275 $pathinfo = pathinfo($this->tempZipFilePath);
276 $this->finalZipFilePath = dirname($pathinfo['dirname']) . '/' . $pathinfo['basename'];
277
278 try {
279 ilFileUtils::rename($this->tempZipFilePath, $this->finalZipFilePath);
280 } catch (\ilFileUtilsException $e) {
281 \ilLoggerFactory::getRootLogger()->error($e->getMessage());
282 }
283 }
static zip(string $a_dir, string $a_file, bool $compress_content=false)
zips given directory/file into given zip.file
static rename(string $a_source, string $a_target)
static getRootLogger()
The unique root logger has a fixed error level.

References Vendor\Package\$e, ilLoggerFactory\getRootLogger(), ilFileUtils\rename(), and ilFileUtils\zip().

Referenced by build().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDispoZipFileName()

ilAssFileUploadUploadsExporter::getDispoZipFileName ( )

Definition at line 295 of file class.ilAssFileUploadUploadsExporter.php.

295 : string
296 {
298 $this->mainFolderName . self::ZIP_FILE_EXTENSION
299 );
300 }
static getASCIIFilename(string $a_filename)

References ilFileUtils\getASCIIFilename().

+ Here is the call graph for this function:

◆ getFileUploadSolutionData()

ilAssFileUploadUploadsExporter::getFileUploadSolutionData ( )
private

Definition at line 179 of file class.ilAssFileUploadUploadsExporter.php.

179 : array
180 {
181 $query = "
182 SELECT tst_solutions.solution_id, tst_solutions.pass, tst_solutions.active_fi, tst_solutions.question_fi,
183 tst_solutions.value1, tst_solutions.value2, tst_solutions.tstamp
184 FROM tst_solutions, tst_active, qpl_questions
185 WHERE tst_solutions.active_fi = tst_active.active_id
186 AND tst_solutions.question_fi = qpl_questions.question_id
187 AND tst_solutions.question_fi = %s
188 AND tst_active.test_fi = %s
189 ORDER BY tst_solutions.active_fi, tst_solutions.tstamp
190 ";
191
192 $res = $this->db->queryF(
193 $query,
194 array("integer", "integer"),
195 array($this->question->getId(), $this->getTestId())
196 );
197
198 $solutionData = array();
199
200 while ($row = $this->db->fetchAssoc($res)) {
201 if (!isset($solutionData[$row['active_fi']])) {
202 $solutionData[ $row['active_fi'] ] = array();
203 }
204
205 if (!isset($solutionData[ $row['active_fi'] ][ $row['pass'] ])) {
206 $solutionData[ $row['active_fi'] ][ $row['pass'] ] = array();
207 }
208
209 $solutionData[ $row['active_fi'] ][ $row['pass'] ][] = $row;
210 }
211
212 return $solutionData;
213 }
$res
Definition: ltiservices.php:69
$query

References $query, and $res.

Referenced by build().

+ Here is the caller graph for this function:

◆ getFinalZipFilePath()

ilAssFileUploadUploadsExporter::getFinalZipFilePath ( )

◆ getParticipantData()

ilAssFileUploadUploadsExporter::getParticipantData (   $solutionData)
private

Definition at line 215 of file class.ilAssFileUploadUploadsExporter.php.

216 {
217 $activeIds = array();
218
219 foreach ($solutionData as $activeId => $passes) {
220 $activeIds[] = $activeId;
221 }
222
223 require_once 'Modules/Test/classes/class.ilTestParticipantData.php';
224 $participantData = new ilTestParticipantData($this->db, $this->lng);
225 $participantData->setActiveIdsFilter($activeIds);
226 $participantData->setParticipantAccessFilter(
228 );
229 $participantData->load($this->getTestId());
230
231 return $participantData;
232 }

References ilTestParticipantAccessFilter\getAccessStatisticsUserFilter(), getRefId(), getTestId(), and ILIAS\Repository\lng().

Referenced by build().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPassSubDirName()

ilAssFileUploadUploadsExporter::getPassSubDirName (   $pass)
private

Definition at line 266 of file class.ilAssFileUploadUploadsExporter.php.

266 : string
267 {
268 return $this->lng->txt('pass') . '_' . ($pass + 1);
269 }

References ILIAS\Repository\lng().

Referenced by collectUploadedFiles().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getQuestion()

ilAssFileUploadUploadsExporter::getQuestion ( )
Returns
ilObjFileHandlingQuestionType

Definition at line 140 of file class.ilAssFileUploadUploadsExporter.php.

141 {
142 return $this->question;
143 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References $question.

◆ getRefId()

ilAssFileUploadUploadsExporter::getRefId ( )
Returns
int

Definition at line 92 of file class.ilAssFileUploadUploadsExporter.php.

References $refId.

Referenced by getParticipantData().

+ Here is the caller graph for this function:

◆ getTestId()

ilAssFileUploadUploadsExporter::getTestId ( )
Returns
int

Definition at line 108 of file class.ilAssFileUploadUploadsExporter.php.

References $testId.

Referenced by collectUploadedFiles(), and getParticipantData().

+ Here is the caller graph for this function:

◆ getTestTitle()

ilAssFileUploadUploadsExporter::getTestTitle ( )
Returns
string

Definition at line 124 of file class.ilAssFileUploadUploadsExporter.php.

References $testTitle.

Referenced by initFilenames().

+ Here is the caller graph for this function:

◆ getZipFileMimeType()

ilAssFileUploadUploadsExporter::getZipFileMimeType ( )

Definition at line 302 of file class.ilAssFileUploadUploadsExporter.php.

References ZIP_FILE_MIME_TYPE.

◆ initFilenames()

ilAssFileUploadUploadsExporter::initFilenames ( )
private

Definition at line 168 of file class.ilAssFileUploadUploadsExporter.php.

168 : void
169 {
170 $this->tempDirPath = ilFileUtils::ilTempnam();
171
172 $this->tempZipFilePath = ilFileUtils::ilTempnam($this->tempDirPath) . self::ZIP_FILE_EXTENSION;
173
174 $this->mainFolderName = ilFileUtils::getASCIIFilename(
175 str_replace(' ', '', $this->getTestTitle() . '_' . $this->question->getTitle())
176 );
177 }
static ilTempnam(?string $a_temp_path=null)
Returns a unique and non existing Path for e temporary file or directory.

References ilFileUtils\getASCIIFilename(), getTestTitle(), ilFileUtils\ilTempnam(), and ZIP_FILE_EXTENSION.

Referenced by build().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeFileUploadCollection()

ilAssFileUploadUploadsExporter::removeFileUploadCollection ( )
private

Definition at line 285 of file class.ilAssFileUploadUploadsExporter.php.

285 : void
286 {
287 ilFileUtils::delDir($this->tempDirPath);
288 }
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively

References ilFileUtils\delDir().

Referenced by build().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setQuestion()

ilAssFileUploadUploadsExporter::setQuestion (   $question)
Parameters
ilObjFileHandlingQuestionType$question

Definition at line 148 of file class.ilAssFileUploadUploadsExporter.php.

148 : void
149 {
150 $this->question = $question;
151 }

References $question.

◆ setRefId()

ilAssFileUploadUploadsExporter::setRefId (   $refId)
Parameters
int$refId

Definition at line 100 of file class.ilAssFileUploadUploadsExporter.php.

100 : void
101 {
102 $this->refId = $refId;
103 }

References $refId.

◆ setTestId()

ilAssFileUploadUploadsExporter::setTestId (   $testId)
Parameters
int$testId

Definition at line 116 of file class.ilAssFileUploadUploadsExporter.php.

116 : void
117 {
118 $this->testId = $testId;
119 }

References $testId.

◆ setTestTitle()

ilAssFileUploadUploadsExporter::setTestTitle (   $testTitle)
Parameters
string$testTitle

Definition at line 132 of file class.ilAssFileUploadUploadsExporter.php.

132 : void
133 {
134 $this->testTitle = $testTitle;
135 }

References $testTitle.

Field Documentation

◆ $db

ilAssFileUploadUploadsExporter::$db
protected

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

Referenced by __construct().

◆ $finalZipFilePath

ilAssFileUploadUploadsExporter::$finalZipFilePath
private

Definition at line 63 of file class.ilAssFileUploadUploadsExporter.php.

Referenced by getFinalZipFilePath().

◆ $lng

ilAssFileUploadUploadsExporter::$lng
protected

Definition at line 38 of file class.ilAssFileUploadUploadsExporter.php.

Referenced by __construct().

◆ $mainFolderName

ilAssFileUploadUploadsExporter::$mainFolderName
private

Definition at line 78 of file class.ilAssFileUploadUploadsExporter.php.

◆ $question

ilAssFileUploadUploadsExporter::$question
private

Definition at line 58 of file class.ilAssFileUploadUploadsExporter.php.

Referenced by getQuestion(), and setQuestion().

◆ $refId

ilAssFileUploadUploadsExporter::$refId
protected

Definition at line 43 of file class.ilAssFileUploadUploadsExporter.php.

Referenced by getRefId(), and setRefId().

◆ $tempDirPath

ilAssFileUploadUploadsExporter::$tempDirPath
private

Definition at line 73 of file class.ilAssFileUploadUploadsExporter.php.

◆ $tempZipFilePath

ilAssFileUploadUploadsExporter::$tempZipFilePath
private

Definition at line 68 of file class.ilAssFileUploadUploadsExporter.php.

◆ $testId

ilAssFileUploadUploadsExporter::$testId
private

Definition at line 48 of file class.ilAssFileUploadUploadsExporter.php.

Referenced by getTestId(), and setTestId().

◆ $testTitle

ilAssFileUploadUploadsExporter::$testTitle
private

Definition at line 53 of file class.ilAssFileUploadUploadsExporter.php.

Referenced by getTestTitle(), and setTestTitle().

◆ ZIP_FILE_EXTENSION

const ilAssFileUploadUploadsExporter::ZIP_FILE_EXTENSION = '.zip'

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

Referenced by initFilenames().

◆ ZIP_FILE_MIME_TYPE

const ilAssFileUploadUploadsExporter::ZIP_FILE_MIME_TYPE = 'application/zip'

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

Referenced by getZipFileMimeType().


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