ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 698 of file class.ilTestArchiver.php.

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

Referenced by createPassMaterialsDirectory(), and getPassDataDirectory().

699  {
700  $line = $this->determinePassDataPath( $date, $active_fi, $pass, $user_firstname, $user_lastname, $matriculation );
701 
702  $this->archive_data_index[] = $line;
703  $output_contents = '';
704 
705  foreach ($this->archive_data_index as $line_data)
706  {
707  if($line_data['identifier'] == "|")
708  {
709  continue;
710  }
711  $output_contents .= implode('|', $line_data) . "\n";
712  }
713 
714  file_put_contents($this->getTestArchive() . self::DIR_SEP . self::DATA_INDEX_FILENAME, $output_contents);
715  $this->readArchiveDataIndex();
716  return;
717  }
determinePassDataPath($date, $active_fi, $pass, $user_firstname, $user_lastname, $matriculation)
Determines the pass data path.
readArchiveDataIndex()
Reads the archive data index.
getTestArchive()
Returns the (theoretical) path to the archive directory of the test, this object is created for...
+ 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 491 of file class.ilTestArchiver.php.

References $pass, and getTestArchive().

Referenced by getPassDataDirectory().

492  {
493  foreach ($this->archive_data_index as $data_index_entry)
494  {
495  if ( $data_index_entry != null && $data_index_entry['identifier'] == $active_fi.'|'.$pass )
496  {
497  array_shift($data_index_entry);
498  return $this->getTestArchive() . self::DIR_SEP . implode(self::DIR_SEP, $data_index_entry);
499  }
500  }
501 
502  return null;
503  }
getTestArchive()
Returns the (theoretical) path to the archive directory of the test, this object is created for...
+ 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 443 of file class.ilTestArchiver.php.

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

444  {
445  $this->updateTestArchive();
447 
448  $zip_output_path = $this->getZipExportDirectory();
449  $zip_output_filename = 'test_archive_obj_'.$this->test_obj_id . '_' . time() . '_.zip';
450 
451  ilUtil::zip($this->getTestArchive(), $zip_output_path . self::DIR_SEP . $zip_output_filename, true);
452  return;
453  }
getZipExportDirectory()
Return the export directory, where zips are placed.
static zip($a_dir, $a_file, $compress_content=false)
zips given directory/file into given zip.file
getTestArchive()
Returns the (theoretical) path to the archive directory of the test, this object is created for...
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
updateTestArchive()
Replaces the test-log with the current one.
+ 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

PhpAssignmentInConditionInspection

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

References $file, and array.

Referenced by handInTestResult(), and handInTestResultsOverview().

775  {
776  $filecount = 0;
777 
779  if ($handle = opendir( $directory ))
780  {
781  while (($file = readdir( $handle )) !== false)
782  {
783  if (!in_array( $file, array( '.', '..' ) ) && !is_dir( $directory . $file ))
784  {
785  if ($pattern && strpos($file, $pattern) === 0 )
786  {
787  $filecount++;
788  }
789  }
790  }
791  }
792  return $filecount;
793  }
Create styles array
The data for the language used.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
+ Here is the caller graph for this function:

◆ createArchiveForTest()

ilTestArchiver::createArchiveForTest ( )
protected

Creates the directory for the test archive.

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

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

Referenced by ensureTestArchiveIsAvailable().

