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

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

References $db, and $lng.

Member Function Documentation

◆ build()

ilAssFileUploadUploadsExporter::build ( )
Returns
string

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

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

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)
+ Here is the call graph for this function:

◆ collectUploadedFiles()

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

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

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

Referenced by build().

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
+ 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.

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

Referenced by build().

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

References ilUtil\getASCIIFilename().

286  {
288  $this->mainFolderName . self::ZIP_FILE_EXTENSION
289  );
290  }
static getASCIIFilename($a_filename)
convert utf8 to ascii filename
+ Here is the call graph for this function:

◆ getFileUploadSolutionData()

ilAssFileUploadUploadsExporter::getFileUploadSolutionData ( )
private

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

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

Referenced by build().

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  }
foreach($_POST as $key=> $value) $res
$query
$row
+ 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 204 of file class.ilAssFileUploadUploadsExporter.php.

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

Referenced by build().

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  }
+ 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.

References $pass.

Referenced by collectUploadedFiles().

256  {
257  return $this->lng->txt('pass') . '_' . ($pass + 1);
258  }
+ 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(), getFileUploadSolutionData(), 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 ( )

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

293  {
294  return self::ZIP_FILE_MIME_TYPE;
295  }

◆ initFilenames()

ilAssFileUploadUploadsExporter::initFilenames ( )
private

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

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

Referenced by build().

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 getASCIIFilename($a_filename)
convert utf8 to ascii filename
static ilTempnam($a_temp_path=null)
Returns a unique and non existing Path for e temporary file or directory.
+ 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.

References ilUtil\delDir().

Referenced by build().

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
+ 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.

References $question.

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

◆ setRefId()

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

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

References $refId.

◆ setTestId()

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

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

References $testId.

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

◆ setTestTitle()

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

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

References $testTitle.

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

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.

◆ 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: