ILIAS  release_8 Revision v8.24
ilTestArchiver Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. 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...
 
 handInParticipantUploadedResults ($active_fi, $pass, $tst_obj)
 
 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_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

const TEST_RESULT_FILENAME = 'test_result.pdf'
 
 $external_directory_path
 
 $client_id
 
 $test_obj_id
 
 $test_ref_id
 
 $archive_data_index
 
ilDBInterface $ilDB
 
 $participantData
 

Private Member Functions

 buildPassDataDirectory ($active_fi, $pass)
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning 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 30 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 763 of file class.ilTestArchiver.php.

764 {
765 $line = $this->determinePassDataPath($date, $active_fi, $pass, $user_firstname, $user_lastname, $matriculation);
766
767 $this->archive_data_index[] = $line;
768 $output_contents = '';
769
770 foreach ($this->archive_data_index as $line_data) {
771 if ($line_data['identifier'] == "|") {
772 continue;
773 }
774 $output_contents .= implode('|', $line_data) . "\n";
775 }
776
777 file_put_contents($this->getTestArchive() . self::DIR_SEP . self::DATA_INDEX_FILENAME, $output_contents);
778 $this->readArchiveDataIndex();
779 return;
780 }
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 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 545 of file class.ilTestArchiver.php.

545 : ?string
546 {
547 foreach ($this->archive_data_index as $data_index_entry) {
548 if ($data_index_entry != null && $data_index_entry['identifier'] == $active_fi . '|' . $pass) {
549 array_shift($data_index_entry);
550 return $this->getTestArchive() . self::DIR_SEP . implode(self::DIR_SEP, $data_index_entry);
551 }
552 }
553
554 return null;
555 }

References 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 498 of file class.ilTestArchiver.php.

499 {
500 $this->updateTestArchive();
502
503 $zip_output_path = $this->getZipExportDirectory();
504 $zip_output_filename = 'test_archive_obj_' . $this->test_obj_id . '_' . time() . '_.zip';
505
506 ilFileUtils::zip($this->getTestArchive(), $zip_output_path . self::DIR_SEP . $zip_output_filename, true);
507 return;
508 }
static zip(string $a_dir, string $a_file, bool $compress_content=false)
zips given directory/file into given zip.file
getZipExportDirectory()
Return the export directory, where zips are placed.
updateTestArchive()
Replaces the test-log with the current one.

References ensureZipExportDirectoryExists(), getTestArchive(), getZipExportDirectory(), updateTestArchive(), and ilFileUtils\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 834 of file class.ilTestArchiver.php.

834 : int
835 {
836 $filecount = 0;
837
839 if ($handle = opendir($directory)) {
840 while (($file = readdir($handle)) !== false) {
841 if (!in_array($file, array( '.', '..' )) && !is_dir($directory . $file)) {
842 if ($pattern && strpos($file, $pattern) === 0) {
843 $filecount++;
844 }
845 }
846 }
847 }
848 return $filecount;
849 }

Referenced by handInTestResultsOverview().

+ Here is the caller graph for this function:

◆ createArchiveForTest()

ilTestArchiver::createArchiveForTest ( )
protected

Creates the directory for the test archive.

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

386 {
388 //mkdir( $this->getTestArchive(), 0777, true );
389 }
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.

References getTestArchive(), and ilFileUtils\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 539 of file class.ilTestArchiver.php.

540 {
541 mkdir($this->getPassDataDirectory($active_fi, $pass), 0777, true);
542 return;
543 }
getPassDataDirectory($active_fi, $pass)
Returns the pass data directory.

References 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
string

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

