ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
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 (int $active_id, bool $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 ilComponentFactory $component_factory
 
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.

@ilCtrl_IsCalledBy 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 298 of file class.ilTestServiceGUI.php.

299 {
300 $table = new ilTestPassOverviewTableGUI($target_gui, '');
301
302 $table->setPdfPresentationEnabled(
303 $this->testrequest->isset('pdf') && $this->testrequest->raw('pdf') == 1
304 );
305
306 $table->setObjectiveOrientedPresentationEnabled(
307 $this->getObjectiveOrientedContainer()?->isObjectiveOrientedPresentationRequired() ?? false
308 );
309
310 return $table;
311 }
Class ilTestPassOverviewTableGUI.

Referenced by ilTestEvaluationGUI\outUserResultsOverview().

+ Here is the caller graph for this function:

◆ buildQuestionRelatedObjectivesList()

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

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

662 $questionRelatedObjectivesList = new ilTestQuestionRelatedObjectivesList();
663
664 $objectives_adapter->buildQuestionRelatedObjectiveList($test_sequence, $questionRelatedObjectivesList);
665
666 return $questionRelatedObjectivesList;
667 }
buildQuestionRelatedObjectiveList(ilTestQuestionSequence $a_test_sequence, ilTestQuestionRelatedObjectivesList $a_objectives_list)

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

+ Here is the caller graph for this function:

◆ executeCommand()

ilTestServiceGUI::executeCommand ( )

execute command

Reimplemented in ilTestEvalObjectiveOrientedGUI, ilTestEvaluationGUI, ilTestPlayerAbstractGUI, and ilTestSubmissionReviewGUI.

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

286 {
287 $cmd = $this->ctrl->getCmd();
288 $next_class = $this->ctrl->getNextClass($this);
289
290 switch ($next_class) {
291 default:
292 $ret = &$this->$cmd();
293 break;
294 }
295 return $ret;
296 }

References ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ getAdditionalUsrDataHtmlAndPopulateWindowTitle()

ilTestServiceGUI::getAdditionalUsrDataHtmlAndPopulateWindowTitle ( int  $active_id,
bool  $overwrite_anonymity = false 
)

Returns the user data for a test results output.

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

