19 declare(strict_types=1);
54 return self::ACTION_ID;
59 return $this->test_access->checkManageParticipantsAccess();
68 return $this->ui_factory->table()->action()->standard(
69 $this->
lng->txt(self::ACTION_ID),
79 array $selected_participants,
80 bool $all_participants_selected
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'));
88 if (count($selected_participants) > 1) {
89 $modal = $modal->withAffectedItems(
91 fn(
Participant $participant) => $this->ui_factory->modal()->interruptiveItem()->standard(
93 (new \ilObjUser($participant->
getUserId()))->getPublicName()
95 $selected_participants
106 array $selected_participants,
107 bool $all_participants_selected
109 if (!$this->test_access->checkManageParticipantsAccess()) {
110 $this->tpl->setOnScreenMessage(
112 $this->
lng->txt(
'no_permission'),
118 if (count($selected_participants) > 1
119 && $this->test_obj->getNrOfTries() === 1
120 && $this->test_obj->getEnableProcessingTime()
121 && !$this->test_obj->getResetProcessingTime()
123 $this->tpl->setOnScreenMessage(
125 $this->
lng->txt(
'finish_pass_for_multiple_users_in_processing_time'),
132 $test_session_factory = new \ilTestSessionFactory(
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()),
143 $this->test_pass_result_repository
144 ))->performFinishTasks($process_locker, StatusOfAttempt::FINISHED_BY_ADMINISTRATOR);
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,
157 $selected_participants
164 $this->tpl->setOnScreenMessage(
166 $this->
lng->txt(
'test_attempts_finished'),
178 array $selected_participants,
179 bool $all_participants_selected
181 if ($all_participants_selected) {
182 return $this->
lng->txt(
'finish_test_all');
185 if (count($selected_participants) === 1) {
187 $this->
lng->txt(
'finish_test_single'),
188 (new \ilObjUser($selected_participants[0]->getUserId()))->getPublicName()
192 return $this->
lng->txt(
'finish_test_multiple');
197 return $this->
lng->txt(
'finish_test_no_valid_participants_selected');
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()
This describes commonalities between the different modals.
TestAdministrationInteractionTypes
onSubmit(URLBuilder $url_builder, ServerRequestInterface $request, array $selected_participants, bool $all_participants_selected)
buildURI()
Get a URI representation of the full URL including query string and fragment/hash.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
haveAllSelectedParticipantsReachedMaxProcessingTime(array $selected_participants)
__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)
getTableAction(URLBuilder $url_builder, URLBuilderToken $row_id_token, URLBuilderToken $action_token, URLBuilderToken $action_type_token)
const MESSAGE_TYPE_SUCCESS
resolveMessage(array $selected_participants, bool $all_participants_selected)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getSelectionErrorMessage()
getModal(URLBuilder $url_builder, array $selected_participants, bool $all_participants_selected)
withParameter(URLBuilderToken $token, string|array $value)
Change an acquired parameter's value if the supplied token is valid.
allowActionForRecord(Participant $record)
const MESSAGE_TYPE_FAILURE