652 : string
653 {
654 // Data are taken from the current user as the implementation expects the first interaction of the pass
655 // takes place from the usage/behaviour of the current user.
656
657 if ($this->getParticipantData()) {
658 $usrData = $this->getParticipantData()->getUserDataByActiveId($active_fi);
659 $user = new ilObjUser();
660 $user->setFirstname($usrData['firstname']);
661 $user->setLastname($usrData['lastname']);
662 $user->setMatriculation($usrData['matriculation']);
663 $user->setFirstname($usrData['firstname']);
664 } else {
665 global $DIC;
666 $ilUser = $DIC['ilUser'];
667 $user = $ilUser;
668 }
669
671 date(DATE_ISO8601),
672 $active_fi,
673 $pass,
674 $user->getFirstname(),
675 $user->getLastname(),
676 $user->getMatriculation()
677 );
678
679 $material_directory = $this->getPassMaterialsDirectory($active_fi, $pass);
680 mkdir($material_directory, 0777, true);
681 return $material_directory;
682 }
User class.
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.
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34

References $DIC, $ilUser, appendToArchiveDataIndex(), 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 477 of file class.ilTestArchiver.php.

478 {
479 mkdir($this->getZipExportDirectory(), 0777, true);
480 }

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 794 of file class.ilTestArchiver.php.

794 : array
795 {
796 $date = date_create_from_format(DATE_ISO8601, $date);
797 $line = array(
798 'identifier' => $active_fi . '|' . $pass,
799 'yyyy' => date_format($date, 'Y'),
800 'mm' => date_format($date, 'm'),
801 'dd' => date_format($date, 'd'),
802 'directory' => $active_fi . '_' . $pass . '_' . $user_firstname . '_' . $user_lastname . '_' . $matriculation
803 );
804 return $line;
805 }

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 615 of file class.ilTestArchiver.php.

616 {
617 if (!$this->hasPassDataDirectory($active_fi, $pass)) {
618 $this->createPassDataDirectory($active_fi, $pass);
619 }
620 return;
621 }
hasPassDataDirectory($active_fi, $pass)
Checks if the directory for pass data is available.
createPassDataDirectory($active_fi, $pass)
Creates pass data directory.

References createPassDataDirectory(), and hasPassDataDirectory().

Referenced by handInParticipantMisc(), handInParticipantQuestionMaterial(), handInParticipantSubmission(), handInParticipantUploadedResults(), 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 707 of file class.ilTestArchiver.php.

708 {
709 if (!$this->hasPassMaterialsDirectory($active_fi, $pass)) {
710 $this->createPassMaterialsDirectory($active_fi, $pass);
711 }
712 }
hasPassMaterialsDirectory($active_fi, $pass)
Returns if the pass materials directory exists for a given pass.
createPassMaterialsDirectory($active_fi, $pass)
Creates pass materials directory.

References createPassMaterialsDirectory(), and hasPassMaterialsDirectory().

Referenced by handInParticipantUploadedResults().

+ Here is the call graph for this function:
+ Here is the caller 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 410 of file class.ilTestArchiver.php.

411 {
412 if (!$this->hasTestArchive()) {
413 $this->createArchiveForTest();
414 }
415 return;
416 }
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(), handInParticipantUploadedResults(), 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 460 of file class.ilTestArchiver.php.

461 {
462 if (!$this->hasZipExportDirectory()) {
464 }
465 }
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 133 of file class.ilTestArchiver.php.

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 565 of file class.ilTestArchiver.php.

565 : ?string
566 {
567 $passDataDir = $this->buildPassDataDirectory($active_fi, $pass);
568
569 if (!$passDataDir) {
570 $test_obj = new ilObjTest($this->test_obj_id, false);
571 if ($test_obj->getAnonymity()) {
572 $firstname = 'anonym';
573 $lastname = '';
574 $matriculation = '0';
575 } else {
576 if ($this->getParticipantData()) {
577 $usrData = $this->getParticipantData()->getUserDataByActiveId($active_fi);
578 $firstname = $usrData['firstname'];
579 $lastname = $usrData['lastname'];
580 $matriculation = $usrData['matriculation'];
581 } else {
582 global $DIC;
583 $ilUser = $DIC['ilUser'];
584 $firstname = $ilUser->getFirstname();
585 $lastname = $ilUser->getLastname();
586 $matriculation = $ilUser->getMatriculation();
587 }
588 }
589
591 date(DATE_ISO8601),
592 $active_fi,
593 $pass,
594 $firstname,
595 $lastname,
596 $matriculation
597 );
598
599 $passDataDir = $this->buildPassDataDirectory($active_fi, $pass);
600 }
601
602 return $passDataDir;
603 }
buildPassDataDirectory($active_fi, $pass)

