ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\Test\Participants\ParticipantTableExtraTimeAction Class Reference
+ Inheritance diagram for ILIAS\Test\Participants\ParticipantTableExtraTimeAction:
+ Collaboration diagram for ILIAS\Test\Participants\ParticipantTableExtraTimeAction:

Public Member Functions

 __construct (private readonly Language $lng, private readonly Refinery $refinery, private readonly \ilGlobalTemplateInterface $tpl, private readonly UIFactory $ui_factory, private readonly ParticipantRepository $participant_repository, private readonly \ilObjUser $current_user, private readonly \ilTestAccess $test_access, private readonly \ilObjTest $test_obj)
 
 getActionId ()
 
 isAvailable ()
 
 getTableAction (URLBuilder $url_builder, URLBuilderToken $row_id_token, URLBuilderToken $action_token, URLBuilderToken $action_type_token)
 
 getModal (URLBuilder $url_builder, array $selected_participants, bool $all_participants_selected)
 
 onSubmit (URLBuilder $url_builder, ServerRequestInterface $request, array $selected_participants, bool $all_participants_selected)
 
 allowActionForRecord (Participant $record)
 
 saveExtraTime (array $participants, int $minutes)
 
 getSelectionErrorMessage ()
 
 getActionId ()
 
 isAvailable ()
 
 getTableAction (URLBuilder $url_builder, URLBuilderToken $row_id_token, URLBuilderToken $action_token, URLBuilderToken $action_type_token)
 
 getModal (URLBuilder $url_builder, array $selected_participants, bool $all_participants_selected)
 
 onSubmit (URLBuilder $url_builder, ServerRequestInterface $request, array $selected_participants, bool $all_participants_selected)
 
 allowActionForRecord (Participant $record)
 
 getSelectionErrorMessage ()
 

Data Fields

const ACTION_ID = 'extratime'
 

Private Member Functions

 resolveInfoMessage (array $selected_participants, bool $all_participants_selected, bool $has_different_extra_time)
 
 resolveHasDifferentExtraTime (array $participants)
 

Detailed Description

Definition at line 34 of file ParticipantTableExtraTimeAction.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Test\Participants\ParticipantTableExtraTimeAction::__construct ( private readonly Language  $lng,
private readonly Refinery  $refinery,
private readonly \ilGlobalTemplateInterface  $tpl,
private readonly UIFactory  $ui_factory,
private readonly ParticipantRepository  $participant_repository,
private readonly \ilObjUser  $current_user,
private readonly \ilTestAccess  $test_access,
private readonly \ilObjTest  $test_obj 
)

Definition at line 38 of file ParticipantTableExtraTimeAction.php.

47 {
48 }

Member Function Documentation

◆ allowActionForRecord()

ILIAS\Test\Participants\ParticipantTableExtraTimeAction::allowActionForRecord ( Participant  $record)

Implements ILIAS\Test\Participants\TableAction.

Definition at line 155 of file ParticipantTableExtraTimeAction.php.

155 : bool
156 {
157 return $record->getUserId() !== ANONYMOUS_USER_ID;
158 }
const ANONYMOUS_USER_ID
Definition: constants.php:27

References ANONYMOUS_USER_ID, and ILIAS\Test\Participants\Participant\getUserId().

+ Here is the call graph for this function:

◆ getActionId()

ILIAS\Test\Participants\ParticipantTableExtraTimeAction::getActionId ( )

◆ getModal()

ILIAS\Test\Participants\ParticipantTableExtraTimeAction::getModal ( URLBuilder  $url_builder,
array  $selected_participants,
bool  $all_participants_selected 
)
Parameters
array<Participant>$selected_participants

Implements ILIAS\Test\Participants\TableAction.

Definition at line 76 of file ParticipantTableExtraTimeAction.php.

80 : ?Modal {
81 $has_different_extra_time = $this->resolveHasDifferentExtraTime($selected_participants);
82 $participant_rows = array_map(
83 fn(Participant $participant) => sprintf(
84 '%s, %s (%s)',
85 $participant->getLastname(),
86 $participant->getFirstname(),
87 sprintf($this->lng->txt('already_added_extra_time'), $participant->getExtraTime())
88 ),
89 $selected_participants
90 );
91
92 return $this->ui_factory->modal()->roundtrip(
93 $this->lng->txt('extratime'),
94 [
95 $this->ui_factory->messageBox()->info(
96 $this->lng->txt(
97 $this->resolveInfoMessage(
98 $selected_participants,
99 $all_participants_selected,
100 $has_different_extra_time
101 )
102 )
103 ),
104 $this->ui_factory->listing()->unordered($participant_rows)
105 ],
106 [
107 'extra_time' => $this->ui_factory->input()->field()->numeric(
108 $this->lng->txt('extratime')
109 )->withRequired(true)
110 ->withAdditionalTransformation($this->refinery->int()->isGreaterThan(0))
111 ->withValue(0)
112 ->withByline(
113 $this->lng->txt('extra_time_byline')
114 )
115 ],
116 $url_builder->buildURI()->__toString()
117 )->withSubmitLabel($this->lng->txt('add'));
118 }
buildURI()
Get a URI representation of the full URL including query string and fragment/hash.
Definition: URLBuilder.php:214

◆ getSelectionErrorMessage()

ILIAS\Test\Participants\ParticipantTableExtraTimeAction::getSelectionErrorMessage ( )

Implements ILIAS\Test\Participants\TableAction.

