ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilAssFileUploadUploadsExporter Class Reference
+ Collaboration diagram for ilAssFileUploadUploadsExporter:

Public Member Functions

 __construct (private ilDBInterface $db, private ilLanguage $lng, private int $ref_id, private int $test_id,)
 
 getRefId ()
 
 getTestId ()
 
 getTestTitle ()
 
 setTestTitle (string $test_title)
 
 getQuestion ()
 
 setQuestion ($question)
 
 buildAndDownload ()
 
 getFinalZipFilePath ()
 
 getDispoZipFileName ()
 
 getZipFileMimeType ()
 

Data Fields

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

Private Member Functions

 initFilenames ()
 
 getFileUploadSolutionData ()
 
 getParticipantData ($solutionData)
 
 collectUploadedFiles (array $solution_data, ilTestParticipantData $participant_data)
 
 getPassSubDirName ($pass)
 
 createFileUploadCollectionZipFile ()
 

Private Attributes

Closure $access_filter
 
ILIAS ResourceStorage Services $irss
 
ILIAS Filesystem Util Archive Archives $archive
 
ILIAS FileDelivery Services $file_delivery
 
 $test_title
 
 $question
 
 $finalZipFilePath
 
 $tempZipFilePath
 
 $tempDirPath
 
 $mainFolderName
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilAssFileUploadUploadsExporter::__construct ( private ilDBInterface  $db,
private ilLanguage  $lng,
private int  $ref_id,
private int  $test_id 
)
Parameters
ilDBInterface$db

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

74 {
75 global $DIC;
77 $this->access_filter = $f->getAccessStatisticsUserFilter($this->ref_id);
78
79 $this->irss = $DIC->resourceStorage();
80 $this->archive = $DIC->archives();
81 $this->file_delivery = $DIC->fileDelivery();
82 }
global $DIC
Definition: shib_login.php:26

References $DIC, and Vendor\Package\$f.

Member Function Documentation

◆ buildAndDownload()

ilAssFileUploadUploadsExporter::buildAndDownload ( )

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

126 : void
127 {
128 $solution_data = $this->getFileUploadSolutionData();
129
130 $participant_data = $this->getParticipantData($solution_data);
131
132 $this->collectUploadedFiles($solution_data, $participant_data);
133 }
collectUploadedFiles(array $solution_data, ilTestParticipantData $participant_data)

References collectUploadedFiles(), getFileUploadSolutionData(), and getParticipantData().

+ Here is the call graph for this function:

◆ collectUploadedFiles()

ilAssFileUploadUploadsExporter::collectUploadedFiles ( array  $solution_data,
ilTestParticipantData  $participant_data 
)
private

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

198 : void
199 {
200 $streams = [];
201
202 foreach ($solution_data as $activeId => $passes) {
203 if (!in_array($activeId, $participant_data->getActiveIds(), true)) {
204 continue;
205 }
206
207 foreach ($passes as $pass => $files) {
208 foreach ($files as $file) {
209 // path inside zip
211 $dir .= $participant_data->getFileSystemCompliantFullnameByActiveId($activeId) . '/';
212 $dir .= $this->getPassSubDirName($file['pass']) . '/';
213
214 // IRSS Version
215 if ($file['value2'] === 'rid') {
216 $revision = $this->irss->manage()->getCurrentRevision(
217 $rid = $this->irss->manage()->find($file['value1'])
218 );
219 $streams[$dir . $revision->getTitle()] = $this->irss->consume()->stream($rid)->getStream();
220 continue;
221 }
222
223 // Legacy Version
224 $file_dir = $this->question->getFileUploadPath(
225 $this->getTestId(),
226 $activeId,
227 $this->question->getId()
228 );
229
230 $legacy_file_path = $file_dir . $file['value1'];
231 if (!is_file($legacy_file_path)) {
232 continue;
233 }
234
235 $streams[$dir . $file['value2']] = Streams::ofResource(fopen($legacy_file_path, 'rb'));
236 }
237 }
238 }
239
240 $zip = $this->archive->zip($streams);
241
242 $this->file_delivery->delivery()->attached(
243 $zip->get(),
244 $this->getDispoZipFileName(),
245 'application/zip'
246 );
247 }

