ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ParticipantTableShowResultsAction.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24use ILIAS\UI\Factory as UIFactory;
29use Psr\Http\Message\ServerRequestInterface;
30
32{
33 public const ACTION_ID = 'show_results';
34
35 public function __construct(
36 private readonly Language $lng,
37 private readonly UIFactory $ui_factory,
38 private readonly \ilTestAccess $test_access,
39 private readonly \ilCtrl $ctrl,
40 private readonly \ilObjTest $test_obj
41 ) {
42 }
43
44 public function getActionId(): string
45 {
46 return self::ACTION_ID;
47 }
48
49 public function isAvailable(): bool
50 {
51 return $this->test_access->checkParticipantsResultsAccess()
52 && $this->test_obj->evalTotalPersons() > 0;
53 }
54
55 public function getTableAction(
56 URLBuilder $url_builder,
57 URLBuilderToken $row_id_token,
58 URLBuilderToken $action_token,
59 URLBuilderToken $action_type_token
60 ): Action {
61 return $this->ui_factory->table()->action()->standard(
62 $this->lng->txt(self::ACTION_ID),
63 $url_builder
64 ->withParameter($action_token, self::ACTION_ID)
65 ->withParameter($action_type_token, ParticipantTableActions::SUBMIT_ACTION),
66 $row_id_token
67 );
68 }
69
70 public function getModal(
71 URLBuilder $url_builder,
72 array $selected_participants,
73 bool $all_participants_selected
74 ): ?Modal {
75 return null;
76 }
77
78 public function onSubmit(
79 URLBuilder $url_builder,
80 ServerRequestInterface $request,
81 array $selected_participants,
82 bool $all_participants_selected
83 ): ?Modal {
84 if ($selected_participants === []) {
85 return null;
86 }
87 foreach ($selected_participants as $participant) {
88 if (!$this->test_access->checkResultsAccessForActiveId(
89 $participant->getActiveId(),
90 $this->test_obj->getTestId()
91 )) {
92 $this->tpl->setOnScreenMessage(
94 $this->lng->txt('no_permission'),
95 true
96 );
97 return null;
98 }
99 }
100 $this->ctrl->setParameterByClass(
101 \ilTestEvaluationGUI::class,
102 'active_ids',
103 array_reduce(
104 $selected_participants,
105 static function (string $c, Participant $v): string {
106 if ($c === '') {
107 return (string) $v->getActiveId();
108 }
109 $c .= ",{$v->getActiveId()}";
110 return $c;
111 },
112 ''
113 )
114 );
115
116 $this->ctrl->redirectByClass(\ilTestEvaluationGUI::class, 'showResults');
117 }
118
119 public function allowActionForRecord(Participant $record): bool
120 {
121 return $record->getActiveId() !== null && $this->test_access->checkResultsAccessForActiveId(
122 $record->getActiveId(),
123 $this->test_obj->getTestId()
124 );
125 }
126
127 public function getSelectionErrorMessage(): ?string
128 {
129 return null;
130 }
131}
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
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)
__construct(private readonly Language $lng, private readonly UIFactory $ui_factory, private readonly \ilTestAccess $test_access, private readonly \ilCtrl $ctrl, private readonly \ilObjTest $test_obj)
Class ilCtrl provides processing control methods.
$c
Definition: deliver.php:25
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This describes commonalities between the different modals.
Definition: Modal.php:35
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Participant.php:21
global $lng
Definition: privfeed.php:31
if(!file_exists('../ilias.ini.php'))