333  {
335  //mkdir( $this->getTestArchive(), 0777, true );
336  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
getTestArchive()
Returns the (theoretical) path to the archive directory of the test, this object is created for...
+ 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 485 of file class.ilTestArchiver.php.

References $pass, and getPassDataDirectory().

Referenced by ensurePassDataDirectoryIsAvailable().

486  {
487  mkdir($this->getPassDataDirectory($active_fi, $pass), 0777, true);
488  return;
489  }
getPassDataDirectory($active_fi, $pass)
Returns the pass data directory.
+ 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 594 of file class.ilTestArchiver.php.

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

Referenced by ensurePassMaterialsDirectoryIsAvailable().

595  {
596  // Data are taken from the current user as the implementation expects the first interaction of the pass
597  // takes place from the usage/behaviour of the current user.
598 
599  if( $this->getParticipantData() )
600  {
601  $usrData = $this->getParticipantData()->getUserDataByActiveId($active_fi);
602  $user = new ilObjUser();
603  $user->setFirstname($usrData['firstname']);
604  $user->setLastname($usrData['lastname']);
605  $user->setMatriculation($usrData['matriculation']);
606  $user->setFirstname($usrData['firstname']);
607  }
608  else
609  {
610  global $ilUser;
611  $user = $ilUser;
612  }
613 
615  date('Y'), $active_fi, $pass, $user->getFirstname(), $user->getLastname(), $user->getMatriculation()
616  );
617  mkdir($this->getPassMaterialsDirectory($active_fi, $pass) , 0777, true );
618  }
getPassMaterialsDirectory($active_fi, $pass)
Returns the pass materials directory.
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
appendToArchiveDataIndex($date, $active_fi, $pass, $user_firstname, $user_lastname, $matriculation)
Appends a line to the archive data index.
$ilUser
Definition: imgupload.php:18
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createZipExportDirectory()

ilTestArchiver::createZipExportDirectory ( )
protected

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

References getZipExportDirectory().

Referenced by ensureZipExportDirectoryExists().

423  {
424  mkdir($this->getZipExportDirectory(), 0777, true);
425  }
getZipExportDirectory()
Return the export directory, where zips are placed.
+ 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 731 of file class.ilTestArchiver.php.

References $pass, and array.

Referenced by appendToArchiveDataIndex().

732  {
733  $date = date_create_from_format(DATE_ISO8601, $date);
734  $line = array(
735  'identifier' => $active_fi . '|' . $pass,
736  'yyyy' => date_format( $date, 'Y' ),
737  'mm' => date_format( $date, 'm' ),
738  'dd' => date_format( $date, 'd' ),
739  'directory' => $active_fi . '_' . $pass . '_' . $user_firstname . '_' . $user_lastname . '_' . $matriculation
740  );
741  return $line;
742  }
Create styles array
The data for the language used.
+ 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 555 of file class.ilTestArchiver.php.

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

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

556  {
557  if (!$this->hasPassDataDirectory( $active_fi, $pass ))
558  {
559  $this->createPassDataDirectory( $active_fi, $pass );
560  }
561  return;
562  }
createPassDataDirectory($active_fi, $pass)
Creates pass data directory.
hasPassDataDirectory($active_fi, $pass)
Checks if the directory for pass data is available.
+ 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 643 of file class.ilTestArchiver.php.

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

644  {
645  if (!$this->hasPassMaterialsDirectory( $active_fi, $pass ))
646  {
647  $this->createPassMaterialsDirectory( $active_fi, $pass );
648  }
649  }
hasPassMaterialsDirectory($active_fi, $pass)
Returns if the pass materials directory exists for a given pass.
createPassMaterialsDirectory($active_fi, $pass)
Creates pass materials directory.
+ 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 357 of file class.ilTestArchiver.php.

References createArchiveForTest(), and hasTestArchive().

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

358  {
359  if (!$this->hasTestArchive())
360  {
361  $this->createArchiveForTest();
362  }
363  return;
364  }
createArchiveForTest()
Creates the directory for the test archive.
hasTestArchive()
Returns if the archive directory structure for the test the object is created for exists...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ensureZipExportDirectoryExists()

ilTestArchiver::ensureZipExportDirectoryExists ( )

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

References createZipExportDirectory(), and hasZipExportDirectory().

Referenced by compressTestArchive().

405  {
406  if (!$this->hasZipExportDirectory())
407  {
408  $this->createZipExportDirectory();
409  }
410  }
hasZipExportDirectory()
Returns if the export directory for zips exists.
+ 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.

References $participantData.