References $DIC, $ilUser, appendToArchiveDataIndex(), buildPassDataDirectory(), and getParticipantData().

Referenced by createPassDataDirectory(), getPassMaterialsDirectory(), 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 692 of file class.ilTestArchiver.php.

692 : string
693 {
694 $pass_data_directory = $this->getPassDataDirectory($active_fi, $pass);
695 return $pass_data_directory . self::DIR_SEP . self::PASS_MATERIALS_PATH_COMPONENT;
696 }

References getPassDataDirectory(), and PASS_MATERIALS_PATH_COMPONENT.

Referenced by createPassMaterialsDirectory(), handInParticipantUploadedResults(), 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 396 of file class.ilTestArchiver.php.

396 : string
397 {
398 $test_archive_directory = $this->external_directory_path . self::DIR_SEP . $this->client_id . self::DIR_SEP . 'tst_data'
399 . self::DIR_SEP . 'archive' . self::DIR_SEP . 'tst_' . $this->test_obj_id;
400 return $test_archive_directory;
401 }

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 487 of file class.ilTestArchiver.php.

487 : string
488 {
489 return $this->external_directory_path . self::DIR_SEP . $this->client_id . self::DIR_SEP . 'tst_data'
490 . self::DIR_SEP . self::EXPORT_DIRECTORY . self::DIR_SEP . 'tst_' . $this->test_obj_id;
491 }

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 301 of file class.ilTestArchiver.php.

302 {
304
305 $best_solution_path = $this->getTestArchive() . self::DIR_SEP . self::TEST_BEST_SOLUTION_PATH_COMPONENT;
306 if (!is_dir($best_solution_path)) {
307 mkdir($best_solution_path, 0777, true);
308 }
309
310 $materials_path = $best_solution_path . self::DIR_SEP . self::TEST_MATERIALS_PATH_COMPONENT;
311 if (!is_dir($materials_path)) {
312 mkdir($materials_path, 0777, true);
313 }
314
315 $question_materials_path = $materials_path . self::DIR_SEP . self::QUESTION_PATH_COMPONENT_PREFIX . $question_fi;
316 if (!is_dir($question_materials_path)) {
317 mkdir($question_materials_path, 0777, true);
318 }
319
320 copy($file_path, $question_materials_path . self::DIR_SEP . $orginial_filename);
321
322 $this->logArchivingProcess(
323 date(self::LOG_DTSGROUP_FORMAT) . self::LOG_ADDITION_STRING
324 . $question_materials_path . self::DIR_SEP . $orginial_filename
325 );
326 }
ensureTestArchiveIsAvailable()
Ensures the availability of the test archive directory.
const TEST_BEST_SOLUTION_PATH_COMPONENT
logArchivingProcess($message)
Logs to the archive log.

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

256 {
258 $this->ensurePassDataDirectoryIsAvailable($active_fi, $pass);
259 $new_path = $this->getPassDataDirectory($active_fi, $pass) . self::DIR_SEP . $original_filename;
260 copy($file_path, $new_path);
261 $this->logArchivingProcess(date(self::LOG_DTSGROUP_FORMAT) . self::LOG_ADDITION_STRING . $new_path);
262 }
ensurePassDataDirectoryIsAvailable($active_fi, $pass)
Ensures the availability of the participant data directory.

