ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
49  protected $questionSetConfig;
50 
55  {
56  $this->lng = $lng;
57  $this->ctrl = $ctrl;
58  }
59 
63  public function getLostPools()
64  {
65  return $this->lostPools;
66  }
67 
71  public function setLostPools($lostPools)
72  {
73  $this->lostPools = $lostPools;
74  }
75 
79  public function doesParticipantDataExists()
80  {
82  }
83 
88  {
89  $this->participantDataExists = $participantDataExists;
90  }
91 
95  public function getTargetGUI()
96  {
97  return $this->targetGUI;
98  }
99 
103  public function setTargetGUI($targetGUI)
104  {
105  $this->targetGUI = $targetGUI;
106  }
107 
111  public function getContext()
112  {
113  return $this->context;
114  }
115 
119  public function setContext($context)
120  {
121  $this->context = $context;
122  }
123 
127  public function getQuestionSetConfig()
128  {
130  }
131 
136  {
137  $this->questionSetConfig = $questionSetConfig;
138  }
139 
140 
141  public function handle()
142  {
143  if( $this->getLostPools() )
144  {
145  ilUtil::sendFailure(sprintf(
146  $this->lng->txt('tst_msg_rand_quest_set_lost_pools'), $this->buildLostQuestionPoolsString()
147  ));
148  }
149 
150  $infoMessage = array();
151 
152  if( !$this->questionSetConfig->isQuestionAmountConfigComplete() )
153  {
154  $infoMessage[] = $this->lng->txt('tst_msg_rand_quest_set_incomplete_quest_amount_cfg');
155 
157  {
158  $infoMessage[] = sprintf(
159  $this->lng->txt('tst_msg_rand_quest_set_change_quest_amount_here'),
161  );
162  }
164  {
165  $infoMessage[] = sprintf(
166  $this->lng->txt('tst_msg_rand_quest_set_change_quest_amount_here'),
168  );
169  }
170  }
171  elseif( !$this->questionSetConfig->hasSourcePoolDefinitions() )
172  {
173  $infoMessage[] = $this->lng->txt('tst_msg_rand_quest_set_no_src_pool_defs');
174  }
175  elseif( !$this->questionSetConfig->isQuestionSetBuildable() )
176  {
177  $infoMessage[] = $this->lng->txt('tst_msg_rand_quest_set_pass_not_buildable');
178  }
179  else
180  {
181  $infoMessage[] = $this->lng->txt('tst_msg_rand_quest_set_pass_buildable');
182 
183  if( $this->questionSetConfig->getLastQuestionSyncTimestamp() )
184  {
185  $syncDate = new ilDateTime(
186  $this->questionSetConfig->getLastQuestionSyncTimestamp(), IL_CAL_UNIX
187  );
188 
189  $infoMessage[] = sprintf(
190  $this->lng->txt('tst_msg_rand_quest_set_stage_pool_last_sync'), ilDatePresentation::formatDate($syncDate)
191  );
192  }
193 
194  if( !$this->doesParticipantDataExists() && !$this->getLostPools() )
195  {
196  $infoMessage[] = $this->buildQuestionStageRebuildLink();
197  }
198  }
199 
201  {
202  $infoMessage[] = $this->lng->txt('tst_msg_rand_quest_set_no_pools_available');
203  }
204 
205  ilUtil::sendInfo(implode('<br />', $infoMessage));
206  }
207 
208  private function buildLostQuestionPoolsString()
209  {
210  $titles = array();
211 
212  foreach($this->getLostPools() as $lostPool)
213  {
214  $titles[] = $lostPool->getTitle();
215  }
216 
217  return implode(', ', $titles);
218  }
219 
221  {
222  switch($this->getContext())
223  {
224  case self::CONTEXT_POOL_SELECTION:
225 
227 
228  case self::CONTEXT_GENERAL_CONFIG:
229  default:
230 
232  }
233  }
234 
239  private function buildQuestionStageRebuildLink()
240  {
241  $this->ctrl->setParameter( $this->getTargetGUI(),
244  );
245 
246  $href = $this->ctrl->getLinkTarget(
248  );
249  $label = $this->lng->txt('tst_btn_rebuild_random_question_stage');
250 
251  return "<a href=\"{$href}\">{$label}</a>";
252  }
253 
254  private function buildGeneralConfigSubTabLink()
255  {
256  $href = $this->ctrl->getLinkTarget(
258  );
259 
260  $label = $this->lng->txt('tst_rnd_quest_cfg_tab_general');
261 
262  return "<a href=\"{$href}\">{$label}</a>";
263  }
264 
266  {
267  $href = $this->ctrl->getLinkTarget(
269  );
270 
271  $label = $this->lng->txt('tst_rnd_quest_cfg_tab_pool');
272 
273  return "<a href=\"{$href}\">{$label}</a>";
274  }
275 
281  {
282  if( $this->getContext() != self::CONTEXT_POOL_SELECTION )
283  {
284  return false;
285  }
286 
287  if( $this->questionSetConfig->doesSelectableQuestionPoolsExist() )
288  {
289  return false;
290  }
291 
292  return true;
293  }
294 
300  {
301  if( $this->getContext() != self::CONTEXT_GENERAL_CONFIG )
302  {
303  return false;
304  }
305 
306  if( !$this->questionSetConfig->isQuestionAmountConfigurationModePerPool() )
307  {
308  return false;
309  }
310 
311  return true;
312  }
313 
319  {
320  if( $this->getContext() != self::CONTEXT_POOL_SELECTION )
321  {
322  return false;
323  }
324 
325  if( !$this->questionSetConfig->isQuestionAmountConfigurationModePerTest() )
326  {
327  return false;
328  }
329 
330  return true;
331  }
332 }
This class provides processing control methods.
const IL_CAL_UNIX
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static formatDate(ilDateTime $date)
Format a date public.
Date and time handling
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
language handling