ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 354 of file QuestionsTableActions.php.

354 : bool
355 {
356 $question_properties = $this->questionrepository
357 ->getQuestionPropertiesForQuestionIds($question_ids);
358 foreach ($question_ids as $q_id) {
359 if (!$this->questionrepository->originalQuestionExists($q_id)) {
360 continue;
361 }
362
365 $question_properties[$q_id]->getGeneralQuestionProperties()->getOriginalId()
366 )
367 );
368
369 if ($type !== 'tst') {
370 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('tst_link_only_unassigned'), true);
371 return false;
372 }
373 }
374 return true;
375 }
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 104 of file QuestionsTableActions.php.

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

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

301 : Interruptive
302 {
303 $items = [];
304 foreach ($row_ids as $id) {
305 $qdata = $this->test_obj->getQuestionDataset($id);
306 $type = $this->questionrepository->getQuestionPropertiesForQuestionId($id)
307 ->getGeneralQuestionProperties()->getTypeName($this->lng);
308 $icon = $this->ui_renderer->render(
309 $this->ui_factory->symbol()->icon()->standard('ques', $type, 'small')
310 );
311 $items[] = $this->ui_factory->modal()->interruptiveItem()->keyvalue(
312 (string) $id,
313 $icon . ' ' . $qdata->title,
314 $type
315 );
316 }
317
318 return $this->ui_factory->modal()->interruptive(
319 $this->lng->txt('remove'),
320 $this->lng->txt(
321 $this->is_in_test_with_results
322 ? 'tst_remove_questions_and_results'
323 : 'tst_remove_questions'
324 ),
325 $this->table_query->getActionURL(self::ACTION_DELETE_CONFIRMED)->__toString()
326 )
327 ->withAffectedItems($items);
328 }
$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 99 of file QuestionsTableActions.php.

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

◆ getQuestionTargetLinkBuilder()

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

Definition at line 135 of file QuestionsTableActions.php.

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

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

154 : bool {
155 switch ($cmd) {
157 $protect_by_write_protection();
158 $data = $get_table()->getTableComponent()->getData();
159 $this->test_obj->setQuestionOrder(array_flip($data), []);
160 $this->tpl->setOnScreenMessage('success', $this->lng->txt('saved_successfully'), true);
161 return true;
162
165 current($row_ids),
166 \ilAssQuestionPreviewGUI::class,
168 );
169 return false;
170
173 current($row_ids),
174 \ilTestCorrectionsGUI::class,
175 'showQuestion'
176 );
177 return false;
178
181 current($row_ids),
182 \ilAssQuestionPreviewGUI::class,
184 );
185 return false;
186
188 $question_id = current($row_ids);
189 $qtype = $this->test_obj->getQuestionType($question_id);
190 $target_class = $qtype . 'GUI';
192 $question_id,
193 $target_class,
194 'editQuestion'
195 );
196 return false;
197
200 current($row_ids),
201 \ilAssQuestionPageGUI::class,
202 'edit'
203 );
204 return false;
205
208 current($row_ids),
209 \ilAssQuestionFeedbackEditingGUI::class,
211 );
212 return false;
213
215 echo $this->ui_renderer->renderAsync(
216 $this->getDeleteConfirmation(array_filter($row_ids))
217 );
218 exit();
219
221 $row_ids = $this->request->getParsedBody()['interruptive_items'] ?? [];
222 if (array_filter($row_ids) === []) {
223 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('msg_no_questions_selected'));
224 return true;
225 }
226 $protect_by_write_protection();
227 if ($this->is_in_test_with_results) {
228 $this->test_obj->removeQuestionsWithResults($row_ids);
229 } else {
230 $this->test_obj->removeQuestions($row_ids);
231 $this->test_obj->saveCompleteStatus($this->test_question_set_config_factory->getQuestionSetConfig());
232 }
233 $this->tpl->setOnScreenMessage('success', $this->lng->txt('tst_questions_removed'), true);
234 return true;
235
237 if (array_filter($row_ids) === []) {
238 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('msg_no_questions_selected'));
239 return true;
240 }
241 $protect_by_write_protection();
242 $this->test_obj->copyQuestions($row_ids);
243 $this->tpl->setOnScreenMessage('success', $this->lng->txt('copy_questions_success'), true);
244 return true;
245
247 if (array_filter($row_ids) === []) {
248 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('tst_no_question_selected_for_moving_to_qpl'));
249 return true;
250 }
251 $protect_by_write_protection();
252 if (!$this->checkQuestionParametersForCopyToPool($row_ids)) {
253 return true;
254 }
255 $copy_and_link_to_questionpool();
256 return false;
257
259 if (array_filter($row_ids) === []) {
260 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('msg_no_questions_selected'));
261 return true;
262 }
263 $protect_by_write_protection();
264 $this->question_printer->printSelectedQuestions(
265 array_reduce(
266 Types::cases(),
267 function (array $c, Types $v): array {
268 $c[$v->getLabel($this->lng)] = $this->table_query
269 ->getPrintViewTypeURL(self::ACTION_PRINT_QUESTIONS, $v->value)->__toString();
270 return $c;
271 },
272 []
273 ),
274 Types::tryFrom($this->table_query->getPrintViewType()) ?? Types::RESULTS_VIEW_TYPE_SHOW,
275 $row_ids
276 );
277 return false;
278
280 $protect_by_write_protection();
281 $this->question_printer->printAnswers(current($row_ids));
282 return false;
283
285 $protect_by_write_protection();
286 $question_object = \assQuestion::instantiateQuestion(current($row_ids));
287 if ($question_object instanceof \ilObjFileHandlingQuestionType) {
288 $question_object->deliverFileUploadZIPFile(
289 $this->test_obj->getRefId(),
290 $this->test_obj->getTestId(),
291 $this->test_obj->getTitle()
292 );
293 }
294
295 // no break
296 default:
297 throw new \InvalidArgumentException("No such table_cmd: '$cmd'.");
298 }
299 }
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 330 of file QuestionsTableActions.php.

334 : void {
335
336 $this->ctrl->setParameterByClass(
337 $target_class,
338 'q_id',
339 $question_id
340 );
341
342 $this->ctrl->setParameterByClass(
343 $target_class,
344 'calling_test',
345 (string) $this->test_obj->getRefId()
346 );
347
348 $this->ctrl->redirectByClass($target_class, $cmd);
349 }

◆ 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_DELETE,
82 $this->is_in_test_with_random_question_set && !$this->is_in_test_with_results
83 )->withDisabledAction(self::ACTION_COPY, $disable_default_actions)
84 ->withDisabledAction(self::ACTION_ADD_TO_POOL, $this->is_in_test_with_random_question_set)
85 ->withDisabledAction(self::ACTION_EDIT_QUESTION, $disable_default_actions)
86 ->withDisabledAction(self::ACTION_EDIT_PAGE, $disable_default_actions)
87 ->withDisabledAction(
88 self::ACTION_ADJUST,
89 $this->is_adjusting_questions_with_results_allowed && !$this->is_in_test_with_results
90 )->withDisabledAction(self::ACTION_FEEDBACK, $disable_default_actions)
91 ->withDisabledAction(self::ACTION_PRINT_ANSWERS, !$this->is_in_test_with_results)
92 ->withDisabledAction(
93 self::ACTION_DOWNLOAD_FILE_QUESTION_ANSWERS,
94 $row->getCellContent('type_tag') !== $this->lng->txt(\assFileUpload::class)
95 || !$this->questionrepository->questionHasAnswers((int) $row->getId())
96 );
97 }
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: