ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilTestArchiver Class Reference

Class ilTestArchiver. More...

+ Collaboration diagram for ilTestArchiver:

Public Member Functions

 getParticipantData ()
 
 setParticipantData ($participantData)
 
 handInParticipantSubmission ($active_fi, $pass, $pdf_path, $html_string)
 Hands in a participants test submission ("a completed test") for archiving. More...
 
 handInParticipantQuestionMaterial ($active_fi, $pass, $question_fi, $original_filename, $file_path)
 Hands in a particpants question material, such as an upload or other binary content. More...
 
 handInParticipantMisc ($active_fi, $pass, $original_filename, $file_path)
 Hands in a participants file, which is relevant for archiving but an unspecified type. More...
 
 handInTestBestSolution ($html_string, $pdf_path)
 Hands in the best solution for a test. More...
 
 handInBestSolutionQuestionMaterial ($question_fi, $orginial_filename, $file_path)
 Hands in a file related to a question in context of the best solution. More...
 
 handInTestResult ($active_fi, $pass, $pdf_path)
 Hands in an individual test result for a pass. More...
 
 handInTestResultsOverview ($html_string, $pdf_path)
 Hands in a test results overview. More...
 
 updateTestArchive ()
 Replaces the test-log with the current one. More...
 
 ensureZipExportDirectoryExists ()
 
 hasZipExportDirectory ()
 Returns if the export directory for zips exists. More...
 
 getZipExportDirectory ()
 Return the export directory, where zips are placed. More...
 
 compressTestArchive ()
 Generate the test archive for download. More...
 

Data Fields

const DIR_SEP = '/'
 
const HTML_SUBMISSION_FILENAME = 'test_submission.html'
 
const PDF_SUBMISSION_FILENAME = 'test_submission.pdf'
 
const PASS_MATERIALS_PATH_COMPONENT = 'materials'
 
const QUESTION_PATH_COMPONENT_PREFIX = 'q_'
 
const TEST_BEST_SOLUTION_PATH_COMPONENT = 'best_solution'
 
const HTML_BEST_SOLUTION_FILENAME = 'best_solution.html'
 
const PDF_BEST_SOLUTION_FILENAME = 'best_solution.pdf'
 
const TEST_MATERIALS_PATH_COMPONENT = 'materials'
 
const TEST_RESULT_FILENAME = 'test_result_v'
 
const TEST_RESULT_POSTFIX = '.pdf'
 
const TEST_OVERVIEW_PDF_FILENAME = 'results_overview_html_v'
 
const TEST_OVERVIEW_PDF_POSTFIX = '.pdf'
 
const TEST_OVERVIEW_HTML_FILENAME = 'results_overview_pdf_v'
 
const TEST_OVERVIEW_HTML_POSTFIX = '.html'
 
const LOG_DTSGROUP_FORMAT = 'D M j G:i:s T Y'
 
const LOG_ADDITION_STRING = ' Adding '
 
const LOG_CREATION_STRING = ' Creating '
 
const LOG_UPDATE_STRING = ' Updating '
 
const LOG_DELETION_STRING = ' Deleting '
 
const TEST_LOG_FILENAME = 'test.log'
 
const DATA_INDEX_FILENAME = 'data_index.csv'
 
const ARCHIVE_LOG = 'archive.log'
 
const EXPORT_DIRECTORY = 'archive_exports'
 

Protected Member Functions

 hasTestArchive ()
 Returns if the archive directory structure for the test the object is created for exists. More...
 
 createArchiveForTest ()
 Creates the directory for the test archive. More...
 
 getTestArchive ()
 Returns the (theoretical) path to the archive directory of the test, this object is created for. More...
 
 ensureTestArchiveIsAvailable ()
 Ensures the availability of the test archive directory. More...
 
 createZipExportDirectory ()
 
 hasPassDataDirectory ($active_fi, $pass)
 Checks if the directory for pass data is available. More...
 
 createPassDataDirectory ($active_fi, $pass)
 Creates pass data directory. More...
 
 getPassDataDirectory ($active_fi, $pass)
 Returns the pass data directory. More...
 
 ensurePassDataDirectoryIsAvailable ($active_fi, $pass)
 Ensures the availability of the participant data directory. More...
 
 hasPassMaterialsDirectory ($active_fi, $pass)
 Returns if the pass materials directory exists for a given pass. More...
 
 createPassMaterialsDirectory ($active_fi, $pass)
 Creates pass materials directory. More...
 
 getPassMaterialsDirectory ($active_fi, $pass)
 Returns the pass materials directory. More...
 
 ensurePassMaterialsDirectoryIsAvailable ($active_fi, $pass)
 Ensures the availability of the pass materials directory. More...
 
 readArchiveDataIndex ()
 Reads the archive data index. More...
 
 appendToArchiveDataIndex ($date, $active_fi, $pass, $user_firstname, $user_lastname, $matriculation)
 Appends a line to the archive data index. More...
 
 determinePassDataPath ($date, $active_fi, $pass, $user_firstname, $user_lastname, $matriculation)
 Determines the pass data path. More...
 
 logArchivingProcess ($message)
 Logs to the archive log. More...
 
 countFilesInDirectory ($directory, $pattern=null)
 Returns the count of files in a directory, eventually matching the given, optional, pattern. More...
 

Protected Attributes

 $external_directory_path
 
 $client_id
 
 $test_obj_id
 
 $archive_data_index
 
 $ilDB
 
 $participantData
 

Private Member Functions

 buildPassDataDirectory ($active_fi, $pass)
 

Detailed Description

Class ilTestArchiver.

Helper class to deal with the generation and maintenance of test archives.

