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

Public Member Functions

 __construct (private readonly ilCtrl $ctrl, private readonly ilRbacSystem $rbac_system, private ilTabsGUI $tabs, private ilToolbarGUI $toolbar, private ilGlobalTemplateInterface $tpl, private readonly UIFactory $ui_factory, private readonly ilLanguage $lng, private readonly ilDBInterface $db, private readonly RandomGroup $random_group, private readonly GlobalScreen $global_screen, private readonly HTTPServices $http, private readonly Refinery $refinery, private readonly int $parent_obj_ref_id)
 
 setInfoMessage (string $message)
 
 setPrimaryCmd (string $label, string $cmd)
 
 addAdditionalCmd (string $label, string $cmd)
 
 getQuestion ()
 
 getObject ()
 
 initQuestion (assQuestionGUI $question_gui, int $parent_obj_id)
 
 initPreviewSettings (int $parent_ref_id)
 
 initPreviewSession (int $user_id, int $question_id)
 
 initStyleSheets ()
 
 executeCommand ()
 
 showCmd (string $commands_panel_html='')
 
 assessmentCmd ()
 
 handleInstantResponseRendering (ilTemplate $tpl)
 
 resetCmd ()
 
 instantResponseCmd ()
 
 handleQuestionActionCmd ()
 
 displayMediaFullscreenCmd ()
 
 saveQuestionSolution ()
 

Data Fields

const CMD_SHOW = 'show'
 
const CMD_RESET = 'reset'
 
const CMD_STATISTICS = 'assessment'
 
const CMD_INSTANT_RESPONSE = 'instantResponse'
 
const CMD_HANDLE_QUESTION_ACTION = 'handleQuestionAction'
 
const TAB_ID_QUESTION = 'question'
 
const FEEDBACK_FOCUS_ANCHOR = 'focus'
 

Protected Member Functions

 buildPreviewFormAction ()
 
 isCommentingRequired ()
 
 populateReachedPointsOutput (ilTemplate $tpl)
 
 populateInstantResponseHeader (ilTemplate $tpl, $withFocusAnchor)
 
 populateInstantResponseMessage (ilTemplate $tpl, string $a_message)
 
 populateCommentsPanel (ilTemplate $tpl, string $comments_panel_html)
 

Protected Attributes

readonly RequestDataCollector $request_data_collector
 

Private Member Functions

 populateToolbar ()
 
 populateQuestionOutput (ilTemplate $tpl)
 
 populateSolutionOutput (ilTemplate $tpl)
 
 getQuestionNavigationHtml ()
 
 populateGenericQuestionFeedback (ilTemplate $tpl)
 Populate the block for an instant generic feedback. More...
 
 populateSpecificQuestionFeedback (ilTemplate $tpl)
 Populate the block for an instant specific feedback. More...
 
 isShowBestSolutionRequired ()
 
 isShowGenericQuestionFeedbackRequired ()
 
 isShowSpecificQuestionFeedbackRequired ()
 
 isShowReachedPointsRequired ()
 
 getQuestionAnswerShuffler ()
 

Private Attributes

assQuestionGUI $question_gui = null
 
assQuestion $question_obj = null
 
ilAssQuestionPreviewSettings $preview_settings = null
 
ilAssQuestionPreviewSession $preview_session = null
 
string $info_message = null
 
array $primary_cmd = []
 
array $additional_cmds = []
 

Detailed Description

Definition at line 44 of file class.ilAssQuestionPreviewGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilAssQuestionPreviewGUI::__construct ( private readonly ilCtrl  $ctrl,
private readonly ilRbacSystem  $rbac_system,
private ilTabsGUI  $tabs,
private ilToolbarGUI  $toolbar,
private ilGlobalTemplateInterface  $tpl,
private readonly UIFactory  $ui_factory,
private readonly ilLanguage  $lng,
private readonly ilDBInterface  $db,
private readonly RandomGroup  $random_group,
private readonly GlobalScreen  $global_screen,
private readonly HTTPServices  $http,
private readonly Refinery  $refinery,
private readonly int  $parent_obj_ref_id 
)

Definition at line 75 of file class.ilAssQuestionPreviewGUI.php.

References ilObjStyleSheet\getContentStylePath(), and ilObjStyleSheet\getSyntaxStylePath().

89  {
90  $this->tpl->addCss(ilObjStyleSheet::getContentStylePath(0));
91  $this->tpl->addCss(ilObjStyleSheet::getSyntaxStylePath());
92 
93  $local_dic = QuestionPoolDIC::dic();
94  $this->request_data_collector = $local_dic['request_data_collector'];
95  }
static getContentStylePath(int $a_style_id, bool $add_random=true, bool $add_token=true)
get content style path static (to avoid full reading)
+ Here is the call graph for this function:

