ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilTestArchiver Class Reference

Class ilTestArchiver. More...

+ Collaboration diagram for ilTestArchiver:

Public Member Functions

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

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.
 createArchiveForTest ()
 Creates the directory for the test archive.
 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.
 createZipExportDirectory ()
 hasPassDataDirectory ($active_fi, $pass)
 Checks if the directory for pass data is available.
 createPassDataDirectory ($active_fi, $pass)
 Creates pass data directory.
 getPassDataDirectory ($active_fi, $pass)
 Returns the pass data directory.
 ensurePassDataDirectoryIsAvailable ($active_fi, $pass)
 Ensures the availability of the participant data directory.
 hasPassMaterialsDirectory ($active_fi, $pass)
 Returns if the pass materials directory exists for a given pass.
 createPassMaterialsDirectory ($active_fi, $pass)
 Creates pass materials directory.
 getPassMaterialsDirectory ($active_fi, $pass)
 Returns the pass materials directory.
 ensurePassMaterialsDirectoryIsAvailable ($active_fi, $pass)
 Ensures the availability of the pass materials directory.
 readArchiveDataIndex ()
 Reads the archive data index.
 appendToArchiveDataIndex ($date, $active_fi, $pass, $user_firstname, $user_lastname, $matriculation)
 Appends a line to the archive data index.
 determinePassDataPath ($date, $active_fi, $pass, $user_firstname, $user_lastname, $matriculation)
 Determines the pass data path.
 logArchivingProcess ($message)
 Logs to the archive log.
 countFilesInDirectory ($directory, $pattern=null)
 Returns the count of files in a directory, eventually matching the given, optional, pattern.

Protected Attributes

 $external_directory_path
 $client_id
 $test_obj_id
 $archive_data_index
 $ilDB

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

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

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

Referenced by createPassMaterialsDirectory(), and getPassDataDirectory().

