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

Public Member Functions

 __construct (private readonly Language $lng, private readonly \ilGlobalTemplateInterface $tpl, private readonly UIFactory $ui_factory, private readonly \ilDBInterface $db, private readonly \ilTestProcessLockerFactory $process_locker_factory, private readonly \ilObjUser $user, private readonly \ilTestAccess $test_access, private readonly \ilObjTest $test_obj, private readonly TestResultRepository $test_pass_result_repository)
 
 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 = 'finish_test'
 

Private Member Functions

 resolveMessage (array $selected_participants, bool $all_participants_selected)
 
 haveAllSelectedParticipantsReachedMaxProcessingTime (array $selected_participants)
 

Detailed Description

Definition at line 35 of file ParticipantTableFinishTestAction.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Test\Participants\ParticipantTableFinishTestAction::__construct ( private readonly Language  $lng,
private readonly \ilGlobalTemplateInterface  $tpl,
private readonly UIFactory  $ui_factory,
private readonly \ilDBInterface  $db,
private readonly \ilTestProcessLockerFactory  $process_locker_factory,
private readonly \ilObjUser  $user,
private readonly \ilTestAccess  $test_access,
private readonly \ilObjTest  $test_obj,
private readonly TestResultRepository  $test_pass_result_repository 
)

Definition at line 39 of file ParticipantTableFinishTestAction.php.

49  {
50  }

Member Function Documentation

◆ allowActionForRecord()

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

Implements ILIAS\Test\Participants\TableAction.

Definition at line 172 of file ParticipantTableFinishTestAction.php.

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

172  : bool
173  {
174  return $record->hasUnfinishedAttempts();
175  }
+ Here is the call graph for this function:

◆ getActionId()

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

Implements ILIAS\Test\Participants\TableAction.

Definition at line 52 of file ParticipantTableFinishTestAction.php.

52  : string
53  {
54  return self::ACTION_ID;
55  }

◆ getModal()

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

Implements ILIAS\Test\Participants\TableAction.

Definition at line 77 of file ParticipantTableFinishTestAction.php.

References ILIAS\UI\URLBuilder\buildURI(), ILIAS\Test\Participants\Participant\getUserId(), ILIAS\Repository\lng(), and ILIAS\Test\Participants\ParticipantTableFinishTestAction\resolveMessage().

81  : ?Modal {
82  $modal = $this->ui_factory->modal()->interruptive(
83  $this->lng->txt('finish_test'),
84  $this->resolveMessage($selected_participants, $all_participants_selected),
85  $url_builder->buildURI()->__toString()
86  )->withActionButtonLabel($this->lng->txt('finish_test'));
87 
88  if (count($selected_participants) > 1) {
89  $modal = $modal->withAffectedItems(
90  array_map(
91  fn(Participant $participant) => $this->ui_factory->modal()->interruptiveItem()->standard(
92  (string) $participant->getUserId(),
93  (new \ilObjUser($participant->getUserId()))->getPublicName()
94  ),
95  $selected_participants
96  )
97  );
98  }
99 
100  return $modal;
101  }
resolveMessage(array $selected_participants, bool $all_participants_selected)
+ Here is the call graph for this function:

◆ getSelectionErrorMessage()

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

Implements ILIAS\Test\Participants\TableAction.

Definition at line 195 of file ParticipantTableFinishTestAction.php.

References ILIAS\Repository\lng().

195  : ?string
196  {
197  return $this->lng->txt('finish_test_no_valid_participants_selected');
198  }
+ Here is the call graph for this function:

◆ getTableAction()

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

Implements ILIAS\Test\Participants\TableAction.

Definition at line 62 of file ParticipantTableFinishTestAction.php.

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

67  : StandardAction {
68  return $this->ui_factory->table()->action()->standard(
69  $this->lng->txt(self::ACTION_ID),
70  $url_builder
71  ->withParameter($action_token, self::ACTION_ID)
72  ->withParameter($action_type_token, ParticipantTableActions::SHOW_ACTION),
73  $row_id_token
74  )->withAsync();
75  }
+ Here is the call graph for this function:

◆ haveAllSelectedParticipantsReachedMaxProcessingTime()

ILIAS\Test\Participants\ParticipantTableFinishTestAction::haveAllSelectedParticipantsReachedMaxProcessingTime ( array  $selected_participants)
private

Definition at line 200 of file ParticipantTableFinishTestAction.php.

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