528 : string
529 {
530 $template = new ilTemplate("tpl.il_as_tst_results_userdata.html", true, true, "components/ILIAS/Test");
532 if (ilObjUser::_lookupLogin($user_id) !== '') {
533 $user = new ilObjUser($user_id);
534 } else {
535 $user = new ilObjUser();
536 $user->setLastname($this->lng->txt('deleted_user'));
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 (
549 $user->getMatriculation() !== ''
550 && ($overwrite_anonymity || !$this->object->getAnonymity())
551 ) {
552 $template->setCurrentBlock("matriculation");
553 $template->setVariable("TXT_USR_MATRIC", $this->lng->txt("matriculation"));
554 $template->setVariable("VALUE_USR_MATRIC", $user->getMatriculation());
555 $template->parseCurrentBlock();
556 $title_matric = " - " . $this->lng->txt("matriculation") . ": " . $user->getMatriculation();
557 }
558
559 $invited_user = array_pop($this->object->getInvitedUsers($user_id));
560 $title_client = '';
561 $template->setVariable("TXT_TEST_TITLE", $this->lng->txt("title"));
562 $template->setVariable("VALUE_TEST_TITLE", $this->object->getTitle());
563
564 // change the pagetitle (tab title or title in title bar of window)
565 $pagetitle = $this->object->getTitle() . $title_matric . $title_client;
566 $this->tpl->setHeaderPageTitle($pagetitle);
567
568 return $template->get();
569 }
static _getUserIdFromActiveId(int $active_id)
User class.
setLastname(string $lastname)
static _lookupLogin(int $a_user_id)
special template class to simplify handling of ITX/PEAR
readonly ilObjUser $user

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

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

+ 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 @access public

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

580 : string
581 {
582 $ilUser = $this->user;
583
584 $test_id = $this->object->getTestId();
585 $question_gui = $this->object->createQuestionGUI("", $question_id);
586
587 $template = new ilTemplate("tpl.il_as_tst_correct_solution_output.html", true, true, "components/ILIAS/Test");
588 $show_question_only = ($this->object->getShowSolutionAnswersOnly()) ? true : false;
589 $result_output = $question_gui->getSolutionOutput($active_id, $pass, true, false, $show_question_only, $this->object->getShowSolutionFeedback(), false, false, true);
590 $best_output = $question_gui->getSolutionOutput($active_id, $pass, false, false, $show_question_only, false, true, false, false);
591 if ($this->object->getShowSolutionFeedback() && $this->testrequest->raw('cmd') != 'outCorrectSolution') {
592 $specificAnswerFeedback = $question_gui->getSpecificFeedbackOutput(
593 $question_gui->getObject()->fetchIndexedValuesFromValuePairs(
594 $question_gui->getObject()->getSolutionValues($active_id, $pass)
595 )
596 );
597 if (strlen($specificAnswerFeedback)) {
598 $template->setCurrentBlock("outline_specific_feedback");
599 $template->setVariable("OUTLINE_SPECIFIC_FEEDBACK", $specificAnswerFeedback);
600 $template->parseCurrentBlock();
601 }
602 }
603 $template->setVariable("TEXT_YOUR_SOLUTION", $this->lng->txt("tst_your_answer_was"));
604 $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
605 // I set both old and new since the old one is set as well in several places.
606 $maxpoints = $question_gui->getObject()->getMaximumPoints();
607 if ($maxpoints == 1) {
608 $template->setVariable("QUESTION_TITLE", $this->object->getQuestionTitle($question_gui->getObject()->getTitleForHTMLOutput()) . " (" . $maxpoints . " " . $this->lng->txt("point") . ")");
609 } else {
610 $template->setVariable("QUESTION_TITLE", $this->object->getQuestionTitle($question_gui->getObject()->getTitleForHTMLOutput()) . " (" . $maxpoints . " " . $this->lng->txt("points") . ")");
611 }
612 if ($objectives_list !== null) {
613 $objectives = $this->lng->txt('tst_res_lo_objectives_header') . ': ';
614 $objectives .= $objectives_list->getQuestionRelatedObjectiveTitles($question_gui->getObject()->getId());
615 $template->setVariable('OBJECTIVES', $objectives);
616 }
617 $template->setVariable("SOLUTION_OUTPUT", $result_output);
618 $template->setVariable("RECEIVED_POINTS", sprintf($this->lng->txt("you_received_a_of_b_points"), $question_gui->getObject()->getReachedPoints($active_id, $pass), $maxpoints));
619 $template->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
620 $template->setVariable("BACKLINK_TEXT", "<< " . $this->lng->txt("back"));
621 return $template->get();
622 }
$objectives

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

+ Here is the call graph for this function:

◆ getGradingMessageBuilder()

ilTestServiceGUI::getGradingMessageBuilder ( int  $active_id)
protected

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

649 {
651 $this->lng,
652 $this->tpl,
653 $this->object,
654 $this->test_result_repository->getTestResult($active_id)
655 );
656 }

References ILIAS\Repository\lng().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getObject()

ilTestServiceGUI::getObject ( )

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

775 : ilObjTest
776 {
777 return $this->object;
778 }

Referenced by ilTestPassOverviewTableGUI\__construct(), and ilTestSubmissionReviewGUI\show().

+ Here is the caller graph for this function:

◆ getObjectiveOrientedContainer()

◆ getParticipantData()

ilTestServiceGUI::getParticipantData ( )

Definition at line 181 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 450 of file class.ilTestServiceGUI.php.

459 $this->ctrl->setParameter($target_gui, 'active_id', $active_id);
460 $this->ctrl->setParameter($target_gui, 'pass', $pass);
461
462 $table_gui = $this->buildPassDetailsOverviewTableGUI($target_gui, $target_cmd);
463
464 if ($objectives_list !== null) {
465 $table_gui->setQuestionRelatedObjectivesList($objectives_list);
466 $table_gui->setObjectiveOrientedPresentationEnabled(true);
467 }
468
469 $table_gui->setMultipleObjectivesInvolved($multiple_objectives_involved);
470
471 $table_gui->setActiveId($active_id);
472 $table_gui->setShowSuggestedSolution(false);
473
474 $users_question_solutions = [];
475
476 foreach ($result_array as $key => $val) {
477 if ($key === 'test' || $key === 'pass') {
478 continue;
479 }
480
481 if ($this->object->getShowSolutionSuggested() && strlen($val['solution'])) {
482 $table_gui->setShowSuggestedSolution(true);
483 }
484
485 if (isset($val['pass'])) {
486 $table_gui->setPassColumnEnabled(true);
487 }
488
489 $users_question_solutions[$key] = $val;
490 }
491
492 $table_gui->initColumns();
493
494 $table_gui->setFilterCommand($target_cmd . 'SetTableFilter');
495 $table_gui->setResetCommand($target_cmd . 'ResetTableFilter');
496
497 $table_gui->setData($users_question_solutions);
498
499 return $table_gui;
500 }
buildPassDetailsOverviewTableGUI(ilTestServiceGUI $target_gui, string $target_cmd)