References 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 186 of file class.ilTestArchiver.php.

187 {
189 $this->ensurePassDataDirectoryIsAvailable($active_fi, $pass);
190
191 $pass_question_directory = $this->getPassDataDirectory($active_fi, $pass)
192 . self::DIR_SEP . self::QUESTION_PATH_COMPONENT_PREFIX . $question_fi;
193 if (!is_dir($pass_question_directory)) {
194 mkdir($pass_question_directory, 0777, true);
195 }
196
197 copy($file_path, $pass_question_directory . self::DIR_SEP . $original_filename);
198
199 $this->logArchivingProcess(
200 date(self::LOG_DTSGROUP_FORMAT) . self::LOG_ADDITION_STRING
201 . $pass_question_directory . self::DIR_SEP . $original_filename
202 );
203 }

References 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 160 of file class.ilTestArchiver.php.

161 {
163 $this->ensurePassDataDirectoryIsAvailable($active_fi, $pass);
164
165 $pdf_new_path = $this->getPassDataDirectory($active_fi, $pass) . self::DIR_SEP
167 copy($pdf_path, $pdf_new_path);
168 # /home/mbecker/public_html/ilias/trunk-primary/extern/default/tst_data/archive/tst_350/2013/09/19/80_1_root_user_/test_submission.pdf
169 $html_new_path = $this->getPassDataDirectory($active_fi, $pass) . self::DIR_SEP
171 file_put_contents($html_new_path, $html_string);
172
173 $this->logArchivingProcess(date(self::LOG_DTSGROUP_FORMAT) . self::LOG_ADDITION_STRING . $pdf_new_path);
174 $this->logArchivingProcess(date(self::LOG_DTSGROUP_FORMAT) . self::LOG_ADDITION_STRING . $html_new_path);
175 }

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

+ Here is the call graph for this function:

◆ handInParticipantUploadedResults()

ilTestArchiver::handInParticipantUploadedResults (   $active_fi,
  $pass,
  $tst_obj 
)
Parameters
$active_fi
$pass
Returns
void

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

211 {
212 $questions = $tst_obj->getQuestionsOfPass($active_fi, $pass);
213 foreach ($questions as $question) {
214 $question = $tst_obj->getQuestionDataset($question['question_fi']);
215 if ($question->type_tag === 'assFileUpload') {
216 $local_folder = CLIENT_WEB_DIR . '/assessment/tst_' . $tst_obj->test_id . self::DIR_SEP . $active_fi . self::DIR_SEP . $question->question_id . '/files/';
217 if (!file_exists($local_folder)) {
218 continue; // no file submissions
219 }
221 $this->ensurePassDataDirectoryIsAvailable($active_fi, $pass);
222 $folder_content = scandir($local_folder);
223 $folder_content = array_diff($folder_content, array('.', '..'));
224 $this->ensurePassMaterialsDirectoryIsAvailable($active_fi, $pass);
225 $pass_material_directory = $this->getPassMaterialsDirectory($active_fi, $pass);
226 $archive_folder = $pass_material_directory . self::DIR_SEP . $question->question_id . self::DIR_SEP;
227 if (!file_exists($archive_folder)) {
228 mkdir($archive_folder, 0777, true);
229 }
230 foreach ($folder_content as $file_name) {
231 if (preg_match('/file_(\d+)_(\d+)_(\d+)/', $file_name, $matches)) {
232 if ($active_fi == intval($matches[1]) && $pass == $matches[2]) {
233
234 $local_file = $local_folder . $file_name;
235 $target_destination = $archive_folder . $file_name;
236 copy($local_file, $target_destination);
237 $this->logArchivingProcess(date(self::LOG_DTSGROUP_FORMAT) . self::LOG_ADDITION_STRING . $target_destination);
238 }
239 }
240 }
241 }
242 }
243 }
ensurePassMaterialsDirectoryIsAvailable($active_fi, $pass)
Ensures the availability of the pass materials directory.
const CLIENT_WEB_DIR
Definition: constants.php:47