200  : bool
201  {
202  foreach ($selected_participants as $participant) {
203  if (!$participant->hasUnfinishedAttempts()
204  || !$this->test_obj->isMaxProcessingTimeReached(
205  $this->test_obj->getStartingTimeOfUser($participant->getActiveId()),
206  $participant->getActiveId()
207  )) {
208  return false;
209  }
210  }
211  return true;
212  }
+ Here is the caller graph for this function:

◆ isAvailable()

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

Implements ILIAS\Test\Participants\TableAction.

Definition at line 57 of file ParticipantTableFinishTestAction.php.

57  : bool
58  {
59  return $this->test_access->checkManageParticipantsAccess();
60  }

◆ onSubmit()

ILIAS\Test\Participants\ParticipantTableFinishTestAction::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 103 of file ParticipantTableFinishTestAction.php.

References ILIAS\Test\Participants\Participant\getUserId(), ILIAS\Test\Participants\ParticipantTableFinishTestAction\haveAllSelectedParticipantsReachedMaxProcessingTime(), ILIAS\Test\Logging\AdditionalInformationGenerator\KEY_USERS, ILIAS\Repository\lng(), ILIAS\UICore\GlobalTemplate\MESSAGE_TYPE_FAILURE, ILIAS\UICore\GlobalTemplate\MESSAGE_TYPE_SUCCESS, null, and ILIAS\Repository\user().

108  : ?Modal {
109  if (!$this->test_access->checkManageParticipantsAccess()) {
110  $this->tpl->setOnScreenMessage(
112  $this->lng->txt('no_permission'),
113  true
114  );
115  return null;
116  }
117 
118  if (count($selected_participants) > 1
119  && $this->test_obj->getNrOfTries() === 1
120  && $this->test_obj->getEnableProcessingTime()
121  && !$this->test_obj->getResetProcessingTime()
122  && !$this->haveAllSelectedParticipantsReachedMaxProcessingTime($selected_participants)) {
123  $this->tpl->setOnScreenMessage(
125  $this->lng->txt('finish_pass_for_multiple_users_in_processing_time'),
126  true
127  );
128  return null;
129  }
130 
131  // This is required here because of late test object binding
132  $test_session_factory = new \ilTestSessionFactory(
133  $this->test_obj,
134  $this->db,
135  $this->user
136  );
137 
138  foreach ($selected_participants as $participant) {
139  $process_locker = $this->process_locker_factory->withContextId($participant->getActiveId())->getLocker();
140  (new \ilTestPassFinishTasks(
141  $test_session_factory->getSession($participant->getActiveId()),
142  $this->test_obj,
143  $this->test_pass_result_repository
144  ))->performFinishTasks($process_locker, StatusOfAttempt::FINISHED_BY_ADMINISTRATOR);
145  }
146 
147  $logger = $this->test_obj->getTestLogger();
148  if ($logger->isLoggingEnabled()) {
149  $logger->logTestAdministrationInteraction(
150  $logger->getInteractionFactory()->buildTestAdministrationInteraction(
151  $this->test_obj->getRefId(),
152  $this->user->getId(),
153  TestAdministrationInteractionTypes::TEST_RUN_OF_PARTICIPANT_CLOSED,
154  [
156  fn(Participant $participant) => $participant->getUserId(),
157  $selected_participants
158  )
159  ]
160  )
161  );
162  }
163 
164  $this->tpl->setOnScreenMessage(
166  $this->lng->txt('test_attempts_finished'),
167  true
168  );
169  return null;
170  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:

◆ resolveMessage()

ILIAS\Test\Participants\ParticipantTableFinishTestAction::resolveMessage ( array  $selected_participants,
bool  $all_participants_selected 
)
private

Definition at line 177 of file ParticipantTableFinishTestAction.php.

References ILIAS\Repository\lng().

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

180  : string {
181  if ($all_participants_selected) {
182  return $this->lng->txt('finish_test_all');
183  }
184 
185  if (count($selected_participants) === 1) {
186  return sprintf(
187  $this->lng->txt('finish_test_single'),
188  (new \ilObjUser($selected_participants[0]->getUserId()))->getPublicName()
189  );
190  }
191 
192  return $this->lng->txt('finish_test_multiple');
193  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ ACTION_ID

const ILIAS\Test\Participants\ParticipantTableFinishTestAction::ACTION_ID = 'finish_test'

Definition at line 37 of file ParticipantTableFinishTestAction.php.


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