Referenced by ilTestEvalObjectiveOrientedGUI\showVirtualPassCmd().

+ 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 @access public

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

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

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

Referenced by ilTestEvaluationGUI\outUserListOfAnswerPasses().

+ 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 190 of file class.ilTestServiceGUI.php.

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

References ilLOTestQuestionAdapter\getInstance().

Referenced by ilTestEvaluationGUI\outUserResultsOverview().

+ 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 @access public

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

508 : string
509 {
510 if ($this->object->getShowSolutionSignature() && !$this->object->getAnonymity()) {
511 $template = new ilTemplate("tpl.il_as_tst_results_userdata_signature.html", true, true, "components/ILIAS/Test");
512 $template->setVariable("TXT_DATE", $this->lng->txt("date"));
515 $template->setVariable("VALUE_DATE", ilDatePresentation::formatDate(new ilDate(time(), IL_CAL_UNIX)));
517 $template->setVariable("TXT_SIGNATURE", $this->lng->txt("tst_signature"));
518 $template->setVariable("IMG_SPACER", ilUtil::getImagePath("media/spacer.png"));
519 return $template->get();
520 } else {
521 return "";
522 }
523 }
const IL_CAL_UNIX
static setUseRelativeDates(bool $a_status)
set use relative dates
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
Class for single dates.
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)

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

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isContextResultPresentation()

ilTestServiceGUI::isContextResultPresentation ( )

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

108 : bool
109 {
111 }

References $contextResultPresentation.

◆ isGradingMessageRequired()

ilTestServiceGUI::isGradingMessageRequired ( )
protected

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

631 : bool
632 {
633 $session = $this->test_session_factory->getSession();
634 if ($this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()
635 || $this->object->getScoreSettings()->getScoringSettings()->getPassScoring() === ilObjTest::SCORE_LAST_PASS
636 && $session->getLastFinishedPass() < $session->getLastStartedPass()) {
637 return false;
638 }
639
640 if ($this->object->isShowGradingStatusEnabled()
641 || $this->object->isShowGradingMarkEnabled()) {
642 return true;
643 }
644
645 return false;
646 }
const SCORE_LAST_PASS

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

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ outCorrectSolution()

ilTestServiceGUI::outCorrectSolution ( )
protected

Reimplemented in ilTestPlayerAbstractGUI.

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

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

References ILIAS\Repository\ctrl(), ilObjStyleSheet\getContentStylePath(), ilLOTestQuestionAdapter\getInstance(), ilUtil\getStyleSheetLocation(), ilObjStyleSheet\getSyntaxStylePath(), ILIAS\Repository\int(), ILIAS\Repository\lng(), and ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ outCorrectSolutionCmd()

ilTestServiceGUI::outCorrectSolutionCmd ( )
protected

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

674 : void
675 {
676 $this->outCorrectSolution(); // cannot be named xxxCmd, because it's also called from context without Cmd in names
677 }

◆ populateContent()

ilTestServiceGUI::populateContent ( string  $content)
protected

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

669 : void
670 {
671 $this->tpl->setContent($content);
672 }

Referenced by ilTestEvalObjectiveOrientedGUI\showVirtualPassCmd().

+ Here is the caller graph for this function:

◆ populateExamId()

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

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

764 : void
765 {
766 if ($this->object->isShowExamIdInTestResultsEnabled()) {
767 $tpl->setVariable('EXAM_ID_TXT', $this->lng->txt('exam_id'));
768 $tpl->setVariable('EXAM_ID', ilObjTest::lookupExamId(
769 $active_id,
770 $pass
771 ));
772 }
773 }
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
static lookupExamId($active_id, $pass)

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

Referenced by ilTestEvaluationGUI\outUserPassDetails().