Referenced by createPassMaterialsDirectory(), and getPassDataDirectory().

117  {
118  return $this->participantData;
119  }
+ 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 513 of file class.ilTestArchiver.php.

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

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

514  {
515  $passDataDir = $this->buildPassDataDirectory($active_fi, $pass);
516 
517  if( !$passDataDir )
518  {
519  if( $this->getParticipantData() )
520  {
521  $usrData = $this->getParticipantData()->getUserDataByActiveId($active_fi);
522  $user = new ilObjUser();
523  $user->setFirstname($usrData['firstname']);
524  $user->setLastname($usrData['lastname']);
525  $user->setMatriculation($usrData['matriculation']);
526  $user->setFirstname($usrData['firstname']);
527  }
528  else
529  {
530  global $ilUser;
531  $user = $ilUser;
532  }
533 
535  date(DATE_ISO8601), $active_fi, $pass,
536  $user->getFirstname(), $user->getLastname(), $user->getMatriculation()
537  );
538 
539  $passDataDir = $this->buildPassDataDirectory($active_fi, $pass);
540  }
541 
542  return $passDataDir;
543  }
buildPassDataDirectory($active_fi, $pass)
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
appendToArchiveDataIndex($date, $active_fi, $pass, $user_firstname, $user_lastname, $matriculation)
Appends a line to the archive data index.
$ilUser
Definition: imgupload.php:18
+ 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 628 of file class.ilTestArchiver.php.

References $pass.

Referenced by createPassMaterialsDirectory(), and hasPassMaterialsDirectory().

629  {
630  $pass_data_directory = $this->getPassMaterialsDirectory($active_fi, $pass);
631  return $pass_data_directory . self::DIR_SEP . self::PASS_MATERIALS_PATH_COMPONENT;
632  }
getPassMaterialsDirectory($active_fi, $pass)
Returns the pass materials directory.
+ 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 343 of file class.ilTestArchiver.php.

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

344  {
345  $test_archive_directory = $this->external_directory_path . self::DIR_SEP . $this->client_id . self::DIR_SEP . 'tst_data'
346  . self::DIR_SEP . 'archive' . self::DIR_SEP . 'tst_'.$this->test_obj_id;
347  return $test_archive_directory;
348  }
+ Here is the caller graph for this function:

◆ getZipExportDirectory()

ilTestArchiver::getZipExportDirectory ( )

Return the export directory, where zips are placed.

Returns
string

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

References $test_obj_id.

Referenced by compressTestArchive(), createZipExportDirectory(), hasZipExportDirectory(), and ilTestExportGUI\listExportFiles().

433  {
434  return $this->external_directory_path . self::DIR_SEP . $this->client_id . self::DIR_SEP . 'tst_data'
435  . self::DIR_SEP . self::EXPORT_DIRECTORY . self::DIR_SEP . 'tst_' . $this->test_obj_id;
436  }
+ 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.

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

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  {
251  mkdir( $best_solution_path , 0777, true);
252  }
253 
254  $materials_path = $best_solution_path . self::DIR_SEP . self::TEST_MATERIALS_PATH_COMPONENT;
255  if ( !is_dir( $materials_path ) )
256  {
257  mkdir( $materials_path , 0777, true);
258  }
259 
260  $question_materials_path = $materials_path . self::DIR_SEP . self::QUESTION_PATH_COMPONENT_PREFIX . $question_fi;
261  if ( !is_dir( $question_materials_path ) )
262  {
263  mkdir( $question_materials_path , 0777, true);
264  }
265 
266  copy( $file_path, $question_materials_path . self::DIR_SEP . $orginial_filename );
267 
268  $this->logArchivingProcess(
269  date(self::LOG_DTSGROUP_FORMAT) . self::LOG_ADDITION_STRING
270  . $question_materials_path . self::DIR_SEP . $orginial_filename);
271  }
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
getTestArchive()
Returns the (theoretical) path to the archive directory of the test, this object is created for...
ensureTestArchiveIsAvailable()
Ensures the availability of the test archive directory.
logArchivingProcess($message)
Logs to the archive log.
+ 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 199 of file class.ilTestArchiver.php.

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

