19declare(strict_types=1);
33use Psr\Http\Message\ServerRequestInterface;
42 private readonly UIFactory $ui_factory,
48 private readonly TestResultRepository $test_pass_result_repository
59 return $this->test_access->checkManageParticipantsAccess();
71 ->withParameter($action_token, 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(
95 $selected_participants
105 ServerRequestInterface $request,
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()
122 && !$this->haveAllSelectedParticipantsReachedMaxProcessingTime($selected_participants)) {
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,
155 AdditionalInformationGenerator::KEY_USERS => array_map(
156 fn(Participant $participant) => $participant->getUserId(),
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()
Builds a Color from either hex- or rgb values.
onSubmit(URLBuilder $url_builder, ServerRequestInterface $request, array $selected_participants, bool $all_participants_selected)
getSelectionErrorMessage()
allowActionForRecord(Participant $record)
haveAllSelectedParticipantsReachedMaxProcessingTime(array $selected_participants)
resolveMessage(array $selected_participants, bool $all_participants_selected)
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)
__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)
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const MESSAGE_TYPE_SUCCESS
const MESSAGE_TYPE_FAILURE
This describes commonalities between the different modals.
modal(string $title="", string $cancel_label="")
TestAdministrationInteractionTypes
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if(!file_exists('../ilias.ini.php'))