ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilTestArchiveService.php
Go to the documentation of this file.
1 <?php
2 
26 {
30  protected $testOBJ;
31 
35  protected $participantData;
36 
37  public function __construct(ilObjTest $testOBJ)
38  {
39  $this->testOBJ = $testOBJ;
40  $this->participantData = null;
41  }
42 
47  {
49  }
50 
55  {
56  $this->participantData = $participantData;
57  }
58 
59  public function archivePassesByActives($passesByActives)
60  {
61  foreach ($passesByActives as $activeId => $passes) {
62  foreach ($passes as $pass) {
63  $this->archiveActivesPass($activeId, $pass);
64  }
65  }
66  }
67 
68  public function archiveActivesPass($activeId, $pass)
69  {
70  $content = $this->renderOverviewContent($activeId, $pass);
71  $filename = $this->buildOverviewFilename($activeId, $pass);
73  $archiver = new ilTestArchiver($this->testOBJ->getId());
74  $archiver->setParticipantData($this->getParticipantData());
75  $archiver->handInTestResult($activeId, $pass, $filename);
76  $archiver->handInParticipantUploadedResults($activeId, $pass, $this->testOBJ);
77  unlink($filename);
78  }
79 
85  private function renderOverviewContent($activeId, $pass): string
86  {
87  $results = $this->testOBJ->getTestResult(
88  $activeId,
89  $pass,
90  false
91  );
92 
93  $gui = new ilTestServiceGUI($this->testOBJ);
94 
95  require_once 'Modules/Test/classes/class.ilTestResultHeaderLabelBuilder.php';
96  $testResultHeaderLabelBuilder = new ilTestResultHeaderLabelBuilder($GLOBALS['DIC']->language(), $GLOBALS['DIC']['ilObjDataCache']);
97 
98  return $gui->getPassListOfAnswers(
99  $results,
100  $activeId,
101  $pass,
102  true,
103  false,
104  false,
105  true,
106  false,
107  null,
108  $testResultHeaderLabelBuilder
109  );
110  }
111 
117  private function buildOverviewFilename($activeId, $pass): string
118  {
119  $tmpFileName = ilFileUtils::ilTempnam();
120  return dirname($tmpFileName) . '/scores-' . $this->testOBJ->getId() . '-' . $activeId . '-' . $pass . '.pdf';
121  }
122 }
renderOverviewContent($activeId, $pass)
archiveActivesPass($activeId, $pass)
const PDF_USER_RESULT
PDF Purposes.
setParticipantData(ilTestParticipantData $participantData)
archivePassesByActives($passesByActives)
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
$results
$filename
Definition: buildRTE.php:78
static ilTempnam(?string $a_temp_path=null)
Returns a unique and non existing Path for e temporary file or directory.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Service GUI class for tests.
static generatePDF($pdf_output, $output_mode, $filename=null, $purpose=null)
buildOverviewFilename($activeId, $pass)
setParticipantData($participantData)