Definition at line 217 of file ParticipantTableExtraTimeAction.php.

217 : ?string
218 {
219 return null;
220 }

◆ getTableAction()

ILIAS\Test\Participants\ParticipantTableExtraTimeAction::getTableAction ( URLBuilder  $url_builder,
URLBuilderToken  $row_id_token,
URLBuilderToken  $action_token,
URLBuilderToken  $action_type_token 
)

Implements ILIAS\Test\Participants\TableAction.

Definition at line 61 of file ParticipantTableExtraTimeAction.php.

66 : Action {
67 return $this->ui_factory->table()->action()->standard(
68 $this->lng->txt(self::ACTION_ID),
69 $url_builder
70 ->withParameter($action_token, self::ACTION_ID)
71 ->withParameter($action_type_token, ParticipantTableActions::SHOW_ACTION),
72 $row_id_token
73 )->withAsync();
74 }
withParameter(URLBuilderToken $token, string|array $value)
Change an acquired parameter's value if the supplied token is valid.
Definition: URLBuilder.php:166

◆ isAvailable()

ILIAS\Test\Participants\ParticipantTableExtraTimeAction::isAvailable ( )

Implements ILIAS\Test\Participants\TableAction.

Definition at line 55 of file ParticipantTableExtraTimeAction.php.

55 : bool
56 {
57 return $this->test_obj->getEnableProcessingTime()
58 && $this->test_access->checkManageParticipantsAccess();
59 }

◆ onSubmit()

ILIAS\Test\Participants\ParticipantTableExtraTimeAction::onSubmit ( URLBuilder  $url_builder,
ServerRequestInterface  $request,
array  $selected_participants,
bool  $all_participants_selected 
)
Parameters
array<Participant>$selected_participants

Implements ILIAS\Test\Participants\TableAction.

Definition at line 120 of file ParticipantTableExtraTimeAction.php.

125 : ?Modal {
126 if (!$this->test_access->checkManageParticipantsAccess()) {
127 $this->tpl->setOnScreenMessage(
129 $this->lng->txt('no_permission'),
130 true
131 );
132 return null;
133 }
134 $modal = $this->getModal(
135 $url_builder,
136 $selected_participants,
137 $all_participants_selected
138 )->withRequest($request);
139
140 $data = $modal->getData();
141 if ($data === null) {
142 return $modal->withOnLoad($modal->getShowSignal());
143 }
144
145 $this->saveExtraTime($selected_participants, $data['extra_time']);
146
147 $this->tpl->setOnScreenMessage(
149 $this->lng->txt('extratime_added'),
150 true
151 );
152 return null;
153 }
getModal(URLBuilder $url_builder, array $selected_participants, bool $all_participants_selected)

References ILIAS\Repository\lng(), and ILIAS\UICore\GlobalTemplate\MESSAGE_TYPE_FAILURE.

+ Here is the call graph for this function:

◆ resolveHasDifferentExtraTime()

ILIAS\Test\Participants\ParticipantTableExtraTimeAction::resolveHasDifferentExtraTime ( array  $participants)
private
Parameters
array<ilTestParticipant>$participants

Definition at line 182 of file ParticipantTableExtraTimeAction.php.

182 : bool
183 {
184 return count(array_unique(array_map(
185 fn(Participant $participant) => $participant->getExtraTime(),
186 $participants
187 ))) > 1;
188 }

References ILIAS\Test\Participants\Participant\getExtraTime().

+ Here is the call graph for this function:

◆ resolveInfoMessage()

ILIAS\Test\Participants\ParticipantTableExtraTimeAction::resolveInfoMessage ( array  $selected_participants,
bool  $all_participants_selected,
bool  $has_different_extra_time 
)
private

Definition at line 160 of file ParticipantTableExtraTimeAction.php.

164 : string {
165 if ($all_participants_selected) {
166 return 'extra_time_for_all_participants';
167 }
168
169 if (count($selected_participants) === 1) {
170 return 'extra_time_for_single_participant';
171 }
172 if ($has_different_extra_time) {
173 return 'extra_time_for_selected_participants_different';
174 }
175
176 return 'extra_time_for_selected_participants';
177 }

◆ saveExtraTime()

ILIAS\Test\Participants\ParticipantTableExtraTimeAction::saveExtraTime ( array  $participants,
int  $minutes 
)
Parameters
array<Participant>$participants

Definition at line 193 of file ParticipantTableExtraTimeAction.php.

193 : void
194 {
195 foreach ($participants as $participant) {
196 $this->participant_repository->updateExtraTime($participant->withAddedExtraTime($minutes));
197 }
198
199 if ($this->test_obj->getTestLogger()->isLoggingEnabled()) {
200 $this->test_obj->getTestLogger()->logTestAdministrationInteraction(
201 $this->test_obj->getTestLogger()->getInteractionFactory()->buildTestAdministrationInteraction(
202 $this->test_obj->getRefId(),
203 $this->current_user->getId(),
204 TestAdministrationInteractionTypes::EXTRA_TIME_ADDED,
205 [
207 fn(Participant $participant) => $participant->getUserId(),
208 $participants
209 ),
211 ]
212 )
213 );
214 }
215 }

References ILIAS\Test\Participants\Participant\getUserId().

+ Here is the call graph for this function:

Field Documentation

◆ ACTION_ID

const ILIAS\Test\Participants\ParticipantTableExtraTimeAction::ACTION_ID = 'extratime'

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