ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ilTestServiceGUI Class Reference

Service GUI class for tests. More...

+ Inheritance diagram for ilTestServiceGUI:
+ Collaboration diagram for ilTestServiceGUI:

Public Member Functions

 isContextResultPresentation ()
 
 setContextResultPresentation (bool $contextResultPresentation)
 
 setParticipantData (ilTestParticipantData $participantData)
 
 getParticipantData ()
 
 getPassOverviewTableData (ilTestSession $test_session, array $passes, bool $with_results)
 
 setObjectiveOrientedContainer (ilTestObjectiveOrientedContainer $objective_oriented_container)
 
 getObjectiveOrientedContainer ()
 
 executeCommand ()
 execute command More...
 
 buildPassOverviewTableGUI (ilTestEvaluationGUI $target_gui)
 
 getPassListOfAnswers (&$result_array, $active_id, $pass, $show_solutions=false, $only_answered_questions=false, $show_question_only=false, $show_reached_points=false, $anchorNav=false, ?ilTestQuestionRelatedObjectivesList $objectives_list=null, ?ResultsTitlesBuilder $testResultHeaderLabelBuilder=null)
 Returns the list of answers of a users test pass. More...
 
 getResultsSignature ()
 Returns HTML code for a signature field. More...
 
 getAdditionalUsrDataHtmlAndPopulateWindowTitle ($testSession, $active_id, $overwrite_anonymity=false)
 Returns the user data for a test results output. More...
 
 getCorrectSolutionOutput ($question_id, $active_id, $pass, ?ilTestQuestionRelatedObjectivesList $objectives_list=null)
 Returns an output of the solution to an answer compared to the correct solution. More...
 
 getObject ()
 

Protected Member Functions

 getPassDetailsOverviewTableGUI (array $result_array, int $active_id, int $pass, ilTestServiceGUI $target_gui, string $target_cmd, ?ilTestQuestionRelatedObjectivesList $objectives_list=null, bool $multiple_objectives_involved=true)
 
 buildPassDetailsOverviewTableGUI (ilTestServiceGUI $target_gui, string $target_cmd)
 
 isGradingMessageRequired ()
 
 getGradingMessageBuilder (int $active_id)
 
 buildQuestionRelatedObjectivesList (ilLOTestQuestionAdapter $objectives_adapter, ilTestQuestionSequence $test_sequence)
 
 populateContent (string $content)
 
 outCorrectSolutionCmd ()
 
 outCorrectSolution ()
 
 populatePassFinishDate (ilTemplate $tpl, ?int $pass_finish_date)
 
 populateExamId (ilTemplate $tpl, int $active_id, int $pass)
 

Protected Attributes

readonly RequestDataCollector $testrequest
 
readonly GeneralQuestionPropertiesRepository $questionrepository
 
readonly TestQuestionsRepository $testquestionsrepository
 
ilTestService $service = null
 
readonly ilDBInterface $db
 
readonly ilLanguage $lng
 
readonly TestLogger $logger
 
readonly ilHelpGUI $help
 
readonly ilRbacSystem $rbac_system
 
ilGlobalTemplateInterface ilTemplate $tpl
 sk 2023-08-01: We need this union type, even if it is wrong! To change this More...
 
readonly ContentStyle $content_style
 
readonly ilErrorHandling $error
 
ilAccess $access
 
readonly HTTPServices $http
 
readonly ilCtrlInterface $ctrl
 
readonly ilToolbarGUI $toolbar
 
readonly ilTabsGUI $tabs
 
readonly ilObjectDataCache $obj_cache
 
readonly ilComponentRepository $component_repository
 
readonly ilObjUser $user
 
readonly ArrayBasedRequestWrapper $post_wrapper
 
readonly ilNavigationHistory $navigation_history
 
readonly Refinery $refinery
 
readonly UIFactory $ui_factory
 
readonly UIRenderer $ui_renderer
 
readonly SkillService $skills_service
 
readonly ilTestShuffler $shuffler
 
readonly ResultsDataFactory $results_data_factory
 
readonly ResultsPresentationFactory $results_presentation_factory
 
readonly ILIAS $ilias
 
readonly ilSetting $settings
 
readonly GlobalScreenServices $global_screen
 
readonly ilTree $tree
 
int $ref_id
 
ilTestSessionFactory $test_session_factory = null
 
ilTestSequenceFactory $test_sequence_factory = null
 
ilTestParticipantData $participantData = null
 
TestResultRepository $test_result_repository
 
ilTestParticipantAccessFilterFactory $participant_access_filter
 

Private Attributes

ilTestObjectiveOrientedContainer $objective_oriented_container
 
bool $contextResultPresentation = true
 

Detailed Description

Service GUI class for tests.

This class is the parent class for all service classes which are called from ilObjTestGUI. This is mainly done to reduce the size of ilObjTestGUI to put command service functions into classes that could be called by ilCtrl.

ilTestServiceGUI: ilObjTestGUI

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Björn Heyser bheys.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

\

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

Member Function Documentation

◆ buildPassDetailsOverviewTableGUI()

ilTestServiceGUI::buildPassDetailsOverviewTableGUI ( ilTestServiceGUI  $target_gui,
string  $target_cmd 
)
protected

◆ buildPassOverviewTableGUI()

ilTestServiceGUI::buildPassOverviewTableGUI ( ilTestEvaluationGUI  $target_gui)

Definition at line 296 of file class.ilTestServiceGUI.php.

References getObjectiveOrientedContainer().

Referenced by ilTestEvaluationGUI\outUserResultsOverview().