Author
Maximilian Becker mbeck.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

Definition at line 15 of file class.ilTestArchiver.php.

Member Function Documentation

◆ appendToArchiveDataIndex()

ilTestArchiver::appendToArchiveDataIndex (   $date,
  $active_fi,
  $pass,
  $user_firstname,
  $user_lastname,
  $matriculation 
)
protected

Appends a line to the archive data index.

Parameters
$datestring Date for the directories path.
$active_fiinteger ActiveFI of the participant.
$passinteger Pass number of the participant.
$user_firstnamestring User firstname.
$user_lastnamestring User lastname.
$matriculationstring Matriculation number of the user.
Returns
void

Definition at line 687 of file class.ilTestArchiver.php.

688 {
689 $line = $this->determinePassDataPath($date, $active_fi, $pass, $user_firstname, $user_lastname, $matriculation);
690
691 $this->archive_data_index[] = $line;
692 $output_contents = '';
693
694 foreach ($this->archive_data_index as $line_data) {
695 if ($line_data['identifier'] == "|") {
696 continue;
697 }
698 $output_contents .= implode('|', $line_data) . "\n";
699 }
700
701 file_put_contents($this->getTestArchive() . self::DIR_SEP . self::DATA_INDEX_FILENAME, $output_contents);
702 $this->readArchiveDataIndex();
703 return;
704 }
getTestArchive()
Returns the (theoretical) path to the archive directory of the test, this object is created for.
readArchiveDataIndex()
Reads the archive data index.
determinePassDataPath($date, $active_fi, $pass, $user_firstname, $user_lastname, $matriculation)
Determines the pass data path.

References $pass, determinePassDataPath(), getTestArchive(), and readArchiveDataIndex().

Referenced by createPassMaterialsDirectory(), and getPassDataDirectory().

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

◆ buildPassDataDirectory()

ilTestArchiver::buildPassDataDirectory (   $active_fi,
  $pass 
)
private

Definition at line 485 of file class.ilTestArchiver.php.

486 {
487 foreach ($this->archive_data_index as $data_index_entry) {
488 if ($data_index_entry != null && $data_index_entry['identifier'] == $active_fi . '|' . $pass) {
489 array_shift($data_index_entry);
490 return $this->getTestArchive() . self::DIR_SEP . implode(self::DIR_SEP, $data_index_entry);
491 }
492 }
493
494 return null;
495 }

References $pass, and getTestArchive().

Referenced by getPassDataDirectory().

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

◆ compressTestArchive()

ilTestArchiver::compressTestArchive ( )

Generate the test archive for download.

Returns
void

Definition at line 437 of file class.ilTestArchiver.php.

438 {
439 $this->updateTestArchive();
441
442 $zip_output_path = $this->getZipExportDirectory();
443 $zip_output_filename = 'test_archive_obj_' . $this->test_obj_id . '_' . time() . '_.zip';
444
445 ilUtil::zip($this->getTestArchive(), $zip_output_path . self::DIR_SEP . $zip_output_filename, true);
446 return;
447 }
getZipExportDirectory()
Return the export directory, where zips are placed.
updateTestArchive()
Replaces the test-log with the current one.
static zip($a_dir, $a_file, $compress_content=false)
zips given directory/file into given zip.file

References ensureZipExportDirectoryExists(), getTestArchive(), getZipExportDirectory(), updateTestArchive(), and ilUtil\zip().

+ Here is the call graph for this function:

◆ countFilesInDirectory()

ilTestArchiver::countFilesInDirectory (   $directory,
  $pattern = null 
)
protected

Returns the count of files in a directory, eventually matching the given, optional, pattern.

Parameters
$directory
null | string$pattern
Returns
integer

@noinspection PhpAssignmentInConditionInspection

Definition at line 758 of file class.ilTestArchiver.php.

759 {
760 $filecount = 0;
761
763 if ($handle = opendir($directory)) {
764 while (($file = readdir($handle)) !== false) {
765 if (!in_array($file, array( '.', '..' )) && !is_dir($directory . $file)) {
766 if ($pattern && strpos($file, $pattern) === 0) {
767 $filecount++;
768 }
769 }
770 }
771 }
772 return $filecount;
773 }
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file

References $file.

Referenced by handInTestResult(), and handInTestResultsOverview().

+ Here is the caller graph for this function:

◆ createArchiveForTest()

ilTestArchiver::createArchiveForTest ( )
protected

Creates the directory for the test archive.

Definition at line 330 of file class.ilTestArchiver.php.

331 {
333 //mkdir( $this->getTestArchive(), 0777, true );
334 }
static makeDirParents($a_dir)
Create a new directory and all parent directories.

References getTestArchive(), and ilUtil\makeDirParents().

Referenced by ensureTestArchiveIsAvailable().

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

◆ createPassDataDirectory()

ilTestArchiver::createPassDataDirectory (   $active_fi,
  $pass 
)
protected

Creates pass data directory.

Parameters
$active_fiinteger ActiveFI of the participant.
$passinteger Pass number of the test.
Returns
void

Definition at line 479 of file class.ilTestArchiver.php.

480 {
481 mkdir($this->getPassDataDirectory($active_fi, $pass), 0777, true);
482 return;
483 }
getPassDataDirectory($active_fi, $pass)
Returns the pass data directory.

References $pass, and getPassDataDirectory().

Referenced by ensurePassDataDirectoryIsAvailable().

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

◆ createPassMaterialsDirectory()

ilTestArchiver::createPassMaterialsDirectory (   $active_fi,
  $pass 
)
protected

Creates pass materials directory.

Parameters
$active_fiinteger ActiveFI of the participant.
$passinteger Pass number of the test.
Returns
void

