ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
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, private readonly ResponseHandler $test_response)
 
 setDisabledActions (OrderingRow $row, Properties $record)
 
 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 36 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,
private readonly ResponseHandler  $test_response 
)
Parameters
array$data<string, mixed>

Definition at line 58 of file QuestionsTableActions.php.

74 {
75 $this->table_id = (string) $test_obj->getId();
76 }

Member Function Documentation

◆ checkQuestionParametersForCopyToPool()

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

Definition at line 392 of file QuestionsTableActions.php.

392 : bool
393 {
394 $question_properties = $this->questionrepository
395 ->getQuestionPropertiesForQuestionIds($question_ids);
396 foreach ($question_ids as $q_id) {
397 if (!$this->questionrepository->originalQuestionExists($q_id)) {
398 continue;
399 }
400
403 $question_properties[$q_id]->getGeneralQuestionProperties()->getOriginalId()
404 )
405 );
406
407 if ($type !== 'tst') {
408 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('tst_link_only_unassigned'), true);
409 return false;
410 }
411 }
412 return true;
413 }
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 111 of file QuestionsTableActions.php.

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

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 335 of file QuestionsTableActions.php.

335 : Interruptive|MessageBox
336 {
337 if ($row_ids === []) {
338 return $this->ui_factory->messageBox()->failure($this->lng->txt('msg_no_questions_selected'));
339 }
340
341 $items = [];
342 foreach ($row_ids as $id) {
343 $qdata = $this->test_obj->getQuestionDataset($id);
344 $type = $this->questionrepository->getQuestionPropertiesForQuestionId($id)
345 ->getGeneralQuestionProperties()->getTypeName($this->lng);
346 $icon = $this->ui_renderer->render(
347 $this->ui_factory->symbol()->icon()->standard('ques', $type, 'small')
348 );
349 $items[] = $this->ui_factory->modal()->interruptiveItem()->keyvalue(
350 (string) $id,
351 $icon . ' ' . $qdata->title,
352 $type
353 );
354 }
355
356 return $this->ui_factory->modal()->interruptive(
357 $this->lng->txt('remove'),
358 $this->lng->txt(
359 $this->is_in_test_with_results
360 ? 'tst_remove_questions_and_results'
361 : 'tst_remove_questions'
362 ),
363 $this->table_query->getActionURL(self::ACTION_DELETE_CONFIRMED)->__toString()
364 )
365 ->withAffectedItems($items);
366 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

References $id, and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getOrderActionUrl()

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

Definition at line 106 of file QuestionsTableActions.php.

106 : URI
107 {
108 return $this->table_query->getActionURL(self::ACTION_SAVE_ORDER);
109 }

◆ getQuestionTargetLinkBuilder()

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

Definition at line 146 of file QuestionsTableActions.php.

146 : \Closure
147 {
148 return function (int $question_id): string {
149 [$url_builder, $row_id_token] = $this->table_query->getRowBoundURLBuilder(self::ACTION_PREVIEW);
150 return $url_builder->withParameter($row_id_token, (string) $question_id)
151 ->buildURI()
152 ->__toString();
153 };
154 }

◆ 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 159 of file QuestionsTableActions.php.

165 : bool {
166 switch ($cmd) {
168 $protect_by_write_protection();
169
170 if ($this->is_in_test_with_random_question_set || $this->is_in_test_with_results) {
171 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('questionlist_cannot_be_altered'));
172 return true;
173 }
174
175 $data = $get_table()->getTableComponent()->getData();
176 $this->test_obj->setQuestionOrder(array_flip($data), []);
177 $this->tpl->setOnScreenMessage('success', $this->lng->txt('saved_successfully'), true);
178 return true;
179
182 current($row_ids),
183 \ilAssQuestionPreviewGUI::class,
185 );
186 return false;
187
190 current($row_ids),
191 \ilTestCorrectionsGUI::class,
192 'showQuestion'
193 );
194 return false;
195
198 current($row_ids),
199 \ilAssQuestionPreviewGUI::class,
201 );
202 return false;
203
205 $question_id = current($row_ids);
206 $qtype = $this->test_obj->getQuestionType($question_id);
207 $target_class = $qtype . 'GUI';
209 $question_id,
210 $target_class,
211 'editQuestion'
212 );
213 return false;
214
217 current($row_ids),
218 \ilAssQuestionPageGUI::class,
219 'edit'
220 );
221 return false;
222
225 current($row_ids),
226 \ilAssQuestionFeedbackEditingGUI::class,
228 );
229 return false;
230
232 $this->test_response->sendAsync(
233 $this->ui_renderer->renderAsync(
234 $this->getDeleteConfirmation(array_filter($row_ids))
235 )
236 );
237 return false;
238
240 $row_ids = $this->request->getParsedBody()['interruptive_items'] ?? [];
241 if (array_filter($row_ids) === []) {
242
243 return true;
244 }
245
246 if ($this->is_in_test_with_random_question_set
247 || $this->is_in_test_with_results
248 && !$this->is_adjusting_questions_with_results_allowed) {
249 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('questionlist_cannot_be_altered'));
250 return true;
251 }
252
253 $protect_by_write_protection();
254 if ($this->is_in_test_with_results) {
255 $this->test_obj->removeQuestionsWithResults($row_ids);
256 } else {
257 $this->test_obj->removeQuestions($row_ids);
258 $this->test_obj->saveCompleteStatus($this->test_question_set_config_factory->getQuestionSetConfig());
259 }
260 $this->tpl->setOnScreenMessage('success', $this->lng->txt('tst_questions_removed'), true);
261 return true;
262
264 if (array_filter($row_ids) === []) {
265 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('msg_no_questions_selected'));
266 return true;
267 }
268
269 if ($this->is_in_test_with_random_question_set || $this->is_in_test_with_results) {
270 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('questionlist_cannot_be_altered'));
271 return true;
272 }
273
274 $protect_by_write_protection();
275 $this->test_obj->copyQuestions($row_ids);
276 $this->tpl->setOnScreenMessage('success', $this->lng->txt('copy_questions_success'), true);
277 $this->ctrl->redirectByClass(\ilObjTestGUI::class, 'showQuestions');
278 return true;
279
281 if (array_filter($row_ids) === []) {
282 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('tst_no_question_selected_for_moving_to_qpl'));
283 return true;
284 }
285 $protect_by_write_protection();
286 if (!$this->checkQuestionParametersForCopyToPool($row_ids)) {
287 return true;
288 }
289 $copy_and_link_to_questionpool();
290 return false;
291
293 if (array_filter($row_ids) === []) {
294 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('msg_no_questions_selected'));
295 return true;
296 }
297 $protect_by_write_protection();
298 $this->question_printer->printSelectedQuestions(
299 array_reduce(
300 Types::cases(),
301 function (array $c, Types $v): array {
302 $c[$v->getLabel($this->lng)] = $this->table_query
303 ->getPrintViewTypeURL(self::ACTION_PRINT_QUESTIONS, $v->value)->__toString();
304 return $c;
305 },
306 []
307 ),
308 Types::tryFrom($this->table_query->getPrintViewType()) ?? Types::RESULTS_VIEW_TYPE_SHOW,
309 $row_ids
310 );
311 return false;
312
314 $protect_by_write_protection();
315 $this->question_printer->printAnswers(current($row_ids));
316 return false;
317
319 $protect_by_write_protection();
320 $question_object = \assQuestion::instantiateQuestion(current($row_ids));
321 if ($question_object instanceof \ilObjFileHandlingQuestionType) {
322 $question_object->deliverFileUploadZIPFile(
323 $this->test_obj->getRefId(),
324 $this->test_obj->getTestId(),
325 $this->test_obj->getTitle()
326 );
327 }
328
329 // no break
330 default:
331 throw new \InvalidArgumentException("No such table_cmd: '$cmd'.");
332 }
333 }
redirectWithQuestionParameters(int $question_id, string $target_class, string $cmd)
static instantiateQuestion(int $question_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$data
Definition: storeScorm.php:45

References Vendor\Package\$c, $data, ilAssQuestionFeedbackEditingGUI\CMD_SHOW, ilAssQuestionPreviewGUI\CMD_SHOW, ilAssQuestionPreviewGUI\CMD_STATISTICS, ILIAS\Repository\ctrl(), 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 368 of file QuestionsTableActions.php.

372 : void {
373
374 $this->ctrl->setParameterByClass(
375 $target_class,
376 'q_id',
377 $question_id
378 );
379
380 $this->ctrl->setParameterByClass(
381 $target_class,
382 'calling_test',
383 (string) $this->test_obj->getRefId()
384 );
385
386 $this->ctrl->redirectByClass($target_class, $cmd);
387 }

◆ setDisabledActions()

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

Definition at line 78 of file QuestionsTableActions.php.

81 : OrderingRow {
82 $disable_default_actions = $this->is_in_test_with_random_question_set
83 || $this->is_in_test_with_results;
84
85 return $row->withDisabledAction(
86 self::ACTION_ADD_TO_POOL,
87 $this->is_in_test_with_random_question_set
88 )->withDisabledAction(self::ACTION_EDIT_QUESTION, $disable_default_actions)
89 ->withDisabledAction(self::ACTION_EDIT_PAGE, $disable_default_actions)
90 ->withDisabledAction(
91 self::ACTION_ADJUST,
92 !$this->is_adjusting_questions_with_results_allowed
93 || !$this->is_in_test_with_results
94 || !\assQuestion::instantiateQuestionGUI(
95 $record->getGeneralQuestionProperties()->getQuestionId()
96 )->supportsAdjustment()
97 )->withDisabledAction(self::ACTION_FEEDBACK, $disable_default_actions)
98 ->withDisabledAction(self::ACTION_PRINT_ANSWERS, !$this->is_in_test_with_results)
99 ->withDisabledAction(
100 self::ACTION_DOWNLOAD_FILE_QUESTION_ANSWERS,
101 $row->getCellContent('type_tag') !== $this->lng->txt(\assFileUpload::class)
102 || !$this->questionrepository->questionHasAnswers((int) $row->getId())
103 );
104 }
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 53 of file QuestionsTableActions.php.

◆ ACTION_ADD_TO_POOL

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

Definition at line 42 of file QuestionsTableActions.php.

◆ ACTION_ADJUST

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

Definition at line 44 of file QuestionsTableActions.php.

◆ ACTION_COPY

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

Definition at line 41 of file QuestionsTableActions.php.

◆ ACTION_DELETE

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

Definition at line 39 of file QuestionsTableActions.php.

◆ ACTION_DELETE_CONFIRMED

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

Definition at line 40 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 51 of file QuestionsTableActions.php.

◆ ACTION_EDIT_PAGE

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

Definition at line 47 of file QuestionsTableActions.php.

◆ ACTION_EDIT_QUESTION

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

Definition at line 46 of file QuestionsTableActions.php.

◆ ACTION_FEEDBACK

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

Definition at line 48 of file QuestionsTableActions.php.

◆ ACTION_PREVIEW

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

Definition at line 43 of file QuestionsTableActions.php.

◆ ACTION_PRINT_ANSWERS

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

Definition at line 50 of file QuestionsTableActions.php.

◆ ACTION_PRINT_QUESTIONS

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

Definition at line 49 of file QuestionsTableActions.php.

◆ ACTION_SAVE_ORDER

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

Definition at line 38 of file QuestionsTableActions.php.

◆ ACTION_STATISTICS

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

Definition at line 45 of file QuestionsTableActions.php.


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