200  {
202  $this->ensurePassDataDirectoryIsAvailable( $active_fi, $pass );
203  $new_path = $this->getPassDataDirectory($active_fi, $pass) . self::DIR_SEP . $original_filename;
204  copy( $file_path, $new_path );
205  $this->logArchivingProcess( date( self::LOG_DTSGROUP_FORMAT ) . self::LOG_ADDITION_STRING . $new_path );
206  }
getPassDataDirectory($active_fi, $pass)
Returns the pass data directory.
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
ensurePassDataDirectoryIsAvailable($active_fi, $pass)
Ensures the availability of the participant data directory.
ensureTestArchiveIsAvailable()
Ensures the availability of the test archive directory.
logArchivingProcess($message)
Logs to the archive log.
+ 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.

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

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  {
178  mkdir( $pass_question_directory , 0777, true );
179  }
180 
181  copy( $file_path, $pass_question_directory . self::DIR_SEP. $original_filename );
182 
183  $this->logArchivingProcess(
184  date(self::LOG_DTSGROUP_FORMAT) . self::LOG_ADDITION_STRING
185  . $pass_question_directory . self::DIR_SEP. $original_filename
186  );
187  }
getPassDataDirectory($active_fi, $pass)
Returns the pass data directory.
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
ensurePassDataDirectoryIsAvailable($active_fi, $pass)
Ensures the availability of the participant data directory.
ensureTestArchiveIsAvailable()
Ensures the availability of the test archive directory.
logArchivingProcess($message)
Logs to the archive log.
+ 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.

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

144  {
146  $this->ensurePassDataDirectoryIsAvailable( $active_fi, $pass );
147 
148  $pdf_new_path = $this->getPassDataDirectory($active_fi, $pass) . self::DIR_SEP
149  . self::PDF_SUBMISSION_FILENAME;
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
153  . self::HTML_SUBMISSION_FILENAME;
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  }
getPassDataDirectory($active_fi, $pass)
Returns the pass data directory.
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
ensurePassDataDirectoryIsAvailable($active_fi, $pass)
Ensures the availability of the participant data directory.
ensureTestArchiveIsAvailable()
Ensures the availability of the test archive directory.
logArchivingProcess($message)
Logs to the archive log.
+ 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 214 of file class.ilTestArchiver.php.

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

215  {
217 
218  $best_solution_path = $this->getTestArchive() . self::DIR_SEP . self::TEST_BEST_SOLUTION_PATH_COMPONENT;
219  if ( !is_dir( $best_solution_path ) )
220  {
221  mkdir( $best_solution_path , 0777, true );
222  }
223 
224  file_put_contents( $best_solution_path . self::DIR_SEP . self::HTML_BEST_SOLUTION_FILENAME, $html_string );
225 
226  copy( $pdf_path, $best_solution_path . self::DIR_SEP . self::PDF_BEST_SOLUTION_FILENAME );
227 
228  $this->logArchivingProcess(
229  date(self::LOG_DTSGROUP_FORMAT) . self::LOG_ADDITION_STRING
230  . $best_solution_path . self::DIR_SEP . self::HTML_BEST_SOLUTION_FILENAME);
231 
232  $this->logArchivingProcess(
233  date(self::LOG_DTSGROUP_FORMAT) . self::LOG_ADDITION_STRING
234  . $best_solution_path . self::DIR_SEP . self::PDF_BEST_SOLUTION_FILENAME);
235  }
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
getTestArchive()
Returns the (theoretical) path to the archive directory of the test, this object is created for...
ensureTestArchiveIsAvailable()
Ensures the availability of the test archive directory.
logArchivingProcess($message)
Logs to the archive log.
+ 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 282 of file class.ilTestArchiver.php.

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