References CLIENT_WEB_DIR, DIR_SEP, ensurePassDataDirectoryIsAvailable(), ensurePassMaterialsDirectoryIsAvailable(), ensureTestArchiveIsAvailable(), getPassMaterialsDirectory(), and logArchivingProcess().

+ 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 270 of file class.ilTestArchiver.php.

271 {
273
274 $best_solution_path = $this->getTestArchive() . self::DIR_SEP . self::TEST_BEST_SOLUTION_PATH_COMPONENT;
275 if (!is_dir($best_solution_path)) {
276 mkdir($best_solution_path, 0777, true);
277 }
278
279 file_put_contents($best_solution_path . self::DIR_SEP . self::HTML_BEST_SOLUTION_FILENAME, $html_string);
280
281 copy($pdf_path, $best_solution_path . self::DIR_SEP . self::PDF_BEST_SOLUTION_FILENAME);
282
283 $this->logArchivingProcess(
284 date(self::LOG_DTSGROUP_FORMAT) . self::LOG_ADDITION_STRING
285 . $best_solution_path . self::DIR_SEP . self::HTML_BEST_SOLUTION_FILENAME
286 );
287
288 $this->logArchivingProcess(
289 date(self::LOG_DTSGROUP_FORMAT) . self::LOG_ADDITION_STRING
290 . $best_solution_path . self::DIR_SEP . self::PDF_BEST_SOLUTION_FILENAME
291 );
292 }

References 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 337 of file class.ilTestArchiver.php.

338 {
340 $this->ensurePassDataDirectoryIsAvailable($active_fi, $pass);
341 $new_path = $this->getPassDataDirectory($active_fi, $pass) . self::DIR_SEP . self::TEST_RESULT_FILENAME;
342 copy($pdf_path, $new_path);
343 $this->logArchivingProcess(date(self::LOG_DTSGROUP_FORMAT) . self::LOG_ADDITION_STRING . $new_path);
344 }

References ensurePassDataDirectoryIsAvailable(), ensureTestArchiveIsAvailable(), getPassDataDirectory(), logArchivingProcess(), and TEST_RESULT_FILENAME.

+ 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 352 of file class.ilTestArchiver.php.

353 {
355 $new_pdf_path = $this->getTestArchive() . self::DIR_SEP
356 . self::TEST_OVERVIEW_PDF_FILENAME
357 . $this->countFilesInDirectory($this->getTestArchive(), self::TEST_OVERVIEW_PDF_FILENAME) . self::TEST_OVERVIEW_PDF_POSTFIX;
358 copy($pdf_path, $new_pdf_path);
359 $html_path = $this->getTestArchive() . self::DIR_SEP . self::TEST_OVERVIEW_HTML_FILENAME
360 . $this->countFilesInDirectory($this->getTestArchive(), self::TEST_OVERVIEW_HTML_FILENAME) . self::TEST_OVERVIEW_HTML_POSTFIX;
361 file_put_contents($html_path, $html_string);
362
363 $this->logArchivingProcess(date(self::LOG_DTSGROUP_FORMAT) . self::LOG_ADDITION_STRING . $new_pdf_path);
364 $this->logArchivingProcess(date(self::LOG_DTSGROUP_FORMAT) . self::LOG_ADDITION_STRING . $html_path);
365 }
countFilesInDirectory($directory, $pattern=null)
Returns the count of files in a directory, eventually matching the given, optional,...

References countFilesInDirectory(), 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 526 of file class.ilTestArchiver.php.

526 : bool
527 {
528 return is_dir($this->getPassDataDirectory($active_fi, $pass));
529 }

References 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 635 of file class.ilTestArchiver.php.

635 : bool
636 {
638 if (@is_dir($this->getPassMaterialsDirectory($active_fi, $pass))) {
639 return true;
640 }
641 return false;
642 }

