ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.exTestPlayerGUI.php
Go to the documentation of this file.
1 <?php
2 
10 {
37  public function showQuestion()
38  {
39  global $DIC; /* @var ILIAS\DI\Container $DIC */
40 
41  $questionId = 0; // initialise with id of question to be shown
42 
47  $participantSolution = $this->getParticipantSolution($questionId);
48 
53  $questionInstance = $DIC->question()->getQuestionInstance($questionId);
54  $questionPresentationGUI = $DIC->question()->getQuestionPresentationInstance($questionInstance);
55 
56  $questionNavigationAware; /* @var ilAsqQuestionNavigationAware $questionNavigationAware */
57  $questionPresentationGUI->setQuestionNavigation($questionNavigationAware);
58 
59  $questionPresentationGUI->setRenderPurpose(ilAsqQuestionPresentation::RENDER_PURPOSE_PLAYBACK);
60 
61  if ($participantSolutionLocked = false) {
62  $renderer = $questionPresentationGUI->getSolutionPresentation($participantSolution);
63  } else {
64  $renderer = $questionPresentationGUI->getQuestionPresentation($participantSolution);
65  }
66 
67  $playerQstPageHTML = $renderer->getContent();
68 
73  if ($showFeedbacks = true && !$participantSolution->isEmpty()) {
74  $genericFeedbackRenderer = $questionPresentationGUI->getGenericFeedbackOutput($participantSolution);
75  $playerQstPageHTML .= $genericFeedbackRenderer->getContent();
76 
77  $specificFeedbackRenderer = $questionPresentationGUI->getSpecificFeedbackOutput($participantSolution);
78  $playerQstPageHTML .= $specificFeedbackRenderer->getContent();
79  }
80 
85  if ($showBestSolution = true) {
86  $renderer = $questionPresentationGUI->getSolutionPresentation(
87  $questionInstance->getBestSolution()
88  );
89 
90  $playerQstPageHTML .= $renderer->getContent();
91  }
92 
93  $playerQstPageHTML; // complete question page html
94  }
95 
123  public function submitSolution()
124  {
125  global $DIC; /* @var ILIAS\DI\Container $DIC */
126 
127  // this can also be $_REQUEST or any other future ilias post-request handler
128  $serverRequestObject; /* @var \Psr\Http\Message\ServerRequestInterface $serverRequestObject */
129 
130  $questionId = 0; // initialise with id of question that just submits
131 
136  $participantSolution = $this->getParticipantSolution($questionId);
137 
142  $participantSolution->initFromServerRequest($serverRequestObject);
143 
149  $questionInstance = $DIC->question()->getQuestionInstance($questionId);
150  $solutionInstance = $this->getParticipantSolution($questionId);
151  $resultCalculator = $DIC->question()->getResultCalculator($questionInstance, $solutionInstance);
152 
153  $resultInstance = $resultCalculator->calculate();
154 
159  // can be stored in any ilTestResult object managed by the test
160  $reachedPoints = $resultInstance->getPoints();
161 
162  // can be used to differ answer status in CTM's test sequence
163  $isCorrect = $resultInstance->isCorrect();
164  }
165 
173  public function getParticipantSolution($questionId)
174  {
175  global $DIC; /* @var ILIAS\DI\Container $DIC */
176 
182  $solutionId = 0;
183 
184  if ($solutionId) {
185  return $DIC->question()->getQuestionSolutionInstance($questionId, $solutionId);
186  }
187 
188  return $DIC->question()->getEmptyQuestionSolutionInstance($questionId);
189  }
190 }
submitSolution()
With the presentation of an assessment question, this question also gets submitted having any solutio...
global $DIC
Definition: feed.php:28
getParticipantSolution($questionId)
this method returns either an initialised solution object instance, or and empty one, depending on self managed test results (handled by a future ilTestResult)
When a component wants to integrate the assessment question service to present questions to users in ...
showQuestion()
When presenting an assessment question to a user, the ilAsqQuestionPresentation provides the interfac...