ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
ILIAS\Test\Questions\Presentation\QuestionsTableActions Class Reference
+ Collaboration diagram for ILIAS\Test\Questions\Presentation\QuestionsTableActions:

Public Member Functions

 __construct (private readonly UIFactory $ui_factory, private readonly UIRenderer $ui_renderer, private \ilGlobalTemplateInterface $tpl, private readonly ServerRequestInterface $request, private readonly QuestionsTableQuery $table_query, private readonly Language $lng, private readonly \ilCtrl $ctrl, private readonly TestQuestionsRepository $questionrepository, private readonly Printer $question_printer, private readonly \ilObjTest $test_obj, private readonly bool $is_adjusting_questions_with_results_allowed, private readonly bool $is_in_test_with_results, private readonly bool $is_in_test_with_random_question_set, private readonly \ilTestQuestionSetConfigFactory $test_question_set_config_factory)
 
 setDisabledActions (OrderingRow $row)
 
 getOrderActionUrl ()
 
 getActions ()
 
 getQuestionTargetLinkBuilder ()
 
 handleCommand (string $cmd, array $row_ids, \Closure $protect_by_write_protection, \Closure $copy_and_link_to_questionpool, \Closure $get_table)
 

Private Member Functions

 getDeleteConfirmation (array $row_ids)
 
 redirectWithQuestionParameters (int $question_id, string $target_class, string $cmd)
 
 checkQuestionParametersForCopyToPool (array $question_ids)
 

Private Attributes

const ACTION_SAVE_ORDER = 'save_order'
 
const ACTION_DELETE = 'delete'
 
const ACTION_DELETE_CONFIRMED = 'deletion_confirmed'
 
const ACTION_COPY = 'copy'
 
const ACTION_ADD_TO_POOL = 'add_qpl'
 
const ACTION_PREVIEW = 'preview'
 
const ACTION_ADJUST = 'correction'
 
const ACTION_STATISTICS = 'statistics'
 
const ACTION_EDIT_QUESTION = 'edit_question'
 
const ACTION_EDIT_PAGE = 'edit_page'
 
const ACTION_FEEDBACK = 'feedback'
 
const ACTION_PRINT_QUESTIONS = 'print_questions'
 
const ACTION_PRINT_ANSWERS = 'print_answers'
 
const ACTION_DOWNLOAD_FILE_QUESTION_ANSWERS = 'download_files'
 
string $table_id
 

Detailed Description

Definition at line 33 of file QuestionsTableActions.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Test\Questions\Presentation\QuestionsTableActions::__construct ( private readonly UIFactory  $ui_factory,
private readonly UIRenderer  $ui_renderer,
private \ilGlobalTemplateInterface  $tpl,
private readonly ServerRequestInterface  $request,
private readonly QuestionsTableQuery  $table_query,
private readonly Language  $lng,
private readonly \ilCtrl  $ctrl,
private readonly TestQuestionsRepository  $questionrepository,
private readonly Printer  $question_printer,
private readonly \ilObjTest  $test_obj,
private readonly bool  $is_adjusting_questions_with_results_allowed,
private readonly bool  $is_in_test_with_results,
private readonly bool  $is_in_test_with_random_question_set,
private readonly \ilTestQuestionSetConfigFactory  $test_question_set_config_factory 
)
Parameters
array$data<string, mixed>

Definition at line 55 of file QuestionsTableActions.php.

70 {
71 $this->table_id = (string) $test_obj->getId();
72 }

Member Function Documentation

◆ checkQuestionParametersForCopyToPool()

ILIAS\Test\Questions\Presentation\QuestionsTableActions::checkQuestionParametersForCopyToPool ( array  $question_ids)
private
Parameters
array<int>$question_ids

Definition at line 376 of file QuestionsTableActions.php.

