ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
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 ()
 

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.

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

155  : bool
156  {
157  return $record->getUserId() !== ANONYMOUS_USER_ID;
158  }
const ANONYMOUS_USER_ID
Definition: constants.php:27
+ Here is the call graph for this function:

◆ getActionId()

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

Implements ILIAS\Test\Participants\TableAction.

Definition at line 50 of file ParticipantTableExtraTimeAction.php.

50  : string
51  {
52  return self::ACTION_ID;
53  }

◆ 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.

References ILIAS\UI\URLBuilder\buildURI(), ILIAS\Test\Participants\Participant\getExtraTime(), ILIAS\Test\Participants\Participant\getFirstname(), ILIAS\Test\Participants\Participant\getLastname(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), ILIAS\Test\Participants\ParticipantTableExtraTimeAction\resolveHasDifferentExtraTime(), and ILIAS\UI\Implementation\Component\Input\withValue().

Referenced by ILIAS\Test\Participants\ParticipantTableExtraTimeAction\onSubmit().

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  }
withValue($value)
Get an input like this with another value displayed on the client side.
Definition: Group.php:61
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSelectionErrorMessage()

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

Implements ILIAS\Test\Participants\TableAction.

Definition at line 217 of file ParticipantTableExtraTimeAction.php.

References null.

217  : ?string
218  {
219  return null;
220  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ 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.

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

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  }
+ Here is the call graph for this function:

◆ 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.

References $data, ILIAS\Test\Participants\ParticipantTableExtraTimeAction\getModal(), ILIAS\Repository\lng(), ILIAS\UICore\GlobalTemplate\MESSAGE_TYPE_FAILURE, ILIAS\UICore\GlobalTemplate\MESSAGE_TYPE_SUCCESS, null, and ILIAS\Test\Participants\ParticipantTableExtraTimeAction\saveExtraTime().

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  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getModal(URLBuilder $url_builder, array $selected_participants, bool $all_participants_selected)
+ 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.

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

Referenced by ILIAS\Test\Participants\ParticipantTableExtraTimeAction\getModal().

182  : bool
183  {
184  return count(array_unique(array_map(
185  fn(Participant $participant) => $participant->getExtraTime(),
186  $participants
187  ))) > 1;
188  }
+ Here is the call graph for this function:
+ Here is the caller 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.

References ILIAS\Test\Participants\Participant\getUserId(), ILIAS\Test\Logging\AdditionalInformationGenerator\KEY_TEST_ADDED_PROCESSING_TIME, and ILIAS\Test\Logging\AdditionalInformationGenerator\KEY_USERS.

Referenced by ILIAS\Test\Participants\ParticipantTableExtraTimeAction\onSubmit().

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  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ ACTION_ID

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

Definition at line 36 of file ParticipantTableExtraTimeAction.php.


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