297  {
298  $table = new ilTestPassOverviewTableGUI($target_gui, '');
299 
300  $table->setPdfPresentationEnabled(
301  $this->testrequest->isset('pdf') && $this->testrequest->raw('pdf') == 1
302  );
303 
304  $table->setObjectiveOrientedPresentationEnabled(
305  $this->getObjectiveOrientedContainer()?->isObjectiveOrientedPresentationRequired() ?? false
306  );
307 
308  return $table;
309  }
Class ilTestPassOverviewTableGUI.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildQuestionRelatedObjectivesList()

ilTestServiceGUI::buildQuestionRelatedObjectivesList ( ilLOTestQuestionAdapter  $objectives_adapter,
ilTestQuestionSequence  $test_sequence 
)
protected

Definition at line 655 of file class.ilTestServiceGUI.php.

References ilLOTestQuestionAdapter\buildQuestionRelatedObjectiveList().

Referenced by ilTestSubmissionReviewGUI\buildUserReviewOutput(), getPassOverviewTableData(), outCorrectSolution(), ilTestEvaluationGUI\outUserListOfAnswerPasses(), ilTestEvaluationGUI\outUserPassDetails(), and ilTestEvalObjectiveOrientedGUI\showVirtualPassCmd().

659  $questionRelatedObjectivesList = new ilTestQuestionRelatedObjectivesList();
660 
661  $objectives_adapter->buildQuestionRelatedObjectiveList($test_sequence, $questionRelatedObjectivesList);
662 
663  return $questionRelatedObjectivesList;
664  }
buildQuestionRelatedObjectiveList(ilTestQuestionSequence $a_test_sequence, ilTestQuestionRelatedObjectivesList $a_objectives_list)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilTestServiceGUI::executeCommand ( )

execute command

Definition at line 283 of file class.ilTestServiceGUI.php.

References ILIAS\Repository\ctrl().

284  {
285  $cmd = $this->ctrl->getCmd();
286  $next_class = $this->ctrl->getNextClass($this);
287 
288  switch ($next_class) {
289  default:
290  $ret = &$this->$cmd();
291  break;
292  }
293  return $ret;
294  }
+ Here is the call graph for this function:

◆ getAdditionalUsrDataHtmlAndPopulateWindowTitle()

ilTestServiceGUI::getAdditionalUsrDataHtmlAndPopulateWindowTitle (   $testSession,
  $active_id,
  $overwrite_anonymity = false 
)

Returns the user data for a test results output.

Parameters
ilTestSession
integer$user_idThe user ID of the user
boolean$overwrite_anonymityTRUE if the anonymity status should be overwritten, FALSE otherwise
Returns
string HTML code of the user data for the test results public

Definition at line 521 of file class.ilTestServiceGUI.php.

References $user_id, ilObjUser\_lookupLogin(), getObjectiveOrientedContainer(), ILIAS\Repository\lng(), and ILIAS\Repository\object().

Referenced by ilTestEvaluationGUI\outUserListOfAnswerPasses(), ilTestEvaluationGUI\outUserResultsOverview(), and ilTestPlayerAbstractGUI\showListOfAnswers().

521  : string
522  {
523  if (!is_object($testSession)) {
524  throw new InvalidArgumentException('Not an object, expected ilTestSession');
525  }
526  $template = new ilTemplate("tpl.il_as_tst_results_userdata.html", true, true, "components/ILIAS/Test");
527  $user_id = $this->object->_getUserIdFromActiveId($active_id);
528  if (strlen(ilObjUser::_lookupLogin($user_id)) > 0) {
529  $user = new ilObjUser($user_id);
530  } else {
531  $user = new ilObjUser();
532  $user->setLastname($this->lng->txt('deleted_user'));
533  }
534  $t = $testSession->getSubmittedTimestamp();
535  if (!$t) {
536  $t = $this->object->_getLastAccess($testSession->getActiveId());
537  }
538 
539  if ($this->getObjectiveOrientedContainer()?->isObjectiveOrientedPresentationRequired()) {
540  $uname = $this->object->userLookupFullName($user_id, $overwrite_anonymity);
541  $template->setCurrentBlock('name');
542  $template->setVariable('TXT_USR_NAME', $this->lng->txt("name"));
543  $template->setVariable('VALUE_USR_NAME', $uname);
544  $template->parseCurrentBlock();
545  }
546 
547  $title_matric = "";
548  if (strlen($user->getMatriculation()) && (($this->object->getAnonymity() == false) || ($overwrite_anonymity))) {
549  $template->setCurrentBlock("matriculation");
550  $template->setVariable("TXT_USR_MATRIC", $this->lng->txt("matriculation"));
551  $template->setVariable("VALUE_USR_MATRIC", $user->getMatriculation());
552  $template->parseCurrentBlock();
553  $title_matric = " - " . $this->lng->txt("matriculation") . ": " . $user->getMatriculation();
554  }
555 
556  $invited_user = array_pop($this->object->getInvitedUsers($user_id));
557  $title_client = '';
558  $template->setVariable("TXT_TEST_TITLE", $this->lng->txt("title"));
559  $template->setVariable("VALUE_TEST_TITLE", $this->object->getTitle());
560 
561  // change the pagetitle (tab title or title in title bar of window)
562  $pagetitle = $this->object->getTitle() . $title_matric . $title_client;
563  $this->tpl->setHeaderPageTitle($pagetitle);
564 
565  return $template->get();
566  }
readonly ilObjUser $user
setLastname(string $a_str)
static _lookupLogin(int $a_user_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCorrectSolutionOutput()

ilTestServiceGUI::getCorrectSolutionOutput (   $question_id,
  $active_id,
  $pass,
?ilTestQuestionRelatedObjectivesList  $objectives_list = null 
)

Returns an output of the solution to an answer compared to the correct solution.

Parameters
integer$question_idDatabase ID of the question
integer$active_idActive ID of the active user
integer$passTest pass
Returns
string HTML code of the correct solution comparison public

Definition at line 577 of file class.ilTestServiceGUI.php.

References $objectives, $user, ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), null, and ILIAS\Repository\object().