Member Function Documentation

◆ addAdditionalCmd()

ilAssQuestionPreviewGUI::addAdditionalCmd ( string  $label,
string  $cmd 
)

Definition at line 107 of file class.ilAssQuestionPreviewGUI.php.

Referenced by ilObjTestGUI\forwardCommandToQuestionPreview().

107  : void
108  {
109  $this->additional_cmds[$label] = $cmd;
110  }
+ Here is the caller graph for this function:

◆ assessmentCmd()

ilAssQuestionPreviewGUI::assessmentCmd ( )

Definition at line 250 of file class.ilAssQuestionPreviewGUI.php.

References ILIAS\Repository\tabs().

251  {
252  $this->tabs->activateTab('statistics');
253  $this->question_gui->assessment();
254  }
+ Here is the call graph for this function:

◆ buildPreviewFormAction()

ilAssQuestionPreviewGUI::buildPreviewFormAction ( )
protected

Definition at line 214 of file class.ilAssQuestionPreviewGUI.php.

References ILIAS\Repository\ctrl().

Referenced by showCmd().

214  : string
215  {
216  return $this->ctrl->getFormAction($this, self::CMD_SHOW) . '#' . self::FEEDBACK_FOCUS_ANCHOR;
217  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ displayMediaFullscreenCmd()

ilAssQuestionPreviewGUI::displayMediaFullscreenCmd ( )

Definition at line 344 of file class.ilAssQuestionPreviewGUI.php.

References ILIAS\Repository\ctrl().

Referenced by executeCommand().

344  : void
345  {
346  $page_id = $this->request_data_collector->int('pg_id');
347  if ($page_id === 0) {
348  return;
349  }
350 
351  (new ilPageObjectGUI(
352  $this->ctrl->getCmdClass() === 'ilassgenfeedbackpagegui' ? 'qfbg' : 'qfbs',
353  $page_id
354  ))->displayMediaFullscreen();
355  }
Class ilPageObjectGUI.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilAssQuestionPreviewGUI::executeCommand ( )

Definition at line 178 of file class.ilAssQuestionPreviewGUI.php.

References $DIC, ILIAS\Repository\ctrl(), displayMediaFullscreenCmd(), ILIAS\Repository\lng(), showCmd(), and ILIAS\Repository\tabs().

178  : void
179  {
180  global $DIC;
181  $ilHelp = $DIC['ilHelp'];
182  $ilHelp->setScreenIdComponent('qpl');
183 
184  $this->tabs->setTabActive(self::TAB_ID_QUESTION);
185 
186  $this->lng->loadLanguageModule('content');
187 
188  $nextClass = $this->ctrl->getNextClass($this);
189 
190  switch ($nextClass) {
191  case 'ilassspecfeedbackpagegui':
192  case 'ilassgenfeedbackpagegui':
193  if ($this->ctrl->getCmd() === 'displayMediaFullscreen') {
194  $this->displayMediaFullscreenCmd();
195  }
197  $this->question_obj,
198  $this->ctrl,
199  $this->tabs,
200  $this->lng
201  ))->forward();
202  break;
203  case 'ilcommentgui':
204  $comment_gui = new ilCommentGUI($this->question_obj->getObjId(), $this->question_obj->getId(), 'quest');
205  $comments_panel_html = $this->ctrl->forwardCommand($comment_gui);
206  $this->showCmd($comments_panel_html);
207  break;
208  default:
209  $cmd = $this->ctrl->getCmd(self::CMD_SHOW);
210  $this->{$cmd . 'Cmd'}();
211  }
212  }
global $DIC
Definition: shib_login.php:26
Comment GUI.
showCmd(string $commands_panel_html='')
+ Here is the call graph for this function:

◆ getObject()

ilAssQuestionPreviewGUI::getObject ( )

Definition at line 117 of file class.ilAssQuestionPreviewGUI.php.

References $question_obj.

◆ getQuestion()

ilAssQuestionPreviewGUI::getQuestion ( )

Definition at line 112 of file class.ilAssQuestionPreviewGUI.php.

References $question_obj.

◆ getQuestionAnswerShuffler()

ilAssQuestionPreviewGUI::getQuestionAnswerShuffler ( )
private
Returns
Transformation

Definition at line 568 of file class.ilAssQuestionPreviewGUI.php.

Referenced by populateQuestionOutput().

