ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilAssFileUploadUploadsExporter Class Reference
+ Collaboration diagram for ilAssFileUploadUploadsExporter:

Public Member Functions

 __construct (ilDBInterface $db, ilLanguage $lng)
 
 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
 

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 
)
Parameters
ilDBInterface$db

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

References $db, and $lng.

Member Function Documentation

◆ build()

ilAssFileUploadUploadsExporter::build ( )
Returns
string

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

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

122  {
123  $this->initFilenames();
124 
125  $solutionData = $this->getFileUploadSolutionData();
126 
127  $participantData = $this->getParticipantData($solutionData);
128 
129  $this->collectUploadedFiles($solutionData, $participantData);
130 
132 
134  }
collectUploadedFiles($solutionData, ilTestParticipantData $participantData)
+ Here is the call graph for this function:

◆ collectUploadedFiles()

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

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

References $file, $files, $pass, ilTestParticipantData\getFileSystemCompliantFullnameByActiveId(), getPassSubDirName(), getTestId(), and ilUtil\makeDirParents().

Referenced by build().

200  {
201  foreach ($solutionData as $activeId => $passes) {
202  foreach ($passes as $pass => $files) {
203  foreach ($files as $file) {
204  $uploadedFileDir = $this->question->getFileUploadPath(
205  $this->getTestId(),
206  $activeId,
207  $this->question->getId()
208  );
209 
210  // #20317
211  if (!is_file($uploadedFileDir . $file['value1'])) {
212  continue;
213  }
214 
215  $destinationDir = $this->tempDirPath . '/' . $this->mainFolderName . '/';
216  $destinationDir .= $participantData->getFileSystemCompliantFullnameByActiveId($activeId) . '/';
217  $destinationDir .= $this->getPassSubDirName($file['pass']) . '/';
218 
219  ilUtil::makeDirParents($destinationDir);
220 
221  copy($uploadedFileDir . $file['value1'], $destinationDir . $file['value2']);
222  }
223  }
224  }
225  }
$files
Definition: add-vimline.php:18
static makeDirParents($a_dir)
Create a new directory and all parent directories.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createFileUploadCollectionZipFile()

ilAssFileUploadUploadsExporter::createFileUploadCollectionZipFile ( )
private

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

References ilLoggerFactory\getRootLogger(), ilFileUtils\rename(), and ilUtil\zip().

Referenced by build().

233  {
234  ilUtil::zip($this->tempDirPath . '/' . $this->mainFolderName, $this->tempZipFilePath);
235 
236  $pathinfo = pathinfo($this->tempZipFilePath);
237  $this->finalZipFilePath = dirname($pathinfo['dirname']) . '/' . $pathinfo['basename'];
238 
239  try {
240  require_once 'Services/Utilities/classes/class.ilFileUtils.php';
241  ilFileUtils::rename($this->tempZipFilePath, $this->finalZipFilePath);
242  } catch (\ilFileUtilsException $e) {
243  \ilLoggerFactory::getRootLogger()->error($e->getMessage());
244  }
245  }
static rename($a_source, $a_target)
Rename a file.
static zip($a_dir, $a_file, $compress_content=false)
zips given directory/file into given zip.file
static getRootLogger()
The unique root logger has a fixed error level.
Class to report exception.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDispoZipFileName()

ilAssFileUploadUploadsExporter::getDispoZipFileName ( )

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

References ilUtil\getASCIIFilename().

258  {
260  $this->mainFolderName . self::ZIP_FILE_EXTENSION
261  );
262  }
static getASCIIFilename($a_filename)
convert utf8 to ascii filename
+ Here is the call graph for this function:

◆ getFileUploadSolutionData()

ilAssFileUploadUploadsExporter::getFileUploadSolutionData ( )
private

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

References $query, $res, $row, array, and getTestId().

Referenced by build().

148  {
149  $query = "
150  SELECT tst_solutions.solution_id, tst_solutions.pass, tst_solutions.active_fi, tst_solutions.question_fi,
151  tst_solutions.value1, tst_solutions.value2, tst_solutions.tstamp
152  FROM tst_solutions, tst_active, qpl_questions
153  WHERE tst_solutions.active_fi = tst_active.active_id
154  AND tst_solutions.question_fi = qpl_questions.question_id
155  AND tst_solutions.question_fi = %s
156  AND tst_active.test_fi = %s
157  ORDER BY tst_solutions.active_fi, tst_solutions.tstamp
158  ";
159 
160  $res = $this->db->queryF(
161  $query,
162  array("integer", "integer"),
163  array($this->question->getId(), $this->getTestId())
164  );
165 
166  $solutionData = array();
167 
168  while ($row = $this->db->fetchAssoc($res)) {
169  if (!isset($solutionData[$row['active_fi']])) {
170  $solutionData[ $row['active_fi'] ] = array();
171  }
172 
173  if (!isset($solutionData[ $row['active_fi'] ][ $row['pass'] ])) {
174  $solutionData[ $row['active_fi'] ][ $row['pass'] ] = array();
175  }
176 
177  $solutionData[ $row['active_fi'] ][ $row['pass'] ][] = $row;
178  }
179 
180  return $solutionData;
181  }
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFinalZipFilePath()

