ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ILIAS\Questions\Presentation\Views\Participant Class Reference
+ Collaboration diagram for ILIAS\Questions\Presentation\Views\Participant:

Public Member Functions

 __construct (private readonly Language $lng, private readonly Refinery $refinery, private readonly UIFactory $ui_factory, private readonly HTTP $http, private readonly QuestionRepository $question_repository, private readonly AttemptRepository $attempt_repository, private readonly CapabilitiesFactory $capabilities_factory, array $capability_identifiers, private readonly int $owner_object_id)
 
 getPresentationIdentifier ()
 
 withShuffleQuestionOrder (bool $shuffle_question_order)
 
 getQuestionView (Uuid $question_id, ?Uuid $attempt_id, bool $interactive, bool $show_marks, bool $show_best_response, bool $show_feedback)
 
 persistResponse (Uuid $question_id, Uuid $attempt_id)
 
 deleteResponsesFor (Uuid $attempt_id, Uuid $question_id)
 

Private Attributes

readonly RequiredCapabilities $required_capabilities
 
bool $shuffle_question_order = false
 
array $attempt_cache = []
 

Detailed Description

Definition at line 37 of file Participant.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Questions\Presentation\Views\Participant::__construct ( private readonly Language  $lng,
private readonly Refinery  $refinery,
private readonly UIFactory  $ui_factory,
private readonly HTTP  $http,
private readonly QuestionRepository  $question_repository,
private readonly AttemptRepository  $attempt_repository,
private readonly CapabilitiesFactory  $capabilities_factory,
array  $capability_identifiers,
private readonly int  $owner_object_id 
)
Parameters
list<string>>$capability_identifiers

Definition at line 48 of file Participant.php.

58 {
59 $this->required_capabilities = $this->capabilities_factory->get(
60 $capability_identifiers
61 );
62 }

Member Function Documentation

◆ deleteResponsesFor()

ILIAS\Questions\Presentation\Views\Participant::deleteResponsesFor ( Uuid  $attempt_id,
Uuid  $question_id 
)

Definition at line 162 of file Participant.php.

165 : void {
166 $this->attempt_repository->deleteResponsesFor(
167 $attempt_id,
168 $this->question_repository->getForQuestionId(
169 $question_id
170 )
171 );
172 }

◆ getPresentationIdentifier()

ILIAS\Questions\Presentation\Views\Participant::getPresentationIdentifier ( )

Definition at line 64 of file Participant.php.

64 : Uuid
65 {
66 return $this->presentation_identifier;
67 }

◆ getQuestionView()

ILIAS\Questions\Presentation\Views\Participant::getQuestionView ( Uuid  $question_id,
?Uuid  $attempt_id,
bool  $interactive,
bool  $show_marks,
bool  $show_best_response,
bool  $show_feedback 
)

Definition at line 77 of file Participant.php.

84 : QuestionParticipantView {
85 $question = $this->question_repository->getForQuestionId(
86 $question_id
87 );
88
89 $marking_required = $this->required_capabilities->isMarkingRequired();
90
91 if ($attempt_id === null
92 || !isset($this->attempt_cache[$attempt_id->toString()][$question_id->toString()])) {
93 $attempt = $this->attempt_repository->getAttemptFor(
94 $attempt_id,
95 [$question]
96 );
97 $attempt_id = $attempt->getId();
98 $this->attempt_cache[$attempt_id->toString()][$question_id->toString()] = $attempt;
99 }
100
101 return $question->getParticipantView(
102 $this->lng,
103 $this->refinery,
104 $this->ui_factory,
105 $this->required_capabilities,
106 $this->attempt_cache[$attempt_id->toString()][$question_id->toString()],
107 $interactive,
108 $show_marks && $marking_required,
109 $show_best_response && $marking_required,
110 $show_feedback && $this->required_capabilities->isCapabilityRequired(
111 TextFeedback::getIdentifier()
112 )
113 );
114 }
toString()
Converts this UUID into a string representation.

References ILIAS\Data\UUID\Uuid\toString().

+ Here is the call graph for this function:

◆ persistResponse()

ILIAS\Questions\Presentation\Views\Participant::persistResponse ( Uuid  $question_id,
Uuid  $attempt_id 
)

Definition at line 116 of file Participant.php.

119 : void {
120 $question = $this->question_repository->getForQuestionId(
121 $question_id
122 );
123
124 $attempt_data = $this->attempt_repository->getAttemptFor(
125 $attempt_id,
126 [$question]
127 );
128
129 if ($attempt_data === null) {
130 throw new \UnexpectedValueException(
131 'The provided attempt identifier is invalid. Response cannot be persisted.'
132 );
133 }
134
135 $response = $this->attempt_repository->getNewResponseFor(
136 $question_id,
137 $attempt_id
138 );
139
140 $response_with_values_from_post = array_reduce(
141 $question->retrieveAnswerFormResponsesFromPost(
142 $this->required_capabilities,
143 $this->http->wrapper()->post(),
144 $response->getId()
145 ),
146 fn(Response $c, AnswerFormResponse $v): Response
147 => $c->withAnswerFormResponse($v),
149 );
150
151 if ($this->required_capabilities->isMarkingRequired()) {
152 $response_with_values_from_post = $question->addAwardedPointsToResponse(
153 $response_with_values_from_post
154 );
155 }
156
157 $this->attempt_repository->storeResponse(
158 $response_with_values_from_post
159 );
160 }
$response
Definition: xapitoken.php:92

◆ withShuffleQuestionOrder()

ILIAS\Questions\Presentation\Views\Participant::withShuffleQuestionOrder ( bool  $shuffle_question_order)

Definition at line 69 of file Participant.php.

71 : self {
72 $clone = clone $this;
73 $clone->shuffle_question_order = $shuffle_question_order;
74 return $clone;
75 }

Field Documentation

◆ $attempt_cache

array ILIAS\Questions\Presentation\Views\Participant::$attempt_cache = []
private

Definition at line 43 of file Participant.php.

◆ $required_capabilities

readonly RequiredCapabilities ILIAS\Questions\Presentation\Views\Participant::$required_capabilities
private

Definition at line 39 of file Participant.php.

◆ $shuffle_question_order

bool ILIAS\Questions\Presentation\Views\Participant::$shuffle_question_order = false
private

Definition at line 41 of file Participant.php.


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