569  {
570  if (!$this->preview_session->randomizerSeedExists()) {
571  $this->preview_session->setRandomizerSeed((new RandomSeed())->createSeed());
572  }
573  return $this->random_group->shuffleArray(new GivenSeed((int) $this->preview_session->getRandomizerSeed()));
574  }
A transformation is a function from one datatype to another.
+ Here is the caller graph for this function:

◆ getQuestionNavigationHtml()

ilAssQuestionPreviewGUI::getQuestionNavigationHtml ( )
private

Definition at line 452 of file class.ilAssQuestionPreviewGUI.php.

References ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

Referenced by populateQuestionOutput().

452  : string
453  {
454  $navGUI = new ilAssQuestionRelatedNavigationBarGUI($this->ctrl, $this->lng);
455 
456  $navGUI->setInstantResponseCmd(self::CMD_INSTANT_RESPONSE);
457  $navGUI->setInstantResponseEnabled($this->preview_settings->isInstantFeedbackNavigationRequired());
458  return $this->ctrl->getHTML($navGUI);
459  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleInstantResponseRendering()

ilAssQuestionPreviewGUI::handleInstantResponseRendering ( ilTemplate  $tpl)

Definition at line 256 of file class.ilAssQuestionPreviewGUI.php.

References isShowBestSolutionRequired(), isShowGenericQuestionFeedbackRequired(), isShowReachedPointsRequired(), isShowSpecificQuestionFeedbackRequired(), ILIAS\Repository\lng(), populateGenericQuestionFeedback(), populateInstantResponseHeader(), populateInstantResponseMessage(), populateReachedPointsOutput(), populateSolutionOutput(), and populateSpecificQuestionFeedback().

Referenced by showCmd().

256  : void
257  {
258  $response_required = false;
259  $response_available = false;
260  $jump_to_response = false;
261 
262  if ($this->isShowReachedPointsRequired()) {
263  $this->populateReachedPointsOutput($tpl);
264  $response_required = true;
265  $response_available = true;
266  $jump_to_response = true;
267  }
268 
269  if ($this->isShowBestSolutionRequired()) {
270  $this->populateSolutionOutput($tpl);
271  $response_required = true;
272  $response_available = true;
273  $jump_to_response = true;
274  }
275 
277  $response_required = true;
278  if ($this->populateGenericQuestionFeedback($tpl)) {
279  $response_available = true;
280  $jump_to_response = true;
281  }
282  }
283 
285  $response_required = true;
286 
287  if ($this->question_gui->hasInlineFeedback()) {
288  // Don't jump to the feedback below the question if some feedback is shown within the question
289  $jump_to_response = false;
290  } else {
291  if ($this->populateSpecificQuestionFeedback($tpl)) {
292  $response_available = true;
293  $jump_to_response = true;
294  }
295  }
296  }
297 
298  if ($response_required) {
299  $this->populateInstantResponseHeader($tpl, $jump_to_response);
300  if (!$response_available) {
301  if ($this->question_gui->hasInlineFeedback()) {
303  $tpl,
304  $this->lng->txt('tst_feedback_is_given_inline')
305  );
306  } else {
308  $tpl,
309  $this->lng->txt('tst_feedback_not_available_for_answer')
310  );
311  }
312  }
313  }
314  }
populateGenericQuestionFeedback(ilTemplate $tpl)
Populate the block for an instant generic feedback.
populateInstantResponseHeader(ilTemplate $tpl, $withFocusAnchor)
populateInstantResponseMessage(ilTemplate $tpl, string $a_message)
populateSpecificQuestionFeedback(ilTemplate $tpl)
Populate the block for an instant specific feedback.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleQuestionActionCmd()

ilAssQuestionPreviewGUI::handleQuestionActionCmd ( )

Definition at line 338 of file class.ilAssQuestionPreviewGUI.php.

References ILIAS\Repository\ctrl().

338  : void
339  {
340  $this->question_obj->persistPreviewState($this->preview_session);
341  $this->ctrl->redirect($this, self::CMD_SHOW);
342  }
+ Here is the call graph for this function:

◆ initPreviewSession()

ilAssQuestionPreviewGUI::initPreviewSession ( int  $user_id,
int  $question_id 
)

Definition at line 161 of file class.ilAssQuestionPreviewGUI.php.

161  : void
162  {
163  $this->preview_session = new ilAssQuestionPreviewSession($user_id, $question_id);
164  $this->preview_session->init();
165  }

◆ initPreviewSettings()

ilAssQuestionPreviewGUI::initPreviewSettings ( int  $parent_ref_id)

