ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilTestArchiveService.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once './Modules/Test/classes/class.ilTestServiceGUI.php';
5 require_once './Modules/Test/classes/class.ilTestPDFGenerator.php';
6 require_once './Modules/Test/classes/class.ilTestArchiver.php';
7 
15 {
19  protected $testOBJ;
20 
24  protected $participantData;
25 
26  public function __construct(ilObjTest $testOBJ)
27  {
28  $this->testOBJ = $testOBJ;
29  $this->participantData = null;
30  }
31 
35  public function getParticipantData()
36  {
38  }
39 
44  {
45  $this->participantData = $participantData;
46  }
47 
48  public function archivePassesByActives($passesByActives)
49  {
50  foreach ($passesByActives as $activeId => $passes) {
51  foreach ($passes as $pass) {
52  $this->archiveActivesPass($activeId, $pass);
53  }
54  }
55  }
56 
57  public function archiveActivesPass($activeId, $pass)
58  {
59  $content = $this->renderOverviewContent($activeId, $pass);
60  $filename = $this->buildOverviewFilename($activeId, $pass);
61 
63 
64  $archiver = new ilTestArchiver($this->testOBJ->getId());
65  $archiver->setParticipantData($this->getParticipantData());
66  $archiver->handInTestResult($activeId, $pass, $filename);
67 
68  unlink($filename);
69  }
70 
76  private function renderOverviewContent($activeId, $pass)
77  {
78  $results = $this->testOBJ->getTestResult(
79  $activeId,
80  $pass,
81  false
82  );
83 
84  $gui = new ilTestServiceGUI($this->testOBJ);
85 
86  require_once 'Modules/Test/classes/class.ilTestResultHeaderLabelBuilder.php';
87  $testResultHeaderLabelBuilder = new ilTestResultHeaderLabelBuilder($GLOBALS['DIC']->language(), $GLOBALS['DIC']['ilObjDataCache']);
88 
89  return $gui->getPassListOfAnswers(
90  $results,
91  $activeId,
92  $pass,
93  true,
94  false,
95  false,
96  true,
97  false,
98  null,
99  $testResultHeaderLabelBuilder
100  );
101  }
102 
108  private function buildOverviewFilename($activeId, $pass)
109  {
110  $tmpFileName = ilUtil::ilTempnam();
111  return dirname($tmpFileName) . '/scores-' . $this->testOBJ->getId() . '-' . $activeId . '-' . $pass . '.pdf';
112  }
113 }
renderOverviewContent($activeId, $pass)
archiveActivesPass($activeId, $pass)
const PDF_USER_RESULT
PDF Purposes.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
setParticipantData(ilTestParticipantData $participantData)
archivePassesByActives($passesByActives)
static ilTempnam($a_temp_path=null)
Create a temporary file in an ILIAS writable directory.
Class ilTestArchiver.
$results
Definition: svg-scanner.php:47
Service GUI class for tests.
static generatePDF($pdf_output, $output_mode, $filename=null, $purpose=null)
buildOverviewFilename($activeId, $pass)
setParticipantData($participantData)