ILIAS  release_8 Revision v8.24
class.ilQuestionEditGUI.php
Go to the documentation of this file.
1<?php
2
31{
32 private \ilGlobalTemplateInterface $main_tpl;
33 private \ILIAS\TestQuestionPool\InternalRequestService $request;
37 private ?int $questionid = null;
38 private ?int $poolrefid = null;
39 private ?int $poolobjid = null;
40 private ?string $questiontype = null;
42 private array $new_id_listeners;
44 private bool $selfassessmenteditingmode = false;
45 private ?int $defaultnroftries = null;
46 private ?ilPageConfig $page_config = null;
47
48 public function __construct()
49 {
50 global $DIC;
51
52 $this->main_tpl = $DIC->ui()->mainTemplate();
53 $this->ctrl = $DIC['ilCtrl'];
54 $this->request = $DIC->testQuestionPool()->internal()->request();
55 $this->lng = $DIC->language();
56 $this->rbac_system = $DIC->rbac()->system();
57
58 if ($this->request->raw('qpool_ref_id')) {
59 $this->setPoolRefId($this->request->raw('qpool_ref_id'));
60 } elseif ($this->request->raw('qpool_obj_id')) {
61 $this->setPoolObjId($this->request->raw('qpool_obj_id'));
62 }
63 $this->setQuestionId($this->request->getQuestionId());
64 $this->setQuestionType($this->request->raw('q_type'));
65 $this->lng->loadLanguageModule('assessment');
66
67 $this->ctrl->saveParameter($this, ['qpool_ref_id', 'qpool_obj_id', 'q_id', 'q_type']);
68
69
70 $this->new_id_listeners = [];
71 $this->new_id_listener_cnt = 0;
72 }
73
74 public function setSelfAssessmentEditingMode(bool $a_selfassessmenteditingmode): void
75 {
76 $this->selfassessmenteditingmode = $a_selfassessmenteditingmode;
77 }
78
79 public function getSelfAssessmentEditingMode(): bool
80 {
82 }
83
84 public function setDefaultNrOfTries(?int $a_defaultnroftries): void
85 {
86 $this->defaultnroftries = $a_defaultnroftries;
87 }
88
89 public function getDefaultNrOfTries(): ?int
90 {
92 }
93
94 public function setPageConfig(ilPageConfig $a_val): void
95 {
96 $this->page_config = $a_val;
97 }
98
99 public function getPageConfig(): ?ilPageConfig
100 {
101 return $this->page_config;
102 }
103
104 public function addNewIdListener(object $a_object, string $a_method, string $a_parameters = ''): void
105 {
107 $this->new_id_listeners[$cnt]['object'] = $a_object;
108 $this->new_id_listeners[$cnt]['method'] = $a_method;
109 $this->new_id_listeners[$cnt]['parameters'] = $a_parameters;
110 $this->new_id_listener_cnt++;
111 }
112
113 public function executeCommand(): string
114 {
115 $cmd = $this->ctrl->getCmd();
116 $next_class = $this->ctrl->getNextClass();
117
118 switch ($next_class) {
119 default:
121 $this->getQuestionType() ?? '',
122 $this->getQuestionId()
123 );
124 $q_gui->object->setSelfAssessmentEditingMode(
126 );
127 if ($this->getDefaultNrOfTries() > 0) {
128 $q_gui->object->setDefaultNrOfTries(
129 $this->getDefaultNrOfTries()
130 );
131 }
132
133 if (is_object($this->page_config)) {
134 $q_gui->object->setPreventRteUsage($this->getPageConfig()->getPreventRteUsage());
135 }
136 $q_gui->object->setObjId((int) $this->getPoolObjId());
137
138 for ($i = 0; $i < $this->new_id_listener_cnt; $i++) {
139 $object = $this->new_id_listeners[$i]['object'];
140 $method = $this->new_id_listeners[$i]['method'];
141 $parameters = $this->new_id_listeners[$i]['parameters'];
142 $q_gui->addNewIdListener(
143 $object,
144 $method,
145 $parameters
146 );
147 }
148
149 $count = $q_gui->object->usageNumber();
150 if ($count > 0) {
151 if ($this->rbac_system->checkAccess('write', $this->getPoolRefId())) {
152 $this->main_tpl->setOnScreenMessage('info', sprintf($this->lng->txt('qpl_question_is_in_use'), $count));
153 }
154 }
155 $this->ctrl->setCmdClass(get_class($q_gui));
156 $ret = (string) $this->ctrl->forwardCommand($q_gui);
157 break;
158 }
159
160 return $ret;
161 }
162
163 public function setQuestionId(?int $a_questionid): void
164 {
165 $this->questionid = $a_questionid;
166 $this->ctrl->setParameter($this, 'q_id', $this->questionid);
167 }
168
169 public function getQuestionId(): ?int
170 {
171 return $this->questionid;
172 }
173
174 public function setPoolRefId(?int $a_poolrefid): void
175 {
176 $this->poolrefid = $a_poolrefid;
177 $this->ctrl->setParameter($this, 'qpool_ref_id', $this->poolrefid);
178
179 if ($this->getPoolRefId() > 0) {
181 } else {
182 $this->setPoolObjId(null);
183 }
184 }
185
186 public function getPoolRefId(): ?int
187 {
188 return $this->poolrefid;
189 }
190
191 public function setPoolObjId(?int $a_poolobjid): void
192 {
193 $this->poolobjid = $a_poolobjid;
194 $this->ctrl->setParameter($this, 'qpool_obj_id', $this->poolobjid);
195 }
196
197 public function getPoolObjId(): ?int
198 {
199 return $this->poolobjid;
200 }
201
202 public function setQuestionType(?string $a_questiontype): void
203 {
204 $this->questiontype = $a_questiontype;
205 $this->ctrl->setParameter($this, 'q_type', $this->questiontype);
206 }
207
208 public function getQuestionType(): ?string
209 {
210 return $this->questiontype;
211 }
212}
static _getQuestionGUI(string $question_type='', int $question_id=-1)
Creates a question gui representation and returns the alias to the question gui.
language handling
static _lookupObjId(int $ref_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setSelfAssessmentEditingMode(bool $a_selfassessmenteditingmode)
setPoolRefId(?int $a_poolrefid)
setQuestionType(?string $a_questiontype)
setQuestionId(?int $a_questionid)
setPageConfig(ilPageConfig $a_val)
ILIAS TestQuestionPool InternalRequestService $request
addNewIdListener(object $a_object, string $a_method, string $a_parameters='')
setPoolObjId(?int $a_poolobjid)
setDefaultNrOfTries(?int $a_defaultnroftries)
ilGlobalTemplateInterface $main_tpl
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$i
Definition: metadata.php:41