Definition at line 154 of file class.ilAssQuestionPreviewGUI.php.

154  : void
155  {
156  $this->preview_settings = new ilAssQuestionPreviewSettings($parent_ref_id);
157 
158  $this->preview_settings->init();
159  }

◆ initQuestion()

ilAssQuestionPreviewGUI::initQuestion ( assQuestionGUI  $question_gui,
int  $parent_obj_id 
)

Definition at line 122 of file class.ilAssQuestionPreviewGUI.php.

References $question_gui, ILIAS\Repository\ctrl(), assQuestionGUI\getObject(), assQuestionGUI\RENDER_PURPOSE_DEMOPLAY, and ILIAS\Repository\tabs().

122  : void
123  {
124  $this->question_gui = $question_gui;
125  $this->question_obj = $this->question_gui->getObject();
126 
127  $this->question_obj->setObjId($parent_obj_id);
128 
129  $this->tabs->clearTargets();
130  $this->tabs->addTarget(
131  self::TAB_ID_QUESTION,
132  $this->ctrl->getLinkTargetByClass(self::class, self::CMD_SHOW),
133  '',
134  [strtolower(__CLASS__)]
135  );
136  // Assessment of questions sub menu entry
137  $q_type = $this->question_obj->getQuestionType();
138  $classname = $q_type . 'GUI';
139  $this->tabs->addTarget(
140  'statistics',
141  $this->ctrl->getLinkTargetByClass(self::class, 'assessment'),
142  ['assessment'],
143  $classname,
144  ''
145  );
146 
147  $this->question_gui->populateJavascriptFilesRequiredForWorkForm($this->tpl);
148  $this->question_gui->setTargetGui($this);
149  $this->question_gui->setQuestionActionCmd(self::CMD_HANDLE_QUESTION_ACTION);
150 
151  $this->question_gui->setRenderPurpose(assQuestionGUI::RENDER_PURPOSE_DEMOPLAY);
152  }
+ Here is the call graph for this function:

◆ initStyleSheets()

ilAssQuestionPreviewGUI::initStyleSheets ( )

Definition at line 167 of file class.ilAssQuestionPreviewGUI.php.

References ilObjStyleSheet\getContentStylePath(), and ilObjStyleSheet\getSyntaxStylePath().

167  : void
168  {
169  $this->tpl->setCurrentBlock('ContentStyle');
170  $this->tpl->setVariable('LOCATION_CONTENT_STYLESHEET', ilObjStyleSheet::getContentStylePath(0));
171  $this->tpl->parseCurrentBlock();
172 
173  $this->tpl->setCurrentBlock('SyntaxStyle');
174  $this->tpl->setVariable('LOCATION_SYNTAX_STYLESHEET', ilObjStyleSheet::getSyntaxStylePath());
175  $this->tpl->parseCurrentBlock();
176  }
static getContentStylePath(int $a_style_id, bool $add_random=true, bool $add_token=true)
get content style path static (to avoid full reading)
+ Here is the call graph for this function:

◆ instantResponseCmd()

ilAssQuestionPreviewGUI::instantResponseCmd ( )

Definition at line 327 of file class.ilAssQuestionPreviewGUI.php.

References ILIAS\Repository\ctrl(), and saveQuestionSolution().

327  : void
328  {
329  if ($this->saveQuestionSolution()) {
330  $this->preview_session->setInstantResponseActive(true);
331  } else {
332  $this->preview_session->setInstantResponseActive(false);
333  }
334 
335  $this->ctrl->redirect($this, self::CMD_SHOW);
336  }
+ Here is the call graph for this function:

◆ isCommentingRequired()

ilAssQuestionPreviewGUI::isCommentingRequired ( )
protected

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

Referenced by showCmd().

219  : bool
220  {
221  return !$this->preview_settings->isTestRefId() &&
222  $this->rbac_system->checkAccess('read', $this->request_data_collector->getRefId());
223  }
+ Here is the caller graph for this function:

◆ isShowBestSolutionRequired()

ilAssQuestionPreviewGUI::isShowBestSolutionRequired ( )
private

Definition at line 524 of file class.ilAssQuestionPreviewGUI.php.

Referenced by handleInstantResponseRendering().

525  {
526  if (!$this->preview_settings->isBestSolutionEnabled()) {
527  return false;
528  }
529 
530  return $this->preview_session->isInstantResponseActive();
531  }
+ Here is the caller graph for this function:

◆ isShowGenericQuestionFeedbackRequired()

