ILIAS  trunk Revision v11.0_alpha-1831-g8615d53dadb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilTestArchiver Class Reference
+ Collaboration diagram for ilTestArchiver:

Public Member Functions

 getParticipantData ()
 
 setParticipantData (ilTestParticipantData $participant_data)
 
 handInParticipantQuestionMaterial (int $active_fi, int $pass, int $question_fi, string $original_filename, string $file_path)
 
 handInParticipantMisc (int $active_fi, int $pass, string $original_filename, string $file_path)
 
 handInTestBestSolution (string $best_solution)
 
 handInParticipantUploadedResults (int $active_fi, int $pass, ilObjTest $tst_obj)
 
 handInBestSolutionQuestionMaterial (int $question_fi, string $orginial_filename, string $file_path)
 
 handInTestResult (int $active_fi, int $pass, string $pdf_path)
 
 updateTestArchive ()
 
 ensureZipExportDirectoryExists ()
 
 hasZipExportDirectory ()
 
 getZipExportDirectory ()
 
 compressTestArchive ()
 
 getResultsOfUserOutput (\ilObjTest $test_obj, ilTestSession $test_session, array $participant_data, int $active_id, int $attempt)
 

Data Fields

const DIR_SEP = DIRECTORY_SEPARATOR
 
const EXPORT_DIRECTORY = 'archive_exports'
 

Protected Member Functions

 hasTestArchive ()
 
 createArchiveForTest ()
 
 getTestArchive ()
 
 ensureTestArchiveIsAvailable ()
 
 createZipExportDirectory ()
 
 hasPassDataDirectory (int $active_fi, int $pass)
 
 createPassDataDirectory (int $active_fi, int $pass)
 
 getPassDataDirectory (int $active_fi, int $pass)
 
 ensurePassDataDirectoryIsAvailable (int $active_fi, int $pass)
 
 hasPassMaterialsDirectory (int $active_fi, int $pass)
 
 createPassMaterialsDirectory (int $active_fi, int $pass)
 
 getPassMaterialsDirectory (int $active_fi, int $pass)
 
 ensurePassMaterialsDirectoryIsAvailable (int $active_fi, int $pass)
 
 readArchiveDataIndex ()
 
 appendToArchiveDataIndex (string $date, int $active_fi, int $pass, string $user_firstname, string $user_lastname, string $matriculation)
 

Protected Attributes

ilTestHTMLGenerator $html_generator
 
ilTestParticipantData $participant_data = null
 

Private Member Functions

 buildPassDataDirectory ($active_fi, $pass)
 
 determinePassDataPath (string $date, int $active_fi, int $pass, string $user_firstname, string $user_lastname, string $matriculation)
 
 createUserResultsForArchive (\ilObjTest $test_obj, array $active_ids,)
 
 getColumnsForAttemptOverviewTable (bool $show_requested_hints_info)
 
 getDataRetrievalForAttemptOverviewTable (array $result_data)
 
 logArchivingProcess (string $message)
 

Private Attributes

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 TEST_MATERIALS_PATH_COMPONENT = 'materials'
 
const TEST_RESULT_FILENAME = 'test_result.html'
 
const LOG_DTSGROUP_FORMAT = 'D M j G:i:s T Y'
 
const LOG_ADDITION_STRING = ' Adding '
 
const TEST_LOG_FILENAME = 'test_log.xlsx'
 
const DATA_INDEX_FILENAME = 'data_index.csv'
 
const ARCHIVE_LOG = 'archive.log'
 
string $external_directory_path
 
string $client_id = CLIENT_ID
 
 $archive_data_index
 

Detailed Description

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

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

Member Function Documentation

◆ appendToArchiveDataIndex()

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

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

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

Referenced by createPassMaterialsDirectory(), and getPassDataDirectory().

481  : void {
482  $line = $this->determinePassDataPath($date, $active_fi, $pass, $user_firstname, $user_lastname, $matriculation);
483 
484  $this->archive_data_index[] = $line;
485  $output_contents = '';
486 
487  foreach ($this->archive_data_index as $line_data) {
488  if ($line_data['identifier'] == "|") {
489  continue;
490  }
491  $output_contents .= implode('|', $line_data) . "\n";
492  }
493 
494  file_put_contents($this->getTestArchive() . DIRECTORY_SEPARATOR . self::DATA_INDEX_FILENAME, $output_contents);
495  $this->readArchiveDataIndex();
496  return;
497  }
determinePassDataPath(string $date, int $active_fi, int $pass, string $user_firstname, string $user_lastname, string $matriculation)
+ 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 337 of file class.ilTestArchiver.php.

References getTestArchive(), and null.

