ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 
30 
35 
36  public function __construct(ilObjTest $testOBJ)
37  {
38  global $ilObjDataCache, $lng;
39 
40  $this->testOBJ = $testOBJ;
41  $this->participantData = null;
42 
43  $this->considerHiddenQuestionsEnabled = true;
44 
45  require_once 'Modules/Test/classes/class.ilTestResultHeaderLabelBuilder.php';
46  $this->testResultHeaderLabelBuilder = new ilTestResultHeaderLabelBuilder($lng, $ilObjDataCache);
47  }
48 
52  public function getParticipantData()
53  {
55  }
56 
61  {
62  $this->participantData = $participantData;
63  }
64 
66  {
68  }
69 
71  {
72  $this->considerHiddenQuestionsEnabled = $considerHiddenQuestionsEnabled;
73  }
74 
75  public function archivePassesByActives($passesByActives)
76  {
77  foreach($passesByActives as $activeId => $passes)
78  {
79  foreach($passes as $pass)
80  {
81  $this->archiveActivesPass($activeId, $pass);
82  }
83  }
84  }
85 
86  public function archiveActivesPass($activeId, $pass)
87  {
88  $content = $this->renderOverviewContent($activeId, $pass);
89  $filename = $this->buildOverviewFilename($activeId, $pass);
90 
92 
93  $archiver = new ilTestArchiver($this->testOBJ->getId());
94  $archiver->setParticipantData($this->getParticipantData());
95  $archiver->handInTestResult($activeId, $pass, $filename);
96 
97  unlink($filename);
98  }
99 
105  private function renderOverviewContent($activeId, $pass)
106  {
107  $results = $this->testOBJ->getTestResult(
108  $activeId, $pass, false, $this->isConsiderHiddenQuestionsEnabled()
109  );
110 
111  $gui = new ilTestServiceGUI($this->testOBJ);
112 
113  return $gui->getPassListOfAnswers(
114  $results, $activeId, $pass, true, false, false, true, false, null, $this->testResultHeaderLabelBuilder
115  );
116  }
117 
123  private function buildOverviewFilename($activeId, $pass)
124  {
125  $tmpFileName = ilUtil::ilTempnam();
126  return dirname($tmpFileName).'/scores-'.$this->testOBJ->getId().'-'.$activeId.'-'.$pass.'.pdf';
127  }
128 }
renderOverviewContent($activeId, $pass)
archiveActivesPass($activeId, $pass)
setParticipantData(ilTestParticipantData $participantData)
archivePassesByActives($passesByActives)
$results
setConsiderHiddenQuestionsEnabled($considerHiddenQuestionsEnabled)
$filename
Definition: buildRTE.php:89
static ilTempnam($a_temp_path=null)
Create a temporary file in an ILIAS writable directory.
Class ilTestArchiver.
global $lng
Definition: privfeed.php:40
static generatePDF($pdf_output, $output_mode, $filename=null)
Service GUI class for tests.
buildOverviewFilename($activeId, $pass)
setParticipantData($participantData)