ilAssQuestionPreviewGUI::isShowGenericQuestionFeedbackRequired ( )
private

Definition at line 533 of file class.ilAssQuestionPreviewGUI.php.

Referenced by handleInstantResponseRendering().

534  {
535  if (!$this->preview_settings->isGenericFeedbackEnabled()) {
536  return false;
537  }
538 
539  return $this->preview_session->isInstantResponseActive();
540  }
+ Here is the caller graph for this function:

◆ isShowReachedPointsRequired()

ilAssQuestionPreviewGUI::isShowReachedPointsRequired ( )
private

Definition at line 551 of file class.ilAssQuestionPreviewGUI.php.

Referenced by handleInstantResponseRendering().

552  {
553  if (!$this->preview_settings->isReachedPointsEnabled()) {
554  return false;
555  }
556 
557  return $this->preview_session->isInstantResponseActive();
558  }
+ Here is the caller graph for this function:

◆ isShowSpecificQuestionFeedbackRequired()

ilAssQuestionPreviewGUI::isShowSpecificQuestionFeedbackRequired ( )
private

Definition at line 542 of file class.ilAssQuestionPreviewGUI.php.

Referenced by handleInstantResponseRendering(), and populateQuestionOutput().

542  : bool
543  {
544  if (!$this->preview_settings->isSpecificFeedbackEnabled()) {
545  return false;
546  }
547 
548  return $this->preview_session->isInstantResponseActive();
549  }
+ Here is the caller graph for this function:

◆ populateCommentsPanel()

ilAssQuestionPreviewGUI::populateCommentsPanel ( ilTemplate  $tpl,
string  $comments_panel_html 
)
protected

Definition at line 576 of file class.ilAssQuestionPreviewGUI.php.

References ilTemplate\parseCurrentBlock(), ilTemplate\setCurrentBlock(), and HTML_Template_IT\setVariable().

Referenced by showCmd().

576  : void
577  {
578  if ($comments_panel_html === '') {
579  $comments_panel_html = $this->question_gui->getCommentsPanelHTML();
580  }
581 
582  $tpl->setCurrentBlock('notes_panel');
583  $tpl->setVariable('NOTES_PANEL', $comments_panel_html);
584  $tpl->parseCurrentBlock();
585  }
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateGenericQuestionFeedback()

ilAssQuestionPreviewGUI::populateGenericQuestionFeedback ( ilTemplate  $tpl)
private

Populate the block for an instant generic feedback.

Returns
bool true, if there is some feedback populated

Definition at line 465 of file class.ilAssQuestionPreviewGUI.php.

References ilAssQuestionFeedback\CSS_CLASS_FEEDBACK_CORRECT, ilAssQuestionFeedback\CSS_CLASS_FEEDBACK_WRONG, ilTemplate\parseCurrentBlock(), ilTemplate\setCurrentBlock(), and HTML_Template_IT\setVariable().

Referenced by handleInstantResponseRendering().

465  : bool
466  {
467  if ($this->question_obj->isPreviewSolutionCorrect($this->preview_session)) {
468  $feedback = $this->question_gui->getGenericFeedbackOutputForCorrectSolution();
470  } else {
471  $feedback = $this->question_gui->getGenericFeedbackOutputForIncorrectSolution();
473  }
474 
475  if ($feedback !== '') {
476  $tpl->setCurrentBlock('instant_feedback_generic');
477  $tpl->setVariable('GENERIC_FEEDBACK', $feedback);
478  $tpl->setVariable('ILC_FB_CSS_CLASS', $cssClass);
479  $tpl->parseCurrentBlock();
480  return true;
481  }
482  return false;
483  }
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateInstantResponseHeader()

ilAssQuestionPreviewGUI::populateInstantResponseHeader ( ilTemplate  $tpl,
  $withFocusAnchor 
)
protected

Definition at line 504 of file class.ilAssQuestionPreviewGUI.php.

References ILIAS\Repository\lng(), ilTemplate\parseCurrentBlock(), ilTemplate\setCurrentBlock(), and HTML_Template_IT\setVariable().

Referenced by handleInstantResponseRendering().

504  : void
505  {
506  if ($withFocusAnchor) {
507  $tpl->setCurrentBlock('inst_resp_id');
508  $tpl->setVariable('INSTANT_RESPONSE_FOCUS_ID', self::FEEDBACK_FOCUS_ANCHOR);
509  $tpl->parseCurrentBlock();
510  }
511 
512  $tpl->setCurrentBlock('instant_response_header');
513  $tpl->setVariable('INSTANT_RESPONSE_HEADER', $this->lng->txt('tst_feedback'));
514  $tpl->parseCurrentBlock();
515  }
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateInstantResponseMessage()