References 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 377 of file class.ilTestArchiver.php.

377 : bool
378 {
379 return is_dir($this->getTestArchive());
380 }

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 472 of file class.ilTestArchiver.php.

472 : bool
473 {
474 return is_dir($this->getZipExportDirectory());
475 }

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 814 of file class.ilTestArchiver.php.

815 {
816 $archive = $this->getTestArchive() . self::DIR_SEP . self::ARCHIVE_LOG;
817 if (file_exists($archive)) {
818 $content = file_get_contents($archive) . "\n" . $message;
819 } else {
820 $content = $message;
821 }
822
823 file_put_contents($archive, $content);
824 }
$message
Definition: xapiexit.php:32

References $message, ARCHIVE_LOG, and getTestArchive().

Referenced by handInBestSolutionQuestionMaterial(), handInParticipantMisc(), handInParticipantQuestionMaterial(), handInParticipantSubmission(), handInParticipantUploadedResults(), 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 721 of file class.ilTestArchiver.php.

721 : array
722 {
727 $data_index_file = $this->getTestArchive() . self::DIR_SEP . self::DATA_INDEX_FILENAME;
728
729 $contents = array();
730
732 if (@file_exists($data_index_file)) {
733 $lines = explode("\n", file_get_contents($data_index_file));
734 foreach ($lines as $line) {
735 if (strlen($line) === 0) {
736 continue;
737 }
738 $line_items = explode('|', $line);
739 $line_data = [];
740 $line_data['identifier'] = $line_items[0] . '|' . $line_items[1];
741 $line_data['yyyy'] = $line_items[2];
742 $line_data['mm'] = $line_items[3];
743 $line_data['dd'] = $line_items[4];
744 $line_data['directory'] = $line_items[5];
745 $contents[] = $line_data;
746 }
747 }
748 return $contents;
749 }

References 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 141 of file class.ilTestArchiver.php.

142 {
143 $this->participantData = $participantData;
144 }

References $participantData.

◆ updateTestArchive()

ilTestArchiver::updateTestArchive ( )

Replaces the test-log with the current one.

Returns
void

@noinspection PhpAssignmentInConditionInspection

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

424 {
425 $query = 'SELECT * FROM ass_log WHERE obj_fi = ' . $this->ilDB->quote($this->test_obj_id, 'integer');
426 $result = $this->ilDB->query($query);
427
428 $outfile_lines = '';
430 while ($row = $this->ilDB->fetchAssoc($result)) {
431 $outfile_lines .= "\r\n" . implode("\t", $row);
432 }
433 file_put_contents($this->getTestArchive() . self::DIR_SEP . self::TEST_LOG_FILENAME, $outfile_lines);
434
435 // Generate test pass overview
436 $test = new ilObjTest($this->test_obj_id, false);
437 if ($this->test_ref_id !== null) {
438 $test->setRefId($this->test_ref_id);
439 }
440
441 $gui = new ilParticipantsTestResultsGUI();
442 $gui->setTestObj($test);
443
444 $objectiveOrientedContainer = new ilTestObjectiveOrientedContainer();
445 $gui->setObjectiveParent($objectiveOrientedContainer);
446 $array_of_actives = array();
447 $participants = $test->getParticipants();
448
449 foreach ($participants as $key => $value) {
450 $array_of_actives[] = $key;
451 }
452 $output_template = $gui->createUserResults(true, false, true, $array_of_actives);
453
454 $filename = realpath($this->getTestArchive()) . self::DIR_SEP . 'participant_pass_overview.pdf';
456
457 return;
458 }
$filename
Definition: buildRTE.php:78
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static generatePDF($pdf_output, $output_mode, $filename=null, $purpose=null)
const PDF_USER_RESULT
PDF Purposes.
string $key
Consumer key/client ID value.
Definition: System.php:193
$query