Definition at line 584 of file class.ilTestArchiver.php.

585 {
586 // Data are taken from the current user as the implementation expects the first interaction of the pass
587 // takes place from the usage/behaviour of the current user.
588
589 if ($this->getParticipantData()) {
590 $usrData = $this->getParticipantData()->getUserDataByActiveId($active_fi);
591 $user = new ilObjUser();
592 $user->setFirstname($usrData['firstname']);
593 $user->setLastname($usrData['lastname']);
594 $user->setMatriculation($usrData['matriculation']);
595 $user->setFirstname($usrData['firstname']);
596 } else {
597 global $ilUser;
598 $user = $ilUser;
599 }
600
602 date('Y'),
603 $active_fi,
604 $pass,
605 $user->getFirstname(),
606 $user->getLastname(),
607 $user->getMatriculation()
608 );
609 mkdir($this->getPassMaterialsDirectory($active_fi, $pass), 0777, true);
610 }
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
getPassMaterialsDirectory($active_fi, $pass)
Returns the pass materials directory.
appendToArchiveDataIndex($date, $active_fi, $pass, $user_firstname, $user_lastname, $matriculation)
Appends a line to the archive data index.
$ilUser
Definition: imgupload.php:18

References $ilUser, $pass, appendToArchiveDataIndex(), date, getParticipantData(), and getPassMaterialsDirectory().

Referenced by ensurePassMaterialsDirectoryIsAvailable().

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

◆ createZipExportDirectory()

ilTestArchiver::createZipExportDirectory ( )
protected

Definition at line 416 of file class.ilTestArchiver.php.

417 {
418 mkdir($this->getZipExportDirectory(), 0777, true);
419 }

References getZipExportDirectory().

Referenced by ensureZipExportDirectoryExists().

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

◆ determinePassDataPath()

ilTestArchiver::determinePassDataPath (   $date,
  $active_fi,
  $pass,
  $user_firstname,
  $user_lastname,
  $matriculation 
)
protected

Determines the pass data path.

Parameters
$date
$active_fi
$pass
$user_firstname
$user_lastname
$matriculation
Returns
array

Definition at line 718 of file class.ilTestArchiver.php.

719 {
720 $date = date_create_from_format(DATE_ISO8601, $date);
721 $line = array(
722 'identifier' => $active_fi . '|' . $pass,
723 'yyyy' => date_format($date, 'Y'),
724 'mm' => date_format($date, 'm'),
725 'dd' => date_format($date, 'd'),
726 'directory' => $active_fi . '_' . $pass . '_' . $user_firstname . '_' . $user_lastname . '_' . $matriculation
727 );
728 return $line;
729 }

References $pass.

Referenced by appendToArchiveDataIndex().

+ Here is the caller graph for this function:

◆ ensurePassDataDirectoryIsAvailable()

ilTestArchiver::ensurePassDataDirectoryIsAvailable (   $active_fi,
  $pass 
)
protected

Ensures the availability of the participant data directory.

Checks if the directory exists and creates it if necessary.

Parameters
$active_fiinteger Active-FI of the test participant
$passinteger Pass-number of the actual test
Returns
void

Definition at line 547 of file class.ilTestArchiver.php.

548 {
549 if (!$this->hasPassDataDirectory($active_fi, $pass)) {
550 $this->createPassDataDirectory($active_fi, $pass);
551 }
552 return;
553 }
hasPassDataDirectory($active_fi, $pass)
Checks if the directory for pass data is available.
createPassDataDirectory($active_fi, $pass)
Creates pass data directory.

References $pass, createPassDataDirectory(), and hasPassDataDirectory().

Referenced by handInParticipantMisc(), handInParticipantQuestionMaterial(), handInParticipantSubmission(), and handInTestResult().

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

◆ ensurePassMaterialsDirectoryIsAvailable()

ilTestArchiver::ensurePassMaterialsDirectoryIsAvailable (   $active_fi,
  $pass 
)
protected

Ensures the availability of the pass materials directory.

Checks if the directory exists and creates it if necessary.

Parameters
$active_fiinteger Active-FI of the test participant
$passinteger Pass-number of the actual test

Definition at line 635 of file class.ilTestArchiver.php.

636 {
637 if (!$this->hasPassMaterialsDirectory($active_fi, $pass)) {
638 $this->createPassMaterialsDirectory($active_fi, $pass);
639 }
640 }
hasPassMaterialsDirectory($active_fi, $pass)
Returns if the pass materials directory exists for a given pass.
createPassMaterialsDirectory($active_fi, $pass)
Creates pass materials directory.

References $pass, createPassMaterialsDirectory(), and hasPassMaterialsDirectory().

+ Here is the call graph for this function:

◆ ensureTestArchiveIsAvailable()

ilTestArchiver::ensureTestArchiveIsAvailable ( )
protected

Ensures the availability of the test archive directory.

Checks if the directory exists and creates it if necessary.

Returns
void

Definition at line 355 of file class.ilTestArchiver.php.

356 {
357 if (!$this->hasTestArchive()) {
358 $this->createArchiveForTest();
359 }
360 return;
361 }
hasTestArchive()
Returns if the archive directory structure for the test the object is created for exists.
createArchiveForTest()
Creates the directory for the test archive.

References createArchiveForTest(), and hasTestArchive().

Referenced by handInBestSolutionQuestionMaterial(), handInParticipantMisc(), handInParticipantQuestionMaterial(), handInParticipantSubmission(), handInTestBestSolution(), handInTestResult(), and handInTestResultsOverview().

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

◆ ensureZipExportDirectoryExists()

ilTestArchiver::ensureZipExportDirectoryExists ( )