ilAssQuestionPreviewGUI::populateInstantResponseMessage ( ilTemplate  $tpl,
string  $a_message 
)
protected

Definition at line 517 of file class.ilAssQuestionPreviewGUI.php.

References ilTemplate\parseCurrentBlock(), ilTemplate\setCurrentBlock(), and HTML_Template_IT\setVariable().

Referenced by handleInstantResponseRendering().

518  {
519  $tpl->setCurrentBlock('instant_response_message');
520  $tpl->setVariable('INSTANT_RESPONSE_MESSAGE', $a_message);
521  $tpl->parseCurrentBlock();
522  }
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateQuestionOutput()

ilAssQuestionPreviewGUI::populateQuestionOutput ( ilTemplate  $tpl)
private

Definition at line 382 of file class.ilAssQuestionPreviewGUI.php.

References ILIAS\Repository\ctrl(), getQuestionAnswerShuffler(), getQuestionNavigationHtml(), isShowSpecificQuestionFeedbackRequired(), ilPageObjectGUI\setFileDownloadLink(), HTML_Template_IT\setVariable(), and ILIAS\Repository\tabs().

Referenced by showCmd().

382  : void
383  {
384  // FOR WHAT EXACTLY IS THIS USEFUL?
385  $this->ctrl->setReturnByClass('ilAssQuestionPageGUI', 'view');
386  $this->ctrl->setReturnByClass('ilObjQuestionPoolGUI', 'questions');
387 
388  $page_gui = new ilAssQuestionPageGUI($this->question_obj->getId());
389  $page_gui->setFileDownloadLink($this->question_gui->buildFileDownloadLink());
390  $page_gui->setRenderPageContainer(false);
391  $page_gui->setEditPreview(true);
392  $page_gui->setEnabledTabs(false);
393 
394  $this->question_gui->setPreviewSession($this->preview_session);
395  $question = $this->question_gui->getObject();
396  $question->setShuffler($this->getQuestionAnswerShuffler());
397  $this->question_gui->setObject($question);
398 
399  $question_html = $this->question_gui->getPreview(true, $this->isShowSpecificQuestionFeedbackRequired());
400  $this->question_gui->magicAfterTestOutput();
401 
402  $question_html .= $this->getQuestionNavigationHtml();
403 
404  $page_gui->setQuestionHTML([$this->question_obj->getId() => $question_html]);
405 
406  $page_gui->setPresentationTitle($this->question_obj->getTitleForHTMLOutput());
407 
408  $tpl->setVariable('QUESTION_OUTPUT', $page_gui->preview());
409  // \ilPageObjectGUI::preview sets an undefined tab, so the "question" tab has to be activated again
410  $this->tabs->setTabActive(self::TAB_ID_QUESTION);
411  }
Question page GUI class.
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
setFileDownloadLink(string $a_download_link)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateReachedPointsOutput()

ilAssQuestionPreviewGUI::populateReachedPointsOutput ( ilTemplate  $tpl)
protected

Definition at line 413 of file class.ilAssQuestionPreviewGUI.php.

References ILIAS\Repository\lng(), ilTemplate\parseCurrentBlock(), ilTemplate\setCurrentBlock(), and HTML_Template_IT\setVariable().

Referenced by handleInstantResponseRendering().

413  : void
414  {
415  $reachedPoints = $this->question_obj->calculateReachedPointsFromPreviewSession($this->preview_session);
416  $maxPoints = $this->question_obj->getMaximumPoints();
417 
418  $scoreInformation = sprintf(
419  $this->lng->txt("you_received_a_of_b_points"),
420  $reachedPoints,
421  $maxPoints
422  );
423 
424  $tpl->setCurrentBlock("reached_points_feedback");
425  $tpl->setVariable("REACHED_POINTS_FEEDBACK", $scoreInformation);
426  $tpl->parseCurrentBlock();
427  }
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateSolutionOutput()

ilAssQuestionPreviewGUI::populateSolutionOutput ( ilTemplate  $tpl)
private

Definition at line 429 of file class.ilAssQuestionPreviewGUI.php.

References ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), null, ilTemplate\parseCurrentBlock(), ilTemplate\setCurrentBlock(), ilPageObjectGUI\setFileDownloadLink(), and HTML_Template_IT\setVariable().

Referenced by handleInstantResponseRendering().