+ 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 751 of file class.ilTestServiceGUI.php.

751 : void
752 {
753 if ($pass_finish_date === null) {
754 return;
755 }
758 $pass_finish_date_string = ilDatePresentation::formatDate(new ilDateTime($pass_finish_date, IL_CAL_UNIX));
760 $tpl->setVariable("PASS_FINISH_DATE_LABEL", $this->lng->txt('tst_pass_finished_on'));
761 $tpl->setVariable("PASS_FINISH_DATE_VALUE", $pass_finish_date_string);
762 }
@classDescription Date and time handling
ilGlobalTemplateInterface ilTemplate $tpl
sk 2023-08-01: We need this union type, even if it is wrong! To change this
setVariable(string $variable, $value='')
Sets the given variable to the given value.

References ILIAS\News\Common\Table\$tpl, ilDatePresentation\formatDate(), IL_CAL_UNIX, ILIAS\Repository\lng(), ilDatePresentation\setUseRelativeDates(), HTML_Template_IT\setVariable(), ILIAS\UICore\GlobalTemplate\setVariable(), and ilDatePresentation\useRelativeDates().

Referenced by ilTestEvaluationGUI\outUserPassDetails().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setContextResultPresentation()

ilTestServiceGUI::setContextResultPresentation ( bool  $contextResultPresentation)

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

114 {
115 $this->contextResultPresentation = $contextResultPresentation;
116 }

References $contextResultPresentation.

Referenced by ilTestEvaluationGUI\outUserListOfAnswerPasses().

+ Here is the caller graph for this function:

◆ setObjectiveOrientedContainer()

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

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

270 {
271 $this->objective_oriented_container = $objective_oriented_container;
272 }

◆ setParticipantData()

ilTestServiceGUI::setParticipantData ( ilTestParticipantData  $participantData)

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

176 : void
177 {
178 $this->participantData = $participantData;
179 }

References $participantData.

Field Documentation

◆ $access

ilAccess ilTestServiceGUI::$access
protected

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

◆ $component_factory

readonly ilComponentFactory ilTestServiceGUI::$component_factory
protected

Definition at line 79 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 93 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 91 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 82 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

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

◆ $participant_access_filter

ilTestParticipantAccessFilterFactory ilTestServiceGUI::$participant_access_filter
protected

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

◆ $participantData

ilTestParticipantData ilTestServiceGUI::$participantData = null
protected

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

Referenced by getParticipantData(), and setParticipantData().

◆ $post_wrapper

readonly ArrayBasedRequestWrapper ilTestServiceGUI::$post_wrapper
protected

Definition at line 81 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 95 of file class.ilTestServiceGUI.php.

◆ $refinery

readonly Refinery ilTestServiceGUI::$refinery
protected

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

◆ $results_data_factory

readonly ResultsDataFactory ilTestServiceGUI::$results_data_factory
protected

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

◆ $results_presentation_factory

readonly ResultsPresentationFactory ilTestServiceGUI::$results_presentation_factory
protected

Definition at line 89 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

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

Referenced by ilTestEvaluationGUI\outUserPassDetails().

◆ $shuffler

readonly ilTestShuffler ilTestServiceGUI::$shuffler
protected

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

◆ $skills_service

readonly SkillService ilTestServiceGUI::$skills_service
protected

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

◆ $tabs

readonly ilTabsGUI ilTestServiceGUI::$tabs
protected

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

◆ $test_result_repository

TestResultRepository ilTestServiceGUI::$test_result_repository
protected

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

◆ $test_sequence_factory

ilTestSequenceFactory ilTestServiceGUI::$test_sequence_factory = null
protected

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

Referenced by ilTestPlayerAbstractGUI\executeCommand().

◆ $test_session_factory

ilTestSessionFactory ilTestServiceGUI::$test_session_factory = null
protected

Definition at line 97 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 ilTestEvaluationGUI\outUserPassDetails(), and ilTestEvalObjectiveOrientedGUI\showVirtualPassCmd().

◆ $tree

readonly ilTree ilTestServiceGUI::$tree
protected

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

◆ $ui_factory

readonly UIFactory ilTestServiceGUI::$ui_factory
protected

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

◆ $ui_renderer

readonly UIRenderer ilTestServiceGUI::$ui_renderer
protected

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

◆ $user

readonly ilObjUser ilTestServiceGUI::$user
protected

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


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