6 require_once(
"./Services/COPage/classes/class.ilPageContent.php");
38 parent::setNode($a_node);
39 $this->q_node =& $a_node->first_child();
49 if (is_object($this->q_node))
51 $this->q_node->set_attribute(
"QRef", $a_questionreference);
62 if (is_object($this->q_node))
64 return $this->q_node->get_attribute(
"QRef", $a_questionreference);
72 function create(&$a_pg_obj, $a_hier_id)
76 $this->q_node = $this->dom->create_element(
"Question");
77 $this->q_node = $this->node->append_child($this->q_node);
78 $this->q_node->set_attribute(
"QRef",
"");
89 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
90 include_once
"./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
92 $duplicate_id = $question->copyObject(0, $question->getTitle());
94 $duplicate->setObjId(0);
143 require_once
'Modules/TestQuestionPool/classes/questions/class.ilAssSelfAssessmentQuestionFormatter.php';
148 $this->q_node->set_attribute(
"QRef",
"il__qst_".$duplicate_id);
157 return array(
"ed_insert_pcqst",
"empty_question",
"pc_qst");
172 include_once(
"./Services/Link/classes/class.ilInternalLink.php");
174 $ilDB->manipulateF(
"DELETE FROM page_question WHERE page_parent_type = %s ".
175 " AND page_id = %s AND page_lang = %s", array(
"text",
"integer",
"text"),
176 array($a_page->getParentType(), $a_page->getId(), $a_page->getLanguage()));
178 $xpath =
new DOMXPath($a_domdoc);
179 $nodes = $xpath->query(
'//Question');
181 foreach ($nodes as
$node)
183 $q_ref = $node->getAttribute(
"QRef");
191 $q_ids[$q_id] = $q_id;
195 foreach($q_ids as $qid)
197 $ilDB->manipulateF(
"INSERT INTO page_question (page_parent_type, page_id, page_lang, question_id)".
198 " VALUES (%s,%s,%s,%s)",
199 array(
"text",
"integer",
"text",
"integer"),
200 array($a_page->getParentType(), $a_page->getId(), $a_page->getLanguage(), $qid));
214 $ilDB->manipulateF(
"DELETE FROM page_question WHERE page_parent_type = %s ".
215 " AND page_id = %s AND page_lang = %s", array(
"text",
"integer",
"text"),
216 array($a_page->getParentType(), $a_page->getId(), $a_page->getLanguage()));
226 $res = $ilDB->queryF(
"SELECT * FROM page_question WHERE page_parent_type = %s ".
227 " AND page_id = %s AND page_lang = %s",
228 array(
"text",
"integer",
"text"),
229 array($a_parent_type, $a_page_id, $a_lang));
231 while ($rec = $ilDB->fetchAssoc(
$res))
233 $q_ids[] = $rec[
"question_id"];
249 $set = $ilDB->query(
"SELECT * FROM page_question ".
250 " WHERE question_id = ".$ilDB->quote($a_q_id,
"integer")
252 while ($rec = $ilDB->fetchAssoc($set))
254 if ($a_parent_type ==
"" || $rec[
"page_parent_type"] == $a_parent_type)
256 return array(
"page_id" => $rec[
"page_id"],
"parent_type" => $rec[
"page_parent_type"]);
272 if ($this->
getPage()->getPageConfig()->getEnableSelfAssessment())
275 $q_ids = $this->
getPage()->getQuestionIds();
278 include_once
"./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
279 foreach($q_ids as $q_id)
283 if(is_object($q_gui->object) && !$q_gui->object->isComplete())
285 $a_output = str_replace(
"{{{{{Question;il__qst_".$q_id.
"}}}}}",
286 "<i>".$lng->txt(
"cont_empty_question").
"</i>",
294 require_once
'./Modules/Scorm2004/classes/class.ilQuestionExporter.php';
295 $a_output =
"<script>".ilQuestionExporter::questionsJS($q_ids).
"</script>".$a_output;
296 if(!self::$initial_done)
298 $a_output =
"<script>var ScormApi=null; var questions = new Array();</script>".$a_output;
299 self::$initial_done =
true;
306 $qhtml = $this->
getPage()->getPageConfig()->getQuestionHTML();
309 if (is_array($qhtml))
311 foreach ($qhtml as $k =>
$h)
313 $a_output = str_replace(
"{{{{{Question;il__qst_$k".
"}}}}}",
" ".
$h, $a_output);
325 self::$initial_done =
false;
335 if ($this->
getPage()->getPageConfig()->getEnableSelfAssessment())
337 $js_files[] =
"./Modules/Scorm2004/scripts/questions/pure.js";
338 $js_files[] =
"./Modules/Scorm2004/scripts/questions/question_handling.js";
339 $js_files[] =
"Modules/TestQuestionPool/js/ilMatchingQuestion.js";
343 && $a_mode !=
"offline")
345 $js_files[] =
"./Services/COPage/js/ilCOPageQuestionHandler.js";
356 if ($this->
getPage()->getPageConfig()->getEnableSelfAssessment())
358 return array(
"./Modules/Scorm2004/templates/default/question_handling.css",
359 "Modules/TestQuestionPool/templates/default/test_javascript.css");
373 if ($this->
getPage()->getPageConfig()->getEnableSelfAssessment())
376 && $a_mode !=
"offline")
378 $ilCtrl->setParameterByClass(strtolower(get_class($this->
getPage())).
"gui",
"page_id", $this->
getPage()->getId());
379 $url = $ilCtrl->getLinkTargetByClass(strtolower(get_class($this->
getPage())).
"gui",
"processAnswer",
"",
true,
false);
380 $code[] =
"ilCOPageQuestionHandler.initCallback('".$url.
"');";
383 if ($this->
getPage()->getPageConfig()->getDisableDefaultQuestionFeedback())
385 $code[] =
"ilias.questions.default_feedback = false;";
388 $code[] = self::getJSTextInitCode($this->
getPage()->getPageConfig()->getLocalizationLanguage()).
' il.COPagePres.updateQuestionOverviews();';
391 $get_stored_tries = $this->
getPage()->getPageConfig()->getUseStoredQuestionTries();
392 if ($get_stored_tries)
394 $q_ids = $this->
getPage()->getQuestionIds();
395 if (count($q_ids) > 0)
397 foreach ($q_ids as $q_id)
399 include_once(
"./Services/COPage/classes/class.ilPageQuestionProcessor.php");
401 $code[] =
"ilias.questions.initAnswer(".$q_id.
", ".(int) $as[
"try"].
", ".($as[
"passed"] ?
"true" :
"null").
");";
420 $a_lang = $ilUser->getLanguage();
425 ilias.questions.txt.wrong_answers = "'.$lng->txtlng(
"content",
"cont_wrong_answers", $a_lang).
'"; 426 ilias.questions.txt.wrong_answers_single = "'.$lng->txtlng(
"content",
"cont_wrong_answers_single", $a_lang).
'"; 427 ilias.questions.txt.tries_remaining = "'.$lng->txtlng(
"content",
"cont_tries_remaining", $a_lang).
'"; 428 ilias.questions.txt.please_try_again = "'.$lng->txtlng(
"content",
"cont_please_try_again", $a_lang).
'"; 429 ilias.questions.txt.all_answers_correct = "'.$lng->txtlng(
"content",
"cont_all_answers_correct", $a_lang).
'"; 430 ilias.questions.txt.enough_answers_correct = "'.$lng->txtlng(
"content",
"cont_enough_answers_correct", $a_lang).
'"; 431 ilias.questions.txt.nr_of_tries_exceeded = "'.$lng->txtlng(
"content",
"cont_nr_of_tries_exceeded", $a_lang).
'"; 432 ilias.questions.txt.correct_answers_shown = "'.$lng->txtlng(
"content",
"cont_correct_answers_shown", $a_lang).
'"; 433 ilias.questions.txt.correct_answers_also = "'.$lng->txtlng(
"content",
"cont_correct_answers_also", $a_lang).
'"; 434 ilias.questions.txt.correct_answer_also = "'.$lng->txtlng(
"content",
"cont_correct_answer_also", $a_lang).
'"; 435 ilias.questions.txt.ov_all_correct = "'.$lng->txtlng(
"content",
"cont_ov_all_correct", $a_lang).
'"; 436 ilias.questions.txt.ov_some_correct = "'.$lng->txtlng(
"content",
"cont_ov_some_correct", $a_lang).
'"; 437 ilias.questions.txt.ov_wrong_answered = "'.$lng->txtlng(
"content",
"cont_ov_wrong_answered", $a_lang).
'"; 438 ilias.questions.txt.please_select = "'.$lng->txtlng(
"content",
"cont_please_select", $a_lang).
'"; 439 ilias.questions.txt.ov_preview = "'.$lng->txtlng(
"content",
"cont_ov_preview", $a_lang).
'"; 440 ilias.questions.refresh_lang(); 450 require_once
'./Modules/Scorm2004/classes/class.ilQuestionExporter.php';
451 $q_ids = $this->
getPage()->getQuestionIds();
453 if (count($q_ids) > 0)
455 foreach ($q_ids as $q_id)
459 if ($a_mode ==
"offline")
461 if ($this->
getPage()->getParentType() ==
"sahs")
463 $image_path =
"./objects/";
465 if ($this->
getPage()->getParentType() ==
"lm")
467 $image_path =
"./assessment/0/".$q_id.
"/images/";
471 $js[$q_id] = $q_exporter->exportQuestion($q_id, $image_path, $a_mode);
static getJSTextInitCode($a_lang)
Get js txt init code.
create(&$a_pg_obj, $a_hier_id)
Create Question Element.
getQuestionJsOfPage($a_no_interaction, $a_mode)
Get question js.
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
Scorm 2004 Question Exporter.
init()
Init page content component.
static _getQuestionIdsForPage($a_parent_type, $a_page_id, $a_lang="-")
Get all questions of a page.
static beforePageDelete($a_page)
Before page is being deleted.
setType($a_type)
Set Type.
_getPageForQuestionId($a_q_id, $a_parent_type="")
Get page for question id.
static getLangVars()
Get lang vars needed for editing.
_extractObjIdOfTarget($a_target)
Extract object id out of target.
static getAnswerStatus($a_q_id, $a_user_id=0)
Get statistics for question.
getJavascriptFiles($a_mode)
Get Javascript files.
_extractInstOfTarget($a_target)
Extract installation id out of target.
& _getQuestionGUI($question_type, $question_id=-1)
Creates a question gui representation and returns the alias to the question gui note: please do not u...
getOnloadCode($a_mode)
Get on load code.
getCssFiles($a_mode)
Get css files.
setNode(&$a_node)
Set node.
static afterPageUpdate($a_page, DOMDocument $a_domdoc, $a_xml, $a_creation)
After page has been updated (or created)
copyPoolQuestionIntoPage($a_q_id, $a_hier_id)
Copy question from pool into page.
modifyPageContentPostXsl($a_output, $a_mode)
Modify page content after xsl.
static resetInitialState()
Reset initial state (for exports)
createPageContentNode($a_set_this_node=true)
Create page content node (always use this method first when adding a new element) ...
setQuestionReference($a_questionreference)
Set Question Reference.
getQuestionReference()
Get Question Reference.