ILIAS  trunk Revision v12.0_alpha-16-g3e876e53c80
Retrieval.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use Generator;
27use ILIAS\Repository\RetrievalBase;
28use ilCtrl;
32
34{
35 use RetrievalBase;
36
37 protected array $question_data;
38
39 public function __construct(
40 protected int $obj_id,
41 protected ilCtrl $ctrl,
42 protected QuestionInfo $question_info
43 ) {
44 }
45
46 protected function getQuestionData(): array
47 {
48 if (isset($this->question_data)) {
50 }
51 $res = ilLMPageObject::queryQuestionsOfLearningModule($this->obj_id, '', '', 0, 0);
52 return $this->question_data = $res['set'];
53 }
54
55 public function getData(
56 array $fields,
57 ?Range $range = null,
58 ?Order $order = null,
59 array $filter = [],
60 array $parameters = []
61 ): Generator {
63
64 $question_data = $this->applyRange($question_data, $range);
65
66 $data = [];
67 foreach ($question_data as $datum) {
68 $data[] = [
69 'id' => $datum['question_id'],
70 'title' => $this->question_info->getGeneralQuestionProperties((int) $datum['question_id'])->getTitle(),
71 'page_title' => ilLMPageObject::_lookupTitle((int) $datum['page_id']),
72 'page_link' => $this->getLinkToPage((int) $datum['page_id'])
73 ];
74 }
75 yield from $data;
76 }
77
78 protected function getLinkToPage(int $page_id): string
79 {
80 $this->ctrl->setParameterByClass(ilLMPageObjectGUI::class, 'obj_id', $page_id);
81 $link = $this->ctrl->getLinkTargetByClass(ilLMPageObjectGUI::class, 'edit');
82 $this->ctrl->clearParameterByClass(ilLMPageObjectGUI::class, 'obj_id');
83 return $link;
84 }
85
86 public function count(
87 array $filter,
88 array $parameters
89 ): int {
90 return count($this->getQuestionData());
91 }
92
93 public function isFieldNumeric(string $field): bool
94 {
95 return $field === 'last_update';
96 }
97}
Both the subject and the direction need to be specified when expressing an order.
Definition: Order.php:29
A simple class to express a naive range of whole positive numbers.
Definition: Range.php:29
__construct(protected int $obj_id, protected ilCtrl $ctrl, protected QuestionInfo $question_info)
Definition: Retrieval.php:39
count(array $filter, array $parameters)
Definition: Retrieval.php:86
getData(array $fields, ?Range $range=null, ?Order $order=null, array $filter=[], array $parameters=[])
Definition: Retrieval.php:55
Class ilCtrl provides processing control methods.
static _lookupTitle(int $a_obj_id)
User Interface for Learning Module Page Objects Editing.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static queryQuestionsOfLearningModule(int $a_lm_id, string $a_order_field, string $a_order_dir, int $a_offset, int $a_limit)
Get questions of learning module.
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$res
Definition: ltiservices.php:69