376 : bool
377 {
378 $question_properties = $this->questionrepository
379 ->getQuestionPropertiesForQuestionIds($question_ids);
380 foreach ($question_ids as $q_id) {
381 if (!$this->questionrepository->originalQuestionExists($q_id)) {
382 continue;
383 }
384
387 $question_properties[$q_id]->getGeneralQuestionProperties()->getOriginalId()
388 )
389 );
390
391 if ($type !== 'tst') {
392 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('tst_link_only_unassigned'), true);
393 return false;
394 }
395 }
396 return true;
397 }
static lookupParentObjId(int $question_id)
static _lookupType(int $id, bool $reference=false)

References ilObject\_lookupType(), ILIAS\Repository\lng(), and assQuestion\lookupParentObjId().

+ Here is the call graph for this function:

◆ getActions()

ILIAS\Test\Questions\Presentation\QuestionsTableActions::getActions ( )

Definition at line 102 of file QuestionsTableActions.php.

102 : array
103 {
104 $ag = fn(string $type, string $label, $action): TableAction => $this->
105 ui_factory->table()->action()->$type(
106 $this->lng->txt($label),
107 ...$this->table_query->getRowBoundURLBuilder($action)
108 );
109
110 $actions = [
111 self::ACTION_PREVIEW => $ag('single', 'preview', self::ACTION_PREVIEW),
112 self::ACTION_ADJUST => $ag('single', 'tst_corrections_qst_form', self::ACTION_ADJUST),
113 self::ACTION_STATISTICS => $ag('single', 'statistics', self::ACTION_STATISTICS),
114 self::ACTION_EDIT_QUESTION => $ag('single', 'edit_question', self::ACTION_EDIT_QUESTION),
115 self::ACTION_EDIT_PAGE => $ag('single', 'edit_page', self::ACTION_EDIT_PAGE),
116 self::ACTION_FEEDBACK => $ag('single', 'tst_feedback', self::ACTION_FEEDBACK),
117 self::ACTION_PRINT_ANSWERS => $ag('single', 'print_answers', self::ACTION_PRINT_ANSWERS),
118 self::ACTION_DOWNLOAD_FILE_QUESTION_ANSWERS => $ag('single', 'download_all_files', self::ACTION_DOWNLOAD_FILE_QUESTION_ANSWERS),
119 ];
120
121 if (!$this->is_in_test_with_random_question_set
122 && (!$this->is_in_test_with_results || $this->is_adjusting_questions_with_results_allowed)) {
123 $actions[self::ACTION_DELETE] = $ag('standard', 'delete', self::ACTION_DELETE)
124 ->withAsync();
125 }
126
127 if (!$this->is_in_test_with_random_question_set && !$this->is_in_test_with_results) {
128 $actions[self::ACTION_COPY] = $ag('standard', 'copy', self::ACTION_COPY);
129 }
130
131 return $actions + [
132 self::ACTION_ADD_TO_POOL => $ag('standard', 'copy_and_link_to_questionpool', self::ACTION_ADD_TO_POOL),
133 self::ACTION_PRINT_QUESTIONS => $ag('multi', 'print', self::ACTION_PRINT_QUESTIONS)
134 ];
135 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getDeleteConfirmation()

ILIAS\Test\Questions\Presentation\QuestionsTableActions::getDeleteConfirmation ( array  $row_ids)
private

Definition at line 323 of file QuestionsTableActions.php.

323 : Interruptive
324 {
325 $items = [];
326 foreach ($row_ids as $id) {
327 $qdata = $this->test_obj->getQuestionDataset($id);
328 $type = $this->questionrepository->getQuestionPropertiesForQuestionId($id)
329 ->getGeneralQuestionProperties()->getTypeName($this->lng);
330 $icon = $this->ui_renderer->render(
331 $this->ui_factory->symbol()->icon()->standard('ques', $type, 'small')
332 );
333 $items[] = $this->ui_factory->modal()->interruptiveItem()->keyvalue(
334 (string) $id,
335 $icon . ' ' . $qdata->title,
336 $type
337 );
338 }
339
340 return $this->ui_factory->modal()->interruptive(
341 $this->lng->txt('remove'),
342 $this->lng->txt(
343 $this->is_in_test_with_results
344 ? 'tst_remove_questions_and_results'
345 : 'tst_remove_questions'
346 ),
347 $this->table_query->getActionURL(self::ACTION_DELETE_CONFIRMED)->__toString()
348 )
349 ->withAffectedItems($items);
350 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

References $id, ILIAS\Repository\lng(), and ILIAS\UI\Component\Modal\Interruptive\withAffectedItems().

+ Here is the call graph for this function:

◆ getOrderActionUrl()

ILIAS\Test\Questions\Presentation\QuestionsTableActions::getOrderActionUrl ( )

Definition at line 97 of file QuestionsTableActions.php.

97 : URI
98 {
99 return $this->table_query->getActionURL(self::ACTION_SAVE_ORDER);
100 }

◆ getQuestionTargetLinkBuilder()

ILIAS\Test\Questions\Presentation\QuestionsTableActions::getQuestionTargetLinkBuilder ( )

Definition at line 137 of file QuestionsTableActions.php.

137 : \Closure
138 {
139 return function (int $question_id): string {
140 [$url_builder, $row_id_token] = $this->table_query->getRowBoundURLBuilder(self::ACTION_PREVIEW);
141 return $url_builder->withParameter($row_id_token, (string) $question_id)
142 ->buildURI()
143 ->__toString();
144 };
145 }

◆ handleCommand()

ILIAS\Test\Questions\Presentation\QuestionsTableActions::handleCommand ( string  $cmd,
array  $row_ids,
\Closure  $protect_by_write_protection,
\Closure  $copy_and_link_to_questionpool,
\Closure  $get_table 
)
Returns
bool Show Questions After Return

Definition at line 150 of file QuestionsTableActions.php.

156 : bool {
157 switch ($cmd) {
159 $protect_by_write_protection();
160
161 if ($this->is_in_test_with_random_question_set || $this->is_in_test_with_results) {
162 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('questionlist_cannot_be_altered'));
163 return true;
164 }
165
166 $data = $get_table()->getTableComponent()->getData();
167 $this->test_obj->setQuestionOrder(array_flip($data), []);
168 $this->tpl->setOnScreenMessage('success', $this->lng->txt('saved_successfully'), true);
169 return true;
170
173 current($row_ids),
174 \ilAssQuestionPreviewGUI::class,
176 );
177 return false;
178
181 current($row_ids),
182 \ilTestCorrectionsGUI::class,
183 'showQuestion'
184 );
185 return false;
186
189 current($row_ids),
190 \ilAssQuestionPreviewGUI::class,
192 );
193 return false;
194
196 $question_id = current($row_ids);
197 $qtype = $this->test_obj->getQuestionType($question_id);
198 $target_class = $qtype . 'GUI';
200 $question_id,
201 $target_class,
202 'editQuestion'
203 );
204 return false;
205
208 current($row_ids),
209 \ilAssQuestionPageGUI::class,
210 'edit'
211 );
212 return false;
213
216 current($row_ids),
217 \ilAssQuestionFeedbackEditingGUI::class,
219 );
220 return false;
221
223 echo $this->ui_renderer->renderAsync(
224 $this->getDeleteConfirmation(array_filter($row_ids))
225 );
226 exit();
227
229 $row_ids = $this->request->getParsedBody()['interruptive_items'] ?? [];
230 if (array_filter($row_ids) === []) {
231
232 return true;
233 }
234
235 if ($this->is_in_test_with_random_question_set
236 || $this->is_in_test_with_results
237 && !$this->is_adjusting_questions_with_results_allowed) {
238 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('questionlist_cannot_be_altered'));
239 return true;
240 }
241
242 $protect_by_write_protection();
243 if ($this->is_in_test_with_results) {
244 $this->test_obj->removeQuestionsWithResults($row_ids);
245 } else {
246 $this->test_obj->removeQuestions($row_ids);
247 $this->test_obj->saveCompleteStatus($this->test_question_set_config_factory->getQuestionSetConfig());
248 }
249 $this->tpl->setOnScreenMessage('success', $this->lng->txt('tst_questions_removed'), true);
250 return true;
251
253 if (array_filter($row_ids) === []) {
254 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('msg_no_questions_selected'));
255 return true;
256 }
257
258 if ($this->is_in_test_with_random_question_set || $this->is_in_test_with_results) {
259 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('questionlist_cannot_be_altered'));
260 return true;
261 }
262
263 $protect_by_write_protection();
264 $this->test_obj->copyQuestions($row_ids);
265 $this->tpl->setOnScreenMessage('success', $this->lng->txt('copy_questions_success'), true);
266 return true;
267
269 if (array_filter($row_ids) === []) {
270 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('tst_no_question_selected_for_moving_to_qpl'));
271 return true;
272 }
273 $protect_by_write_protection();
274 if (!$this->checkQuestionParametersForCopyToPool($row_ids)) {
275 return true;
276 }
277 $copy_and_link_to_questionpool();
278 return false;
279
281 if (array_filter($row_ids) === []) {
282 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('msg_no_questions_selected'));
283 return true;
284 }
285 $protect_by_write_protection();
286 $this->question_printer->printSelectedQuestions(
287 array_reduce(
288 Types::cases(),
289 function (array $c, Types $v): array {
290 $c[$v->getLabel($this->lng)] = $this->table_query
291 ->getPrintViewTypeURL(self::ACTION_PRINT_QUESTIONS, $v->value)->__toString();
292 return $c;
293 },
294 []
295 ),
296 Types::tryFrom($this->table_query->getPrintViewType()) ?? Types::RESULTS_VIEW_TYPE_SHOW,
297 $row_ids
298 );
299 return false;
300
302 $protect_by_write_protection();
303 $this->question_printer->printAnswers(current($row_ids));
304 return false;
305
307 $protect_by_write_protection();
308 $question_object = \assQuestion::instantiateQuestion(current($row_ids));
309 if ($question_object instanceof \ilObjFileHandlingQuestionType) {
310 $question_object->deliverFileUploadZIPFile(
311 $this->test_obj->getRefId(),
312 $this->test_obj->getTestId(),
313 $this->test_obj->getTitle()
314 );
315 }
316
317 // no break
318 default:
319 throw new \InvalidArgumentException("No such table_cmd: '$cmd'.");
320 }
321 }
redirectWithQuestionParameters(int $question_id, string $target_class, string $cmd)
static instantiateQuestion(int $question_id)
$c
Definition: deliver.php:25
exit
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References $c, $data, ilAssQuestionFeedbackEditingGUI\CMD_SHOW, ilAssQuestionPreviewGUI\CMD_SHOW, ilAssQuestionPreviewGUI\CMD_STATISTICS, exit, assQuestion\instantiateQuestion(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ redirectWithQuestionParameters()

ILIAS\Test\Questions\Presentation\QuestionsTableActions::redirectWithQuestionParameters ( int  $question_id,
string  $target_class,
string  $cmd 
)
private

Definition at line 352 of file QuestionsTableActions.php.

356 : void {
357
358 $this->ctrl->setParameterByClass(
359 $target_class,
360 'q_id',
361 $question_id
362 );
363
364 $this->ctrl->setParameterByClass(
365 $target_class,
366 'calling_test',
367 (string) $this->test_obj->getRefId()
368 );
369
370 $this->ctrl->redirectByClass($target_class, $cmd);
371 }

◆ setDisabledActions()

ILIAS\Test\Questions\Presentation\QuestionsTableActions::setDisabledActions ( OrderingRow  $row)

Definition at line 74 of file QuestionsTableActions.php.

76 : OrderingRow {
77 $disable_default_actions = $this->is_in_test_with_random_question_set
78 || $this->is_in_test_with_results;
79
80 return $row->withDisabledAction(
81 self::ACTION_ADD_TO_POOL,
82 $this->is_in_test_with_random_question_set
83 )->withDisabledAction(self::ACTION_EDIT_QUESTION, $disable_default_actions)
84 ->withDisabledAction(self::ACTION_EDIT_PAGE, $disable_default_actions)
85 ->withDisabledAction(
86 self::ACTION_ADJUST,
87 !$this->is_adjusting_questions_with_results_allowed || !$this->is_in_test_with_results
88 )->withDisabledAction(self::ACTION_FEEDBACK, $disable_default_actions)
89 ->withDisabledAction(self::ACTION_PRINT_ANSWERS, !$this->is_in_test_with_results)
90 ->withDisabledAction(
91 self::ACTION_DOWNLOAD_FILE_QUESTION_ANSWERS,
92 $row->getCellContent('type_tag') !== $this->lng->txt(\assFileUpload::class)
93 || !$this->questionrepository->questionHasAnswers((int) $row->getId())
94 );
95 }
withDisabledAction(string $action_id, bool $disable=true)
Refer to an Action by its id and disable it for this row/record only.

Field Documentation

◆ $table_id

string ILIAS\Test\Questions\Presentation\QuestionsTableActions::$table_id
private

Definition at line 50 of file QuestionsTableActions.php.

◆ ACTION_ADD_TO_POOL

const ILIAS\Test\Questions\Presentation\QuestionsTableActions::ACTION_ADD_TO_POOL = 'add_qpl'
private

Definition at line 39 of file QuestionsTableActions.php.

◆ ACTION_ADJUST

const ILIAS\Test\Questions\Presentation\QuestionsTableActions::ACTION_ADJUST = 'correction'
private

Definition at line 41 of file QuestionsTableActions.php.

◆ ACTION_COPY

const ILIAS\Test\Questions\Presentation\QuestionsTableActions::ACTION_COPY = 'copy'
private

Definition at line 38 of file QuestionsTableActions.php.

◆ ACTION_DELETE

const ILIAS\Test\Questions\Presentation\QuestionsTableActions::ACTION_DELETE = 'delete'
private

Definition at line 36 of file QuestionsTableActions.php.

◆ ACTION_DELETE_CONFIRMED

const ILIAS\Test\Questions\Presentation\QuestionsTableActions::ACTION_DELETE_CONFIRMED = 'deletion_confirmed'
private

Definition at line 37 of file QuestionsTableActions.php.

◆ ACTION_DOWNLOAD_FILE_QUESTION_ANSWERS

const ILIAS\Test\Questions\Presentation\QuestionsTableActions::ACTION_DOWNLOAD_FILE_QUESTION_ANSWERS = 'download_files'
private

Definition at line 48 of file QuestionsTableActions.php.

◆ ACTION_EDIT_PAGE

const ILIAS\Test\Questions\Presentation\QuestionsTableActions::ACTION_EDIT_PAGE = 'edit_page'
private

Definition at line 44 of file QuestionsTableActions.php.

◆ ACTION_EDIT_QUESTION

const ILIAS\Test\Questions\Presentation\QuestionsTableActions::ACTION_EDIT_QUESTION = 'edit_question'
private

Definition at line 43 of file QuestionsTableActions.php.

◆ ACTION_FEEDBACK

const ILIAS\Test\Questions\Presentation\QuestionsTableActions::ACTION_FEEDBACK = 'feedback'
private

Definition at line 45 of file QuestionsTableActions.php.

◆ ACTION_PREVIEW

const ILIAS\Test\Questions\Presentation\QuestionsTableActions::ACTION_PREVIEW = 'preview'
private

Definition at line 40 of file QuestionsTableActions.php.

◆ ACTION_PRINT_ANSWERS

const ILIAS\Test\Questions\Presentation\QuestionsTableActions::ACTION_PRINT_ANSWERS = 'print_answers'
private

Definition at line 47 of file QuestionsTableActions.php.

◆ ACTION_PRINT_QUESTIONS

const ILIAS\Test\Questions\Presentation\QuestionsTableActions::ACTION_PRINT_QUESTIONS = 'print_questions'
private

Definition at line 46 of file QuestionsTableActions.php.

◆ ACTION_SAVE_ORDER

const ILIAS\Test\Questions\Presentation\QuestionsTableActions::ACTION_SAVE_ORDER = 'save_order'
private

Definition at line 35 of file QuestionsTableActions.php.

◆ ACTION_STATISTICS

const ILIAS\Test\Questions\Presentation\QuestionsTableActions::ACTION_STATISTICS = 'statistics'
private

Definition at line 42 of file QuestionsTableActions.php.


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