ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilTestRandomQuestionSetConfigStateMessageHandler.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
12{
16 protected $lng;
17
21 protected $ctrl;
22
26 protected $targetGUI;
27
28 const CONTEXT_GENERAL_CONFIG = 'generalConfigContext';
29 const CONTEXT_POOL_SELECTION = 'poolSelectionContext';
30
34 protected $context;
35
40
44 protected $lostPools;
45
50
55
60
65 {
66 $this->lng = $lng;
67 $this->ctrl = $ctrl;
68 $this->validationFailed = false;
69 $this->validationReports = array();
70 }
71
75 public function getLostPools()
76 {
77 return $this->lostPools;
78 }
79
83 public function setLostPools($lostPools)
84 {
85 $this->lostPools = $lostPools;
86 }
87
91 public function doesParticipantDataExists()
92 {
94 }
95
100 {
101 $this->participantDataExists = $participantDataExists;
102 }
103
107 public function getTargetGUI()
108 {
109 return $this->targetGUI;
110 }
111
115 public function setTargetGUI($targetGUI)
116 {
117 $this->targetGUI = $targetGUI;
118 }
119
123 public function getContext()
124 {
125 return $this->context;
126 }
127
131 public function setContext($context)
132 {
133 $this->context = $context;
134 }
135
139 public function getQuestionSetConfig()
140 {
142 }
143
148 {
149 $this->questionSetConfig = $questionSetConfig;
150 }
151
155 public function isValidationFailed()
156 {
158 }
159
164 {
165 $this->validationFailed = $validationFailed;
166 }
167
171 public function getValidationReportHtml()
172 {
173 return implode('<br />', $this->validationReports);
174 }
175
179 public function hasValidationReports()
180 {
181 return count($this->validationReports);
182 }
183
187 public function addValidationReport($validationReport)
188 {
189 $this->validationReports[] = $validationReport;
190 }
191
192 public function handle()
193 {
195 $this->addValidationReport($this->lng->txt('tst_msg_rand_quest_set_no_pools_available'));
196 } elseif ($this->getLostPools()) {
198 } elseif (!$this->questionSetConfig->isQuestionAmountConfigComplete()) {
199 $this->addValidationReport($this->lng->txt('tst_msg_rand_quest_set_incomplete_quest_amount_cfg'));
200
202 $this->addValidationReport(
203 sprintf(
204 $this->lng->txt('tst_msg_rand_quest_set_change_quest_amount_here'),
205 $this->buildGeneralConfigSubTabLink()
206 )
207 );
209 $this->addValidationReport(
210 sprintf(
211 $this->lng->txt('tst_msg_rand_quest_set_change_quest_amount_here'),
212 $this->buildQuestionSelectionSubTabLink()
213 )
214 );
215 }
216 } elseif (!$this->questionSetConfig->hasSourcePoolDefinitions()) {
217 $this->addValidationReport($this->lng->txt('tst_msg_rand_quest_set_no_src_pool_defs'));
218 }
219 // fau: delayCopyRandomQuestions - show info message if date of last synchronisation is empty
220 elseif ($this->questionSetConfig->getLastQuestionSyncTimestamp() == 0) {
221 $this->addValidationReport($this->lng->txt('tst_msg_rand_quest_set_not_sync'));
222 $this->addValidationReport("<br />{$this->buildQuestionStageRebuildLink()}");
223 $this->addValidationReport("<br><small>" . $this->lng->txt('tst_msg_rand_quest_set_sync_duration') . "</small>");
224 }
225 // fau.
226
227 elseif (!$this->questionSetConfig->isQuestionSetBuildable()) {
228 $this->setValidationFailed(true);
229 $this->addValidationReport($this->lng->txt('tst_msg_rand_quest_set_pass_not_buildable'));
230
231 //fau: fixRandomTestBuildable - show the messages if set is not buildable
232 $this->addValidationReport(implode('<br />', $this->questionSetConfig->getBuildableMessages()));
233 //fau.
234 } else {
235 //fau: fixRandomTestBuildable - show the messages if set is buildable but messages exist
236 #if (count($this->questionSetConfig->getBuildableMessages()))
237 #{
238 //$this->setValidationFailed(true);
239
240 // REALLY REQUIRED !?? vielleicht doch?
241 //ilUtil::sendFailure(implode('<br />', $this->questionSetConfig->getBuildableMessages()));
242 #}
243 //fau.
244
245 $this->addValidationReport($this->lng->txt('tst_msg_rand_quest_set_pass_buildable'));
246
247 if ($this->questionSetConfig->getLastQuestionSyncTimestamp()) {
248 $syncDate = new ilDateTime(
249 $this->questionSetConfig->getLastQuestionSyncTimestamp(),
251 );
252
254 $this->lng->txt('tst_msg_rand_quest_set_stage_pool_last_sync'),
256 ));
257 }
258
259 if (!$this->doesParticipantDataExists() && !$this->getLostPools()) {
261 }
262 }
263 }
264
266 {
267 $titles = array();
268
269 foreach ($this->getLostPools() as $lostPool) {
270 $titles[] = $lostPool->getTitle();
271 }
272
273 return implode(', ', $titles);
274 }
275
277 {
278 switch ($this->getContext()) {
280
282
284 default:
285
287 }
288 }
289
295 {
296 $this->ctrl->setParameter(
297 $this->getTargetGUI(),
300 );
301
302 $href = $this->ctrl->getLinkTarget(
303 $this->getTargetGUI(),
305 );
306 $label = $this->lng->txt('tst_btn_rebuild_random_question_stage');
307
308 return "<a href=\"{$href}\">{$label}</a>";
309 }
310
312 {
313 $href = $this->ctrl->getLinkTarget(
314 $this->getTargetGUI(),
316 );
317
318 $label = $this->lng->txt('tst_rnd_quest_cfg_tab_general');
319
320 return "<a href=\"{$href}\">{$label}</a>";
321 }
322
324 {
325 $href = $this->ctrl->getLinkTarget(
326 $this->getTargetGUI(),
328 );
329
330 $label = $this->lng->txt('tst_rnd_quest_cfg_tab_pool');
331
332 return "<a href=\"{$href}\">{$label}</a>";
333 }
334
340 {
341 if ($this->getContext() != self::CONTEXT_POOL_SELECTION) {
342 return false;
343 }
344
345 if ($this->questionSetConfig->doesSelectableQuestionPoolsExist()) {
346 return false;
347 }
348
349 return true;
350 }
351
357 {
358 if ($this->getContext() != self::CONTEXT_GENERAL_CONFIG) {
359 return false;
360 }
361
362 if (!$this->questionSetConfig->isQuestionAmountConfigurationModePerPool()) {
363 return false;
364 }
365
366 return true;
367 }
368
374 {
375 if ($this->getContext() != self::CONTEXT_POOL_SELECTION) {
376 return false;
377 }
378
379 if (!$this->questionSetConfig->isQuestionAmountConfigurationModePerTest()) {
380 return false;
381 }
382
383 return true;
384 }
385
389 protected function buildLostPoolsReport()
390 {
391 $report = sprintf(
392 $this->lng->txt('tst_msg_rand_quest_set_lost_pools'),
393 $this->buildLostQuestionPoolsString()
394 );
395
396 if ($this->getContext() == self::CONTEXT_GENERAL_CONFIG) {
397 $report .= '<br /><br />' . sprintf(
398 $this->lng->txt('tst_msg_rand_quest_set_lost_pools_link'),
399 $this->buildQuestionPoolsTabLink()
400 );
401 }
402
403 return $report;
404 }
405
409 protected function buildQuestionPoolsTabLink()
410 {
411 $href = $this->ctrl->getLinkTarget(
412 $this->getTargetGUI(),
414 );
415
416 $label = $this->getTargetGUI()->getPoolConfigTabLabel();
417
418 return "<a href=\"{$href}\">{$label}</a>";
419 }
420}
sprintf('%.4f', $callTime)
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_UNIX
This class provides processing control methods.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date @access public.
@classDescription Date and time handling
language handling