283  {
285  $this->ensurePassDataDirectoryIsAvailable( $active_fi, $pass );
286  $new_path = $this->getPassDataDirectory($active_fi, $pass) . self::DIR_SEP
287  . self::TEST_RESULT_FILENAME . ($this->countFilesInDirectory( $this->getPassDataDirectory($active_fi, $pass), self::TEST_RESULT_FILENAME ))
288  . self::TEST_RESULT_POSTFIX;
289  copy( $pdf_path, $new_path );
290  $this->logArchivingProcess( date( self::LOG_DTSGROUP_FORMAT ) . self::LOG_ADDITION_STRING . $new_path );
291  }
getPassDataDirectory($active_fi, $pass)
Returns the pass data directory.
countFilesInDirectory($directory, $pattern=null)
Returns the count of files in a directory, eventually matching the given, optional, pattern.
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
ensurePassDataDirectoryIsAvailable($active_fi, $pass)
Ensures the availability of the participant data directory.
ensureTestArchiveIsAvailable()
Ensures the availability of the test archive directory.
logArchivingProcess($message)
Logs to the archive log.
+ 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 299 of file class.ilTestArchiver.php.

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

300  {
302  $new_pdf_path = $this->getTestArchive() . self::DIR_SEP
303  . self::TEST_OVERVIEW_PDF_FILENAME
304  . $this->countFilesInDirectory($this->getTestArchive(), self::TEST_OVERVIEW_PDF_FILENAME) . self::TEST_OVERVIEW_PDF_POSTFIX;
305  copy( $pdf_path, $new_pdf_path );
306  $html_path = $this->getTestArchive() . self::DIR_SEP . self::TEST_OVERVIEW_HTML_FILENAME
307  . $this->countFilesInDirectory($this->getTestArchive(), self::TEST_OVERVIEW_HTML_FILENAME) . self::TEST_OVERVIEW_HTML_POSTFIX;
308  file_put_contents($html_path, $html_string);
309 
310  $this->logArchivingProcess( date( self::LOG_DTSGROUP_FORMAT ) . self::LOG_ADDITION_STRING . $new_pdf_path );
311  $this->logArchivingProcess( date( self::LOG_DTSGROUP_FORMAT ) . self::LOG_ADDITION_STRING . $html_path );
312  }
countFilesInDirectory($directory, $pattern=null)
Returns the count of files in a directory, eventually matching the given, optional, pattern.
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
getTestArchive()
Returns the (theoretical) path to the archive directory of the test, this object is created for...
ensureTestArchiveIsAvailable()
Ensures the availability of the test archive directory.
logArchivingProcess($message)
Logs to the archive log.
+ 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 471 of file class.ilTestArchiver.php.

References $pass, and getPassDataDirectory().

Referenced by ensurePassDataDirectoryIsAvailable().

472  {
473  $pass_data_dir = $this->getPassDataDirectory($active_fi, $pass);
474  return is_dir($this->getPassDataDirectory($active_fi, $pass));
475  }
getPassDataDirectory($active_fi, $pass)
Returns the pass data directory.
+ 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.

PhpUsageOfSilenceOperatorInspection

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

References $pass, and getPassMaterialsDirectory().

Referenced by ensurePassMaterialsDirectoryIsAvailable().

577  {
579  if ( @is_dir( $this->getPassMaterialsDirectory($active_fi, $pass)) )
580  {
581  return true;
582  }
583  return false;
584  }
getPassMaterialsDirectory($active_fi, $pass)
Returns the pass materials directory.
+ 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 324 of file class.ilTestArchiver.php.

References getTestArchive().

Referenced by ensureTestArchiveIsAvailable().

325  {
326  return is_dir($this->getTestArchive());
327  }
getTestArchive()
Returns the (theoretical) path to the archive directory of the test, this object is created for...
+ 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 417 of file class.ilTestArchiver.php.

References getZipExportDirectory().

Referenced by ensureZipExportDirectoryExists().

