ILIAS  trunk Revision v12.0_alpha-1540-g00f839d5fa1
SelfAssQuestionRetrieval.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2023 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5declare(strict_types=1);
6
8
12use ILIAS\Repository\RetrievalBase;
18
24{
25 use RetrievalBase;
26
27 public function __construct(
28 protected InternalDomainService $domain,
29 protected int $pool_ref_id,
30 protected int $pool_obj_id
31 ) {
32 }
33
34 public function getData(
35 array $fields,
36 ?Range $range = null,
37 ?Order $order = null,
38 array $filter = [],
39 array $parameters = []
40 ): \Generator {
41 $data = $this->collectData();
42
43 // Apply ordering if specified
44 $data = $this->applyOrder($data, $order);
45
46 // Apply range (pagination) if specified
47 $data = $this->applyRange($data, $range);
48
49 foreach ($data as $row) {
50 yield $row;
51 }
52 }
53
54 public function count(
55 array $filter,
56 array $parameters
57 ): int {
58 return count($this->collectData());
59 }
60
61 protected function collectData(): array
62 {
63 $access = $this->domain->access();
64
66 $all_ids = array();
67 foreach ($all_types as $k => $v) {
68 $all_ids[] = $v["question_type_id"];
69 }
70
71 $questions = array();
72 if ($access->checkAccess("read", "", $this->pool_ref_id)) {
73 $questionList = new ilAssQuestionList(
74 $this->domain->database(),
75 $this->domain->lng(),
76 $this->domain->refinery(),
77 $this->domain->componentRepository()
78 );
79 $questionList->setParentObjId($this->pool_obj_id);
80 $questionList->load();
81
82 $data = $questionList->getQuestionDataArray();
83
84 foreach ($data as $d) {
85 // list only self assessment question types
86 if (in_array($d["question_type_fi"], $all_ids)) {
87 $d["id"] = $d["question_id"];
88 $questions[] = $d;
89 }
90 }
91 }
92 return $questions;
93 }
94
95 public function isFieldNumeric(string $field): bool
96 {
97 return $field === "question_id";
98 }
99}
Retrieval for self assessment questions from a pool.
__construct(protected InternalDomainService $domain, protected int $pool_ref_id, protected int $pool_obj_id)
getData(array $fields, ?Range $range=null, ?Order $order=null, array $filter=[], array $parameters=[])
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:36
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
static & _getSelfAssessmentQuestionTypes($all_tags=false)
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...