References $mainFolderName, ilTestParticipantData\getActiveIds(), ilTestParticipantData\getFileSystemCompliantFullnameByActiveId(), getPassSubDirName(), and getTestId().

Referenced by buildAndDownload().

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

◆ createFileUploadCollectionZipFile()

ilAssFileUploadUploadsExporter::createFileUploadCollectionZipFile ( )
private

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

254 : void
255 {
256 ilFileUtils::zip($this->tempDirPath . '/' . $this->mainFolderName, $this->tempZipFilePath);
257
258 $pathinfo = pathinfo($this->tempZipFilePath);
259 $this->finalZipFilePath = dirname($pathinfo['dirname']) . '/' . $pathinfo['basename'];
260
261 try {
262 ilFileUtils::rename($this->tempZipFilePath, $this->finalZipFilePath);
263 } catch (\ilFileUtilsException $e) {
264 \ilLoggerFactory::getRootLogger()->error($e->getMessage());
265 }
266 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static zip(string $a_dir, string $a_file, bool $compress_content=false)
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().

+ Here is the call graph for this function:

◆ getDispoZipFileName()

ilAssFileUploadUploadsExporter::getDispoZipFileName ( )

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

273 : string
274 {
276 $this->test_title . '_' . $this->question->getTitle() . self::ZIP_FILE_EXTENSION
277 );
278 }
static getASCIIFilename(string $a_filename)

References ilFileUtils\getASCIIFilename().

+ Here is the call graph for this function:

◆ getFileUploadSolutionData()

ilAssFileUploadUploadsExporter::getFileUploadSolutionData ( )
private

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

146 : array
147 {
148 $query = "
149 SELECT tst_solutions.solution_id, tst_solutions.pass, tst_solutions.active_fi, tst_solutions.question_fi,
150 tst_solutions.value1, tst_solutions.value2, tst_solutions.tstamp
151 FROM tst_solutions, tst_active, qpl_questions
152 WHERE tst_solutions.active_fi = tst_active.active_id
153 AND tst_solutions.question_fi = qpl_questions.question_id
154 AND tst_solutions.question_fi = %s
155 AND tst_active.test_fi = %s
156 ORDER BY tst_solutions.active_fi, tst_solutions.tstamp
157 ";
158
159 $res = $this->db->queryF(
160 $query,
161 ["integer", "integer"],
162 [$this->question->getId(), $this->getTestId()]
163 );
164
165 $solutionData = [];
166
167 while ($row = $this->db->fetchAssoc($res)) {
168 if (!isset($solutionData[$row['active_fi']])) {
169 $solutionData[ $row['active_fi'] ] = [];
170 }
171
172 if (!isset($solutionData[ $row['active_fi'] ][ $row['pass'] ])) {
173 $solutionData[ $row['active_fi'] ][ $row['pass'] ] = [];
174 }
175
176 $solutionData[ $row['active_fi'] ][ $row['pass'] ][] = $row;
177 }
178
179 return $solutionData;
180 }
$res
Definition: ltiservices.php:69

References $res.

Referenced by buildAndDownload().

+ Here is the caller graph for this function:

◆ getFinalZipFilePath()

ilAssFileUploadUploadsExporter::getFinalZipFilePath ( )

◆ getParticipantData()

ilAssFileUploadUploadsExporter::getParticipantData (   $solutionData)
private

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

183 {
184 $activeIds = [];
185
186 foreach ($solutionData as $activeId => $passes) {
187 $activeIds[] = $activeId;
188 }
189
190 $participantData = new ilTestParticipantData($this->db, $this->lng);
191 $participantData->setActiveIdsFilter($activeIds);
192 $participantData->setParticipantAccessFilter($this->access_filter);
193 $participantData->load($this->getTestId());
194
195 return $participantData;
196 }

