ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 11 of file class.ilAssFileUploadUploadsExporter.php.

Constructor & Destructor Documentation

◆ __construct()

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

Member Function Documentation

◆ build()

ilAssFileUploadUploadsExporter::build ( )
Returns
string

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

143 {
144 $this->initFilenames();
145
146 $solutionData = $this->getFileUploadSolutionData();
147
148 $participantData = $this->getParticipantData($solutionData);
149
150 $this->collectUploadedFiles($solutionData, $participantData);
151
153
155 }
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 223 of file class.ilAssFileUploadUploadsExporter.php.

224 {
225 foreach ($solutionData as $activeId => $passes) {
226 if (!in_array($activeId, $participantData->getActiveIds())) {
227 continue;
228 }
229
230 foreach ($passes as $pass => $files) {
231 foreach ($files as $file) {
232 $uploadedFileDir = $this->question->getFileUploadPath(
233 $this->getTestId(),
234 $activeId,
235 $this->question->getId()
236 );
237
238 // #20317
239 if (!is_file($uploadedFileDir . $file['value1'])) {
240 continue;
241 }
242
243 $destinationDir = $this->tempDirPath . '/' . $this->mainFolderName . '/';
244 $destinationDir .= $participantData->getFileSystemCompliantFullnameByActiveId($activeId) . '/';
245 $destinationDir .= $this->getPassSubDirName($file['pass']) . '/';
246
247 ilUtil::makeDirParents($destinationDir);
248
249 copy($uploadedFileDir . $file['value1'], $destinationDir . $file['value2']);
250 }
251 }
252 }
253 }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
$files
Definition: metarefresh.php:49

References $files, $pass, ilTestParticipantData\getActiveIds(), ilTestParticipantData\getFileSystemCompliantFullnameByActiveId(), getPassSubDirName(), getTestId(), and ilUtil\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 260 of file class.ilAssFileUploadUploadsExporter.php.

261 {
262 ilUtil::zip($this->tempDirPath . '/' . $this->mainFolderName, $this->tempZipFilePath);
263
264 $pathinfo = pathinfo($this->tempZipFilePath);
265 $this->finalZipFilePath = dirname($pathinfo['dirname']) . '/' . $pathinfo['basename'];
266
267 try {
268 require_once 'Services/Utilities/classes/class.ilFileUtils.php';
269 ilFileUtils::rename($this->tempZipFilePath, $this->finalZipFilePath);
270 } catch (\ilFileUtilsException $e) {
271 \ilLoggerFactory::getRootLogger()->error($e->getMessage());
272 }
273 }
Class to report exception.
static rename($a_source, $a_target)
Rename a file.
static getRootLogger()
The unique root logger has a fixed error level.
static zip($a_dir, $a_file, $compress_content=false)
zips given directory/file into given zip.file

References ilLoggerFactory\getRootLogger(), ilFileUtils\rename(), and ilUtil\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 285 of file class.ilAssFileUploadUploadsExporter.php.

286 {
288 $this->mainFolderName . self::ZIP_FILE_EXTENSION
289 );
290 }
static getASCIIFilename($a_filename)
convert utf8 to ascii filename

References ilUtil\getASCIIFilename().

+ Here is the call graph for this function:

◆ getFileUploadSolutionData()

ilAssFileUploadUploadsExporter::getFileUploadSolutionData ( )
private

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

169 {
170 $query = "
171 SELECT tst_solutions.solution_id, tst_solutions.pass, tst_solutions.active_fi, tst_solutions.question_fi,
172 tst_solutions.value1, tst_solutions.value2, tst_solutions.tstamp
173 FROM tst_solutions, tst_active, qpl_questions
174 WHERE tst_solutions.active_fi = tst_active.active_id
175 AND tst_solutions.question_fi = qpl_questions.question_id
176 AND tst_solutions.question_fi = %s
177 AND tst_active.test_fi = %s
178 ORDER BY tst_solutions.active_fi, tst_solutions.tstamp
179 ";
180
181 $res = $this->db->queryF(
182 $query,
183 array("integer", "integer"),
184 array($this->question->getId(), $this->getTestId())
185 );
186
187 $solutionData = array();
188
189 while ($row = $this->db->fetchAssoc($res)) {
190 if (!isset($solutionData[$row['active_fi']])) {
191 $solutionData[ $row['active_fi'] ] = array();
192 }
193
194 if (!isset($solutionData[ $row['active_fi'] ][ $row['pass'] ])) {
195 $solutionData[ $row['active_fi'] ][ $row['pass'] ] = array();
196 }
197
198 $solutionData[ $row['active_fi'] ][ $row['pass'] ][] = $row;
199 }
200
201 return $solutionData;
202 }
$row
$query
foreach($_POST as $key=> $value) $res