Definition at line 399 of file class.ilTestArchiver.php.

400 {
401 if (!$this->hasZipExportDirectory()) {
403 }
404 }
hasZipExportDirectory()
Returns if the export directory for zips exists.

References createZipExportDirectory(), and hasZipExportDirectory().

Referenced by compressTestArchive().

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

◆ getParticipantData()

ilTestArchiver::getParticipantData ( )
Returns
ilTestParticipantData

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

117 {
119 }

References $participantData.

Referenced by createPassMaterialsDirectory(), and getPassDataDirectory().

+ Here is the caller graph for this function:

◆ getPassDataDirectory()

ilTestArchiver::getPassDataDirectory (   $active_fi,
  $pass 
)
protected

Returns the pass data directory.

Parameters
$active_fiinteger ActiveFI of the participant.
$passinteger Pass number of the test.
Returns
string $pass_data_directory Path to the pass data directory.

Definition at line 505 of file class.ilTestArchiver.php.

506 {
507 $passDataDir = $this->buildPassDataDirectory($active_fi, $pass);
508
509 if (!$passDataDir) {
510 if ($this->getParticipantData()) {
511 $usrData = $this->getParticipantData()->getUserDataByActiveId($active_fi);
512 $user = new ilObjUser();
513 $user->setFirstname($usrData['firstname']);
514 $user->setLastname($usrData['lastname']);
515 $user->setMatriculation($usrData['matriculation']);
516 $user->setFirstname($usrData['firstname']);
517 } else {
518 global $ilUser;
519 $user = $ilUser;
520 }
521
523 date(DATE_ISO8601),
524 $active_fi,
525 $pass,
526 $user->getFirstname(),
527 $user->getLastname(),
528 $user->getMatriculation()
529 );
530
531 $passDataDir = $this->buildPassDataDirectory($active_fi, $pass);
532 }
533
534 return $passDataDir;
535 }
buildPassDataDirectory($active_fi, $pass)

References $ilUser, $pass, appendToArchiveDataIndex(), buildPassDataDirectory(), date, and getParticipantData().

Referenced by createPassDataDirectory(), handInParticipantMisc(), handInParticipantQuestionMaterial(), handInParticipantSubmission(), handInTestResult(), and hasPassDataDirectory().

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

◆ getPassMaterialsDirectory()

ilTestArchiver::getPassMaterialsDirectory (   $active_fi,
  $pass 
)
protected

Returns the pass materials directory.

Parameters
$active_fiinteger ActiveFI of the participant.
$passinteger Pass number.
Returns
string $pass_materials_directory Path to the pass materials directory.

Definition at line 620 of file class.ilTestArchiver.php.

621 {
622 $pass_data_directory = $this->getPassMaterialsDirectory($active_fi, $pass);
623 return $pass_data_directory . self::DIR_SEP . self::PASS_MATERIALS_PATH_COMPONENT;
624 }

References $pass, getPassMaterialsDirectory(), and PASS_MATERIALS_PATH_COMPONENT.

Referenced by createPassMaterialsDirectory(), getPassMaterialsDirectory(), and hasPassMaterialsDirectory().

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

◆ getTestArchive()

ilTestArchiver::getTestArchive ( )
protected

Returns the (theoretical) path to the archive directory of the test, this object is created for.

Returns
string $test_archive Path to this tests archive directory.

Definition at line 341 of file class.ilTestArchiver.php.

342 {
343 $test_archive_directory = $this->external_directory_path . self::DIR_SEP . $this->client_id . self::DIR_SEP . 'tst_data'
344 . self::DIR_SEP . 'archive' . self::DIR_SEP . 'tst_' . $this->test_obj_id;
345 return $test_archive_directory;
346 }

References $test_obj_id.

Referenced by appendToArchiveDataIndex(), buildPassDataDirectory(), compressTestArchive(), createArchiveForTest(), handInBestSolutionQuestionMaterial(), handInTestBestSolution(), handInTestResultsOverview(), hasTestArchive(), logArchivingProcess(), readArchiveDataIndex(), and updateTestArchive().

+ Here is the caller graph for this function:

◆ getZipExportDirectory()

ilTestArchiver::getZipExportDirectory ( )

Return the export directory, where zips are placed.

Returns
string

Definition at line 426 of file class.ilTestArchiver.php.

427 {
428 return $this->external_directory_path . self::DIR_SEP . $this->client_id . self::DIR_SEP . 'tst_data'
429 . self::DIR_SEP . self::EXPORT_DIRECTORY . self::DIR_SEP . 'tst_' . $this->test_obj_id;
430 }

References $test_obj_id.

Referenced by compressTestArchive(), createZipExportDirectory(), and hasZipExportDirectory().

+ Here is the caller graph for this function:

◆ handInBestSolutionQuestionMaterial()

ilTestArchiver::handInBestSolutionQuestionMaterial (   $question_fi,
  $orginial_filename,
  $file_path 
)

Hands in a file related to a question in context of the best solution.

Parameters
$question_fiinteger QuestionFI of the question, material is to be stored for.
$orginial_filenamestring Original filename of the material to be stored.
$file_pathstring Path to the material to be stored.

Definition at line 244 of file class.ilTestArchiver.php.

