ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\Test\Participants\ParticipantTableDeleteResultsAction Class Reference
+ Inheritance diagram for ILIAS\Test\Participants\ParticipantTableDeleteResultsAction:
+ Collaboration diagram for ILIAS\Test\Participants\ParticipantTableDeleteResultsAction:

Public Member Functions

 __construct (private readonly Language $lng, private readonly \ilGlobalTemplateInterface $tpl, private readonly UIFactory $ui_factory, private readonly \ilDBInterface $db, private readonly \ilTestParticipantAccessFilterFactory $participant_access_filter_factory, 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)
 
 getSelectionErrorMessage ()
 
 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 = 'delete_results'
 

Private Member Functions

 resolveMessage (bool $all_participants_selected)
 

Detailed Description

Definition at line 31 of file ParticipantTableDeleteResultsAction.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Test\Participants\ParticipantTableDeleteResultsAction::__construct ( private readonly Language  $lng,
private readonly \ilGlobalTemplateInterface  $tpl,
private readonly UIFactory  $ui_factory,
private readonly \ilDBInterface  $db,
private readonly \ilTestParticipantAccessFilterFactory  $participant_access_filter_factory,
private readonly \ilTestAccess  $test_access,
private readonly \ilObjTest  $test_obj 
)

Definition at line 35 of file ParticipantTableDeleteResultsAction.php.

43 {
44 }

Member Function Documentation

◆ allowActionForRecord()

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

Implements ILIAS\Test\Participants\TableAction.

Definition at line 130 of file ParticipantTableDeleteResultsAction.php.

130 : bool
131 {
132 return $record->getActiveId() !== null;
133 }

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

+ Here is the call graph for this function:

◆ getActionId()

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

◆ getModal()

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

Implements ILIAS\Test\Participants\TableAction.

Definition at line 72 of file ParticipantTableDeleteResultsAction.php.

76 : ?Modal {
77 return $this->ui_factory->modal()->interruptive(
78 $this->lng->txt('confirm'),
79 $this->resolveMessage($all_participants_selected),
80 $url_builder->buildURI()->__toString()
81 )->withAffectedItems(
82 array_map(
83 fn(Participant $v) => $this->ui_factory->modal()->interruptiveItem()->standard(
84 (string) $v->getUserId(),
85 $this->test_obj->getAnonymity()
86 ? $this->lng->txt('anonymous')
88 ),
89 $selected_participants
90 )
91 );
92 }
buildURI()
Get a URI representation of the full URL including query string and fragment/hash.
Definition: URLBuilder.php:214
static _lookupFullname(int $a_user_id)

◆ getSelectionErrorMessage()

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

Implements ILIAS\Test\Participants\TableAction.

Definition at line 144 of file ParticipantTableDeleteResultsAction.php.

144 : ?string
145 {
146 return $this->lng->txt('delete_result_no_valid_participants_selected');
147 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getTableAction()

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

Implements ILIAS\Test\Participants\TableAction.

Definition at line 57 of file ParticipantTableDeleteResultsAction.php.

62 : Action {
63 return $this->ui_factory->table()->action()->standard(
64 $this->lng->txt('delete_user_data'),
65 $url_builder
66 ->withParameter($action_token, self::ACTION_ID)
67 ->withParameter($action_type_token, ParticipantTableActions::SHOW_ACTION),
68 $row_id_token
69 )->withAsync();
70 }
withParameter(URLBuilderToken $token, string|array $value)
Change an acquired parameter's value if the supplied token is valid.
Definition: URLBuilder.php:166

◆ isAvailable()

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

Implements ILIAS\Test\Participants\TableAction.

Definition at line 51 of file ParticipantTableDeleteResultsAction.php.

51 : bool
52 {
53 return $this->test_access->checkManageParticipantsAccess()
54 && $this->test_obj->evalTotalPersons() > 0;
55 }

◆ onSubmit()

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

99 : ?Modal {
100 if (!$this->test_access->checkManageParticipantsAccess()) {
101 $this->tpl->setOnScreenMessage(
103 $this->lng->txt('no_permission'),
104 true
105 );
106 return null;
107 }
108
109 $access_filter = $this->participant_access_filter_factory
110 ->getManageParticipantsUserFilter($this->test_obj->getRefId());
111 $participant_data = new \ilTestParticipantData($this->db, $this->lng);
112 $participant_data->setParticipantAccessFilter($access_filter);
113 $participant_data->setActiveIdsFilter(
114 array_map(
115 static fn(Participant $v): int => $v->getActiveId(),
116 $selected_participants
117 )
118 );
119 $participant_data->load($this->test_obj->getTestId());
120 $this->test_obj->removeTestResults($participant_data);
121
122 $this->tpl->setOnScreenMessage(
124 $this->lng->txt('tst_selected_user_data_deleted'),
125 true
126 );
127 return null;
128 }

References ILIAS\Repository\lng(), and ILIAS\UICore\GlobalTemplate\MESSAGE_TYPE_FAILURE.

+ Here is the call graph for this function:

◆ resolveMessage()

ILIAS\Test\Participants\ParticipantTableDeleteResultsAction::resolveMessage ( bool  $all_participants_selected)
private

Definition at line 135 of file ParticipantTableDeleteResultsAction.php.

135 : string
136 {
137 if ($all_participants_selected) {
138 return $this->lng->txt('delete_all_user_data_confirmation');
139 }
140
141 return $this->lng->txt('delete_selected_user_data_confirmation');
142 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

Field Documentation

◆ ACTION_ID

const ILIAS\Test\Participants\ParticipantTableDeleteResultsAction::ACTION_ID = 'delete_results'

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