418  {
419  return is_dir($this->getZipExportDirectory());
420  }
getZipExportDirectory()
Return the export directory, where zips are placed.
+ 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 751 of file class.ilTestArchiver.php.

References getTestArchive().

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

752  {
753  $archive = $this->getTestArchive() . self::DIR_SEP . self::ARCHIVE_LOG;
754  if( file_exists($archive) )
755  {
756  $content = file_get_contents($archive). "\n" . $message;
757  }
758  else
759  {
760  $content = $message;
761  }
762 
763  file_put_contents($archive, $content);
764  }
getTestArchive()
Returns the (theoretical) path to the archive directory of the test, this object is created for...
+ 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>

PhpUsageOfSilenceOperatorInspection

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

References $contents, array, and getTestArchive().

Referenced by appendToArchiveDataIndex().

659  {
664  $data_index_file = $this->getTestArchive() . self::DIR_SEP . self::DATA_INDEX_FILENAME;
665 
666  $contents = array();
667 
669  if ( @file_exists( $data_index_file ) )
670  {
671  $lines = explode( "\n", file_get_contents( $data_index_file ) );
672  foreach ($lines as $line)
673  {
674  $line_items = explode('|', $line);
675  $line_data['identifier'] = $line_items[0] . '|' . $line_items[1];
676  $line_data['yyyy'] = $line_items[2];
677  $line_data['mm'] = $line_items[3];
678  $line_data['dd'] = $line_items[4];
679  $line_data['directory'] = $line_items[5];
680  $contents[] = $line_data;
681  }
682  }
683  return $contents;
684  }
Create styles array
The data for the language used.
getTestArchive()
Returns the (theoretical) path to the archive directory of the test, this object is created for...
+ 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.

References $participantData.

Referenced by ilTestArchiveService\archiveActivesPass().

125  {
126  $this->participantData = $participantData;
127  }
+ Here is the caller graph for this function:

◆ updateTestArchive()

ilTestArchiver::updateTestArchive ( )

Replaces the test-log with the current one.

Returns
void

PhpAssignmentInConditionInspection

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

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

Referenced by compressTestArchive().

372  {
373  $query = 'SELECT * FROM ass_log WHERE obj_fi = ' . $this->ilDB->quote($this->test_obj_id, 'integer');
374  $result = $this->ilDB->query($query);
375 
376  $outfile_lines = '';
378  while ($row = $this->ilDB->fetchAssoc($result))
379  {
380  $outfile_lines .= "\r\n" . implode("\t", $row);
381  }
382  file_put_contents($this->getTestArchive() . self::DIR_SEP . self::TEST_LOG_FILENAME, $outfile_lines);
383 
384  // Generate test pass overview
385  $test = new ilObjTest($this->test_obj_id, false);
386  $gui = new ilObjTestGUI();
387  $gui->object = $test;
388  $array_of_actives = array();
389  $participants = $test->getParticipants();
390 
391  foreach($participants as $key => $value)
392  {
393  $array_of_actives[] = $key;
394  }
395  $output_template = $gui->createUserResults(true, false, true, $array_of_actives);
396 
397  require_once 'class.ilTestPDFGenerator.php';
398  $filename = realpath($this->getTestArchive()) . self::DIR_SEP . 'participant_pass_overview.pdf';
400 
401  return;
402  }
Class ilObjTestGUI.
$result
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.
Create styles array
The data for the language used.
getTestArchive()
Returns the (theoretical) path to the archive directory of the test, this object is created for...
Database Wrapper.
Definition: class.ilDB.php:29
static generatePDF($pdf_output, $output_mode, $filename=null)
$test
Definition: Utf8Test.php:84
+ 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 getZipExportDirectory().

◆ ARCHIVE_LOG

const ilTestArchiver::ARCHIVE_LOG = 'archive.log'

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

◆ DATA_INDEX_FILENAME

const ilTestArchiver::DATA_INDEX_FILENAME = 'data_index.csv'

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

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

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

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

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

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

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

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

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

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