245 {
247
248 $best_solution_path = $this->getTestArchive() . self::DIR_SEP . self::TEST_BEST_SOLUTION_PATH_COMPONENT;
249 if (!is_dir($best_solution_path)) {
250 mkdir($best_solution_path, 0777, true);
251 }
252
253 $materials_path = $best_solution_path . self::DIR_SEP . self::TEST_MATERIALS_PATH_COMPONENT;
254 if (!is_dir($materials_path)) {
255 mkdir($materials_path, 0777, true);
256 }
257
258 $question_materials_path = $materials_path . self::DIR_SEP . self::QUESTION_PATH_COMPONENT_PREFIX . $question_fi;
259 if (!is_dir($question_materials_path)) {
260 mkdir($question_materials_path, 0777, true);
261 }
262
263 copy($file_path, $question_materials_path . self::DIR_SEP . $orginial_filename);
264
265 $this->logArchivingProcess(
266 date(self::LOG_DTSGROUP_FORMAT) . self::LOG_ADDITION_STRING
267 . $question_materials_path . self::DIR_SEP . $orginial_filename
268 );
269 }
ensureTestArchiveIsAvailable()
Ensures the availability of the test archive directory.
const TEST_BEST_SOLUTION_PATH_COMPONENT
logArchivingProcess($message)
Logs to the archive log.

References date, ensureTestArchiveIsAvailable(), getTestArchive(), logArchivingProcess(), TEST_BEST_SOLUTION_PATH_COMPONENT, and TEST_MATERIALS_PATH_COMPONENT.

+ Here is the call graph for this function:

◆ handInParticipantMisc()

ilTestArchiver::handInParticipantMisc (   $active_fi,
  $pass,
  $original_filename,
  $file_path 
)

Hands in a participants file, which is relevant for archiving but an unspecified type.

Examples for such are signature files, remarks, feedback or the like.

Parameters
$active_fiinteger Active-FI of the test participant
$passinteger Pass-number of the actual test
$original_filenamestring Original filename of the material to be stored.
$file_pathstring Location of the file to be archived

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

199 {
201 $this->ensurePassDataDirectoryIsAvailable($active_fi, $pass);
202 $new_path = $this->getPassDataDirectory($active_fi, $pass) . self::DIR_SEP . $original_filename;
203 copy($file_path, $new_path);
204 $this->logArchivingProcess(date(self::LOG_DTSGROUP_FORMAT) . self::LOG_ADDITION_STRING . $new_path);
205 }
ensurePassDataDirectoryIsAvailable($active_fi, $pass)
Ensures the availability of the participant data directory.

References $pass, date, ensurePassDataDirectoryIsAvailable(), ensureTestArchiveIsAvailable(), getPassDataDirectory(), and logArchivingProcess().

+ Here is the call graph for this function:

◆ handInParticipantQuestionMaterial()

ilTestArchiver::handInParticipantQuestionMaterial (   $active_fi,
  $pass,
  $question_fi,
  $original_filename,
  $file_path 
)

Hands in a particpants question material, such as an upload or other binary content.

Parameters
$active_fiinteger Active-FI of the test participant
$passinteger Pass-number of the actual test
$question_fiinteger Question-FI of the question, the file is to be stored for.
$original_filenamestring Original filename of the material to be stored.
$file_pathstring Location of the file to be archived

Definition at line 169 of file class.ilTestArchiver.php.

170 {
172 $this->ensurePassDataDirectoryIsAvailable($active_fi, $pass);
173
174 $pass_question_directory = $this->getPassDataDirectory($active_fi, $pass)
175 . self::DIR_SEP . self::QUESTION_PATH_COMPONENT_PREFIX . $question_fi;
176 if (!is_dir($pass_question_directory)) {
177 mkdir($pass_question_directory, 0777, true);
178 }
179
180 copy($file_path, $pass_question_directory . self::DIR_SEP . $original_filename);
181
182 $this->logArchivingProcess(
183 date(self::LOG_DTSGROUP_FORMAT) . self::LOG_ADDITION_STRING
184 . $pass_question_directory . self::DIR_SEP . $original_filename
185 );
186 }

References $pass, date, ensurePassDataDirectoryIsAvailable(), ensureTestArchiveIsAvailable(), getPassDataDirectory(), and logArchivingProcess().

+ Here is the call graph for this function:

◆ handInParticipantSubmission()

ilTestArchiver::handInParticipantSubmission (   $active_fi,
  $pass,
  $pdf_path,
  $html_string 
)

Hands in a participants test submission ("a completed test") for archiving.

The archive takes an html-string and a path to a PDF-file and saves it according to the archives general structure. The test is identified by active_fi and pass number, allowing to store relevant files even for anonymous tests.

Parameters
$active_fiinteger Active-FI of the test participant
$passinteger Pass-number of the actual test
$html_stringstring HTML-string of the test submission
$pdf_pathstring Path to a pdf representation of the test submission.

Definition at line 143 of file class.ilTestArchiver.php.

144 {
146 $this->ensurePassDataDirectoryIsAvailable($active_fi, $pass);
147
148 $pdf_new_path = $this->getPassDataDirectory($active_fi, $pass) . self::DIR_SEP
150 copy($pdf_path, $pdf_new_path);
151 # /home/mbecker/public_html/ilias/trunk-primary/extern/default/tst_data/archive/tst_350/2013/09/19/80_1_root_user_/test_submission.pdf
152 $html_new_path = $this->getPassDataDirectory($active_fi, $pass) . self::DIR_SEP
154 file_put_contents($html_new_path, $html_string);
155
156 $this->logArchivingProcess(date(self::LOG_DTSGROUP_FORMAT) . self::LOG_ADDITION_STRING . $pdf_new_path);
157 $this->logArchivingProcess(date(self::LOG_DTSGROUP_FORMAT) . self::LOG_ADDITION_STRING . $html_new_path);
158 }

References $pass, date, ensurePassDataDirectoryIsAvailable(), ensureTestArchiveIsAvailable(), getPassDataDirectory(), HTML_SUBMISSION_FILENAME, logArchivingProcess(), and PDF_SUBMISSION_FILENAME.

