ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
ilTestArchiveService Class Reference
+ Collaboration diagram for ilTestArchiveService:

Public Member Functions

 __construct (private readonly ilObjTest $test_obj, private readonly ilLanguage $lng, private readonly ilDBInterface $db, private readonly ilObjUser $user, private readonly UIFactory $ui_factory, private readonly UIRenderer $ui_renderer, private readonly IRSS $irss, private readonly ServerRequestInterface $request, private readonly ilObjectDataCache $obj_cache, private readonly ilTestParticipantAccessFilterFactory $participant_access_filter_factory, private readonly ilTestHTMLGenerator $html_generator)
 
 getParticipantData ()
 
 setParticipantData (ilTestParticipantData $participantData)
 
 archivePassesByActives ($passesByActives)
 
 archiveActivesPass (int $active_id, int $pass)
 

Protected Attributes

ilTestParticipantData $participantData = null
 

Private Member Functions

 renderOverviewContent ($activeId, $pass)
 
 buildOverviewFilename ($activeId, $pass)
 

Detailed Description

Definition at line 33 of file class.ilTestArchiveService.php.

Constructor & Destructor Documentation

◆ __construct()

ilTestArchiveService::__construct ( private readonly ilObjTest  $test_obj,
private readonly ilLanguage  $lng,
private readonly ilDBInterface  $db,
private readonly ilObjUser  $user,
private readonly UIFactory  $ui_factory,
private readonly UIRenderer  $ui_renderer,
private readonly IRSS  $irss,
private readonly ServerRequestInterface  $request,
private readonly ilObjectDataCache  $obj_cache,
private readonly ilTestParticipantAccessFilterFactory  $participant_access_filter_factory,
private readonly ilTestHTMLGenerator  $html_generator 
)

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

49 {
50 $this->participantData = null;
51 }

Member Function Documentation

◆ archiveActivesPass()

ilTestArchiveService::archiveActivesPass ( int  $active_id,
int  $pass 
)

Definition at line 72 of file class.ilTestArchiveService.php.

72 : void
73 {
74 $participant_data = $this->getParticipantData();
75 $user = $participant_data->getUserDataByActiveId($active_id);
76
77 $tpl = new ilTemplate(
78 'tpl.il_as_tst_archive_page.html',
79 true,
80 true,
81 'components/ILIAS/Test'
82 );
83
84 $tpl->setVariable(
85 'NAME',
86 sprintf(
87 $this->lng->txt('tst_result_user_name'),
88 $this->test_obj->buildName(
89 $user['user_id'],
90 $user['firstname'],
91 $user['lastname']
92 )
93 )
94 );
95
96 if (!empty($user['matriculation']) && $this->test_obj->getAnonymity() === false) {
97 $tpl->setCurrentBlock('matriculation');
98 $tpl->setVariable(
99 'MATRICULATION_LABEL',
100 $this->lng->txt('matriculation')
101 );
102 $tpl->setVariable(
103 'MATRICULATION',
104 $user['matriculation']
105 );
106 $tpl->parseCurrentBlock();
107 }
108
109 $tpl->setVariable(
110 'PASS_FINISH_DATE_LABEL',
111 $this->lng->txt('tst_pass_finished_on')
112 );
113
114 $finish_date = ilObjTest::lookupLastTestPassAccess($active_id, $pass);
115 $tpl->setVariable(
116 'PASS_FINISH_DATE',
117 $finish_date === null
118 ? ''
119 : (new DateTimeImmutable(
120 "@{$finish_date}",
121 new DateTimeZone($this->user->getTimeZone())
122 ))->format(
123 $this->user->getDateTimeFormat()->toString()
124 )
125 );
126
127 $tpl->setVariable(
128 'OVERVIEW',
129 $this->renderOverviewContent($active_id, $pass)
130 );
131
132 $filename = $this->buildOverviewFilename($active_id, $pass);
133 $this->html_generator->generateHTML($tpl->get(), $filename);
134 $archiver = new ilTestArchiver(
135 $this->lng,
136 $this->db,
137 $this->user,
138 $this->ui_factory,
139 $this->ui_renderer,
140 $this->irss,
141 $this->request,
142 $this->obj_cache,
143 $this->participant_access_filter_factory,
144 $this->test_obj->getTestLogViewer(),
145 $this->test_obj->getId()
146 );
147 $archiver->setParticipantData($this->getParticipantData());
148 $archiver->handInTestResult($active_id, $pass, $filename);
149 $archiver->handInParticipantUploadedResults($active_id, $pass, $this->test_obj);
150 unlink($filename);
151 }
$filename
Definition: buildRTE.php:78
special template class to simplify handling of ITX/PEAR
renderOverviewContent($activeId, $pass)
buildOverviewFilename($activeId, $pass)

References $filename, buildOverviewFilename(), getParticipantData(), ILIAS\Repository\lng(), renderOverviewContent(), and ILIAS\Repository\user().

Referenced by archivePassesByActives().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ archivePassesByActives()

ilTestArchiveService::archivePassesByActives (   $passesByActives)

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

63 : void
64 {
65 foreach ($passesByActives as $activeId => $passes) {
66 foreach ($passes as $pass) {
67 $this->archiveActivesPass($activeId, $pass);
68 }
69 }
70 }
archiveActivesPass(int $active_id, int $pass)

References archiveActivesPass().

+ Here is the call graph for this function:

◆ buildOverviewFilename()

ilTestArchiveService::buildOverviewFilename (   $activeId,
  $pass 
)
private
Parameters
$activeId
$pass
Returns
string

Definition at line 188 of file class.ilTestArchiveService.php.

188 : string
189 {
190 $tmpFileName = ilFileUtils::ilTempnam();
191 return dirname($tmpFileName) . '/scores-' . $this->test_obj->getId() . '-' . $activeId . '-' . $pass . '.html';
192 }
static ilTempnam(?string $a_temp_path=null)
Returns a unique and non existing Path for e temporary file or directory.

References ilFileUtils\ilTempnam().

Referenced by archiveActivesPass().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getParticipantData()

ilTestArchiveService::getParticipantData ( )

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

References $participantData.

Referenced by archiveActivesPass().

+ Here is the caller graph for this function:

◆ renderOverviewContent()

ilTestArchiveService::renderOverviewContent (   $activeId,
  $pass 
)
private
Parameters
$activeId
$pass
Returns
string

Definition at line 158 of file class.ilTestArchiveService.php.

158 : string
159 {
160 $results = $this->test_obj->getTestResult(
161 $activeId,
162 $pass,
163 false
164 );
165
166 $gui = new ilTestServiceGUI($this->test_obj);
167 $testResultHeaderLabelBuilder = new ResultsTitlesBuilder($this->lng, $this->obj_cache);
168
169 return $gui->getPassListOfAnswers(
170 $results,
171 $activeId,
172 $pass,
173 true,
174 false,
175 false,
176 true,
177 false,
178 null,
179 $testResultHeaderLabelBuilder
180 );
181 }
Service GUI class for tests.
$results

References $results, and ILIAS\Repository\lng().

Referenced by archiveActivesPass().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setParticipantData()

ilTestArchiveService::setParticipantData ( ilTestParticipantData  $participantData)

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

58 : void
59 {
60 $this->participantData = $participantData;
61 }

References $participantData.

Field Documentation

◆ $participantData

ilTestParticipantData ilTestArchiveService::$participantData = null
protected

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

Referenced by getParticipantData(), and setParticipantData().


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