429  : void
430  {
431  // FOR WHAT EXACTLY IS THIS USEFUL?
432  $this->ctrl->setReturnByClass('ilAssQuestionPageGUI', 'view');
433  $this->ctrl->setReturnByClass('ilObjQuestionPoolGUI', 'questions');
434 
435  $page_gui = new ilAssQuestionPageGUI($this->question_obj->getId());
436  $page_gui->setFileDownloadLink($this->question_gui->buildFileDownloadLink());
437  $page_gui->setEditPreview(true);
438  $page_gui->setEnabledTabs(false);
439 
440  $this->question_gui->setPreviewSession($this->preview_session);
441 
442  $page_gui->setQuestionHTML([$this->question_obj->getId() => $this->question_gui->getSolutionOutput(0, null, false, false, true, false, true, false, false)]);
443 
444  $output = $this->question_gui->getSolutionOutput(0, null, false, false, true, false, true, false, false);
445 
446  $tpl->setCurrentBlock('solution_output');
447  $tpl->setVariable('TXT_CORRECT_SOLUTION', $this->lng->txt('tst_best_solution_is'));
448  $tpl->setVariable('SOLUTION_OUTPUT', $output);
449  $tpl->parseCurrentBlock();
450  }
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
Question page GUI class.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
setFileDownloadLink(string $a_download_link)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateSpecificQuestionFeedback()

ilAssQuestionPreviewGUI::populateSpecificQuestionFeedback ( ilTemplate  $tpl)
private

Populate the block for an instant specific feedback.

Returns
bool true, if there is some feedback populated

Definition at line 489 of file class.ilAssQuestionPreviewGUI.php.

References ilTemplate\parseCurrentBlock(), ilTemplate\setCurrentBlock(), and HTML_Template_IT\setVariable().

Referenced by handleInstantResponseRendering().

489  : bool
490  {
491  $fb = $this->question_gui->getSpecificFeedbackOutput(
492  (array) $this->preview_session->getParticipantsSolution()
493  );
494 
495  if (!empty($fb)) {
496  $tpl->setCurrentBlock('instant_feedback_specific');
497  $tpl->setVariable('ANSWER_FEEDBACK', $fb);
498  $tpl->parseCurrentBlock();
499  return true;
500  }
501  return false;
502  }
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateToolbar()

ilAssQuestionPreviewGUI::populateToolbar ( )
private

Definition at line 357 of file class.ilAssQuestionPreviewGUI.php.

References ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ILIAS\Repository\toolbar().

Referenced by showCmd().