References getTestId(), and ILIAS\Repository\lng().

Referenced by buildAndDownload().

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

◆ getPassSubDirName()

ilAssFileUploadUploadsExporter::getPassSubDirName (   $pass)
private

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

249 : string
250 {
251 return $this->lng->txt('pass') . '_' . ($pass + 1);
252 }

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 113 of file class.ilAssFileUploadUploadsExporter.php.

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

References $question.

◆ getRefId()

ilAssFileUploadUploadsExporter::getRefId ( )

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

84 : int
85 {
86 return $this->ref_id;
87 }
$ref_id
Definition: ltiauth.php:66

References $ref_id.

◆ getTestId()

ilAssFileUploadUploadsExporter::getTestId ( )

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

90 : int
91 {
92 return $this->test_id;
93 }

Referenced by collectUploadedFiles(), and getParticipantData().

+ Here is the caller graph for this function:

◆ getTestTitle()

ilAssFileUploadUploadsExporter::getTestTitle ( )
Returns
string

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

References $test_title.

Referenced by initFilenames().

+ Here is the caller graph for this function:

◆ getZipFileMimeType()

ilAssFileUploadUploadsExporter::getZipFileMimeType ( )

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

References ZIP_FILE_MIME_TYPE.

◆ initFilenames()

ilAssFileUploadUploadsExporter::initFilenames ( )
private

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

135 : void
136 {
137 $this->tempDirPath = ilFileUtils::ilTempnam();
138
139 $this->tempZipFilePath = ilFileUtils::ilTempnam($this->tempDirPath) . self::ZIP_FILE_EXTENSION;
140
141 $this->mainFolderName = ilFileUtils::getASCIIFilename(
142 str_replace(' ', '', $this->getTestTitle() . '_' . $this->question->getTitle())
143 );
144 }
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.

+ Here is the call graph for this function:

◆ setQuestion()

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

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

121 : void
122 {
123 $this->question = $question;
124 }

References $question.

◆ setTestTitle()

ilAssFileUploadUploadsExporter::setTestTitle ( string  $test_title)

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

105 : void
106 {
107 $this->test_title = $test_title;
108 }

References $test_title.

Field Documentation

◆ $access_filter

Closure ilAssFileUploadUploadsExporter::$access_filter
private

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

◆ $archive

ILIAS Filesystem Util Archive Archives ilAssFileUploadUploadsExporter::$archive
private

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

◆ $file_delivery

ILIAS FileDelivery Services ilAssFileUploadUploadsExporter::$file_delivery
private

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

◆ $finalZipFilePath

ilAssFileUploadUploadsExporter::$finalZipFilePath
private

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

Referenced by getFinalZipFilePath().

◆ $irss

ILIAS ResourceStorage Services ilAssFileUploadUploadsExporter::$irss
private

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

◆ $mainFolderName

ilAssFileUploadUploadsExporter::$mainFolderName
private

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

Referenced by collectUploadedFiles().

◆ $question

ilAssFileUploadUploadsExporter::$question
private

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

Referenced by getQuestion(), and setQuestion().

◆ $tempDirPath

ilAssFileUploadUploadsExporter::$tempDirPath
private

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

◆ $tempZipFilePath

ilAssFileUploadUploadsExporter::$tempZipFilePath
private

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

◆ $test_title

ilAssFileUploadUploadsExporter::$test_title
private

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

Referenced by getTestTitle(), and setTestTitle().

◆ ZIP_FILE_EXTENSION

const ilAssFileUploadUploadsExporter::ZIP_FILE_EXTENSION = '.zip'

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

Referenced by initFilenames().

◆ ZIP_FILE_MIME_TYPE

const ilAssFileUploadUploadsExporter::ZIP_FILE_MIME_TYPE = 'application/zip'

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

Referenced by getZipFileMimeType().


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