Referenced by getPassDataDirectory().

337  : ?string
338  {
339  foreach ($this->archive_data_index as $data_index_entry) {
340  if ($data_index_entry != null && $data_index_entry['identifier'] == $active_fi . '|' . $pass) {
341  array_shift($data_index_entry);
342  return $this->getTestArchive() . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, $data_index_entry);
343  }
344  }
345 
346  return null;
347  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ compressTestArchive()

ilTestArchiver::compressTestArchive ( )

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

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

314  : void
315  {
316  $this->updateTestArchive();
318 
319  $zip_output_path = $this->getZipExportDirectory();
320  $zip_output_filename = 'test_archive_obj_' . $this->test_obj_id . '_' . time() . '.zip';
321 
322  ilFileUtils::zip($this->getTestArchive(), $zip_output_path . DIRECTORY_SEPARATOR . $zip_output_filename, true);
323  return;
324  }
static zip(string $a_dir, string $a_file, bool $compress_content=false)
+ Here is the call graph for this function:

◆ createArchiveForTest()

ilTestArchiver::createArchiveForTest ( )
protected

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

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

Referenced by ensureTestArchiveIsAvailable().

240  : void
241  {
243  }
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createPassDataDirectory()

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

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

References getPassDataDirectory().

Referenced by ensurePassDataDirectoryIsAvailable().

331  : void
332  {
333  mkdir($this->getPassDataDirectory($active_fi, $pass), 0777, true);
334  return;
335  }
getPassDataDirectory(int $active_fi, int $pass)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createPassMaterialsDirectory()

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

Data is 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. (skergomard, 11.09.24: Whatever the f*** this means.)

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

References appendToArchiveDataIndex(), getParticipantData(), getPassMaterialsDirectory(), and ILIAS\Repository\lng().

Referenced by ensurePassMaterialsDirectoryIsAvailable().

401  : string
402  {
408  $user = $this->user;
409 
410  if ($this->getParticipantData()) {
411  $usrData = $this->getParticipantData()->getUserDataByActiveId($active_fi);
412  $user = new ilObjUser();
413  $user->setFirstname($usrData['firstname'] ?? $this->lng->txt('deleted_user'));
414  $user->setLastname($usrData['lastname'] ?? '');
415  $user->setMatriculation($usrData['matriculation'] ?? '');
416  }
417 
419  date('c'),
420  $active_fi,
421  $pass,
422  $user->getFirstname(),
423  $user->getLastname(),
424  $user->getMatriculation()
425  );
426  $material_directory = $this->getPassMaterialsDirectory($active_fi, $pass);
427  mkdir($material_directory, 0777, true);
428  return $material_directory;
429  }
getPassMaterialsDirectory(int $active_fi, int $pass)
appendToArchiveDataIndex(string $date, int $active_fi, int $pass, string $user_firstname, string $user_lastname, string $matriculation)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createUserResultsForArchive()

ilTestArchiver::createUserResultsForArchive ( \ilObjTest  $test_obj,
array  $active_ids 
)
private

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

References $results, ilObjTest\_getResultPass(), ilTestParticipantData\getActiveIds(), ilObject\getRefId(), getResultsOfUserOutput(), ilObjTest\getTestId(), ilTestParticipantData\getUserDataByActiveId(), ILIAS\Repository\int(), ILIAS\Repository\lng(), ilTestParticipantData\load(), ilTestParticipantData\setActiveIdsFilter(), ilTestParticipantData\setParticipantAccessFilter(), and ILIAS\Repository\user().

Referenced by updateTestArchive().

525  : string {
526  $template = new ilTemplate('tpl.il_as_tst_participants_result_output.html', true, true, 'components/ILIAS/Test');
527 
528  $participant_data = new ilTestParticipantData($this->db, $this->lng);
530  $this->participant_access_filter_factory->getAccessResultsUserFilter($test_obj->getRefId())
531  );
533  $participant_data->load($test_obj->getTestId());
534 
535  $test_session_factory = new ilTestSessionFactory($test_obj, $this->db, $this->user);
536 
537  $count = 0;
538  foreach ($active_ids as $active_id) {
539  if (!in_array($active_id, $participant_data->getActiveIds())) {
540  continue;
541  }
542 
543  $count++;
544  $results = '';
545  if ($active_id > 0) {
547  $test_obj,
548  $test_session_factory->getSession($active_id),
550  (int) $active_id,
551  ilObjTest::_getResultPass($active_id)
552  );
553  }
554  if ($count < count($active_ids)) {
555  $template->touchBlock('break');
556  }
557  $template->setCurrentBlock('user_result');
558  $template->setVariable('USER_RESULT', $results);
559  $template->parseCurrentBlock();
560  }
561 
562  return $template->get();
563  }
ilTestParticipantData $participant_data
setParticipantAccessFilter(Closure $participantAccessFilter)
setActiveIdsFilter(array $active_ids_filter)
static _getResultPass($active_id)
Retrieves the pass number that should be counted for a given user.
$results
getResultsOfUserOutput(\ilObjTest $test_obj, ilTestSession $test_session, array $participant_data, int $active_id, int $attempt)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createZipExportDirectory()