+ Here is the call graph for this function:

◆ handInTestBestSolution()

ilTestArchiver::handInTestBestSolution (   $html_string,
  $pdf_path 
)

Hands in the best solution for a test.

Parameters
$html_stringstring HTML-string of the test submission
$pdf_pathstring Path to a pdf representation of the test submission.

Definition at line 213 of file class.ilTestArchiver.php.

214 {
216
217 $best_solution_path = $this->getTestArchive() . self::DIR_SEP . self::TEST_BEST_SOLUTION_PATH_COMPONENT;
218 if (!is_dir($best_solution_path)) {
219 mkdir($best_solution_path, 0777, true);
220 }
221
222 file_put_contents($best_solution_path . self::DIR_SEP . self::HTML_BEST_SOLUTION_FILENAME, $html_string);
223
224 copy($pdf_path, $best_solution_path . self::DIR_SEP . self::PDF_BEST_SOLUTION_FILENAME);
225
226 $this->logArchivingProcess(
227 date(self::LOG_DTSGROUP_FORMAT) . self::LOG_ADDITION_STRING
228 . $best_solution_path . self::DIR_SEP . self::HTML_BEST_SOLUTION_FILENAME
229 );
230
231 $this->logArchivingProcess(
232 date(self::LOG_DTSGROUP_FORMAT) . self::LOG_ADDITION_STRING
233 . $best_solution_path . self::DIR_SEP . self::PDF_BEST_SOLUTION_FILENAME
234 );
235 }

References date, ensureTestArchiveIsAvailable(), getTestArchive(), logArchivingProcess(), and TEST_BEST_SOLUTION_PATH_COMPONENT.

+ Here is the call graph for this function:

◆ handInTestResult()

ilTestArchiver::handInTestResult (   $active_fi,
  $pass,
  $pdf_path 
)

Hands in an individual test result for a pass.

Parameters
$active_fiinteger ActiveFI of the participant.
$passinteger Pass of the test.
$pdf_pathstring Path to the PDF containing the result.
Returns
void

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

281 {
283 $this->ensurePassDataDirectoryIsAvailable($active_fi, $pass);
284 $new_path = $this->getPassDataDirectory($active_fi, $pass) . self::DIR_SEP
285 . self::TEST_RESULT_FILENAME . ($this->countFilesInDirectory($this->getPassDataDirectory($active_fi, $pass), self::TEST_RESULT_FILENAME))
286 . self::TEST_RESULT_POSTFIX;
287 copy($pdf_path, $new_path);
288 $this->logArchivingProcess(date(self::LOG_DTSGROUP_FORMAT) . self::LOG_ADDITION_STRING . $new_path);
289 }
countFilesInDirectory($directory, $pattern=null)
Returns the count of files in a directory, eventually matching the given, optional,...

References $pass, countFilesInDirectory(), date, ensurePassDataDirectoryIsAvailable(), ensureTestArchiveIsAvailable(), getPassDataDirectory(), and logArchivingProcess().

+ Here is the call graph for this function:

◆ handInTestResultsOverview()

ilTestArchiver::handInTestResultsOverview (   $html_string,
  $pdf_path 
)

Hands in a test results overview.

Parameters
$html_stringstring HTML of the test results overview.
$pdf_pathstring Path

Definition at line 297 of file class.ilTestArchiver.php.

298 {
300 $new_pdf_path = $this->getTestArchive() . self::DIR_SEP
301 . self::TEST_OVERVIEW_PDF_FILENAME
302 . $this->countFilesInDirectory($this->getTestArchive(), self::TEST_OVERVIEW_PDF_FILENAME) . self::TEST_OVERVIEW_PDF_POSTFIX;
303 copy($pdf_path, $new_pdf_path);
304 $html_path = $this->getTestArchive() . self::DIR_SEP . self::TEST_OVERVIEW_HTML_FILENAME
305 . $this->countFilesInDirectory($this->getTestArchive(), self::TEST_OVERVIEW_HTML_FILENAME) . self::TEST_OVERVIEW_HTML_POSTFIX;
306 file_put_contents($html_path, $html_string);
307
308 $this->logArchivingProcess(date(self::LOG_DTSGROUP_FORMAT) . self::LOG_ADDITION_STRING . $new_pdf_path);
309 $this->logArchivingProcess(date(self::LOG_DTSGROUP_FORMAT) . self::LOG_ADDITION_STRING . $html_path);
310 }

References countFilesInDirectory(), date, ensureTestArchiveIsAvailable(), getTestArchive(), logArchivingProcess(), TEST_OVERVIEW_HTML_POSTFIX, and TEST_OVERVIEW_PDF_POSTFIX.

+ Here is the call graph for this function:

◆ hasPassDataDirectory()

ilTestArchiver::hasPassDataDirectory (   $active_fi,
  $pass 
)
protected

Checks if the directory for pass data is available.

Parameters
$active_fiinteger ActiveFI of the pass.
$passinteger Pass-number of the pass.
Returns
bool $hasPassDataDirectory True, if the pass data directory exists.

Definition at line 465 of file class.ilTestArchiver.php.

466 {
467 $pass_data_dir = $this->getPassDataDirectory($active_fi, $pass);
468 return is_dir($this->getPassDataDirectory($active_fi, $pass));
469 }

References $pass, and getPassDataDirectory().

Referenced by ensurePassDataDirectoryIsAvailable().

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

◆ hasPassMaterialsDirectory()

ilTestArchiver::hasPassMaterialsDirectory (   $active_fi,
  $pass 
)
protected

Returns if the pass materials directory exists for a given pass.