{
$line = $this->determinePassDataPath( $date, $active_fi, $pass, $user_firstname, $user_lastname, $matriculation );
$this->archive_data_index[] = $line;
$output_contents = '';
foreach ($this->archive_data_index as $line_data)
{
if($line_data['identifier'] == "|")
{
continue;
}
$output_contents .= implode('|', $line_data) . "\n";
}
file_put_contents($this->getTestArchive() . self::DIR_SEP . self::DATA_INDEX_FILENAME, $output_contents);
return;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilTestArchiver::compressTestArchive ( )

Generate the test archive for download.

Returns
void

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

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

{
$zip_output_path = $this->getZipExportDirectory();
$zip_output_filename = 'test_archive_obj_'.$this->test_obj_id . '_' . time() . '_.zip';
ilUtil::zip($this->getTestArchive(), $zip_output_path . self::DIR_SEP . $zip_output_filename, true);
return;
}

+ Here is the call graph for this function:

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

References $file.

Referenced by handInTestResult(), and handInTestResultsOverview().

{
$filecount = 0;
if ($handle = opendir( $directory ))
{
while (($file = readdir( $handle )) !== false)
{
if (!in_array( $file, array( '.', '..' ) ) && !is_dir( $directory . $file ))
{
if ($pattern && strpos($file, $pattern) === 0 )
{
$filecount++;
}
}
}
}
return $filecount;
}

+ Here is the caller graph for this function:

ilTestArchiver::createArchiveForTest ( )
protected

Creates the directory for the test archive.

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

References getTestArchive().

Referenced by ensureTestArchiveIsAvailable().

{
mkdir( $this->getTestArchive(), 0777, true );
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

References $pass, and getPassDataDirectory().

Referenced by ensurePassDataDirectoryIsAvailable().

{
mkdir($this->getPassDataDirectory($active_fi, $pass), 0777, true);
return;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

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

Referenced by ensurePassMaterialsDirectoryIsAvailable().

{
// Data are taken from the current user as the implementation expects the first interaction of the pass
// takes place from the usage/behaviour of the current user.
global $ilUser;
$this->appendToArchiveDataIndex(date('Y'), $active_fi, $pass, $ilUser->getFirstname(), $ilUser->getLastname(), $ilUser->getMatriculation());
mkdir($this->getPassMaterialsDirectory($active_fi, $pass) , 0777, true );
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilTestArchiver::createZipExportDirectory ( )
protected

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

References getZipExportDirectory().

Referenced by ensureZipExportDirectoryExists().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

References $pass.

Referenced by appendToArchiveDataIndex().

{
$date = date_create_from_format(DATE_ISO8601, $date);
$line = array(
'identifier' => $active_fi . '|' . $pass,
'yyyy' => date_format( $date, 'Y' ),
'mm' => date_format( $date, 'm' ),
'dd' => date_format( $date, 'd' ),
'directory' => $active_fi . '_' . $pass . '_' . $user_firstname . '_' . $user_lastname . '_' . $matriculation
);
return $line;
}

+ Here is the caller graph for this function:

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

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

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

{
if (!$this->hasPassDataDirectory( $active_fi, $pass ))
{
$this->createPassDataDirectory( $active_fi, $pass );
}
return;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

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

{
if (!$this->hasPassMaterialsDirectory( $active_fi, $pass ))
{
$this->createPassMaterialsDirectory( $active_fi, $pass );
}
}

+ Here is the call graph for this function:

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

References createArchiveForTest(), and hasTestArchive().

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

{
if (!$this->hasTestArchive())
{
}
return;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilTestArchiver::ensureZipExportDirectoryExists ( )

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

References createZipExportDirectory(), and hasZipExportDirectory().

Referenced by compressTestArchive().

{
if (!$this->hasZipExportDirectory())
{
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

References $ilUser, $pass, appendToArchiveDataIndex(), and getTestArchive().

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

{
foreach ($this->archive_data_index as $data_index_entry)
{
if ( $data_index_entry != null && $data_index_entry['identifier'] == $active_fi.'|'.$pass )
{
array_shift($data_index_entry);
return $this->getTestArchive() . self::DIR_SEP . implode(self::DIR_SEP, $data_index_entry);
}
}
global $ilUser;
$this->appendToArchiveDataIndex(date(DATE_ISO8601), $active_fi, $pass, $ilUser->getFirstname(), $ilUser->getLastname(), $ilUser->getMatriculation());
$data_index_entry = $this->getPassDataDirectory($active_fi, $pass);
@array_shift($data_index_entry);
return $this->getTestArchive() . self::DIR_SEP . implode(self::DIR_SEP, $data_index_entry);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

References $pass, and PASS_MATERIALS_PATH_COMPONENT.

Referenced by createPassMaterialsDirectory(), and hasPassMaterialsDirectory().

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

+ Here is the caller graph for this function:

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

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

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

+ Here is the caller graph for this function:

ilTestArchiver::getZipExportDirectory ( )

Return the export directory, where zips are placed.

Returns
string

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

References $test_obj_id.

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

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

+ Here is the caller graph for this function:

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

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

{
$best_solution_path = $this->getTestArchive() . self::DIR_SEP . self::TEST_BEST_SOLUTION_PATH_COMPONENT;
if ( !is_dir( $best_solution_path ) )
{
mkdir( $best_solution_path , 0777, true);
}
$materials_path = $best_solution_path . self::DIR_SEP . self::TEST_MATERIALS_PATH_COMPONENT;
if ( !is_dir( $materials_path ) )
{
mkdir( $materials_path , 0777, true);
}
$question_materials_path = $materials_path . self::DIR_SEP . self::QUESTION_PATH_COMPONENT_PREFIX . $question_fi;
if ( !is_dir( $question_materials_path ) )
{
mkdir( $question_materials_path , 0777, true);
}
copy( $file_path, $question_materials_path . self::DIR_SEP . $orginial_filename );
date(self::LOG_DTSGROUP_FORMAT) . self::LOG_ADDITION_STRING
. $question_materials_path . self::DIR_SEP . $orginial_filename);
}

+ Here is the call graph for this function:

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

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

{
$new_path = $this->getPassDataDirectory($active_fi, $pass) . self::DIR_SEP . $original_filename;
copy( $file_path, $new_path );
$this->logArchivingProcess( date( self::LOG_DTSGROUP_FORMAT ) . self::LOG_ADDITION_STRING . $new_path );
}

+ Here is the call graph for this function:

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

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

{
$pass_question_directory = $this->getPassDataDirectory( $active_fi, $pass )
. self::DIR_SEP . self::QUESTION_PATH_COMPONENT_PREFIX . $question_fi;
if ( !is_dir( $pass_question_directory ) )
{
mkdir( $pass_question_directory , 0777, true );
}
copy( $file_path, $pass_question_directory . self::DIR_SEP. $original_filename );
date(self::LOG_DTSGROUP_FORMAT) . self::LOG_ADDITION_STRING
. $pass_question_directory . self::DIR_SEP. $original_filename
);
}

+ Here is the call graph for this function:

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

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

{
$pdf_new_path = $this->getPassDataDirectory($active_fi, $pass) . self::DIR_SEP
copy( $pdf_path, $pdf_new_path );
# /home/mbecker/public_html/ilias/trunk-primary/extern/default/tst_data/archive/tst_350/2013/09/19/80_1_root_user_/test_submission.pdf
$html_new_path = $this->getPassDataDirectory($active_fi, $pass) . self::DIR_SEP
file_put_contents($html_new_path, $html_string);
$this->logArchivingProcess( date( self::LOG_DTSGROUP_FORMAT ) . self::LOG_ADDITION_STRING . $pdf_new_path );
$this->logArchivingProcess( date( self::LOG_DTSGROUP_FORMAT ) . self::LOG_ADDITION_STRING . $html_new_path );
}

+ Here is the call graph for this function:

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

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

{
$best_solution_path = $this->getTestArchive() . self::DIR_SEP . self::TEST_BEST_SOLUTION_PATH_COMPONENT;
if ( !is_dir( $best_solution_path ) )
{
mkdir( $best_solution_path , 0777, true );
}
file_put_contents( $best_solution_path . self::DIR_SEP . self::HTML_BEST_SOLUTION_FILENAME, $html_string );
copy( $pdf_path, $best_solution_path . self::DIR_SEP . self::PDF_BEST_SOLUTION_FILENAME );
date(self::LOG_DTSGROUP_FORMAT) . self::LOG_ADDITION_STRING
. $best_solution_path . self::DIR_SEP . self::HTML_BEST_SOLUTION_FILENAME);
date(self::LOG_DTSGROUP_FORMAT) . self::LOG_ADDITION_STRING
. $best_solution_path . self::DIR_SEP . self::PDF_BEST_SOLUTION_FILENAME);
}

+ Here is the call graph for this function:

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

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

Referenced by ilTestScoring\recalculatePasses().

{
$new_path = $this->getPassDataDirectory($active_fi, $pass) . self::DIR_SEP
. self::TEST_RESULT_FILENAME . ($this->countFilesInDirectory( $this->getPassDataDirectory($active_fi, $pass), self::TEST_RESULT_FILENAME ))
. self::TEST_RESULT_POSTFIX;
copy( $pdf_path, $new_path );
$this->logArchivingProcess( date( self::LOG_DTSGROUP_FORMAT ) . self::LOG_ADDITION_STRING . $new_path );
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

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

{
$new_pdf_path = $this->getTestArchive() . self::DIR_SEP
. self::TEST_OVERVIEW_PDF_FILENAME
. $this->countFilesInDirectory($this->getTestArchive(), self::TEST_OVERVIEW_PDF_FILENAME) . self::TEST_OVERVIEW_PDF_POSTFIX;
copy( $pdf_path, $new_pdf_path );
$html_path = $this->getTestArchive() . self::DIR_SEP . self::TEST_OVERVIEW_HTML_FILENAME
. $this->countFilesInDirectory($this->getTestArchive(), self::TEST_OVERVIEW_HTML_FILENAME) . self::TEST_OVERVIEW_HTML_POSTFIX;
file_put_contents($html_path, $html_string);
$this->logArchivingProcess( date( self::LOG_DTSGROUP_FORMAT ) . self::LOG_ADDITION_STRING . $new_pdf_path );
$this->logArchivingProcess( date( self::LOG_DTSGROUP_FORMAT ) . self::LOG_ADDITION_STRING . $html_path );
}

+ Here is the call graph for this function:

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

References $pass, and getPassDataDirectory().

Referenced by ensurePassDataDirectoryIsAvailable().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

References $pass, and getPassMaterialsDirectory().

Referenced by ensurePassMaterialsDirectoryIsAvailable().

{
if ( @is_dir( $this->getPassMaterialsDirectory($active_fi, $pass)) )
{
return true;
}
return false;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

References getTestArchive().

Referenced by ensureTestArchiveIsAvailable().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilTestArchiver::hasZipExportDirectory ( )

Returns if the export directory for zips exists.

Returns
bool

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

References getZipExportDirectory().

Referenced by ensureZipExportDirectoryExists().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilTestArchiver::logArchivingProcess (   $message)
protected

Logs to the archive log.

Parameters
$messagestring Complete log message.
Returns
void

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

References ARCHIVE_LOG, and getTestArchive().

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

{
$archive = $this->getTestArchive() . self::DIR_SEP . self::ARCHIVE_LOG;
file_put_contents($archive, file_get_contents($archive) . "\n" . $message);
return;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

References DATA_INDEX_FILENAME, and getTestArchive().

Referenced by appendToArchiveDataIndex().

{
$data_index_file = $this->getTestArchive() . self::DIR_SEP . self::DATA_INDEX_FILENAME;
$contents = array();
if ( @file_exists( $data_index_file ) )
{
$lines = explode( "\n", file_get_contents( $data_index_file ) );
foreach ($lines as $line)
{
$line_items = explode('|', $line);
$line_data['identifier'] = $line_items[0] . '|' . $line_items[1];
$line_data['yyyy'] = $line_items[2];
$line_data['mm'] = $line_items[3];
$line_data['dd'] = $line_items[4];
$line_data['directory'] = $line_items[5];
$contents[] = $line_data;
}
}
return $contents;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilTestArchiver::updateTestArchive ( )

Replaces the test-log with the current one.

Returns
void

PhpAssignmentInConditionInspection

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

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

Referenced by compressTestArchive().

{
$query = 'SELECT * FROM ass_log WHERE obj_fi = ' . $this->ilDB->quote($this->test_obj_id, 'integer');
$result = $this->ilDB->query($query);
$outfile_lines = '';
while ($row = $this->ilDB->fetchAssoc($result))
{
$outfile_lines .= "\r\n" . implode("\t", $row);
}
file_put_contents($this->getTestArchive() . self::DIR_SEP . self::TEST_LOG_FILENAME, $outfile_lines);
// Generate test pass overview
$test = new ilObjTest($this->test_obj_id, false);
$gui = new ilObjTestGUI();
$gui->object = $test;
$array_of_actives = array();
$participants = $test->getParticipants();
foreach($participants as $key => $value)
{
$array_of_actives[] = $key;
}
$output_template = $gui->createUserResults(true, false, true, $array_of_actives);
require_once 'class.ilTestPDFGenerator.php';
$filename = $this->getTestArchive() . self::DIR_SEP . 'participant_pass_overview.pdf';
return;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ilTestArchiver::$archive_data_index
protected

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

ilTestArchiver::$client_id
protected

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

ilTestArchiver::$external_directory_path
protected

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

ilTestArchiver::$ilDB
protected

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

ilTestArchiver::$test_obj_id
protected

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

Referenced by getZipExportDirectory().

const ilTestArchiver::ARCHIVE_LOG = 'archive.log'

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

Referenced by logArchivingProcess().

const ilTestArchiver::DATA_INDEX_FILENAME = 'data_index.csv'

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

Referenced by readArchiveDataIndex().

const ilTestArchiver::DIR_SEP = '/'
const ilTestArchiver::EXPORT_DIRECTORY = 'archive_exports'

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

const ilTestArchiver::HTML_BEST_SOLUTION_FILENAME = 'best_solution.html'

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

const ilTestArchiver::HTML_SUBMISSION_FILENAME = 'test_submission.html'

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

Referenced by handInParticipantSubmission().

const ilTestArchiver::LOG_ADDITION_STRING = ' Adding '

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

const ilTestArchiver::LOG_CREATION_STRING = ' Creating '

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

const ilTestArchiver::LOG_DELETION_STRING = ' Deleting '

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

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

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

const ilTestArchiver::LOG_UPDATE_STRING = ' Updating '

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

const ilTestArchiver::PASS_MATERIALS_PATH_COMPONENT = 'materials'

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

Referenced by getPassMaterialsDirectory().

const ilTestArchiver::PDF_BEST_SOLUTION_FILENAME = 'best_solution.pdf'

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

const ilTestArchiver::PDF_SUBMISSION_FILENAME = 'test_submission.pdf'

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

Referenced by handInParticipantSubmission().

const ilTestArchiver::QUESTION_PATH_COMPONENT_PREFIX = 'q_'

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

const ilTestArchiver::TEST_BEST_SOLUTION_PATH_COMPONENT = 'best_solution'
const ilTestArchiver::TEST_LOG_FILENAME = 'test.log'

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

const ilTestArchiver::TEST_MATERIALS_PATH_COMPONENT = 'materials'

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

Referenced by handInBestSolutionQuestionMaterial().

const ilTestArchiver::TEST_OVERVIEW_HTML_FILENAME = 'results_overview_pdf_v'

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

const ilTestArchiver::TEST_OVERVIEW_HTML_POSTFIX = '.html'

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

Referenced by handInTestResultsOverview().

const ilTestArchiver::TEST_OVERVIEW_PDF_FILENAME = 'results_overview_html_v'

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

const ilTestArchiver::TEST_OVERVIEW_PDF_POSTFIX = '.pdf'

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

Referenced by handInTestResultsOverview().

const ilTestArchiver::TEST_RESULT_FILENAME = 'test_result_v'

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

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: