ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilTestRandomQuestionSetConfigStateMessageHandler Class Reference
+ Collaboration diagram for ilTestRandomQuestionSetConfigStateMessageHandler:

Public Member Functions

 __construct (private ilLanguage $lng, private UIFactory $ui_factory, private UIRenderer $ui_renderer, private ilCtrl $ctrl)
 
 getLostPools ()
 
 setLostPools (array $lostPools)
 
 doesParticipantDataExists ()
 
 setParticipantDataExists (bool $participantDataExists)
 
 getTargetGUI ()
 
 setTargetGUI (ilTestRandomQuestionSetConfigGUI $targetGUI)
 
 getContext ()
 
 setContext (string $context)
 
 getQuestionSetConfig ()
 
 setQuestionSetConfig (ilTestRandomQuestionSetConfig $questionSetConfig)
 
 isValidationFailed ()
 
 getValidationReportHtml ()
 
 hasValidationReports ()
 
 getSyncInfoMessage ()
 
 handle ()
 

Data Fields

const CONTEXT_GENERAL_CONFIG = 'generalConfigContext'
 
const CONTEXT_POOL_SELECTION = 'poolSelectionContext'
 

Protected Member Functions

 setValidationFailed (bool $validationFailed)
 
 addValidationReport (string $validationReport)
 
 setSyncInfoMessage (string $message)
 
 buildLostPoolsReportMessage ()
 
 buildLastSyncMessage ()
 
 buildNotSyncedMessage ()
 

Protected Attributes

ilTestRandomQuestionSetConfigGUI $targetGUI
 
string $context
 
bool $participantDataExists
 
array $lostPools
 
ilTestRandomQuestionSetConfig $questionSetConfig
 
bool $validationFailed = false
 
array $validationReports = []
 
string $sync_info_message = ''
 

Private Member Functions

 buildLostQuestionPoolsString ()
 
 getAfterRebuildQuestionStageCommand ()
 
 buildQuestionStageRebuildButton ()
 
 buildGeneralConfigSubTabLink ()
 
 buildQuestionSelectionSubTabLink ()
 
 isNoAvailableQuestionPoolsHintRequired ()
 
 isQuestionAmountConfigPerPoolHintRequired ()
 
 isQuestionAmountConfigPerTestHintRequired ()
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilTestRandomQuestionSetConfigStateMessageHandler::__construct ( private ilLanguage  $lng,
private UIFactory  $ui_factory,
private UIRenderer  $ui_renderer,
private ilCtrl  $ctrl 
)

Definition at line 52 of file class.ilTestRandomQuestionSetConfigStateMessageHandler.php.

57  {
58  $this->validationFailed = false;
59  $this->validationReports = [];
60  }

Member Function Documentation

◆ addValidationReport()

ilTestRandomQuestionSetConfigStateMessageHandler::addValidationReport ( string  $validationReport)
protected

Definition at line 141 of file class.ilTestRandomQuestionSetConfigStateMessageHandler.php.

Referenced by handle().

142  {
143  $this->validationReports[] = $validationReport;
144  }
+ Here is the caller graph for this function:

◆ buildGeneralConfigSubTabLink()

ilTestRandomQuestionSetConfigStateMessageHandler::buildGeneralConfigSubTabLink ( )
private

Definition at line 236 of file class.ilTestRandomQuestionSetConfigStateMessageHandler.php.

References ilTestRandomQuestionSetConfigGUI\CMD_SHOW_GENERAL_CONFIG_FORM, ILIAS\Repository\ctrl(), getTargetGUI(), and ILIAS\Repository\lng().

Referenced by handle().