Referenced by outCorrectSolution(), and ilTestPlayerAbstractGUI\outCorrectSolution().

577  : string
578  {
579  $ilUser = $this->user;
580 
581  $test_id = $this->object->getTestId();
582  $question_gui = $this->object->createQuestionGUI("", $question_id);
583 
584  $template = new ilTemplate("tpl.il_as_tst_correct_solution_output.html", true, true, "components/ILIAS/Test");
585  $show_question_only = ($this->object->getShowSolutionAnswersOnly()) ? true : false;
586  $result_output = $question_gui->getSolutionOutput($active_id, $pass, true, false, $show_question_only, $this->object->getShowSolutionFeedback(), false, false, true);
587  $best_output = $question_gui->getSolutionOutput($active_id, $pass, false, false, $show_question_only, false, true, false, false);
588  if ($this->object->getShowSolutionFeedback() && $this->testrequest->raw('cmd') != 'outCorrectSolution') {
589  $specificAnswerFeedback = $question_gui->getSpecificFeedbackOutput(
590  $question_gui->getObject()->fetchIndexedValuesFromValuePairs(
591  $question_gui->getObject()->getSolutionValues($active_id, $pass)
592  )
593  );
594  if (strlen($specificAnswerFeedback)) {
595  $template->setCurrentBlock("outline_specific_feedback");
596  $template->setVariable("OUTLINE_SPECIFIC_FEEDBACK", $specificAnswerFeedback);
597  $template->parseCurrentBlock();
598  }
599  }
600  $template->setVariable("TEXT_YOUR_SOLUTION", $this->lng->txt("tst_your_answer_was"));
601  $template->setVariable("TEXT_SOLUTION_OUTPUT", $this->lng->txt("tst_your_answer_was")); // Mantis 28646. I don't really know why Ingmar renamed the placeholder, so
602  // I set both old and new since the old one is set as well in several places.
603  $maxpoints = $question_gui->getObject()->getMaximumPoints();
604  if ($maxpoints == 1) {
605  $template->setVariable("QUESTION_TITLE", $this->object->getQuestionTitle($question_gui->getObject()->getTitleForHTMLOutput()) . " (" . $maxpoints . " " . $this->lng->txt("point") . ")");
606  } else {
607  $template->setVariable("QUESTION_TITLE", $this->object->getQuestionTitle($question_gui->getObject()->getTitleForHTMLOutput()) . " (" . $maxpoints . " " . $this->lng->txt("points") . ")");
608  }
609  if ($objectives_list !== null) {
610  $objectives = $this->lng->txt('tst_res_lo_objectives_header') . ': ';
611  $objectives .= $objectives_list->getQuestionRelatedObjectiveTitles($question_gui->getObject()->getId());
612  $template->setVariable('OBJECTIVES', $objectives);
613  }
614  $template->setVariable("SOLUTION_OUTPUT", $result_output);
615  $template->setVariable("RECEIVED_POINTS", sprintf($this->lng->txt("you_received_a_of_b_points"), $question_gui->getObject()->getReachedPoints($active_id, $pass), $maxpoints));
616  $template->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
617  $template->setVariable("BACKLINK_TEXT", "<< " . $this->lng->txt("back"));
618  return $template->get();
619  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$objectives
readonly ilObjUser $user
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getGradingMessageBuilder()

ilTestServiceGUI::getGradingMessageBuilder ( int  $active_id)
protected

Definition at line 645 of file class.ilTestServiceGUI.php.

References ILIAS\Repository\lng().

Referenced by ilTestEvaluationGUI\outUserPassDetails(), and ilTestEvaluationGUI\outUserResultsOverview().

646  {
647  return new ilTestGradingMessageBuilder(
648  $this->lng,
649  $this->tpl,
650  $this->object,
651  $this->test_result_repository->getTestResult($active_id)
652  );
653  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getObject()

◆ getObjectiveOrientedContainer()

◆ getParticipantData()

ilTestServiceGUI::getParticipantData ( )

Definition at line 179 of file class.ilTestServiceGUI.php.

References $participantData.

◆ getPassDetailsOverviewTableGUI()

ilTestServiceGUI::getPassDetailsOverviewTableGUI ( array  $result_array,
int  $active_id,
int  $pass,
ilTestServiceGUI  $target_gui,
string  $target_cmd,
?ilTestQuestionRelatedObjectivesList  $objectives_list = null,
bool  $multiple_objectives_involved = true 
)
protected

Definition at line 437 of file class.ilTestServiceGUI.php.

References buildPassDetailsOverviewTableGUI(), ILIAS\Repository\ctrl(), null, and ILIAS\Repository\object().

Referenced by ilTestEvalObjectiveOrientedGUI\showVirtualPassCmd().

446  $this->ctrl->setParameter($target_gui, 'active_id', $active_id);
447  $this->ctrl->setParameter($target_gui, 'pass', $pass);
448 
449  $table_gui = $this->buildPassDetailsOverviewTableGUI($target_gui, $target_cmd);
450 
451  if ($objectives_list !== null) {
452  $table_gui->setQuestionRelatedObjectivesList($objectives_list);
453  $table_gui->setObjectiveOrientedPresentationEnabled(true);
454  }
455 
456  $table_gui->setMultipleObjectivesInvolved($multiple_objectives_involved);
457 
458  $table_gui->setActiveId($active_id);
459  $table_gui->setShowSuggestedSolution(false);
460 
461  $users_question_solutions = [];
462 
463  foreach ($result_array as $key => $val) {
464  if ($key === 'test' || $key === 'pass') {
465  continue;
466  }
467 
468  if ($this->object->getShowSolutionSuggested() && strlen($val['solution'])) {
469  $table_gui->setShowSuggestedSolution(true);
470  }
471 
472  if (isset($val['pass'])) {
473  $table_gui->setPassColumnEnabled(true);
474  }
475 
476  $users_question_solutions[$key] = $val;
477  }
478 
479  $table_gui->initColumns();
480 
481  $table_gui->setFilterCommand($target_cmd . 'SetTableFilter');
482  $table_gui->setResetCommand($target_cmd . 'ResetTableFilter');
483 
484  $table_gui->setData($users_question_solutions);
485 
486  return $table_gui;
487  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
buildPassDetailsOverviewTableGUI(ilTestServiceGUI $target_gui, string $target_cmd)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPassListOfAnswers()

ilTestServiceGUI::getPassListOfAnswers ( $result_array,
  $active_id,
  $pass,
  $show_solutions = false,
  $only_answered_questions = false,
  $show_question_only = false,
  $show_reached_points = false,
  $anchorNav = false,
?ilTestQuestionRelatedObjectivesList  $objectives_list = null,
?ResultsTitlesBuilder  $testResultHeaderLabelBuilder = null 
)

Returns the list of answers of a users test pass.

Parameters
array$result_arrayAn array containing the results of the users test pass (generated by ilObjTest::getTestResult)
integer$active_idActive ID of the active user
integer$passTest pass
boolean$show_solutionsTRUE, if the solution output should be shown in the answers, FALSE otherwise
Returns
string HTML code of the list of answers public

Definition at line 321 of file class.ilTestServiceGUI.php.

References $objectives, isContextResultPresentation(), ILIAS\Repository\lng(), null, and ILIAS\Repository\object().

Referenced by ilTestEvaluationGUI\outUserListOfAnswerPasses().

332  : string {
333  $maintemplate = new ilTemplate('tpl.il_as_tst_list_of_answers.html', true, true, 'components/ILIAS/Test');
334 
335  $counter = 1;
336  // output of questions with solutions
337  foreach ($result_array as $question_data) {
338  if (!array_key_exists('workedthrough', $question_data)) {
339  $question_data['workedthrough'] = 0;
340  }
341  if (!array_key_exists('qid', $question_data)) {
342  $question_data['qid'] = -1;
343  }
344 
345  if (($question_data['workedthrough'] == 1) || ($only_answered_questions == false)) {
346  $template = new ilTemplate('tpl.il_as_qpl_question_printview.html', true, true, 'components/ILIAS/TestQuestionPool');
347  $question_id = $question_data["qid"] ?? null;
348  if ($question_id !== null
349  && $question_id !== -1
350  && is_numeric($question_id)) {
351  $maintemplate->setCurrentBlock('printview_question');
352  $question_gui = $this->object->createQuestionGUI("", $question_id);
353 
354  $question_gui->getObject()->setShuffler($this->shuffler->getAnswerShuffleFor(
355  (int) $question_id,
356  (int) $active_id,
357  (int) $pass
358  ));
359  if (is_object($question_gui)) {
360  if ($anchorNav) {
361  $template->setCurrentBlock('block_id');
362  $template->setVariable('BLOCK_ID', "detailed_answer_block_act_{$active_id}_qst_{$question_id}");
363  $template->parseCurrentBlock();
364 
365  $template->setCurrentBlock('back_anchor');
366  $template->setVariable('HREF_BACK_ANCHOR', "#pass_details_tbl_row_act_{$active_id}_qst_{$question_id}");
367  $template->setVariable('TXT_BACK_ANCHOR', $this->lng->txt('tst_back_to_question_list'));
368  $template->parseCurrentBlock();
369  }
370 
371  if ($show_reached_points) {
372  $template->setCurrentBlock("result_points");
373  $template->setVariable("RESULT_POINTS", $this->lng->txt("tst_reached_points") . ": " . $question_gui->getObject()->getReachedPoints($active_id, $pass) . " " . $this->lng->txt("of") . " " . $question_gui->getObject()->getMaximumPoints());
374  $template->parseCurrentBlock();
375  }
376  $template->setVariable("COUNTER_QUESTION", $counter . ". ");
377  $template->setVariable("TXT_QUESTION_ID", $this->lng->txt('question_id_short'));
378  $template->setVariable("QUESTION_ID", $question_gui->getObject()->getId());
379  $template->setVariable("QUESTION_TITLE", $this->object->getQuestionTitle($question_gui->getObject()->getTitleForHTMLOutput()));
380 
381  if ($objectives_list !== null) {
382  $objectives = $this->lng->txt('tst_res_lo_objectives_header') . ': ';
383  $objectives .= $objectives_list->getQuestionRelatedObjectiveTitles($question_gui->getObject()->getId());
384  $template->setVariable("OBJECTIVES", $objectives);
385  }
386 
387  $show_question_only = ($this->object->getShowSolutionAnswersOnly()) ? true : false;
388 
389  $show_feedback = $this->isContextResultPresentation() && $this->object->getShowSolutionFeedback();
390  $show_best_solution = $this->isContextResultPresentation() && $show_solutions;
391  $show_graphical_output = $this->isContextResultPresentation();
392 
393  if ($show_best_solution) {
394  $compare_template = new ilTemplate('tpl.il_as_tst_answers_compare.html', true, true, 'components/ILIAS/Test');
395  $test_session = $this->test_session_factory->getSession($active_id);
396  if ($pass <= $test_session->getLastFinishedPass()) {
397  $compare_template->setVariable("HEADER_PARTICIPANT", $this->lng->txt('tst_header_participant'));
398  } else {
399  $compare_template->setVariable("HEADER_PARTICIPANT", $this->lng->txt('tst_header_participant_no_answer'));
400  }
401 
402  $compare_template->setVariable("HEADER_SOLUTION", $this->lng->txt('tst_header_solution'));
403  $result_output = $question_gui->getSolutionOutput($active_id, $pass, $show_graphical_output, false, $show_question_only, $show_feedback);
404  $best_output = $question_gui->getSolutionOutput($active_id, $pass, false, false, $show_question_only, false, true);
405 
406  $compare_template->setVariable('PARTICIPANT', $result_output);
407  $compare_template->setVariable('SOLUTION', $best_output);
408  $template->setVariable('SOLUTION_OUTPUT', $compare_template->get());
409  } else {
410  $result_output = $question_gui->getSolutionOutput($active_id, $pass, $show_graphical_output, false, $show_question_only, $show_feedback);
411  $template->setVariable('SOLUTION_OUTPUT', $result_output);
412  }
413 
414  $maintemplate->setCurrentBlock('printview_question');
415  $maintemplate->setVariable("QUESTION_PRINTVIEW", $template->get());
416  $maintemplate->parseCurrentBlock();
417  $counter++;
418  }
419  }
420  }
421  }
422 
423  if ($testResultHeaderLabelBuilder !== null) {
424  if ($pass !== null) {
425  $headerText = $testResultHeaderLabelBuilder->getListOfAnswersHeaderLabel($pass + 1);
426  } else {
427  $headerText = $testResultHeaderLabelBuilder->getVirtualListOfAnswersHeaderLabel();
428  }
429  } else {
430  $headerText = '';
431  }
432 
433  $maintemplate->setVariable('RESULTS_OVERVIEW', $headerText);
434  return $maintemplate->get();
435  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$objectives
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPassOverviewTableData()

ilTestServiceGUI::getPassOverviewTableData ( ilTestSession  $test_session,
array  $passes,
bool  $with_results 
)
Parameters
array<int>$passes An integer array of test runs
Returns
array<mixed>

Definition at line 188 of file class.ilTestServiceGUI.php.

References $data, ilObjTest\_getResultPass(), buildQuestionRelatedObjectivesList(), ilTestSession\getActiveId(), ilLOTestQuestionAdapter\getInstance(), getObjectiveOrientedContainer(), and ILIAS\Repository\object().

Referenced by ilTestEvaluationGUI\outUserResultsOverview().

192  : array {
193  $data = [];
194 
195  $objective_oriented_presentation = $this->getObjectiveOrientedContainer()
196  ?->isObjectiveOrientedPresentationRequired() ?? false;
197 
198  if ($objective_oriented_presentation) {
199  $consider_hidden_questions = false;
200 
201  $objectives_adapter = ilLOTestQuestionAdapter::getInstance($test_session);
202  } else {
203  $consider_hidden_questions = true;
204  }
205 
206  $scored_pass = \ilObjTest::_getResultPass($test_session->getActiveId());
207 
208  foreach ($passes as $pass) {
209  $row = [
210  'scored' => false,
211  'pass' => $pass,
212  'date' => ilObjTest::lookupLastTestPassAccess($test_session->getActiveId(), $pass)
213  ];
214  $considerOptionalQuestions = true;
215 
216  if ($objective_oriented_presentation) {
217  $test_sequence = $this->test_sequence_factory->getSequenceByActiveIdAndPass($test_session->getActiveId(), $pass);
218  $test_sequence->loadFromDb();
219  $test_sequence->loadQuestions();
220 
221  if ($this->object->isRandomTest() && !$test_sequence->isAnsweringOptionalQuestionsConfirmed()) {
222  $considerOptionalQuestions = false;
223  }
224 
225  $test_sequence->setConsiderHiddenQuestionsEnabled($consider_hidden_questions);
226  $test_sequence->setConsiderOptionalQuestionsEnabled($considerOptionalQuestions);
227 
228  $objectives_list = $this->buildQuestionRelatedObjectivesList($objectives_adapter, $test_sequence);
229  $objectives_list->loadObjectivesTitles();
230 
231  $row['objectives'] = $objectives_list->getUniqueObjectivesStringForQuestions($test_sequence->getUserSequenceQuestions());
232  }
233 
234  if (!$with_results) {
235  $data[] = $row;
236  continue;
237  }
238 
239  $result_array = $this->object->getTestResult(
240  $test_session->getActiveId(),
241  $pass,
242  false,
243  $consider_hidden_questions,
244  $considerOptionalQuestions
245  );
246 
247  if (!$result_array['pass']['total_max_points']) {
248  $row['percentage'] = 0;
249  } else {
250  $row['percentage'] = ($result_array['pass']['total_reached_points'] / $result_array['pass']['total_max_points']) * 100;
251  }
252 
253  $row['max_points'] = $result_array['pass']['total_max_points'];
254  $row['reached_points'] = $result_array['pass']['total_reached_points'];
255  $row['scored'] = ($pass == $scored_pass);
256  $row['num_workedthrough_questions'] = $result_array['pass']['num_workedthrough'];
257  $row['num_questions_total'] = $result_array['pass']['num_questions_total'];
258  $data[] = $row;
259  }
260 
261  return $data;
262  }
static getInstance(ilTestSession $a_test_session)
static _getResultPass($active_id)
Retrieves the pass number that should be counted for a given user.
buildQuestionRelatedObjectivesList(ilLOTestQuestionAdapter $objectives_adapter, ilTestQuestionSequence $test_sequence)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getResultsSignature()

ilTestServiceGUI::getResultsSignature ( )

Returns HTML code for a signature field.

Returns
string HTML code of the date and signature field for the test results public

Definition at line 495 of file class.ilTestServiceGUI.php.

References ilDatePresentation\formatDate(), ilUtil\getImagePath(), IL_CAL_UNIX, ILIAS\Repository\lng(), ILIAS\Repository\object(), ilDatePresentation\setUseRelativeDates(), and ilDatePresentation\useRelativeDates().

Referenced by ilTestEvaluationGUI\outUserListOfAnswerPasses(), ilTestEvaluationGUI\outUserPassDetails(), and ilTestPlayerAbstractGUI\showListOfAnswers().

495  : string
496  {
497  if ($this->object->getShowSolutionSignature() && !$this->object->getAnonymity()) {
498  $template = new ilTemplate("tpl.il_as_tst_results_userdata_signature.html", true, true, "components/ILIAS/Test");
499  $template->setVariable("TXT_DATE", $this->lng->txt("date"));
502  $template->setVariable("VALUE_DATE", ilDatePresentation::formatDate(new ilDate(time(), IL_CAL_UNIX)));
504  $template->setVariable("TXT_SIGNATURE", $this->lng->txt("tst_signature"));
505  $template->setVariable("IMG_SPACER", ilUtil::getImagePath("media/spacer.png"));
506  return $template->get();
507  } else {
508  return "";
509  }
510  }
static array static setUseRelativeDates(bool $a_status)
set use relative dates
const IL_CAL_UNIX
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isContextResultPresentation()

ilTestServiceGUI::isContextResultPresentation ( )

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

References $contextResultPresentation.

Referenced by getPassListOfAnswers().

107  : bool
108  {
110  }
+ Here is the caller graph for this function:

◆ isGradingMessageRequired()

ilTestServiceGUI::isGradingMessageRequired ( )
protected

Definition at line 628 of file class.ilTestServiceGUI.php.

References getObjectiveOrientedContainer(), ILIAS\Repository\object(), and ilObjTest\SCORE_LAST_PASS.

Referenced by ilTestEvaluationGUI\outUserPassDetails(), and ilTestEvaluationGUI\outUserResultsOverview().

628  : bool
629  {
630  $session = $this->test_session_factory->getSession();
631  if ($this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()
632  || $this->object->getScoreSettings()->getScoringSettings()->getPassScoring() === ilObjTest::SCORE_LAST_PASS
633  && $session->getLastFinishedPass() < $session->getLastStartedPass()) {
634  return false;
635  }
636 
637  if ($this->object->isShowGradingStatusEnabled()
638  || $this->object->isShowGradingMarkEnabled()) {
639  return true;
640  }
641 
642  return false;
643  }
const SCORE_LAST_PASS
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ outCorrectSolution()

ilTestServiceGUI::outCorrectSolution ( )
protected

Definition at line 676 of file class.ilTestServiceGUI.php.

References $tabs, buildQuestionRelatedObjectivesList(), ILIAS\Repository\ctrl(), ilObjStyleSheet\getContentStylePath(), getCorrectSolutionOutput(), ilLOTestQuestionAdapter\getInstance(), getObjectiveOrientedContainer(), ilUtil\getStyleSheetLocation(), ilObjStyleSheet\getSyntaxStylePath(), ILIAS\Repository\int(), ILIAS\Repository\lng(), null, ILIAS\Repository\object(), and ilTabsGUI\setBackTarget().

Referenced by outCorrectSolutionCmd().

676  : void
677  {
678  if (!$this->object->getShowSolutionDetails()) {
679  $this->tpl->setOnScreenMessage('info', $this->lng->txt("no_permission"), true);
680  $this->ctrl->redirectByClass([ilRepositoryGUI::class, ilObjTestGUI::class, ilInfoScreenGUI::class]);
681  }
682 
683  $testSession = $this->test_session_factory->getSession();
684  $active_id = $testSession->getActiveId();
685 
686  if (!($active_id > 0)) {
687  $this->ctrl->redirectByClass([ilRepositoryGUI::class, ilObjTestGUI::class, ilInfoScreenGUI::class]);
688  }
689 
690  $this->ctrl->saveParameter($this, "pass");
691  $pass = (int) $this->testrequest->raw("pass");
692 
693  $active_id = (int) $this->testrequest->raw('evaluation');
694 
695  $test_sequence = $this->test_sequence_factory->getSequenceByActiveIdAndPass($active_id, $pass);
696  $test_sequence->loadFromDb();
697  $test_sequence->loadQuestions();
698 
699  if (!$test_sequence->questionExists($active_id)) {
700  ilObjTestGUI::accessViolationRedirect();
701  }
702 
703  if ($this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) {
704  $test_sequence = $this->test_sequence_factory->getSequenceByActiveIdAndPass($active_id, $pass);
705  $test_sequence->loadFromDb();
706  $test_sequence->loadQuestions();
707 
708  $objectives_adapter = ilLOTestQuestionAdapter::getInstance($testSession);
709  $objectives_list = $this->buildQuestionRelatedObjectivesList($objectives_adapter, $test_sequence);
710  $objectives_list->loadObjectivesTitles();
711  } else {
712  $objectives_list = null;
713  }
714 
715  $ilTabs = $this->tabs;
716 
717  if ($this instanceof ilTestEvalObjectiveOrientedGUI) {
718  $ilTabs->setBackTarget(
719  $this->lng->txt("tst_back_to_virtual_pass"),
720  $this->ctrl->getLinkTarget($this, 'showVirtualPass')
721  );
722  } else {
723  $ilTabs->setBackTarget(
724  $this->lng->txt("tst_back_to_pass_details"),
725  $this->ctrl->getLinkTarget($this, 'outUserPassDetails')
726  );
727  }
728  $ilTabs->clearSubTabs();
729 
730  $this->tpl->setCurrentBlock("ContentStyle");
731  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath(0));
732  $this->tpl->parseCurrentBlock();
733 
734  $this->tpl->setCurrentBlock("SyntaxStyle");
735  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", ilObjStyleSheet::getSyntaxStylePath());
736  $this->tpl->parseCurrentBlock();
737 
738  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css"), "print");
739  if ($this->object->getShowSolutionAnswersOnly()) {
740  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css"), "print");
741  }
742 
743  $solution = $this->getCorrectSolutionOutput($active_id, $active_id, $pass, $objectives_list);
744 
745  $this->tpl->setContent($solution);
746  }
static getStyleSheetLocation(string $mode="output", string $a_css_name="")
get full style sheet file name (path inclusive) of current user
getCorrectSolutionOutput($question_id, $active_id, $pass, ?ilTestQuestionRelatedObjectivesList $objectives_list=null)
Returns an output of the solution to an answer compared to the correct solution.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static getInstance(ilTestSession $a_test_session)
setBackTarget(string $a_title, string $a_target, string $a_frame="")
static getContentStylePath(int $a_style_id, bool $add_random=true, bool $add_token=true)
get content style path static (to avoid full reading)
buildQuestionRelatedObjectivesList(ilLOTestQuestionAdapter $objectives_adapter, ilTestQuestionSequence $test_sequence)
readonly ilTabsGUI $tabs
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ outCorrectSolutionCmd()

ilTestServiceGUI::outCorrectSolutionCmd ( )
protected

Definition at line 671 of file class.ilTestServiceGUI.php.

References outCorrectSolution().

671  : void
672  {
673  $this->outCorrectSolution(); // cannot be named xxxCmd, because it's also called from context without Cmd in names
674  }
+ Here is the call graph for this function:

◆ populateContent()

ilTestServiceGUI::populateContent ( string  $content)
protected

Definition at line 666 of file class.ilTestServiceGUI.php.

Referenced by ilTestEvalObjectiveOrientedGUI\showVirtualPassCmd().

666  : void
667  {
668  $this->tpl->setContent($content);
669  }
+ Here is the caller graph for this function:

◆ populateExamId()

ilTestServiceGUI::populateExamId ( ilTemplate  $tpl,
int  $active_id,
int  $pass 
)
protected

Definition at line 761 of file class.ilTestServiceGUI.php.

References ILIAS\Repository\lng(), ilObjTest\lookupExamId(), ILIAS\Repository\object(), and HTML_Template_IT\setVariable().

Referenced by ilTestEvaluationGUI\outUserPassDetails().

761  : void
762  {
763  if ($this->object->isShowExamIdInTestResultsEnabled()) {
764  $tpl->setVariable('EXAM_ID_TXT', $this->lng->txt('exam_id'));
765  $tpl->setVariable('EXAM_ID', ilObjTest::lookupExamId(
766  $active_id,
767  $pass
768  ));
769  }
770  }
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
static lookupExamId($active_id, $pass)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populatePassFinishDate()

ilTestServiceGUI::populatePassFinishDate ( ilTemplate  $tpl,
?int  $pass_finish_date 
)
protected

Definition at line 748 of file class.ilTestServiceGUI.php.

References ilDatePresentation\formatDate(), IL_CAL_UNIX, ILIAS\Repository\lng(), null, ilDatePresentation\setUseRelativeDates(), HTML_Template_IT\setVariable(), and ilDatePresentation\useRelativeDates().

Referenced by ilTestEvaluationGUI\outUserPassDetails().

748  : void
749  {
750  if ($pass_finish_date === null) {
751  return;
752  }
755  $pass_finish_date_string = ilDatePresentation::formatDate(new ilDateTime($pass_finish_date, IL_CAL_UNIX));
757  $tpl->setVariable("PASS_FINISH_DATE_LABEL", $this->lng->txt('tst_pass_finished_on'));
758  $tpl->setVariable("PASS_FINISH_DATE_VALUE", $pass_finish_date_string);
759  }
static array static setUseRelativeDates(bool $a_status)
set use relative dates
const IL_CAL_UNIX
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setContextResultPresentation()

ilTestServiceGUI::setContextResultPresentation ( bool  $contextResultPresentation)

◆ setObjectiveOrientedContainer()

ilTestServiceGUI::setObjectiveOrientedContainer ( ilTestObjectiveOrientedContainer  $objective_oriented_container)
Parameters
ilTestObjectiveOrientedContainer$objective_oriented_container

Definition at line 267 of file class.ilTestServiceGUI.php.

References $objective_oriented_container.

268  {
269  $this->objective_oriented_container = $objective_oriented_container;
270  }
ilTestObjectiveOrientedContainer $objective_oriented_container

◆ setParticipantData()

ilTestServiceGUI::setParticipantData ( ilTestParticipantData  $participantData)

Definition at line 174 of file class.ilTestServiceGUI.php.

References $participantData.

174  : void
175  {
176  $this->participantData = $participantData;
177  }
ilTestParticipantData $participantData

Field Documentation

◆ $access

ilAccess ilTestServiceGUI::$access
protected

Definition at line 72 of file class.ilTestServiceGUI.php.

◆ $component_repository

readonly ilComponentRepository ilTestServiceGUI::$component_repository
protected

Definition at line 78 of file class.ilTestServiceGUI.php.

◆ $content_style

readonly ContentStyle ilTestServiceGUI::$content_style
protected

Definition at line 70 of file class.ilTestServiceGUI.php.

◆ $contextResultPresentation

bool ilTestServiceGUI::$contextResultPresentation = true
private

◆ $ctrl

readonly ilCtrlInterface ilTestServiceGUI::$ctrl
protected

Definition at line 74 of file class.ilTestServiceGUI.php.

◆ $db

readonly ilDBInterface ilTestServiceGUI::$db
protected

◆ $error

readonly ilErrorHandling ilTestServiceGUI::$error
protected

Definition at line 71 of file class.ilTestServiceGUI.php.

◆ $global_screen

readonly GlobalScreenServices ilTestServiceGUI::$global_screen
protected

Definition at line 92 of file class.ilTestServiceGUI.php.

◆ $help

readonly ilHelpGUI ilTestServiceGUI::$help
protected

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

◆ $http

readonly HTTPServices ilTestServiceGUI::$http
protected

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

◆ $ilias

readonly ILIAS ilTestServiceGUI::$ilias
protected

Definition at line 90 of file class.ilTestServiceGUI.php.

◆ $lng

readonly ilLanguage ilTestServiceGUI::$lng
protected

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

◆ $logger

readonly TestLogger ilTestServiceGUI::$logger
protected

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

◆ $navigation_history

readonly ilNavigationHistory ilTestServiceGUI::$navigation_history
protected

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

◆ $obj_cache

readonly ilObjectDataCache ilTestServiceGUI::$obj_cache
protected

Definition at line 77 of file class.ilTestServiceGUI.php.

◆ $objective_oriented_container

ilTestObjectiveOrientedContainer ilTestServiceGUI::$objective_oriented_container
private

◆ $participant_access_filter

ilTestParticipantAccessFilterFactory ilTestServiceGUI::$participant_access_filter
protected

Definition at line 101 of file class.ilTestServiceGUI.php.

◆ $participantData

◆ $post_wrapper

readonly ArrayBasedRequestWrapper ilTestServiceGUI::$post_wrapper
protected

Definition at line 80 of file class.ilTestServiceGUI.php.

◆ $questionrepository

readonly GeneralQuestionPropertiesRepository ilTestServiceGUI::$questionrepository
protected

Definition at line 55 of file class.ilTestServiceGUI.php.

◆ $rbac_system

readonly ilRbacSystem ilTestServiceGUI::$rbac_system
protected

Definition at line 62 of file class.ilTestServiceGUI.php.

◆ $ref_id

int ilTestServiceGUI::$ref_id
protected

Definition at line 94 of file class.ilTestServiceGUI.php.

◆ $refinery

readonly Refinery ilTestServiceGUI::$refinery
protected

Definition at line 82 of file class.ilTestServiceGUI.php.

◆ $results_data_factory

readonly ResultsDataFactory ilTestServiceGUI::$results_data_factory
protected

Definition at line 87 of file class.ilTestServiceGUI.php.

◆ $results_presentation_factory

readonly ResultsPresentationFactory ilTestServiceGUI::$results_presentation_factory
protected

Definition at line 88 of file class.ilTestServiceGUI.php.

◆ $service

ilTestService ilTestServiceGUI::$service = null
protected

Definition at line 57 of file class.ilTestServiceGUI.php.

◆ $settings

readonly ilSetting ilTestServiceGUI::$settings
protected

◆ $shuffler

readonly ilTestShuffler ilTestServiceGUI::$shuffler
protected

Definition at line 86 of file class.ilTestServiceGUI.php.

◆ $skills_service

readonly SkillService ilTestServiceGUI::$skills_service
protected

Definition at line 85 of file class.ilTestServiceGUI.php.

◆ $tabs

readonly ilTabsGUI ilTestServiceGUI::$tabs
protected

Definition at line 76 of file class.ilTestServiceGUI.php.

Referenced by outCorrectSolution().

◆ $test_result_repository

TestResultRepository ilTestServiceGUI::$test_result_repository
protected

Definition at line 99 of file class.ilTestServiceGUI.php.

◆ $test_sequence_factory

ilTestSequenceFactory ilTestServiceGUI::$test_sequence_factory = null
protected

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

Referenced by ilTestPlayerAbstractGUI\executeCommand().

◆ $test_session_factory

ilTestSessionFactory ilTestServiceGUI::$test_session_factory = null
protected

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

◆ $testquestionsrepository

readonly TestQuestionsRepository ilTestServiceGUI::$testquestionsrepository
protected

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

◆ $testrequest

readonly RequestDataCollector ilTestServiceGUI::$testrequest
protected

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

◆ $toolbar

readonly ilToolbarGUI ilTestServiceGUI::$toolbar
protected

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

Referenced by ilTestSubmissionReviewGUI\buildToolbar().

◆ $tpl

ilGlobalTemplateInterface ilTemplate ilTestServiceGUI::$tpl
protected

sk 2023-08-01: We need this union type, even if it is wrong! To change this

Todo:
we have to fix the rendering of the feedback modal in ilTestPlayerAbstractGUI::populateIntantResponseModal().

Definition at line 69 of file class.ilTestServiceGUI.php.

Referenced by ilTestPlayerAbstractGUI\getQuestionGuiInstance(), ilTestEvaluationGUI\outUserPassDetails(), ilTestPlayerAbstractGUI\populateInstantResponseModal(), and ilTestEvalObjectiveOrientedGUI\showVirtualPassCmd().

◆ $tree

readonly ilTree ilTestServiceGUI::$tree
protected

Definition at line 93 of file class.ilTestServiceGUI.php.

◆ $ui_factory

readonly UIFactory ilTestServiceGUI::$ui_factory
protected

Definition at line 83 of file class.ilTestServiceGUI.php.

◆ $ui_renderer

readonly UIRenderer ilTestServiceGUI::$ui_renderer
protected

Definition at line 84 of file class.ilTestServiceGUI.php.

◆ $user

readonly ilObjUser ilTestServiceGUI::$user
protected

Definition at line 79 of file class.ilTestServiceGUI.php.

Referenced by getCorrectSolutionOutput().


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