Parameters
$active_fiinteger ActiveFI for the participant.
$passinteger Pass number.
Returns
bool $hasPassmaterialsDirectory True, if the directory exists.

@noinspection PhpUsageOfSilenceOperatorInspection

Definition at line 567 of file class.ilTestArchiver.php.

568 {
570 if (@is_dir($this->getPassMaterialsDirectory($active_fi, $pass))) {
571 return true;
572 }
573 return false;
574 }

References $pass, and getPassMaterialsDirectory().

Referenced by ensurePassMaterialsDirectoryIsAvailable().

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

◆ hasTestArchive()

ilTestArchiver::hasTestArchive ( )
protected

Returns if the archive directory structure for the test the object is created for exists.

Returns
bool $hasTestArchive True, if the archive directory structure exists.

Definition at line 322 of file class.ilTestArchiver.php.

323 {
324 return is_dir($this->getTestArchive());
325 }

References getTestArchive().

Referenced by ensureTestArchiveIsAvailable().

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

◆ hasZipExportDirectory()

ilTestArchiver::hasZipExportDirectory ( )

Returns if the export directory for zips exists.

Returns
bool

Definition at line 411 of file class.ilTestArchiver.php.

412 {
413 return is_dir($this->getZipExportDirectory());
414 }

References getZipExportDirectory().

Referenced by ensureZipExportDirectoryExists().

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

◆ logArchivingProcess()

ilTestArchiver::logArchivingProcess (   $message)
protected

Logs to the archive log.

Parameters
$messagestring Complete log message.
Returns
void

Definition at line 738 of file class.ilTestArchiver.php.

739 {
740 $archive = $this->getTestArchive() . self::DIR_SEP . self::ARCHIVE_LOG;
741 if (file_exists($archive)) {
742 $content = file_get_contents($archive) . "\n" . $message;
743 } else {
744 $content = $message;
745 }
746
747 file_put_contents($archive, $content);
748 }
catch(Exception $e) $message

References $message, ARCHIVE_LOG, and getTestArchive().

Referenced by handInBestSolutionQuestionMaterial(), handInParticipantMisc(), handInParticipantQuestionMaterial(), handInParticipantSubmission(), handInTestBestSolution(), handInTestResult(), and handInTestResultsOverview().

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

◆ readArchiveDataIndex()

ilTestArchiver::readArchiveDataIndex ( )
protected

Reads the archive data index.

Returns
array[array] $archive_data_index Archive data index.

The Archive Data Index is a csv-file containing the following columns <active_fi>|<pass>|<yyyy>|<mm>||<directory>

@noinspection PhpUsageOfSilenceOperatorInspection

Definition at line 649 of file class.ilTestArchiver.php.

650 {
655 $data_index_file = $this->getTestArchive() . self::DIR_SEP . self::DATA_INDEX_FILENAME;
656
657 $contents = array();
658
660 if (@file_exists($data_index_file)) {
661 $lines = explode("\n", file_get_contents($data_index_file));
662 foreach ($lines as $line) {
663 $line_items = explode('|', $line);
664 $line_data['identifier'] = $line_items[0] . '|' . $line_items[1];
665 $line_data['yyyy'] = $line_items[2];
666 $line_data['mm'] = $line_items[3];
667 $line_data['dd'] = $line_items[4];
668 $line_data['directory'] = $line_items[5];
669 $contents[] = $line_data;
670 }
671 }
672 return $contents;
673 }

References $contents, DATA_INDEX_FILENAME, and getTestArchive().

Referenced by appendToArchiveDataIndex().

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

◆ setParticipantData()

ilTestArchiver::setParticipantData (   $participantData)
Parameters
ilTestParticipantData$participantData

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

125 {
126 $this->participantData = $participantData;
127 }

References $participantData.

◆ updateTestArchive()

ilTestArchiver::updateTestArchive ( )

Replaces the test-log with the current one.

Returns
void

@noinspection PhpAssignmentInConditionInspection

Definition at line 368 of file class.ilTestArchiver.php.

369 {
370 $query = 'SELECT * FROM ass_log WHERE obj_fi = ' . $this->ilDB->quote($this->test_obj_id, 'integer');
371 $result = $this->ilDB->query($query);
372
373 $outfile_lines = '';
375 while ($row = $this->ilDB->fetchAssoc($result)) {
376 $outfile_lines .= "\r\n" . implode("\t", $row);
377 }
378 file_put_contents($this->getTestArchive() . self::DIR_SEP . self::TEST_LOG_FILENAME, $outfile_lines);
379
380 // Generate test pass overview
381 $test = new ilObjTest($this->test_obj_id, false);
382 $gui = new ilObjTestGUI();
383 $gui->object = $test;
384 $array_of_actives = array();
385 $participants = $test->getParticipants();
386
387 foreach ($participants as $key => $value) {
388 $array_of_actives[] = $key;
389 }
390 $output_template = $gui->createUserResults(true, false, true, $array_of_actives);
391
392 require_once 'class.ilTestPDFGenerator.php';
393 $filename = realpath($this->getTestArchive()) . self::DIR_SEP . 'participant_pass_overview.pdf';
395
396 return;
397 }
$result
$test
Definition: Utf8Test.php:84
Database Wrapper.
Definition: class.ilDB.php:30
query($sql, $a_handle_error=true)
Query.
fetchAssoc($a_set)
Fetch row as associative array from result set.
quote($a_query, $a_type=null)
Wrapper for quote method.
Class ilObjTestGUI.
static generatePDF($pdf_output, $output_mode, $filename=null, $purpose=null)
$key
Definition: croninfo.php:18
const PDF_USER_RESULT
PDF Purposes.
$query

