ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ilTestRandomQuestionSetConfigStateMessageHandler Class Reference
+ Collaboration diagram for ilTestRandomQuestionSetConfigStateMessageHandler:

Public Member Functions

 __construct (private ilLanguage $lng, private UIFactory $ui_factory, private UIRenderer $ui_renderer, private ilCtrlInterface $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 ilCtrlInterface  $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 258 of file class.ilTestRandomQuestionSetConfigStateMessageHandler.php.

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

Referenced by handle().

258  : string
259  {
260  $href = $this->ctrl->getLinkTarget(
261  $this->getTargetGUI(),
263  );
264 
265  $label = $this->lng->txt('tst_rnd_quest_cfg_tab_general');
266 
267  return "<a href=\"{$href}\">{$label}</a>";
268  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildLastSyncMessage()

ilTestRandomQuestionSetConfigStateMessageHandler::buildLastSyncMessage ( )
protected

Definition at line 355 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().

355  : string
356  {
357  $sync_date = new ilDateTime(
358  $this->questionSetConfig->getLastQuestionSyncTimestamp(),
360  );
361  $message = sprintf(
362  $this->lng->txt('tst_msg_rand_quest_set_stage_pool_last_sync'),
364  );
365  if ($this->doesParticipantDataExists()) {
366  $message .= '<br>' . $this->lng->txt('tst_msg_cannot_modify_random_question_set_conf_due_to_part');
367 
368  $msg_box = $this->ui_factory->messageBox()->info($message);
369  } else {
370  $href = $this->ctrl->getLinkTargetByClass(ilTestRandomQuestionSetConfigGUI::class, ilTestRandomQuestionSetConfigGUI::CMD_RESET_POOLSYNC);
371  $label = $this->lng->txt('tst_btn_reset_pool_sync');
372 
373  $buttons = [
374  $this->ui_factory->button()->standard($label, $href)
375  ];
376 
377  $msg_box = $this->ui_factory->messageBox()
378  ->info($message)
379  ->withButtons($buttons);
380  }
381 
382  return $this->ui_renderer->render($msg_box);
383  }
const IL_CAL_UNIX
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
$message
Definition: xapiexit.php:31
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildLostPoolsReportMessage()

ilTestRandomQuestionSetConfigStateMessageHandler::buildLostPoolsReportMessage ( )
protected

Definition at line 329 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().

329  : string
330  {
331  $report = sprintf(
332  $this->lng->txt('tst_msg_rand_quest_set_lost_pools'),
334  );
335 
336  if ($this->getContext() == self::CONTEXT_GENERAL_CONFIG) {
337  $action = $this->ctrl->getLinkTarget(
338  $this->getTargetGUI(),
340  );
341 
342  $link = $this->ui_factory->link()->standard(
343  $this->lng->txt('tst_msg_rand_quest_set_lost_pools_link'),
344  $action
345  );
346 
347  $msg_box = $this->ui_factory->messageBox()->info($report)->withLinks([$link]);
348  } else {
349  $msg_box = $this->ui_factory->messageBox()->info($report);
350  }
351 
352  return $this->ui_renderer->render($msg_box);
353  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildLostQuestionPoolsString()

ilTestRandomQuestionSetConfigStateMessageHandler::buildLostQuestionPoolsString ( )
private

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

References getLostPools().

Referenced by buildLostPoolsReportMessage().

216  : string
217  {
218  $titles = [];
219 
220  foreach ($this->getLostPools() as $lostPool) {
221  $titles[] = $lostPool->getTitle();
222  }
223 
224  return implode(', ', $titles);
225  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildNotSyncedMessage()

ilTestRandomQuestionSetConfigStateMessageHandler::buildNotSyncedMessage ( )
protected

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

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

Referenced by handle().

385  : string
386  {
387  $message = $this->lng->txt('tst_msg_rand_quest_set_not_sync');
388  $button = $this->buildQuestionStageRebuildButton();
389  $msg_box = $this->ui_factory->messageBox()->info($message)->withButtons([$button]);
390 
391  return $this->ui_renderer->render($msg_box);
392  }
$message
Definition: xapiexit.php:31
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildQuestionSelectionSubTabLink()

ilTestRandomQuestionSetConfigStateMessageHandler::buildQuestionSelectionSubTabLink ( )
private

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

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

Referenced by handle().

270  : string
271  {
272  $href = $this->ctrl->getLinkTarget(
273  $this->getTargetGUI(),
275  );
276 
277  $label = $this->lng->txt('tst_rnd_quest_cfg_tab_pool');
278 
279  return "<a href=\"{$href}\">{$label}</a>";
280  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildQuestionStageRebuildButton()

ilTestRandomQuestionSetConfigStateMessageHandler::buildQuestionStageRebuildButton ( )
private

Definition at line 241 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().

242  {
243  $this->ctrl->setParameter(
244  $this->getTargetGUI(),
247  );
248 
249  $href = $this->ctrl->getLinkTarget(
250  $this->getTargetGUI(),
252  );
253  $label = $this->lng->txt('tst_btn_rebuild_random_question_stage');
254 
255  return $this->ui_factory->button()->standard($label, $href)->withLoadingAnimationOnClick(true);
256  }
+ 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 227 of file class.ilTestRandomQuestionSetConfigStateMessageHandler.php.

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

Referenced by buildQuestionStageRebuildButton().

227  : string
228  {
229  switch ($this->getContext()) {
230  case self::CONTEXT_POOL_SELECTION:
231 
233 
234  case self::CONTEXT_GENERAL_CONFIG:
235  default:
236 
238  }
239  }
+ 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()

ilTestRandomQuestionSetConfigStateMessageHandler::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(), null, setSyncInfoMessage(), and setValidationFailed().

156  : void
157  {
159  $this->addValidationReport($this->lng->txt('tst_msg_rand_quest_set_no_pools_available'));
160  return;
161  }
162 
163  if ($this->getLostPools()) {
165  return;
166  }
167 
168  if (!$this->questionSetConfig->isQuestionAmountConfigComplete()) {
169  $this->addValidationReport($this->lng->txt('tst_msg_rand_quest_set_incomplete_quest_amount_cfg'));
170 
172  $this->addValidationReport(
173  sprintf(
174  $this->lng->txt('tst_msg_rand_quest_set_change_quest_amount_here'),
176  )
177  );
178  return;
179  }
180 
182  $this->addValidationReport(
183  sprintf(
184  $this->lng->txt('tst_msg_rand_quest_set_change_quest_amount_here'),
186  )
187  );
188  return;
189  }
190  }
191 
192  if (!$this->questionSetConfig->hasSourcePoolDefinitions()) {
193  $this->addValidationReport($this->lng->txt('tst_msg_rand_quest_set_no_src_pool_defs'));
194  return;
195  }
196 
197  if ($this->questionSetConfig->getLastQuestionSyncTimestamp() === 0 ||
198  $this->questionSetConfig->getLastQuestionSyncTimestamp() === null) {
199  $this->setSyncInfoMessage($this->buildNotSyncedMessage());
200  return;
201  }
202 
203  if (!$this->questionSetConfig->isQuestionSetBuildable()) {
204  $this->setValidationFailed(true);
205  $this->addValidationReport($this->lng->txt('tst_msg_rand_quest_set_pass_not_buildable'));
206  $this->addValidationReport(implode('<br />', $this->questionSetConfig->getBuildableMessages()));
207  return;
208  }
209 
210  if ($this->questionSetConfig->getLastQuestionSyncTimestamp()) {
211  $this->setSyncInfoMessage($this->buildLastSyncMessage());
212  return;
213  }
214  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ 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 286 of file class.ilTestRandomQuestionSetConfigStateMessageHandler.php.

References getContext().

Referenced by handle().

286  : bool
287  {
288  if ($this->getContext() !== self::CONTEXT_POOL_SELECTION) {
289  return false;
290  }
291 
292  if ($this->questionSetConfig->doesSelectableQuestionPoolsExist()) {
293  return false;
294  }
295 
296  return true;
297  }
+ 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 303 of file class.ilTestRandomQuestionSetConfigStateMessageHandler.php.

References getContext().

Referenced by handle().

303  : bool
304  {
305  if ($this->getContext() != self::CONTEXT_GENERAL_CONFIG) {
306  return false;
307  }
308 
309  if (!$this->questionSetConfig->isQuestionAmountConfigurationModePerPool()) {
310  return false;
311  }
312 
313  return true;
314  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isQuestionAmountConfigPerTestHintRequired()

ilTestRandomQuestionSetConfigStateMessageHandler::isQuestionAmountConfigPerTestHintRequired ( )
private

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

References getContext().

Referenced by handle().

316  : bool
317  {
318  if ($this->getContext() != self::CONTEXT_POOL_SELECTION) {
319  return false;
320  }
321 
322  if (!$this->questionSetConfig->isQuestionAmountConfigurationModePerTest()) {
323  return false;
324  }
325 
326  return true;
327  }
+ 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:31
+ 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: