ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ILIAS\Test\Participants\ParticipantTableActions Class Reference
+ Collaboration diagram for ILIAS\Test\Participants\ParticipantTableActions:

Public Member Functions

 __construct (protected readonly \ilCtrlInterface $ctrl, protected readonly Language $lng, protected readonly \ilGlobalTemplateInterface $tpl, protected readonly UIFactory $ui_factory, protected readonly UIRenderer $ui_renderer, protected readonly Refinery $refinery, protected readonly RequestDataCollector $test_request, protected readonly ResponseHandler $test_response, protected readonly ParticipantRepository $repository, protected readonly \ilObjTest $test_obj, protected readonly array $actions)
 
 getEnabledActions (URLBuilder $url_builder, URLBuilderToken $row_id_token, URLBuilderToken $action_token, URLBuilderToken $action_type_token)
 
 getAction (string $action_id)
 
 execute (URLBuilder $url_builder, URLBuilderToken $row_id_token, URLBuilderToken $action_token, URLBuilderToken $action_type_token)
 
 onDataRow (DataRow $row, mixed $record)
 

Data Fields

const ROW_ID_PARAMETER = 'p_id'
 
const ACTION_PARAMETER = 'action'
 
const ACTION_TYPE_PARAMETER = 'action_type'
 
const SHOW_ACTION = 'showTableAction'
 
const SUBMIT_ACTION = 'submitTableAction'
 

Protected Member Functions

 showModal (URLBuilder $url_builder, URLBuilderToken $row_id_token, URLBuilderToken $action_token, URLBuilderToken $action_type_token)
 
 submit (URLBuilder $url_builder, URLBuilderToken $row_id_token, URLBuilderToken $action_token, URLBuilderToken $action_type_token)
 
 resolveSelectedParticipants (TableAction $action, array|string $selected_participants)
 

Detailed Description

Definition at line 35 of file ParticipantTableActions.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Test\Participants\ParticipantTableActions::__construct ( protected readonly \ilCtrlInterface  $ctrl,
protected readonly Language  $lng,
protected readonly \ilGlobalTemplateInterface  $tpl,
protected readonly UIFactory  $ui_factory,
protected readonly UIRenderer  $ui_renderer,
protected readonly Refinery  $refinery,
protected readonly RequestDataCollector  $test_request,
protected readonly ResponseHandler  $test_response,
protected readonly ParticipantRepository  $repository,
protected readonly \ilObjTest  $test_obj,
protected readonly array  $actions 
)
Parameters
array<string,TableAction>$actions

Definition at line 45 of file ParticipantTableActions.php.

57  {
58  }

Member Function Documentation

◆ execute()

ILIAS\Test\Participants\ParticipantTableActions::execute ( URLBuilder  $url_builder,
URLBuilderToken  $row_id_token,
URLBuilderToken  $action_token,
URLBuilderToken  $action_type_token 
)

Definition at line 95 of file ParticipantTableActions.php.

References ILIAS\UI\URLBuilderToken\getName(), ILIAS\Test\Participants\ParticipantTableActions\showModal(), and ILIAS\Test\Participants\ParticipantTableActions\submit().

100  : ?Modal {
101  return match($this->test_request->strVal($action_type_token->getName())) {
102  self::SUBMIT_ACTION => $this->submit(
103  $url_builder,
104  $row_id_token,
105  $action_token,
106  $action_type_token
107  ),
108  default => $this->showModal(
109  $url_builder,
110  $row_id_token,
111  $action_token,
112  $action_type_token
113  ),
114  };
115  }
showModal(URLBuilder $url_builder, URLBuilderToken $row_id_token, URLBuilderToken $action_token, URLBuilderToken $action_type_token)
submit(URLBuilder $url_builder, URLBuilderToken $row_id_token, URLBuilderToken $action_token, URLBuilderToken $action_type_token)
+ Here is the call graph for this function:

◆ getAction()

ILIAS\Test\Participants\ParticipantTableActions::getAction ( string  $action_id)

Definition at line 90 of file ParticipantTableActions.php.

References null.

