19declare(strict_types=1);
40 public function init(): void
48 return [
'ed_insert_pcqst',
'empty_question',
'pc_qst'];
55 bool $abstract_only =
false
62 $global_tpl =
$DIC[
'tpl'];
64 $ui_factory =
$DIC[
'ui.factory'];
68 return mb_ereg_replace_callback(
69 self::ANSWER_FORM_PLACEHOLDER,
70 fn(array $matches):
string => $this->renderAnswerForm(
76 $this->pg_obj->getQuestion()->getAnswerFormPropertiesByIdString($matches[1]),
77 $this->pg_obj->getAttemptData()
84 public static function afterPageUpdate(
95 $dom_util =
$DIC->copage()->internal()->domain()->domUtil();
97 $question_repository = LocalDIC::dic()[Repository::class];
99 $uuid_factory =
new UuidFactory();
102 $question =
$page->getQuestion();
108 foreach ($dom_util->path($domdoc,
'//AnswerForm') as $node) {
109 $answer_form_id = $node->getAttribute(self::ANSWER_FORM_ID_ATTRIBUTE);
110 $answer_form = $question->getAnswerFormPropertiesByIdString($answer_form_id);
112 if ($answer_form ===
null && in_array($answer_form_id, $answer_form_mapping)) {
113 $old_answer_form_id = array_search($answer_form_id, $answer_form_mapping);
114 $old_answer_form = $question->getAnswerFormPropertiesByIdString(
118 if ($old_answer_form ===
null) {
119 $old_answer_form_uuid = $uuid_factory->fromString($answer_form_id);
120 $old_answer_form = $question_repository->getQuestionForAnswerFormId(
121 $old_answer_form_uuid
122 )->getAnswerFormPropertiesByIdString(
123 $old_answer_form_uuid
127 $question = $question->withAnswerFormProperties(
128 $old_answer_form->clone(
131 'new_question_id' => $question->getId(),
132 'answer_form_id' => $uuid_factory->fromString(
140 $answer_forms[] = $answer_form_id;
143 $page->setQuestion($question->withoutDeletedAnswerForms($answer_forms));
145 $question_repository->update(
146 [
$page->getQuestion()]
153 bool $self_ass =
true,
154 bool $clone_mobs =
false,
155 int $new_parent_id = 0,
159 $dom_util =
$DIC->copage()->internal()->domain()->domUtil();
162 if ($answer_form_mapping === []) {
166 foreach ($dom_util->path($domdoc,
'//AnswerForm') as $node) {
167 $old_answer_form_id = $node->getAttribute(self::ANSWER_FORM_ID_ATTRIBUTE);
168 if (isset($answer_form_mapping[$old_answer_form_id])) {
170 self::ANSWER_FORM_ID_ATTRIBUTE,
171 $answer_form_mapping[$old_answer_form_id]
180 $this->createInitialChildNode(
183 self::ANSWER_FORM_ELEMENT_TAG,
184 [self::ANSWER_FORM_ID_ATTRIBUTE => $answer_form_id->
toString()]
190 return $this->getChildNode()->attributes
191 ->getNamedItem(self::ANSWER_FORM_ID_ATTRIBUTE)->nodeValue;
194 private function renderAnswerForm(
197 UIFactory $ui_factory,
200 ?AnswerFormProperties $answer_form_properties,
203 if ($answer_form_properties === null) {
204 return $lng->txt(
'broken_answer_form');
208 $required_capabilities = $this->pg_obj->getRequiredCapabilities();
211 $answer_form_properties->getQuestionId()
212 )?->getAnswerFormResponse(
213 $answer_form_properties->getAnswerFormId()
217 $required_capabilities
218 ->getParticipantViewProvider()
219 ->getParticipantView($answer_form_properties)
225 $required_capabilities,
226 $this->pg_obj->getViewConfiguration(),
227 $answer_form_properties,
229 $answer_form_response
Builds a Color from either hex- or rgb values.
getResponseForQuestion(Uuid $question_id)
static setAnswerFormMapping(array $answer_form_mapping)
static getAnswerFormMapping()
2026-06-30, sk:This is awfull, but as there are statics used in the copy process this is the only way...
Content object of ilPageObject (see ILIAS DTD).
setType(string $a_type)
Set Type.
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
An entity that renders components to a string output.
readonly UIRenderer $ui_renderer
if(!file_exists('../ilias.ini.php'))