ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
exTestPlayerGUI Class Reference

When a component wants to integrate the assessment question service to present questions to users in an assessment scenario, the following use cases needs to be handled by the component. More...

+ Collaboration diagram for exTestPlayerGUI:

Public Member Functions

 showQuestion ()
 When presenting an assessment question to a user, the ilAsqQuestionPresentation provides the interface methods to either get a renerable UI coponent for a question presentation or for a solution presentation. More...
 
 submitSolution ()
 With the presentation of an assessment question, this question also gets submitted having any solution filled out by any user. More...
 
 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) More...
 

Detailed Description

When a component wants to integrate the assessment question service to present questions to users in an assessment scenario, the following use cases needs to be handled by the component.

This kind consume of the assessment question service does not support the offline export presentation yet.

Definition at line 9 of file class.exTestPlayerGUI.php.

Member Function Documentation

◆ getParticipantSolution()

exTestPlayerGUI::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)

Parameters
integer$questionId
Returns
ilAsqQuestionSolution

when the test has any test result based on an existing participant solution, the solution id needs to be looked up. an empty solution is returned otherwise.

Definition at line 173 of file class.exTestPlayerGUI.php.

References $DIC.

Referenced by showQuestion(), and submitSolution().

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  }
$DIC
Definition: xapitoken.php:46
+ Here is the caller graph for this function:

◆ showQuestion()

exTestPlayerGUI::showQuestion ( )

When presenting an assessment question to a user, the ilAsqQuestionPresentation provides the interface methods to either get a renerable UI coponent for a question presentation or for a solution presentation.

An instance implementing the ilAsqPresentation according to the given question type is provided by a factory method within ilAsqFactory.

Both methods getQuestionPresentation and getSolutionPresentation gets an instance of ilAsqSolution injected. This solution can either be an user solution or the best solution.

Additional interface methods in ilAsqQuestionPresentation return renderable UI components for the generic and specific feedbacks. These methods also need to get an ilAsqSolution instance injected.

In case of presenting the best solution the required ilAsqSolution instance can be retrieved from the ilAsqQuestion interface.

For any existing user response that is to be presented with the question the instance implementing ilAsqSolution can be requested from the ilAsqFactory using the solutionId that is to be registered within the consuming component in relation to the user's id and additional information (like e.g. test results).

Variants in usage defined by the consumer:

  • question can be shown writable for the examine
  • question can be shown readable for the examine
  • feedbacks can be shown if required
  • best solution can be shown if required

fetch possibly existing participant solution, an empty one is required otherwise

question presentation to be answered by the examine

feedback presentation for the given

best solution presentation to be answered by the examine

Definition at line 37 of file class.exTestPlayerGUI.php.

References $DIC, and getParticipantSolution().

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  }
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)
$DIC
Definition: xapitoken.php:46
+ Here is the call graph for this function:

◆ submitSolution()

exTestPlayerGUI::submitSolution ( )

With the presentation of an assessment question, this question also gets submitted having any solution filled out by any user.

With the first presentation there should be no previous user response available. The consuming component needs to request an empty ilAsqSolution instance for the given questionId.

The ilAsqSolution interface method initFromServerRequest is to be used to initialize the object instance with the user response. With the current concept the newly introduced needs to be injected to this method, but may simply passing $_POST could be an alternative. This depends on the future strategy of abstracting the http server request in ILIAS.

After having this solution saved, the consuming component needs to register the now available solutionId together with the questionId and the userId. Additionally this ilAsqSolution instance can be used with a question corresponding ilAsqResultCalculator to retrieve the information about right/wrong (used for e.g. answer status in CTM's test sequence) and reached points (used as a future ilTestResult) to be stored as any result within the consuming component.

After the first submission of any user response the consuming component needs to provide the corresponsing solutionId to request the existing ilAsqSolution instance from the ilAsqFactory for every additional submit.

The way harvesting and handling solution data in short:

  • post submit gets parsed by ilAsqSolution
  • ilAsqResultCalculator calculates points and right/wrong
  • the test object can use these information for different purposes
  • points can be saved as an ilTestResult referenced by the questionId and the participantId
  • right/wrong can be used for determining the correct feedbacks for the feedback loop
  • right/wrong can be used as the answer status within the CTM test sequence

fetch possibly existing participant solution, an empty one is required otherwise

let the solution object instance harvest the submission post data

get results calculator to be used to retrieve calculated reached points that can be stored in a test result storage managed by the test object

handle the calculated result in any kind

Definition at line 123 of file class.exTestPlayerGUI.php.

References $DIC, and getParticipantSolution().

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  }
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)
$DIC
Definition: xapitoken.php:46
+ Here is the call graph for this function:

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