236  : string
237  {
238  $href = $this->ctrl->getLinkTarget(
239  $this->getTargetGUI(),
241  );
242 
243  $label = $this->lng->txt('tst_rnd_quest_cfg_tab_general');
244 
245  return "<a href=\"{$href}\">{$label}</a>";
246  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildLastSyncMessage()

ilTestRandomQuestionSetConfigStateMessageHandler::buildLastSyncMessage ( )
protected

Definition at line 333 of file class.ilTestRandomQuestionSetConfigStateMessageHandler.php.

References $message, ilTestRandomQuestionSetConfigGUI\CMD_RESET_POOLSYNC, ILIAS\Repository\ctrl(), doesParticipantDataExists(), ilDatePresentation\formatDate(), IL_CAL_UNIX, and ILIAS\Repository\lng().

Referenced by handle().

333  : string
334  {
335  $sync_date = new ilDateTime(
336  $this->questionSetConfig->getLastQuestionSyncTimestamp(),
338  );
339  $message = sprintf(
340  $this->lng->txt('tst_msg_rand_quest_set_stage_pool_last_sync'),
342  );
343  if ($this->doesParticipantDataExists()) {
344  $message .= '<br>' . $this->lng->txt('tst_msg_cannot_modify_random_question_set_conf_due_to_part');
345 
346  $msg_box = $this->ui_factory->messageBox()->info($message);
347  } else {
348  $href = $this->ctrl->getLinkTargetByClass(ilTestRandomQuestionSetConfigGUI::class, ilTestRandomQuestionSetConfigGUI::CMD_RESET_POOLSYNC);
349  $label = $this->lng->txt('tst_btn_reset_pool_sync');
350 
351  $buttons = [
352  $this->ui_factory->button()->standard($label, $href)
353  ];
354 
355  $msg_box = $this->ui_factory->messageBox()
356  ->info($message)
357  ->withButtons($buttons);
358  }
359 
360  return $this->ui_renderer->render($msg_box);
361  }
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
const IL_CAL_UNIX
$message
Definition: xapiexit.php:32
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildLostPoolsReportMessage()

ilTestRandomQuestionSetConfigStateMessageHandler::buildLostPoolsReportMessage ( )
protected

Definition at line 307 of file class.ilTestRandomQuestionSetConfigStateMessageHandler.php.

References buildLostQuestionPoolsString(), ilTestRandomQuestionSetConfigGUI\CMD_SHOW_SRC_POOL_DEF_LIST, ILIAS\Repository\ctrl(), getContext(), getTargetGUI(), and ILIAS\Repository\lng().

Referenced by handle().

307  : string
308  {
309  $report = sprintf(
310  $this->lng->txt('tst_msg_rand_quest_set_lost_pools'),
312  );
313 
314  if ($this->getContext() == self::CONTEXT_GENERAL_CONFIG) {
315  $action = $this->ctrl->getLinkTarget(
316  $this->getTargetGUI(),
318  );
319 
320  $link = $this->ui_factory->link()->standard(
321  $this->lng->txt('tst_msg_rand_quest_set_lost_pools_link'),
322  $action
323  );
324 
325  $msg_box = $this->ui_factory->messageBox()->info($report)->withLinks(array($link));
326  } else {
327  $msg_box = $this->ui_factory->messageBox()->info($report);
328  }
329 
330  return $this->ui_renderer->render($msg_box);
331  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildLostQuestionPoolsString()

ilTestRandomQuestionSetConfigStateMessageHandler::buildLostQuestionPoolsString ( )
private

Definition at line 194 of file class.ilTestRandomQuestionSetConfigStateMessageHandler.php.

References getLostPools().

Referenced by buildLostPoolsReportMessage().

194  : string
195  {
196  $titles = array();
197 
198  foreach ($this->getLostPools() as $lostPool) {
199  $titles[] = $lostPool->getTitle();
200  }
201 
202  return implode(', ', $titles);
203  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildNotSyncedMessage()

ilTestRandomQuestionSetConfigStateMessageHandler::buildNotSyncedMessage ( )
protected

Definition at line 363 of file class.ilTestRandomQuestionSetConfigStateMessageHandler.php.

References $message, buildQuestionStageRebuildButton(), and ILIAS\Repository\lng().

Referenced by handle().

363  : string
364  {
365  $message = $this->lng->txt('tst_msg_rand_quest_set_not_sync');
366  $button = $this->buildQuestionStageRebuildButton();
367  $msg_box = $this->ui_factory->messageBox()->info($message)->withButtons(array($button));
368 
369  return $this->ui_renderer->render($msg_box);
370  }
$message
Definition: xapiexit.php:32
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildQuestionSelectionSubTabLink()

ilTestRandomQuestionSetConfigStateMessageHandler::buildQuestionSelectionSubTabLink ( )
private

Definition at line 248 of file class.ilTestRandomQuestionSetConfigStateMessageHandler.php.

References ilTestRandomQuestionSetConfigGUI\CMD_SHOW_SRC_POOL_DEF_LIST, ILIAS\Repository\ctrl(), getTargetGUI(), and ILIAS\Repository\lng().

Referenced by handle().

248  : string
249  {
250  $href = $this->ctrl->getLinkTarget(
251  $this->getTargetGUI(),
253  );
254 
255  $label = $this->lng->txt('tst_rnd_quest_cfg_tab_pool');
256 
257  return "<a href=\"{$href}\">{$label}</a>";
258  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildQuestionStageRebuildButton()

ilTestRandomQuestionSetConfigStateMessageHandler::buildQuestionStageRebuildButton ( )
private

Definition at line 219 of file class.ilTestRandomQuestionSetConfigStateMessageHandler.php.

References ilTestRandomQuestionSetConfigGUI\CMD_BUILD_QUESTION_STAGE, ILIAS\Repository\ctrl(), getAfterRebuildQuestionStageCommand(), getTargetGUI(), ilTestRandomQuestionSetConfigGUI\HTTP_PARAM_AFTER_REBUILD_QUESTION_STAGE_CMD, and ILIAS\Repository\lng().

Referenced by buildNotSyncedMessage().

220  {
221  $this->ctrl->setParameter(
222  $this->getTargetGUI(),
225  );
226 
227  $href = $this->ctrl->getLinkTarget(
228  $this->getTargetGUI(),
230  );
231  $label = $this->lng->txt('tst_btn_rebuild_random_question_stage');
232 
233  return $this->ui_factory->button()->standard($label, $href)->withLoadingAnimationOnClick(true);
234  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ doesParticipantDataExists()

ilTestRandomQuestionSetConfigStateMessageHandler::doesParticipantDataExists ( )
Returns
boolean

Definition at line 81 of file class.ilTestRandomQuestionSetConfigStateMessageHandler.php.

References $participantDataExists.

Referenced by buildLastSyncMessage().

+ Here is the caller graph for this function:

◆ getAfterRebuildQuestionStageCommand()

ilTestRandomQuestionSetConfigStateMessageHandler::getAfterRebuildQuestionStageCommand ( )
private

Definition at line 205 of file class.ilTestRandomQuestionSetConfigStateMessageHandler.php.

References ilTestRandomQuestionSetConfigGUI\CMD_SHOW_GENERAL_CONFIG_FORM, ilTestRandomQuestionSetConfigGUI\CMD_SHOW_SRC_POOL_DEF_LIST, and getContext().

Referenced by buildQuestionStageRebuildButton().

205  : string
206  {
207  switch ($this->getContext()) {
208  case self::CONTEXT_POOL_SELECTION:
209 
211 
212  case self::CONTEXT_GENERAL_CONFIG:
213  default:
214 
216  }
217  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getContext()

◆ getLostPools()

ilTestRandomQuestionSetConfigStateMessageHandler::getLostPools ( )
Returns
ilTestRandomQuestionSetNonAvailablePool[]

Definition at line 65 of file class.ilTestRandomQuestionSetConfigStateMessageHandler.php.

References $lostPools.

Referenced by buildLostQuestionPoolsString(), and handle().

+ Here is the caller graph for this function:

◆ getQuestionSetConfig()

ilTestRandomQuestionSetConfigStateMessageHandler::getQuestionSetConfig ( )

◆ getSyncInfoMessage()

ilTestRandomQuestionSetConfigStateMessageHandler::getSyncInfoMessage ( )

◆ getTargetGUI()

◆ getValidationReportHtml()

ilTestRandomQuestionSetConfigStateMessageHandler::getValidationReportHtml ( )

Definition at line 131 of file class.ilTestRandomQuestionSetConfigStateMessageHandler.php.

131  : string
132  {
133  return implode('<br />', $this->validationReports);
134  }

◆ handle()

ilTestRandomQuestionSetConfigStateMessageHandler::handle ( )

Definition at line 156 of file class.ilTestRandomQuestionSetConfigStateMessageHandler.php.

References addValidationReport(), buildGeneralConfigSubTabLink(), buildLastSyncMessage(), buildLostPoolsReportMessage(), buildNotSyncedMessage(), buildQuestionSelectionSubTabLink(), getLostPools(), isNoAvailableQuestionPoolsHintRequired(), isQuestionAmountConfigPerPoolHintRequired(), isQuestionAmountConfigPerTestHintRequired(), ILIAS\Repository\lng(), setSyncInfoMessage(), and setValidationFailed().

156  : void
157  {
159  $this->addValidationReport($this->lng->txt('tst_msg_rand_quest_set_no_pools_available'));
160  } elseif ($this->getLostPools()) {
162  } elseif (!$this->questionSetConfig->isQuestionAmountConfigComplete()) {
163  $this->addValidationReport($this->lng->txt('tst_msg_rand_quest_set_incomplete_quest_amount_cfg'));
164 
166  $this->addValidationReport(
167  sprintf(
168  $this->lng->txt('tst_msg_rand_quest_set_change_quest_amount_here'),
170  )
171  );
172  } elseif ($this->isQuestionAmountConfigPerPoolHintRequired()) {
173  $this->addValidationReport(
174  sprintf(
175  $this->lng->txt('tst_msg_rand_quest_set_change_quest_amount_here'),
177  )
178  );
179  }
180  } elseif (!$this->questionSetConfig->hasSourcePoolDefinitions()) {
181  $this->addValidationReport($this->lng->txt('tst_msg_rand_quest_set_no_src_pool_defs'));
182  } elseif ($this->questionSetConfig->getLastQuestionSyncTimestamp() === 0 ||
183  $this->questionSetConfig->getLastQuestionSyncTimestamp() === null) {
184  $this->setSyncInfoMessage($this->buildNotSyncedMessage());
185  } elseif (!$this->questionSetConfig->isQuestionSetBuildable()) {
186  $this->setValidationFailed(true);
187  $this->addValidationReport($this->lng->txt('tst_msg_rand_quest_set_pass_not_buildable'));
188  $this->addValidationReport(implode('<br />', $this->questionSetConfig->getBuildableMessages()));
189  } elseif ($this->questionSetConfig->getLastQuestionSyncTimestamp()) {
190  $this->setSyncInfoMessage($this->buildLastSyncMessage());
191  }
192  }
+ Here is the call graph for this function:

◆ hasValidationReports()

ilTestRandomQuestionSetConfigStateMessageHandler::hasValidationReports ( )

Definition at line 136 of file class.ilTestRandomQuestionSetConfigStateMessageHandler.php.

136  : int
137  {
138  return count($this->validationReports);
139  }

◆ isNoAvailableQuestionPoolsHintRequired()

ilTestRandomQuestionSetConfigStateMessageHandler::isNoAvailableQuestionPoolsHintRequired ( )
private
Parameters
$currentRequestCmd
Returns
bool

Definition at line 264 of file class.ilTestRandomQuestionSetConfigStateMessageHandler.php.

References getContext().

Referenced by handle().

264  : bool
265  {
266  if ($this->getContext() !== self::CONTEXT_POOL_SELECTION) {
267  return false;
268  }
269 
270  if ($this->questionSetConfig->doesSelectableQuestionPoolsExist()) {
271  return false;
272  }
273 
274  return true;
275  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isQuestionAmountConfigPerPoolHintRequired()

ilTestRandomQuestionSetConfigStateMessageHandler::isQuestionAmountConfigPerPoolHintRequired ( )
private
Parameters
$currentRequestCmd
Returns
bool

Definition at line 281 of file class.ilTestRandomQuestionSetConfigStateMessageHandler.php.

References getContext().

Referenced by handle().

281  : bool
282  {
283  if ($this->getContext() != self::CONTEXT_GENERAL_CONFIG) {
284  return false;
285  }
286 
287  if (!$this->questionSetConfig->isQuestionAmountConfigurationModePerPool()) {
288  return false;
289  }
290 
291  return true;
292  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isQuestionAmountConfigPerTestHintRequired()

ilTestRandomQuestionSetConfigStateMessageHandler::isQuestionAmountConfigPerTestHintRequired ( )
private

Definition at line 294 of file class.ilTestRandomQuestionSetConfigStateMessageHandler.php.

References getContext().

Referenced by handle().

294  : bool
295  {
296  if ($this->getContext() != self::CONTEXT_POOL_SELECTION) {
297  return false;
298  }
299 
300  if (!$this->questionSetConfig->isQuestionAmountConfigurationModePerTest()) {
301  return false;
302  }
303 
304  return true;
305  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isValidationFailed()

ilTestRandomQuestionSetConfigStateMessageHandler::isValidationFailed ( )

◆ setContext()

ilTestRandomQuestionSetConfigStateMessageHandler::setContext ( string  $context)

◆ setLostPools()

ilTestRandomQuestionSetConfigStateMessageHandler::setLostPools ( array  $lostPools)
Parameters
ilTestRandomQuestionSetNonAvailablePool[]$lostPools

Definition at line 73 of file class.ilTestRandomQuestionSetConfigStateMessageHandler.php.

References $lostPools.

◆ setParticipantDataExists()

ilTestRandomQuestionSetConfigStateMessageHandler::setParticipantDataExists ( bool  $participantDataExists)

◆ setQuestionSetConfig()

ilTestRandomQuestionSetConfigStateMessageHandler::setQuestionSetConfig ( ilTestRandomQuestionSetConfig  $questionSetConfig)

Definition at line 116 of file class.ilTestRandomQuestionSetConfigStateMessageHandler.php.

References $questionSetConfig.

117  {
118  $this->questionSetConfig = $questionSetConfig;
119  }

◆ setSyncInfoMessage()

ilTestRandomQuestionSetConfigStateMessageHandler::setSyncInfoMessage ( string  $message)
protected

Definition at line 151 of file class.ilTestRandomQuestionSetConfigStateMessageHandler.php.

References $message.

Referenced by handle().

151  : void
152  {
153  $this->sync_info_message = $message;
154  }
$message
Definition: xapiexit.php:32
+ Here is the caller graph for this function:

◆ setTargetGUI()

ilTestRandomQuestionSetConfigStateMessageHandler::setTargetGUI ( ilTestRandomQuestionSetConfigGUI  $targetGUI)

Definition at line 96 of file class.ilTestRandomQuestionSetConfigStateMessageHandler.php.

References $targetGUI.

97  {
98  $this->targetGUI = $targetGUI;
99  }

◆ setValidationFailed()

ilTestRandomQuestionSetConfigStateMessageHandler::setValidationFailed ( bool  $validationFailed)
protected

Definition at line 126 of file class.ilTestRandomQuestionSetConfigStateMessageHandler.php.

References $validationFailed.

Referenced by handle().

+ Here is the caller graph for this function:

Field Documentation

◆ $context

string ilTestRandomQuestionSetConfigStateMessageHandler::$context
protected

◆ $lostPools

array ilTestRandomQuestionSetConfigStateMessageHandler::$lostPools
protected

◆ $participantDataExists

bool ilTestRandomQuestionSetConfigStateMessageHandler::$participantDataExists
protected

◆ $questionSetConfig

ilTestRandomQuestionSetConfig ilTestRandomQuestionSetConfigStateMessageHandler::$questionSetConfig
protected

◆ $sync_info_message

string ilTestRandomQuestionSetConfigStateMessageHandler::$sync_info_message = ''
protected

◆ $targetGUI

ilTestRandomQuestionSetConfigGUI ilTestRandomQuestionSetConfigStateMessageHandler::$targetGUI
protected

◆ $validationFailed

bool ilTestRandomQuestionSetConfigStateMessageHandler::$validationFailed = false
protected

◆ $validationReports

array ilTestRandomQuestionSetConfigStateMessageHandler::$validationReports = []
protected

◆ CONTEXT_GENERAL_CONFIG

const ilTestRandomQuestionSetConfigStateMessageHandler::CONTEXT_GENERAL_CONFIG = 'generalConfigContext'

◆ CONTEXT_POOL_SELECTION

const ilTestRandomQuestionSetConfigStateMessageHandler::CONTEXT_POOL_SELECTION = 'poolSelectionContext'

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