References $query, $res, and $row.

Referenced by build().

+ Here is the caller graph for this function:

◆ getFinalZipFilePath()

ilAssFileUploadUploadsExporter::getFinalZipFilePath ( )

◆ getParticipantData()

ilAssFileUploadUploadsExporter::getParticipantData (   $solutionData)
private

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

205 {
206 $activeIds = array();
207
208 foreach ($solutionData as $activeId => $passes) {
209 $activeIds[] = $activeId;
210 }
211
212 require_once 'Modules/Test/classes/class.ilTestParticipantData.php';
213 $participantData = new ilTestParticipantData($this->db, $this->lng);
214 $participantData->setActiveIdsFilter($activeIds);
215 $participantData->setParticipantAccessFilter(
217 );
218 $participantData->load($this->getTestId());
219
220 return $participantData;
221 }

References ilTestParticipantAccessFilter\getAccessStatisticsUserFilter(), getRefId(), and getTestId().

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

256 {
257 return $this->lng->txt('pass') . '_' . ($pass + 1);
258 }

References $pass.

Referenced by collectUploadedFiles().

+ Here is the caller graph for this function:

◆ getQuestion()

ilAssFileUploadUploadsExporter::getQuestion ( )

◆ getRefId()

ilAssFileUploadUploadsExporter::getRefId ( )
Returns
int

Definition at line 78 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 94 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 110 of file class.ilAssFileUploadUploadsExporter.php.

References $testTitle.

Referenced by initFilenames().

+ Here is the caller graph for this function:

◆ getZipFileMimeType()

ilAssFileUploadUploadsExporter::getZipFileMimeType ( )

◆ initFilenames()

ilAssFileUploadUploadsExporter::initFilenames ( )
private

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

158 {
159 $this->tempDirPath = ilUtil::ilTempnam();
160
161 $this->tempZipFilePath = ilUtil::ilTempnam($this->tempDirPath) . self::ZIP_FILE_EXTENSION;
162
163 $this->mainFolderName = ilUtil::getASCIIFilename(
164 str_replace(' ', '', $this->getTestTitle() . '_' . $this->question->getTitle())
165 );
166 }
static ilTempnam($a_temp_path=null)
Returns a unique and non existing Path for e temporary file or directory.

References ilUtil\getASCIIFilename(), getTestTitle(), ilUtil\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 275 of file class.ilAssFileUploadUploadsExporter.php.

276 {
277 ilUtil::delDir($this->tempDirPath);
278 }
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively

References ilUtil\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 134 of file class.ilAssFileUploadUploadsExporter.php.

135 {
136 $this->question = $question;
137 }

References $question.

◆ setRefId()

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

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

87 {
88 $this->refId = $refId;
89 }

References $refId.

◆ setTestId()

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

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

103 {
104 $this->testId = $testId;
105 }

References $testId.

◆ setTestTitle()

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

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

119 {
120 $this->testTitle = $testTitle;
121 }

References $testTitle.

Field Documentation

◆ $db

ilAssFileUploadUploadsExporter::$db
protected

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

Referenced by __construct().

◆ $finalZipFilePath

ilAssFileUploadUploadsExporter::$finalZipFilePath
private

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

Referenced by getFinalZipFilePath().

◆ $lng

ilAssFileUploadUploadsExporter::$lng
protected

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

Referenced by __construct().

◆ $mainFolderName

ilAssFileUploadUploadsExporter::$mainFolderName
private

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

◆ $question

ilAssFileUploadUploadsExporter::$question
private

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

Referenced by getQuestion(), and setQuestion().

◆ $refId

ilAssFileUploadUploadsExporter::$refId
protected

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

Referenced by getRefId(), and setRefId().

◆ $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.

◆ $testId

ilAssFileUploadUploadsExporter::$testId
private

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

Referenced by getTestId(), and setTestId().

◆ $testTitle

ilAssFileUploadUploadsExporter::$testTitle
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 14 of file class.ilAssFileUploadUploadsExporter.php.

Referenced by initFilenames().

◆ ZIP_FILE_MIME_TYPE

const ilAssFileUploadUploadsExporter::ZIP_FILE_MIME_TYPE = 'application/zip'

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

Referenced by getZipFileMimeType().


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