References $filename, ILIAS\LTI\ToolProvider\$key, $query, ilTestPDFGenerator\generatePDF(), getTestArchive(), ilTestPDFGenerator\PDF_OUTPUT_FILE, and PDF_USER_RESULT.

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 98 of file class.ilTestArchiver.php.

◆ $client_id

ilTestArchiver::$client_id
protected

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

◆ $external_directory_path

ilTestArchiver::$external_directory_path
protected

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

◆ $ilDB

ilDBInterface ilTestArchiver::$ilDB
protected

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

◆ $participantData

ilTestArchiver::$participantData
protected

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

Referenced by getParticipantData(), and setParticipantData().

◆ $test_obj_id

ilTestArchiver::$test_obj_id
protected

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

Referenced by getTestArchive(), and getZipExportDirectory().

◆ $test_ref_id

ilTestArchiver::$test_ref_id
protected

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

◆ ARCHIVE_LOG

const ilTestArchiver::ARCHIVE_LOG = 'archive.log'

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

Referenced by logArchivingProcess().

◆ DATA_INDEX_FILENAME

const ilTestArchiver::DATA_INDEX_FILENAME = 'data_index.csv'

Definition at line 61 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 64 of file class.ilTestArchiver.php.

◆ HTML_BEST_SOLUTION_FILENAME

const ilTestArchiver::HTML_BEST_SOLUTION_FILENAME = 'best_solution.html'

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

◆ HTML_SUBMISSION_FILENAME

const ilTestArchiver::HTML_SUBMISSION_FILENAME = 'test_submission.html'

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

Referenced by handInParticipantSubmission().

◆ LOG_ADDITION_STRING

const ilTestArchiver::LOG_ADDITION_STRING = ' Adding '

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

◆ LOG_CREATION_STRING

const ilTestArchiver::LOG_CREATION_STRING = ' Creating '

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

◆ LOG_DELETION_STRING

const ilTestArchiver::LOG_DELETION_STRING = ' Deleting '

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

◆ LOG_DTSGROUP_FORMAT

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

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

◆ LOG_UPDATE_STRING

const ilTestArchiver::LOG_UPDATE_STRING = ' Updating '

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

◆ PASS_MATERIALS_PATH_COMPONENT

const ilTestArchiver::PASS_MATERIALS_PATH_COMPONENT = 'materials'

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

Referenced by getPassMaterialsDirectory().

◆ PDF_BEST_SOLUTION_FILENAME

const ilTestArchiver::PDF_BEST_SOLUTION_FILENAME = 'best_solution.pdf'

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

◆ PDF_SUBMISSION_FILENAME

const ilTestArchiver::PDF_SUBMISSION_FILENAME = 'test_submission.pdf'

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

Referenced by handInParticipantSubmission().

◆ QUESTION_PATH_COMPONENT_PREFIX

const ilTestArchiver::QUESTION_PATH_COMPONENT_PREFIX = 'q_'

Definition at line 39 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 60 of file class.ilTestArchiver.php.

◆ TEST_MATERIALS_PATH_COMPONENT

const ilTestArchiver::TEST_MATERIALS_PATH_COMPONENT = 'materials'

Definition at line 44 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 51 of file class.ilTestArchiver.php.

◆ TEST_OVERVIEW_HTML_POSTFIX

const ilTestArchiver::TEST_OVERVIEW_HTML_POSTFIX = '.html'

Definition at line 52 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 48 of file class.ilTestArchiver.php.

◆ TEST_OVERVIEW_PDF_POSTFIX

const ilTestArchiver::TEST_OVERVIEW_PDF_POSTFIX = '.pdf'

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

Referenced by handInTestResultsOverview().

◆ TEST_RESULT_FILENAME

const ilTestArchiver::TEST_RESULT_FILENAME = 'test_result.pdf'
protected

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

Referenced by handInTestResult().


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