References $filename, $key, $query, $result, $row, $test, ilDB\fetchAssoc(), ilTestPDFGenerator\generatePDF(), getTestArchive(), ilTestPDFGenerator\PDF_OUTPUT_FILE, PDF_USER_RESULT, ilDB\query(), and ilDB\quote().

Referenced by compressTestArchive().

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

Field Documentation

◆ $archive_data_index

ilTestArchiver::$archive_data_index
protected

Definition at line 83 of file class.ilTestArchiver.php.

◆ $client_id

ilTestArchiver::$client_id
protected

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

◆ $external_directory_path

ilTestArchiver::$external_directory_path
protected

Definition at line 80 of file class.ilTestArchiver.php.

◆ $ilDB

ilTestArchiver::$ilDB
protected

Definition at line 85 of file class.ilTestArchiver.php.

◆ $participantData

ilTestArchiver::$participantData
protected

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

Referenced by getParticipantData(), and setParticipantData().

◆ $test_obj_id

ilTestArchiver::$test_obj_id
protected

Definition at line 82 of file class.ilTestArchiver.php.

Referenced by getTestArchive(), and getZipExportDirectory().

◆ ARCHIVE_LOG

const ilTestArchiver::ARCHIVE_LOG = 'archive.log'

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

Referenced by logArchivingProcess().

◆ DATA_INDEX_FILENAME

const ilTestArchiver::DATA_INDEX_FILENAME = 'data_index.csv'

Definition at line 47 of file class.ilTestArchiver.php.

Referenced by readArchiveDataIndex().

◆ DIR_SEP

const ilTestArchiver::DIR_SEP = '/'

◆ EXPORT_DIRECTORY

const ilTestArchiver::EXPORT_DIRECTORY = 'archive_exports'

Definition at line 50 of file class.ilTestArchiver.php.

◆ HTML_BEST_SOLUTION_FILENAME

const ilTestArchiver::HTML_BEST_SOLUTION_FILENAME = 'best_solution.html'

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

◆ HTML_SUBMISSION_FILENAME

const ilTestArchiver::HTML_SUBMISSION_FILENAME = 'test_submission.html'

Definition at line 21 of file class.ilTestArchiver.php.

Referenced by handInParticipantSubmission().

◆ LOG_ADDITION_STRING

const ilTestArchiver::LOG_ADDITION_STRING = ' Adding '

Definition at line 41 of file class.ilTestArchiver.php.

◆ LOG_CREATION_STRING

const ilTestArchiver::LOG_CREATION_STRING = ' Creating '

Definition at line 42 of file class.ilTestArchiver.php.

◆ LOG_DELETION_STRING

const ilTestArchiver::LOG_DELETION_STRING = ' Deleting '

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

◆ LOG_DTSGROUP_FORMAT

const ilTestArchiver::LOG_DTSGROUP_FORMAT = 'D M j G:i:s T Y'

Definition at line 40 of file class.ilTestArchiver.php.

◆ LOG_UPDATE_STRING

const ilTestArchiver::LOG_UPDATE_STRING = ' Updating '

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

◆ PASS_MATERIALS_PATH_COMPONENT

const ilTestArchiver::PASS_MATERIALS_PATH_COMPONENT = 'materials'

Definition at line 23 of file class.ilTestArchiver.php.

Referenced by getPassMaterialsDirectory().

◆ PDF_BEST_SOLUTION_FILENAME

const ilTestArchiver::PDF_BEST_SOLUTION_FILENAME = 'best_solution.pdf'

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

◆ PDF_SUBMISSION_FILENAME

const ilTestArchiver::PDF_SUBMISSION_FILENAME = 'test_submission.pdf'

Definition at line 22 of file class.ilTestArchiver.php.

Referenced by handInParticipantSubmission().

◆ QUESTION_PATH_COMPONENT_PREFIX

const ilTestArchiver::QUESTION_PATH_COMPONENT_PREFIX = 'q_'

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

◆ TEST_BEST_SOLUTION_PATH_COMPONENT

const ilTestArchiver::TEST_BEST_SOLUTION_PATH_COMPONENT = 'best_solution'

◆ TEST_LOG_FILENAME

const ilTestArchiver::TEST_LOG_FILENAME = 'test.log'

Definition at line 46 of file class.ilTestArchiver.php.

◆ TEST_MATERIALS_PATH_COMPONENT

const ilTestArchiver::TEST_MATERIALS_PATH_COMPONENT = 'materials'

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

Referenced by handInBestSolutionQuestionMaterial().

◆ TEST_OVERVIEW_HTML_FILENAME

const ilTestArchiver::TEST_OVERVIEW_HTML_FILENAME = 'results_overview_pdf_v'

Definition at line 37 of file class.ilTestArchiver.php.

◆ TEST_OVERVIEW_HTML_POSTFIX

const ilTestArchiver::TEST_OVERVIEW_HTML_POSTFIX = '.html'

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

Referenced by handInTestResultsOverview().

◆ TEST_OVERVIEW_PDF_FILENAME

const ilTestArchiver::TEST_OVERVIEW_PDF_FILENAME = 'results_overview_html_v'

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

◆ TEST_OVERVIEW_PDF_POSTFIX

const ilTestArchiver::TEST_OVERVIEW_PDF_POSTFIX = '.pdf'

Definition at line 35 of file class.ilTestArchiver.php.

Referenced by handInTestResultsOverview().

◆ TEST_RESULT_FILENAME

const ilTestArchiver::TEST_RESULT_FILENAME = 'test_result_v'

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

◆ TEST_RESULT_POSTFIX

const ilTestArchiver::TEST_RESULT_POSTFIX = '.pdf'

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


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