90  : ?TableAction
91  {
92  return $this->actions[$action_id] ?? null;
93  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ getEnabledActions()

ILIAS\Test\Participants\ParticipantTableActions::getEnabledActions ( URLBuilder  $url_builder,
URLBuilderToken  $row_id_token,
URLBuilderToken  $action_token,
URLBuilderToken  $action_type_token 
)

Definition at line 60 of file ParticipantTableActions.php.

References ILIAS\Test\Participants\TableAction\getTableAction(), ILIAS\Test\Participants\TableAction\isAvailable(), and null.

65  : array {
66  return array_filter(
67  array_map(
68  function (TableAction $action) use (
69  $url_builder,
70  $row_id_token,
71  $action_token,
72  $action_type_token
73  ): ?Action {
74  if (!$action->isAvailable()) {
75  return null;
76  }
77 
78  return $action->getTableAction(
79  $url_builder,
80  $row_id_token,
81  $action_token,
82  $action_type_token
83  );
84  },
85  $this->actions
86  )
87  );
88  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:

◆ onDataRow()

ILIAS\Test\Participants\ParticipantTableActions::onDataRow ( DataRow  $row,
mixed  $record 
)

Definition at line 117 of file ParticipantTableActions.php.

References $c, and ILIAS\UI\Component\Table\DataRow\withDisabledAction().

117  : DataRow
118  {
119  return array_reduce(
120  array_keys($this->actions),
121  fn(DataRow $c, string $v): DataRow => $this->actions[$v]->allowActionForRecord($record)
122  ? $c
123  : $c->withDisabledAction($v),
124  $row
125  );
126  }
$c
Definition: deliver.php:25
+ Here is the call graph for this function:

◆ resolveSelectedParticipants()

ILIAS\Test\Participants\ParticipantTableActions::resolveSelectedParticipants ( TableAction  $action,
array|string  $selected_participants 
)
protected

Definition at line 200 of file ParticipantTableActions.php.

References $user_id, ILIAS\Test\Participants\TableAction\allowActionForRecord(), and ILIAS\UI\examples\Deck\repository().

Referenced by ILIAS\Test\Participants\ParticipantTableActions\showModal(), and ILIAS\Test\Participants\ParticipantTableActions\submit().

200  : array
201  {
202  if ($selected_participants === 'ALL_OBJECTS') {
203  return array_filter(
204  iterator_to_array($this->repository->getParticipants($this->test_obj->getTestId())),
205  fn(Participant $participant) => $action->allowActionForRecord($participant)
206  );
207  }
208 
209  return array_filter(
210  array_map(
211  fn(int $user_id) => $this->repository->getParticipantByUserId($this->test_obj->getTestId(), $user_id),
212  $selected_participants
213  ),
214  fn(Participant $participant) => $action->allowActionForRecord($participant)
215  );
216  }
repository()
description: > Example for rendering a repository card
Definition: repository.php:33
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showModal()

ILIAS\Test\Participants\ParticipantTableActions::showModal ( URLBuilder  $url_builder,
URLBuilderToken  $row_id_token,
URLBuilderToken  $action_token,
URLBuilderToken  $action_type_token 
)
protected

Definition at line 128 of file ParticipantTableActions.php.

References ILIAS\UI\URLBuilderToken\getName(), ILIAS\Repository\lng(), ILIAS\Test\Participants\ParticipantTableActions\resolveSelectedParticipants(), and ILIAS\UI\URLBuilder\withParameter().

Referenced by ILIAS\Test\Participants\ParticipantTableActions\execute().

133  : void {
134  $action = $this->actions[$this->test_request->strVal($action_token->getName())];
135  $selected_participants_from_request = $this->test_request
136  ->getMultiSelectionIds($row_id_token->getName());
137  $selected_participants = $this->resolveSelectedParticipants(
138  $action,
139  $selected_participants_from_request
140  );
141 
142  if ($selected_participants === []) {
143  $error_message = $action->getSelectionErrorMessage() ?? $this->lng->txt('no_valid_participant_selection');
144  $this->test_response->sendAsync(
145  $this->ui_renderer->renderAsync(
146  $this->ui_factory->messageBox()->failure(
147  $error_message
148  )
149  )
150  );
151  }
152 
153  $this->test_response->sendAsync(
154  $this->ui_renderer->renderAsync(
155  $action->getModal(
156  $url_builder
157  ->withParameter($row_id_token, $selected_participants_from_request)
158  ->withParameter($action_token, $action->getActionId())
159  ->withParameter($action_type_token, self::SUBMIT_ACTION),
160  $selected_participants,
161  $selected_participants_from_request === 'ALL_OBJECTS'
162  )
163  )
164  );
165  }
resolveSelectedParticipants(TableAction $action, array|string $selected_participants)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ submit()

ILIAS\Test\Participants\ParticipantTableActions::submit ( URLBuilder  $url_builder,
URLBuilderToken  $row_id_token,
URLBuilderToken  $action_token,
URLBuilderToken  $action_type_token 
)
protected

Definition at line 167 of file ParticipantTableActions.php.

References ILIAS\UI\URLBuilderToken\getName(), ILIAS\Repository\lng(), ILIAS\UICore\GlobalTemplate\MESSAGE_TYPE_FAILURE, and ILIAS\Test\Participants\ParticipantTableActions\resolveSelectedParticipants().

Referenced by ILIAS\Test\Participants\ParticipantTableActions\execute().

172  : ?Modal {
173  $action = $this->actions[$this->test_request->strVal($action_token->getName())];
174  $selected_participants_from_request = $this->test_request
175  ->getMultiSelectionIds($row_id_token->getName());
176  $selected_participants = $this->resolveSelectedParticipants(
177  $action,
178  $selected_participants_from_request
179  );
180 
181  if ($selected_participants === []) {
182  $this->tpl->setOnScreenMessage(
184  $this->lng->txt('no_valid_participant_selection'),
185  true
186  );
187  }
188 
189  return $action->onSubmit(
190  $url_builder
191  ->withParameter($row_id_token, $selected_participants_from_request)
192  ->withParameter($action_token, $action->getActionId())
193  ->withParameter($action_type_token, self::SUBMIT_ACTION),
194  $this->test_request->getRequest(),
195  $selected_participants,
196  $selected_participants_from_request === 'ALL_OBJECTS'
197  );
198  }
resolveSelectedParticipants(TableAction $action, array|string $selected_participants)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ ACTION_PARAMETER

const ILIAS\Test\Participants\ParticipantTableActions::ACTION_PARAMETER = 'action'

◆ ACTION_TYPE_PARAMETER

const ILIAS\Test\Participants\ParticipantTableActions::ACTION_TYPE_PARAMETER = 'action_type'

◆ ROW_ID_PARAMETER

const ILIAS\Test\Participants\ParticipantTableActions::ROW_ID_PARAMETER = 'p_id'

◆ SHOW_ACTION

◆ SUBMIT_ACTION

const ILIAS\Test\Participants\ParticipantTableActions::SUBMIT_ACTION = 'submitTableAction'

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