ilAssFileUploadUploadsExporter::getFinalZipFilePath ( )

◆ getParticipantData()

ilAssFileUploadUploadsExporter::getParticipantData (   $solutionData)
private

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

References array, and getTestId().

Referenced by build().

184  {
185  $activeIds = array();
186 
187  foreach ($solutionData as $activeId => $passes) {
188  $activeIds[] = $activeId;
189  }
190 
191  require_once 'Modules/Test/classes/class.ilTestParticipantData.php';
192  $participantData = new ilTestParticipantData($this->db, $this->lng);
193  $participantData->setActiveIds($activeIds);
194  $participantData->load($this->getTestId());
195 
196  return $participantData;
197  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPassSubDirName()

ilAssFileUploadUploadsExporter::getPassSubDirName (   $pass)
private

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

References $pass.

Referenced by collectUploadedFiles().

228  {
229  return $this->lng->txt('pass') . '_' . ($pass + 1);
230  }
+ Here is the caller graph for this function:

◆ getQuestion()

ilAssFileUploadUploadsExporter::getQuestion ( )

◆ getTestId()

ilAssFileUploadUploadsExporter::getTestId ( )
Returns
int

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

References $testId.

Referenced by collectUploadedFiles(), getFileUploadSolutionData(), and getParticipantData().

+ Here is the caller graph for this function:

◆ getTestTitle()

ilAssFileUploadUploadsExporter::getTestTitle ( )
Returns
string

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

References $testTitle.

Referenced by initFilenames().

+ Here is the caller graph for this function:

◆ getZipFileMimeType()

ilAssFileUploadUploadsExporter::getZipFileMimeType ( )

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

265  {
266  return self::ZIP_FILE_MIME_TYPE;
267  }

◆ initFilenames()

ilAssFileUploadUploadsExporter::initFilenames ( )
private

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

References ilUtil\getASCIIFilename(), getTestTitle(), and ilUtil\ilTempnam().

Referenced by build().

137  {
138  $this->tempDirPath = ilUtil::ilTempnam();
139 
140  $this->tempZipFilePath = ilUtil::ilTempnam($this->tempDirPath) . self::ZIP_FILE_EXTENSION;
141 
142  $this->mainFolderName = ilUtil::getASCIIFilename(
143  str_replace(' ', '', $this->getTestTitle() . '_' . $this->question->getTitle())
144  );
145  }
static getASCIIFilename($a_filename)
convert utf8 to ascii filename
static ilTempnam($a_temp_path=null)
Create a temporary file in an ILIAS writable directory.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeFileUploadCollection()

ilAssFileUploadUploadsExporter::removeFileUploadCollection ( )
private

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

References ilUtil\delDir().

Referenced by build().

248  {
249  ilUtil::delDir($this->tempDirPath);
250  }
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
+ 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 113 of file class.ilAssFileUploadUploadsExporter.php.

References $question.

114  {
115  $this->question = $question;
116  }

◆ setTestId()

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

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

References $testId.

◆ setTestTitle()

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

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

References $testTitle.

98  {
99  $this->testTitle = $testTitle;
100  }

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

◆ $question

ilAssFileUploadUploadsExporter::$question
private

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

Referenced by getQuestion(), and setQuestion().

◆ $tempDirPath

ilAssFileUploadUploadsExporter::$tempDirPath
private

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

◆ $tempZipFilePath

ilAssFileUploadUploadsExporter::$tempZipFilePath
private

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

◆ $testId

ilAssFileUploadUploadsExporter::$testId
private

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

Referenced by getTestId(), and setTestId().

◆ $testTitle

ilAssFileUploadUploadsExporter::$testTitle
private

Definition at line 34 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.

◆ ZIP_FILE_MIME_TYPE

const ilAssFileUploadUploadsExporter::ZIP_FILE_MIME_TYPE = 'application/zip'

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


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