35 public function init(): void
39 $this->
lng = $DIC->language();
40 $this->
ctrl = $DIC->ctrl();
41 $this->
user = $DIC->user();
47 parent::setNode($a_node);
53 if (is_object($this->q_node)) {
54 $this->q_node->set_attribute(
"QRef", $a_questionreference);
60 if (is_object($this->q_node)) {
61 return $this->q_node->get_attribute(
"QRef");
73 $this->q_node = $this->dom->create_element(
"Question");
74 $this->q_node = $this->node->append_child($this->q_node);
75 $this->q_node->set_attribute(
"QRef",
"");
86 $duplicate_id = $question->copyObject(0, $question->getTitle());
88 $duplicate->setObjId(0);
92 $this->q_node->set_attribute(
"QRef",
"il__qst_" . $duplicate_id);
97 return array(
"ed_insert_pcqst",
"empty_question",
"pc_qst");
111 $ilDB = $DIC->database();
114 "DELETE FROM page_question WHERE page_parent_type = %s " .
115 " AND page_id = %s AND page_lang = %s",
116 array(
"text",
"integer",
"text"),
121 $nodes = $xpath->query(
'//Question');
123 foreach ($nodes as
$node) {
124 $q_ref = $node->getAttribute(
"QRef");
127 if (!($inst_id > 0)) {
130 $q_ids[$q_id] = $q_id;
134 foreach ($q_ids as $qid) {
139 "page_id" => [
"integer", $a_page->
getId()],
141 "question_id" => [
"integer", $qid]
153 $ilDB = $DIC->database();
156 "DELETE FROM page_question WHERE page_parent_type = %s " .
157 " AND page_id = %s AND page_lang = %s",
158 array(
"text",
"integer",
"text"),
164 string $a_parent_type,
170 $ilDB = $DIC->database();
172 $parent_type_array = explode(
':', $a_parent_type);
175 "SELECT * FROM page_question WHERE page_parent_type = %s " .
176 " AND page_id = %s AND page_lang = %s",
177 array(
"text",
"integer",
"text"),
178 array($parent_type_array[0], $a_page_id, $a_lang)
182 $q_ids[] = $rec[
"question_id"];
190 string $a_parent_type =
"" 194 $ilDB = $DIC->database();
197 "SELECT * FROM page_question " .
198 " WHERE question_id = " .
$ilDB->quote($a_q_id,
"integer")
200 while ($rec =
$ilDB->fetchAssoc($set)) {
201 if ($a_parent_type ==
"" || $rec[
"page_parent_type"] == $a_parent_type) {
202 return array(
"page_id" => $rec[
"page_id"],
"parent_type" => $rec[
"page_parent_type"]);
211 bool $a_abstract_only =
false 217 if ($this->
getPage()->getPageConfig()->getEnableSelfAssessment()) {
219 $q_ids = $this->
getPage()->getQuestionIds();
221 foreach ($q_ids as $q_id) {
224 if (is_object($q_gui->object) && !$q_gui->object->isComplete()) {
225 $a_output = str_replace(
226 "{{{{{Question;il__qst_" . $q_id .
"}}}}}",
227 "<i>" . $lng->
txt(
"cont_empty_question") .
"</i>",
237 if (!self::$initial_done) {
238 $a_output =
"<script>var ScormApi=null; var questions = new Array();</script>" . $a_output;
239 self::$initial_done =
true;
244 $qhtml = $this->
getPage()->getPageConfig()->getQuestionHTML();
247 if (!is_array($qhtml) || count($qhtml) == 0) {
249 $q_ids = $this->
getPage()->getQuestionIds();
251 foreach ($q_ids as $k) {
252 $a_output = str_replace(
"{{{{{Question;il__qst_$k" .
"}}}}}",
" " . $lng->
txt(
"copg_questions_not_supported_here"), $a_output);
258 if (is_array($qhtml)) {
259 foreach ($qhtml as $k => $h) {
260 $a_output = str_replace(
"{{{{{Question;il__qst_$k" .
"}}}}}",
" " . $h, $a_output);
272 self::$initial_done =
false;
279 if ($this->
getPage()->getPageConfig()->getEnableSelfAssessment()) {
280 $js_files[] =
"./Modules/Scorm2004/scripts/questions/pure.js";
281 $js_files[] =
"./Modules/Scorm2004/scripts/questions/question_handling.js";
282 $js_files[] =
'Modules/TestQuestionPool/js/ilAssMultipleChoice.js';
283 $js_files[] =
"Modules/TestQuestionPool/js/ilMatchingQuestion.js";
285 foreach ($this->
getPage()->getQuestionIds() as $qId) {
287 $js_files = array_merge($js_files, $qstGui->getPresentationJavascripts());
292 && $a_mode !=
"offline") {
293 $js_files[] =
"./Services/COPage/js/ilCOPageQuestionHandler.js";
301 if ($this->
getPage()->getPageConfig()->getEnableSelfAssessment()) {
302 return array(
"./Modules/Scorm2004/templates/default/question_handling.css",
303 "Modules/TestQuestionPool/templates/default/test_javascript.css");
315 if ($this->
getPage()->getPageConfig()->getEnableSelfAssessment()) {
317 && $a_mode !=
"offline" && $a_mode !==
"edit") {
318 $ilCtrl->setParameterByClass(strtolower(get_class($this->
getPage())) .
"gui",
"page_id", $this->
getPage()->
getId());
319 $url = $ilCtrl->getLinkTargetByClass(strtolower(get_class($this->
getPage())) .
"gui",
"processAnswer",
"",
true,
false);
320 $code[] =
"ilCOPageQuestionHandler.initCallback('" .
$url .
"');";
323 if ($this->
getPage()->getPageConfig()->getDisableDefaultQuestionFeedback()) {
324 $code[] =
"ilias.questions.default_feedback = false;";
327 $code[] = self::getJSTextInitCode($this->
getPage()->getPageConfig()->getLocalizationLanguage()) .
' il.COPagePres.updateQuestionOverviews();';
330 $q_ids = $this->
getPage()->getQuestionIds();
333 foreach ($q_ids as $q_id) {
334 $code[] =
"renderILQuestion$q_id();";
338 $get_stored_tries = $this->
getPage()->getPageConfig()->getUseStoredQuestionTries();
339 if ($get_stored_tries) {
340 if (count($q_ids) > 0) {
341 foreach ($q_ids as $q_id) {
343 $code[] =
"ilias.questions.initAnswer(" . $q_id .
", " . (
int) ($as[
"try"] ?? 0) .
", " . ($as[
"passed"] ?
"true" :
"null") .
");";
357 $lng = $DIC->language();
361 $a_lang =
$ilUser->getLanguage();
366 ilias.questions.txt.wrong_answers = "' . $lng->
txtlng(
"content",
"cont_wrong_answers", $a_lang) .
'"; 367 ilias.questions.txt.wrong_answers_single = "' . $lng->
txtlng(
"content",
"cont_wrong_answers_single", $a_lang) .
'"; 368 ilias.questions.txt.tries_remaining = "' . $lng->
txtlng(
"content",
"cont_tries_remaining", $a_lang) .
'"; 369 ilias.questions.txt.please_try_again = "' . $lng->
txtlng(
"content",
"cont_please_try_again", $a_lang) .
'"; 370 ilias.questions.txt.all_answers_correct = "' . $lng->
txtlng(
"content",
"cont_all_answers_correct", $a_lang) .
'"; 371 ilias.questions.txt.enough_answers_correct = "' . $lng->
txtlng(
"content",
"cont_enough_answers_correct", $a_lang) .
'"; 372 ilias.questions.txt.nr_of_tries_exceeded = "' . $lng->
txtlng(
"content",
"cont_nr_of_tries_exceeded", $a_lang) .
'"; 373 ilias.questions.txt.correct_answers_separator = "' . $lng->
txtlng(
"assessment",
"or", $a_lang) .
'"; 374 ilias.questions.txt.correct_answers_shown = "' . $lng->
txtlng(
"content",
"cont_correct_answers_shown", $a_lang) .
'"; 375 ilias.questions.txt.correct_answers_also = "' . $lng->
txtlng(
"content",
"cont_correct_answers_also", $a_lang) .
'"; 376 ilias.questions.txt.correct_answer_also = "' . $lng->
txtlng(
"content",
"cont_correct_answer_also", $a_lang) .
'"; 377 ilias.questions.txt.ov_all_correct = "' . $lng->
txtlng(
"content",
"cont_ov_all_correct", $a_lang) .
'"; 378 ilias.questions.txt.ov_some_correct = "' . $lng->
txtlng(
"content",
"cont_ov_some_correct", $a_lang) .
'"; 379 ilias.questions.txt.ov_wrong_answered = "' . $lng->
txtlng(
"content",
"cont_ov_wrong_answered", $a_lang) .
'"; 380 ilias.questions.txt.please_select = "' . $lng->
txtlng(
"content",
"cont_please_select", $a_lang) .
'"; 381 ilias.questions.txt.ov_preview = "' . $lng->
txtlng(
"content",
"cont_ov_preview", $a_lang) .
'"; 382 ilias.questions.txt.submit_answers = "' . $lng->
txtlng(
"content",
"cont_submit_answers", $a_lang) .
'"; 383 ilias.questions.refresh_lang(); 388 bool $a_no_interaction,
391 $q_ids = $this->
getPage()->getQuestionIds();
393 if (count($q_ids) > 0) {
394 foreach ($q_ids as $q_id) {
397 if ($a_mode ==
"offline") {
398 if ($this->
getPage()->getParentType() ==
"sahs") {
399 $image_path =
"./objects/";
401 if ($this->
getPage()->getParentType() ==
"lm") {
402 $image_path =
"./assessment/0/" . $q_id .
"/images/";
405 $js[$q_id] = $q_exporter->exportQuestion($q_id, $image_path, $a_mode);
setType(string $a_type)
Set Type.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static bool $initial_done
init()
Init page content component.
getQuestionJsOfPage(bool $a_no_interaction, string $a_mode)
txtlng(string $a_module, string $a_topic, string $a_language)
gets the text for a given topic in a given language if the topic is not in the list, the topic itself with "-" will be returned
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static _extractObjIdOfTarget(string $a_target)
Extract object id out of target.
getCssFiles(string $a_mode)
copyPoolQuestionIntoPage(string $a_q_id, string $a_hier_id)
Copy question from pool into page.
setNode(php4DOMElement $a_node)
static _getPageForQuestionId(int $a_q_id, string $a_parent_type="")
static getAnswerStatus( $a_q_id, int $a_user_id=0)
modifyPageContentPostXsl(string $a_output, string $a_mode, bool $a_abstract_only=false)
static _getQuestionGUI(string $question_type='', int $question_id=-1)
Creates a question gui representation and returns the alias to the question gui.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getOnloadCode(string $a_mode)
static _extractInstOfTarget(string $a_target)
Extract installation id out of target.
static getJSTextInitCode(string $a_lang)
Get js txt init code.
static instantiateQuestion(int $question_id)
static afterPageUpdate(ilPageObject $a_page, DOMDocument $a_domdoc, string $a_xml, bool $a_creation)
After page has been updated (or created)
insertContent(ilPageContent $a_cont_obj, string $a_pos, int $a_mode=IL_INSERT_AFTER, string $a_pcid="", bool $remove_placeholder=true)
insert a content node before/after a sibling or as first child of a parent
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
create(ilPageObject $a_pg_obj, string $a_hier_id, string $a_pc_id="")
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
createPageContentNode(bool $a_set_this_node=true)
Create page content node (always use this method first when adding a new element) ...
getJavascriptFiles(string $a_mode)
setQuestionReference(string $a_questionreference)
static resetInitialState()
Reset initial state (for exports)
static beforePageDelete(ilPageObject $a_page)
static _getQuestionIdsForPage(string $a_parent_type, int $a_page_id, string $a_lang="-")
static questionsJS(array $a_qids=null)