ilTestArchiver::createZipExportDirectory ( )
protected

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

References getZipExportDirectory().

Referenced by ensureZipExportDirectoryExists().

303  : void
304  {
305  mkdir($this->getZipExportDirectory(), 0777, true);
306  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ determinePassDataPath()

ilTestArchiver::determinePassDataPath ( string  $date,
int  $active_fi,
int  $pass,
string  $user_firstname,
string  $user_lastname,
string  $matriculation 
)
private

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

Referenced by appendToArchiveDataIndex().

506  : array {
507  $parsed_date = date_create_from_format('Y-m-d\TH:i:sP', $date);
508  if (!$parsed_date) {
509  throw new Exception('Invalid date format. Expected ISO 8601 format.');
510  }
511 
512  $line = [
513  'identifier' => $active_fi . '|' . $pass,
514  'yyyy' => date_format($parsed_date, 'Y'),
515  'mm' => date_format($parsed_date, 'm'),
516  'dd' => date_format($parsed_date, 'd'),
517  'directory' => $active_fi . '_' . $pass . '_' . $user_firstname . '_' . $user_lastname . '_' . $matriculation
518  ];
519  return $line;
520  }
+ Here is the caller graph for this function:

◆ ensurePassDataDirectoryIsAvailable()

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

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

References createPassDataDirectory(), and hasPassDataDirectory().

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

385  : void
386  {
387  if (!$this->hasPassDataDirectory($active_fi, $pass)) {
388  $this->createPassDataDirectory($active_fi, $pass);
389  }
390  return;
391  }
createPassDataDirectory(int $active_fi, int $pass)
hasPassDataDirectory(int $active_fi, int $pass)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ensurePassMaterialsDirectoryIsAvailable()

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

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

References createPassMaterialsDirectory(), and hasPassMaterialsDirectory().

Referenced by handInParticipantUploadedResults().

437  : void
438  {
439  if (!$this->hasPassMaterialsDirectory($active_fi, $pass)) {
440  $this->createPassMaterialsDirectory($active_fi, $pass);
441  }
442  }
createPassMaterialsDirectory(int $active_fi, int $pass)
hasPassMaterialsDirectory(int $active_fi, int $pass)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ensureTestArchiveIsAvailable()

ilTestArchiver::ensureTestArchiveIsAvailable ( )
protected

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

References createArchiveForTest(), and hasTestArchive().

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

252  : void
253  {
254  if (!$this->hasTestArchive()) {
255  $this->createArchiveForTest();
256  }
257  return;
258  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ensureZipExportDirectoryExists()

ilTestArchiver::ensureZipExportDirectoryExists ( )

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

References createZipExportDirectory(), and hasZipExportDirectory().

Referenced by compressTestArchive().

291  : void
292  {
293  if (!$this->hasZipExportDirectory()) {
294  $this->createZipExportDirectory();
295  }
296  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getColumnsForAttemptOverviewTable()

ilTestArchiver::getColumnsForAttemptOverviewTable ( bool  $show_requested_hints_info)
private

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

References ILIAS\Repository\lng().

Referenced by getResultsOfUserOutput().

639  : array {
640  $cf = $this->ui_factory->table()->column();
641  $columns = [
642  'order' => $cf->number($this->lng->txt('order')),
643  'question_id' => $cf->number($this->lng->txt('question_id')),
644  'title' => $cf->text($this->lng->txt('tst_question_title')),
645  'reachable_points' => $cf->number($this->lng->txt('tst_maximum_points')),
646  'reached_points' => $cf->number($this->lng->txt('tst_reached_points'))
647  ];
648  if ($show_requested_hints_info) {
649  $columns['hints'] = $cf->number($this->lng->txt('tst_question_hints_requested_hint_count_header'));
650  }
651  $columns['solved'] = $cf->text($this->lng->txt('tst_percent_solved'));
652  return $columns;
653  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDataRetrievalForAttemptOverviewTable()

ilTestArchiver::getDataRetrievalForAttemptOverviewTable ( array  $result_data)
private

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

References ILIAS\UI\Implementation\Component\Table\$range, ILIAS\GlobalScreen\Provider\__construct(), and ILIAS\UI\Component\Table\DataRowBuilder\buildDataRow().

Referenced by getResultsOfUserOutput().

655  : DataRetrieval
656  {
657  return new class ($result_data) implements DataRetrieval {
658  public function __construct(
659  private readonly array $result_data
660  ) {
661  }
662 
663  public function getRows(
664  DataRowBuilder $row_builder,
665  array $visible_column_ids,
666  Range $range,
667  Order $order,
668  ?array $filter_data,
669  ?array $additional_parameters
670  ): \Generator {
671  $i = 1;
672  foreach ($this->result_data as $result) {
673  if (!isset($result['qid'])) {
674  continue;
675  }
676  yield $row_builder->buildDataRow(
677  (string) $result['qid'],
678  [
679  'order' => $i++,
680  'question_id' => $result['qid'],
681  'title' => $result['title'],
682  'reachable_points' => $result['max'],
683  'reached_points' => $result['reached'],
684  'hints' => $result['requested_hints'] ?? 0,
685  'solved' => $result['percent']
686  ]
687  );
688  }
689  }
690 
691  public function getTotalRowCount(
692  ?array $filter_data,
693  ?array $additional_parameters
694  ): ?int {
695  return count($this->result_data);
696  }
697  };
698  }
Both the subject and the direction need to be specified when expressing an order. ...
Definition: Order.php:28
buildDataRow(string $id, array $record)
__construct(Container $dic, ilPlugin $plugin)
A simple class to express a naive range of whole positive numbers.
Definition: Range.php:28
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getParticipantData()

ilTestArchiver::getParticipantData ( )

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

References $participant_data.

Referenced by createPassMaterialsDirectory(), and getPassDataDirectory().

+ Here is the caller graph for this function:

◆ getPassDataDirectory()

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

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

References appendToArchiveDataIndex(), buildPassDataDirectory(), getParticipantData(), ILIAS\Repository\lng(), null, and ILIAS\Repository\user().

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

349  : ?string
350  {
351  $pass_data_dir = $this->buildPassDataDirectory($active_fi, $pass);
352 
353  if ($pass_data_dir !== null) {
354  return $pass_data_dir;
355  }
356 
357  $test_obj = new ilObjTest($this->test_obj_id, false);
358  if ($test_obj->getAnonymity()) {
359  $firstname = $this->lng->txt('anonymous');
360  $lastname = '';
361  $matriculation = '';
362  } elseif ($this->getParticipantData()) {
363  $usr_data = $this->getParticipantData()->getUserDataByActiveId($active_fi);
364  $firstname = $usr_data['firstname'] ?? $this->lng->txt('deleted_user');
365  $lastname = $usr_data['lastname'] ?? '';
366  $matriculation = $usr_data['matriculation'] ?? '';
367  } else {
368  $firstname = $this->user->getFirstname();
369  $lastname = $this->user->getLastname();
370  $matriculation = $this->user->getMatriculation();
371  }
372 
374  date(DATE_ISO8601),
375  $active_fi,
376  $pass,
377  $firstname,
378  $lastname,
379  $matriculation
380  );
381 
382  return $this->buildPassDataDirectory($active_fi, $pass);
383  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
buildPassDataDirectory($active_fi, $pass)
appendToArchiveDataIndex(string $date, int $active_fi, int $pass, string $user_firstname, string $user_lastname, string $matriculation)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPassMaterialsDirectory()

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

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

References getPassDataDirectory().

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

431  : string
432  {
433  $pass_data_directory = $this->getPassDataDirectory($active_fi, $pass);
434  return $pass_data_directory . DIRECTORY_SEPARATOR . self::PASS_MATERIALS_PATH_COMPONENT;
435  }
getPassDataDirectory(int $active_fi, int $pass)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getResultsOfUserOutput()

ilTestArchiver::getResultsOfUserOutput ( \ilObjTest  $test_obj,
ilTestSession  $test_session,
array  $participant_data,
int  $active_id,
int  $attempt 
)

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

References $results, ilTestSession\getActiveId(), ilObjTest\getAnonymity(), getColumnsForAttemptOverviewTable(), getDataRetrievalForAttemptOverviewTable(), ilObjTest\getResultsForActiveId(), ilObjTest\getTestResult(), ilObjTest\isOfferingQuestionHintsEnabled(), ilObjTest\isShowExamIdInTestResultsEnabled(), ILIAS\Repository\lng(), ilObjTest\lookupExamId(), and ILIAS\Repository\user().

Referenced by createUserResultsForArchive().

571  : string {
572  $template = new ilTemplate('tpl.il_as_tst_results_participant.html', true, true, 'components/ILIAS/Test');
573 
574  $uname = "{$participant_data['firstname']} {$participant_data['lastname']}";
575  if ($test_obj->getAnonymity()) {
576  $uname = $this->lng->txt('anonymous');
577  }
578 
579  $test_result_title_builder = new ResultsTitleBuilder($this->lng, $this->obj_cache);
580 
581  $result_array = $test_obj->getTestResult(
582  $active_id,
583  $attempt,
584  false,
585  true
586  );
587 
588  $table = $this->ui_factory->table()->data(
589  $this->getDataRetrievalForAttemptOverviewTable($result_array),
590  $test_result_title_builder->getPassDetailsHeaderLabel($attempt + 1),
591  $this->getColumnsForAttemptOverviewTable($test_obj->isOfferingQuestionHintsEnabled()),
592  )->withRequest($this->request);
593  $template->setVariable(
594  'PASS_DETAILS',
595  $this->ui_renderer->render($table)
596  );
597 
598  if ($test_obj->isShowExamIdInTestResultsEnabled()) {
599  $template->setCurrentBlock('exam_id_footer');
600  $template->setVariable('EXAM_ID_VAL', ilObjTest::lookupExamId(
601  $test_session->getActiveId(),
602  $attempt
603  ));
604  $template->setVariable('EXAM_ID_TXT', $this->lng->txt('exam_id'));
605  $template->parseCurrentBlock();
606  }
607 
608  $template->setCurrentBlock('participant_block_id');
609  $template->setVariable('PARTICIPANT_BLOCK_ID', "participant_active_{$active_id}");
610  $template->parseCurrentBlock();
611 
612  $template->setVariable('TEXT_HEADING', sprintf($this->lng->txt('tst_result_user_name'), $uname));
613 
614  if ($participant_data['matriculation'] !== '') {
615  $template->setVariable('USER_DATA', "{$this->lng->txt('matriculation')}: {$participant_data['matriculation']}");
616  }
617 
618  $results = $test_obj->getResultsForActiveId($active_id);
619  $status = $this->lng->txt($results['passed'] ? 'passed_official' : 'failed_official');
620  $template->setVariable(
621  'GRADING_MESSAGE',
622  "{$this->lng->txt('passed_status')}: {$status}<br>"
623  . "{$this->lng->txt('tst_mark')}: {$results['mark_official']}"
624  );
625 
626  $template->setVariable('PASS_FINISH_DATE_LABEL', $this->lng->txt('tst_pass_finished_on'));
627  $template->setVariable(
628  'PASS_FINISH_DATE_VALUE',
629  (new \DateTimeImmutable('@' . ilObjTest::lookupLastTestPassAccess($active_id, $attempt)))
630  ->setTimezone(new DateTimeZone($this->user->getTimeZone()))
631  ->format($this->user->getDateTimeFormat()->toString())
632  );
633 
634  return $template->get();
635  }
ilTestParticipantData $participant_data
$results
getDataRetrievalForAttemptOverviewTable(array $result_data)
static lookupExamId($active_id, $pass)
getColumnsForAttemptOverviewTable(bool $show_requested_hints_info)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTestArchive()

ilTestArchiver::getTestArchive ( )
protected

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

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

245  : string
246  {
247  $test_archive_directory = $this->external_directory_path . DIRECTORY_SEPARATOR . $this->client_id . DIRECTORY_SEPARATOR . 'tst_data'
248  . DIRECTORY_SEPARATOR . 'archive' . DIRECTORY_SEPARATOR . 'tst_' . $this->test_obj_id;
249  return $test_archive_directory;
250  }
+ Here is the caller graph for this function:

◆ getZipExportDirectory()

ilTestArchiver::getZipExportDirectory ( )

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

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

308  : string
309  {
310  return $this->external_directory_path . DIRECTORY_SEPARATOR . $this->client_id . DIRECTORY_SEPARATOR . 'tst_data'
311  . DIRECTORY_SEPARATOR . self::EXPORT_DIRECTORY . DIRECTORY_SEPARATOR . 'tst_' . $this->test_obj_id;
312  }
+ Here is the caller graph for this function:

◆ handInBestSolutionQuestionMaterial()

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

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

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

200  : void {
202 
203  $best_solution_path = $this->getTestArchive() . DIRECTORY_SEPARATOR . self::TEST_BEST_SOLUTION_PATH_COMPONENT;
204  if (!is_dir($best_solution_path)) {
205  mkdir($best_solution_path, 0777, true);
206  }
207 
208  $materials_path = $best_solution_path . DIRECTORY_SEPARATOR . self::TEST_MATERIALS_PATH_COMPONENT;
209  if (!is_dir($materials_path)) {
210  mkdir($materials_path, 0777, true);
211  }
212 
213  $question_materials_path = $materials_path . DIRECTORY_SEPARATOR . self::QUESTION_PATH_COMPONENT_PREFIX . $question_fi;
214  if (!is_dir($question_materials_path)) {
215  mkdir($question_materials_path, 0777, true);
216  }
217 
218  copy($file_path, $question_materials_path . DIRECTORY_SEPARATOR . $orginial_filename);
219 
220  $this->logArchivingProcess(
221  date(self::LOG_DTSGROUP_FORMAT) . self::LOG_ADDITION_STRING
222  . $question_materials_path . DIRECTORY_SEPARATOR . $orginial_filename
223  );
224  }
logArchivingProcess(string $message)
+ Here is the call graph for this function:

◆ handInParticipantMisc()

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

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

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

127  : void {
129  $this->ensurePassDataDirectoryIsAvailable($active_fi, $pass);
130  $new_path = $this->getPassDataDirectory($active_fi, $pass) . DIRECTORY_SEPARATOR . $original_filename;
131  copy($file_path, $new_path);
132  $this->logArchivingProcess(date(self::LOG_DTSGROUP_FORMAT) . self::LOG_ADDITION_STRING . $new_path);
133  }
getPassDataDirectory(int $active_fi, int $pass)
ensurePassDataDirectoryIsAvailable(int $active_fi, int $pass)
logArchivingProcess(string $message)
+ Here is the call graph for this function:

◆ handInParticipantQuestionMaterial()

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

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

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

104  : void {
106  $this->ensurePassDataDirectoryIsAvailable($active_fi, $pass);
107 
108  $pass_question_directory = $this->getPassDataDirectory($active_fi, $pass)
109  . DIRECTORY_SEPARATOR . self::QUESTION_PATH_COMPONENT_PREFIX . $question_fi;
110  if (!is_dir($pass_question_directory)) {
111  mkdir($pass_question_directory, 0777, true);
112  }
113 
114  copy($file_path, $pass_question_directory . DIRECTORY_SEPARATOR . $original_filename);
115 
116  $this->logArchivingProcess(
117  date(self::LOG_DTSGROUP_FORMAT) . self::LOG_ADDITION_STRING
118  . $pass_question_directory . DIRECTORY_SEPARATOR . $original_filename
119  );
120  }
getPassDataDirectory(int $active_fi, int $pass)
ensurePassDataDirectoryIsAvailable(int $active_fi, int $pass)
logArchivingProcess(string $message)
+ Here is the call graph for this function:

◆ handInParticipantUploadedResults()

ilTestArchiver::handInParticipantUploadedResults ( int  $active_fi,
int  $pass,
ilObjTest  $tst_obj 
)

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

References ensurePassDataDirectoryIsAvailable(), ensurePassMaterialsDirectoryIsAvailable(), ensureTestArchiveIsAvailable(), getPassMaterialsDirectory(), ilObjTest\getQuestionDataset(), ilObjTest\getQuestionsOfPass(), ilObjTest\getTextAnswer(), and null.

163  : void {
164  $questions = $tst_obj->getQuestionsOfPass($active_fi, $pass);
165  foreach ($questions as $question) {
166  $question = $tst_obj->getQuestionDataset($question['question_fi']);
167  if ($question->type_tag === 'assFileUpload') {
169  $this->ensurePassDataDirectoryIsAvailable($active_fi, $pass);
170  $this->ensurePassMaterialsDirectoryIsAvailable($active_fi, $pass);
171  $pass_material_directory = $this->getPassMaterialsDirectory($active_fi, $pass);
172  $archive_folder = $pass_material_directory . DIRECTORY_SEPARATOR . $question->question_id . DIRECTORY_SEPARATOR;
173  if (!file_exists($archive_folder)) {
174  mkdir($archive_folder, 0777, true);
175  }
176  $resource_id = $tst_obj->getTextAnswer($active_fi, $question->question_id, $pass);
177  if ($resource_id === '') {
178  continue;
179  }
180  $irss_unique_id = $this->irss->manage()->find($resource_id);
181  if ($irss_unique_id != null) {
182  $resource = $this->irss->manage()->getResource($irss_unique_id);
183  $information = $resource->getCurrentRevision()->getInformation();
184  $stream = $this->irss->consume()->stream($irss_unique_id);
185  // this feels unnecessary..
186  $file_stream = fopen($stream->getStream()->getMetadata('uri'), 'r');
187  $file_content = stream_get_contents($file_stream);
188  fclose($file_stream);
189  $target_destination = $archive_folder . $information->getTitle();
190  file_put_contents($target_destination, $file_content);
191  }
192  }
193  }
194  }
ensurePassDataDirectoryIsAvailable(int $active_fi, int $pass)
getQuestionsOfPass(int $active_id, int $pass)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getPassMaterialsDirectory(int $active_fi, int $pass)
getQuestionDataset($question_id)
Returns the dataset for a given question id.
getTextAnswer($active_id, $question_id, $pass=null)
Returns the text answer of a given user for a given question.
ensurePassMaterialsDirectoryIsAvailable(int $active_fi, int $pass)
+ Here is the call graph for this function:

◆ handInTestBestSolution()

ilTestArchiver::handInTestBestSolution ( string  $best_solution)

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

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

135  : void
136  {
138 
139  $best_solution_path = $this->getTestArchive() . DIRECTORY_SEPARATOR . self::TEST_BEST_SOLUTION_PATH_COMPONENT;
140  if (!is_dir($best_solution_path)) {
141  mkdir($best_solution_path, 0777, true);
142  }
143 
144  $this->html_generator->generateHTML(
145  $best_solution,
146  $best_solution_path . DIRECTORY_SEPARATOR . self::HTML_BEST_SOLUTION_FILENAME
147  );
148 
149  $this->logArchivingProcess(
150  date(self::LOG_DTSGROUP_FORMAT) . self::LOG_ADDITION_STRING
151  . $best_solution_path . DIRECTORY_SEPARATOR . self::HTML_BEST_SOLUTION_FILENAME
152  );
153 
154  $this->logArchivingProcess(
155  date(self::LOG_DTSGROUP_FORMAT) . self::LOG_ADDITION_STRING . $best_solution_path
156  );
157  }
logArchivingProcess(string $message)
+ Here is the call graph for this function:

◆ handInTestResult()

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

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

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

226  : void
227  {
229  $this->ensurePassDataDirectoryIsAvailable($active_fi, $pass);
230  $new_path = $this->getPassDataDirectory($active_fi, $pass) . DIRECTORY_SEPARATOR . self::TEST_RESULT_FILENAME;
231  copy($pdf_path, $new_path);
232  $this->logArchivingProcess(date(self::LOG_DTSGROUP_FORMAT) . self::LOG_ADDITION_STRING . $new_path);
233  }
getPassDataDirectory(int $active_fi, int $pass)
ensurePassDataDirectoryIsAvailable(int $active_fi, int $pass)
logArchivingProcess(string $message)
+ Here is the call graph for this function:

◆ hasPassDataDirectory()

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

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

References getPassDataDirectory().

Referenced by ensurePassDataDirectoryIsAvailable().

326  : bool
327  {
328  return is_dir($this->getPassDataDirectory($active_fi, $pass));
329  }
getPassDataDirectory(int $active_fi, int $pass)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasPassMaterialsDirectory()

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

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

References getPassMaterialsDirectory().

Referenced by ensurePassMaterialsDirectoryIsAvailable().

393  : bool
394  {
395  if (is_dir($this->getPassMaterialsDirectory($active_fi, $pass))) {
396  return true;
397  }
398  return false;
399  }
getPassMaterialsDirectory(int $active_fi, int $pass)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasTestArchive()

ilTestArchiver::hasTestArchive ( )
protected

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

References getTestArchive().

Referenced by ensureTestArchiveIsAvailable().

235  : bool
236  {
237  return is_dir($this->getTestArchive());
238  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasZipExportDirectory()

ilTestArchiver::hasZipExportDirectory ( )

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

References getZipExportDirectory().

Referenced by ensureZipExportDirectoryExists().

298  : bool
299  {
300  return is_dir($this->getZipExportDirectory());
301  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ logArchivingProcess()

ilTestArchiver::logArchivingProcess ( string  $message)
private

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

References $message, and getTestArchive().

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

700  : void
701  {
702  $archive = $this->getTestArchive() . DIRECTORY_SEPARATOR . self::ARCHIVE_LOG;
703  if (file_exists($archive)) {
704  $content = file_get_contents($archive) . "\n" . $message;
705  } else {
706  $content = $message;
707  }
708 
709  file_put_contents($archive, $content);
710  }
$message
Definition: xapiexit.php:31
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readArchiveDataIndex()

ilTestArchiver::readArchiveDataIndex ( )
protected

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

PhpUsageOfSilenceOperatorInspection

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

References getTestArchive().

Referenced by appendToArchiveDataIndex().

444  : array
445  {
450  $data_index_file = $this->getTestArchive() . DIRECTORY_SEPARATOR . self::DATA_INDEX_FILENAME;
451 
452  $contents = [];
453 
455  if (@file_exists($data_index_file)) {
456  $lines = explode("\n", file_get_contents($data_index_file));
457  foreach ($lines as $line) {
458  if (strlen($line) === 0) {
459  continue;
460  }
461  $line_items = explode('|', $line);
462  $line_data = [];
463  $line_data['identifier'] = $line_items[0] . '|' . $line_items[1];
464  $line_data['yyyy'] = $line_items[2];
465  $line_data['mm'] = $line_items[3];
466  $line_data['dd'] = $line_items[4];
467  $line_data['directory'] = $line_items[5];
468  $contents[] = $line_data;
469  }
470  }
471  return $contents;
472  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setParticipantData()

ilTestArchiver::setParticipantData ( ilTestParticipantData  $participant_data)

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

References $participant_data.

Referenced by ilTestArchiveService\archiveActivesPass().

93  : void
94  {
95  $this->participant_data = $participant_data;
96  }
ilTestParticipantData $participant_data
+ Here is the caller graph for this function:

◆ updateTestArchive()

ilTestArchiver::updateTestArchive ( )

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

References $filename, createUserResultsForArchive(), getTestArchive(), and null.

Referenced by compressTestArchive().

260  : void
261  {
262  $this->log_viewer->getLogExportForRefjId(
263  $this->test_ref_id
264  )->writeToFile(
265  $this->getTestArchive() . DIRECTORY_SEPARATOR . self::TEST_LOG_FILENAME
266  );
267 
268  // Generate test pass overview
269  $test = new ilObjTest($this->test_obj_id, false);
270  if ($this->test_ref_id !== null) {
271  $test->setRefId($this->test_ref_id);
272  }
273 
274  $array_of_actives = [];
275  $participants = $test->getParticipants();
276 
277  foreach (array_keys($participants) as $key) {
278  $array_of_actives[] = $key;
279  }
280 
281  $filename = realpath($this->getTestArchive()) . DIRECTORY_SEPARATOR . 'participant_attempt_overview.html';
282  $this->html_generator->generateHTML(
284  $test,
285  $array_of_actives
286  ),
287  $filename
288  );
289  }
createUserResultsForArchive(\ilObjTest $test_obj, array $active_ids,)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$filename
Definition: buildRTE.php:78
+ 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
private

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

◆ $client_id

string ilTestArchiver::$client_id = CLIENT_ID
private

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

◆ $external_directory_path

string ilTestArchiver::$external_directory_path
private

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

◆ $html_generator

ilTestHTMLGenerator ilTestArchiver::$html_generator
protected

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

◆ $participant_data

ilTestParticipantData ilTestArchiver::$participant_data = null
protected

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

Referenced by getParticipantData(), and setParticipantData().

◆ ARCHIVE_LOG

const ilTestArchiver::ARCHIVE_LOG = 'archive.log'
private

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

◆ DATA_INDEX_FILENAME

const ilTestArchiver::DATA_INDEX_FILENAME = 'data_index.csv'
private

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

◆ DIR_SEP

const ilTestArchiver::DIR_SEP = DIRECTORY_SEPARATOR

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

◆ EXPORT_DIRECTORY

const ilTestArchiver::EXPORT_DIRECTORY = 'archive_exports'

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

Referenced by ilTestExportOptionARC\getDirectory().

◆ HTML_BEST_SOLUTION_FILENAME

const ilTestArchiver::HTML_BEST_SOLUTION_FILENAME = 'best_solution.html'
private

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

◆ LOG_ADDITION_STRING

const ilTestArchiver::LOG_ADDITION_STRING = ' Adding '
private

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

◆ LOG_DTSGROUP_FORMAT

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

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

◆ PASS_MATERIALS_PATH_COMPONENT

const ilTestArchiver::PASS_MATERIALS_PATH_COMPONENT = 'materials'
private

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

◆ QUESTION_PATH_COMPONENT_PREFIX

const ilTestArchiver::QUESTION_PATH_COMPONENT_PREFIX = 'q_'
private

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

◆ TEST_BEST_SOLUTION_PATH_COMPONENT

const ilTestArchiver::TEST_BEST_SOLUTION_PATH_COMPONENT = 'best_solution'
private

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

◆ TEST_LOG_FILENAME

const ilTestArchiver::TEST_LOG_FILENAME = 'test_log.xlsx'
private

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

◆ TEST_MATERIALS_PATH_COMPONENT

const ilTestArchiver::TEST_MATERIALS_PATH_COMPONENT = 'materials'
private

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

◆ TEST_RESULT_FILENAME

const ilTestArchiver::TEST_RESULT_FILENAME = 'test_result.html'
private

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


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