357  : void
358  {
359  $this->toolbar->setFormAction($this->ctrl->getFormAction($this, self::CMD_SHOW));
360 
361  if ($this->rbac_system->checkAccess('write', $this->parent_obj_ref_id)) {
362  if ($this->primary_cmd !== []) {
363  $this->toolbar->addComponent(
364  $this->ui_factory->button()->primary(key($this->primary_cmd), current($this->primary_cmd))
365  );
366  }
367  foreach ($this->additional_cmds as $label => $action) {
368  $this->toolbar->addComponent(
369  $this->ui_factory->button()->standard($label, $action)
370  );
371  }
372  }
373 
374  $this->toolbar->addComponent(
375  $this->ui_factory->button()->standard(
376  $this->lng->txt('qpl_reset_preview'),
377  $this->ctrl->getLinkTargetByClass(ilAssQuestionPreviewGUI::class, self::CMD_RESET)
378  )
379  );
380  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resetCmd()

ilAssQuestionPreviewGUI::resetCmd ( )

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

References ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and null.

316  : void
317  {
318  $this->preview_session->setRandomizerSeed(null);
319  $this->preview_session->setParticipantsSolution(null);
320  $this->preview_session->setInstantResponseActive(false);
321 
322  $this->tpl->setOnScreenMessage('info', $this->lng->txt('qst_preview_reset_msg'), true);
323 
324  $this->ctrl->redirect($this, self::CMD_SHOW);
325  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:

◆ saveQuestionSolution()

ilAssQuestionPreviewGUI::saveQuestionSolution ( )

Definition at line 560 of file class.ilAssQuestionPreviewGUI.php.

Referenced by instantResponseCmd().

560  : bool
561  {
562  return $this->question_obj->persistPreviewState($this->preview_session);
563  }
+ Here is the caller graph for this function:

◆ setInfoMessage()

ilAssQuestionPreviewGUI::setInfoMessage ( string  $message)

Definition at line 97 of file class.ilAssQuestionPreviewGUI.php.

References $message.

97  : void
98  {
99  $this->info_message = $message;
100  }
$message
Definition: xapiexit.php:31

◆ setPrimaryCmd()

ilAssQuestionPreviewGUI::setPrimaryCmd ( string  $label,
string  $cmd 
)

Definition at line 102 of file class.ilAssQuestionPreviewGUI.php.

102  : void
103  {
104  $this->primary_cmd[$label] = $cmd;
105  }

◆ showCmd()

ilAssQuestionPreviewGUI::showCmd ( string  $commands_panel_html = '')

Definition at line 225 of file class.ilAssQuestionPreviewGUI.php.

References buildPreviewFormAction(), assQuestionGUI\CMD_SYNC_QUESTION_AND_RETURN, handleInstantResponseRendering(), isCommentingRequired(), null, populateCommentsPanel(), populateQuestionOutput(), and populateToolbar().

Referenced by executeCommand().

225  : void
226  {
227  $tpl = new ilTemplate('tpl.qpl_question_preview.html', true, true, 'components/ILIAS/TestQuestionPool');
228  $tpl->setVariable('PREVIEW_FORMACTION', $this->buildPreviewFormAction());
229 
230  $modal = '';
231  if ($this->question_gui->isSaveCommand() && $this->question_gui->needsSyncQuery()) {
232  $modal = $this->question_gui->getQuestionSyncModal(assQuestionGUI::CMD_SYNC_QUESTION_AND_RETURN);
233  }
234 
235  if ($this->info_message !== null) {
236  $this->tpl->setOnScreenMessage('info', $this->info_message, true);
237  }
238 
239  $this->populateToolbar();
240  $this->populateQuestionOutput($tpl);
241  $this->handleInstantResponseRendering($tpl);
242 
243  if ($this->isCommentingRequired()) {
244  $this->populateCommentsPanel($tpl, $commands_panel_html);
245  }
246 
247  $this->tpl->setContent($tpl->get() . $modal);
248  }
populateCommentsPanel(ilTemplate $tpl, string $comments_panel_html)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $additional_cmds

array< string $label, string $action > ilAssQuestionPreviewGUI::$additional_cmds = []
private

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

◆ $info_message

string ilAssQuestionPreviewGUI::$info_message = null
private

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

◆ $preview_session

ilAssQuestionPreviewSession ilAssQuestionPreviewGUI::$preview_session = null
private

Definition at line 61 of file class.ilAssQuestionPreviewGUI.php.

◆ $preview_settings

ilAssQuestionPreviewSettings ilAssQuestionPreviewGUI::$preview_settings = null
private

Definition at line 60 of file class.ilAssQuestionPreviewGUI.php.

◆ $primary_cmd

array< string $label, string $action > ilAssQuestionPreviewGUI::$primary_cmd = []
private

Definition at line 68 of file class.ilAssQuestionPreviewGUI.php.

◆ $question_gui

assQuestionGUI ilAssQuestionPreviewGUI::$question_gui = null
private

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

Referenced by initQuestion().

◆ $question_obj

assQuestion ilAssQuestionPreviewGUI::$question_obj = null
private

Definition at line 59 of file class.ilAssQuestionPreviewGUI.php.

Referenced by getObject(), and getQuestion().

◆ $request_data_collector

readonly RequestDataCollector ilAssQuestionPreviewGUI::$request_data_collector
protected

Definition at line 56 of file class.ilAssQuestionPreviewGUI.php.

◆ CMD_HANDLE_QUESTION_ACTION

const ilAssQuestionPreviewGUI::CMD_HANDLE_QUESTION_ACTION = 'handleQuestionAction'

Definition at line 50 of file class.ilAssQuestionPreviewGUI.php.

◆ CMD_INSTANT_RESPONSE

const ilAssQuestionPreviewGUI::CMD_INSTANT_RESPONSE = 'instantResponse'

Definition at line 49 of file class.ilAssQuestionPreviewGUI.php.

◆ CMD_RESET

const ilAssQuestionPreviewGUI::CMD_RESET = 'reset'

Definition at line 47 of file class.ilAssQuestionPreviewGUI.php.

◆ CMD_SHOW

◆ CMD_STATISTICS

const ilAssQuestionPreviewGUI::CMD_STATISTICS = 'assessment'

◆ FEEDBACK_FOCUS_ANCHOR

const ilAssQuestionPreviewGUI::FEEDBACK_FOCUS_ANCHOR = 'focus'

Definition at line 54 of file class.ilAssQuestionPreviewGUI.php.

◆ TAB_ID_QUESTION

const ilAssQuestionPreviewGUI::TAB_ID_QUESTION = 'question'

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


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