6require_once(
"./Services/COPage/classes/class.ilPageContent.php");
 
   47        $this->lng = 
$DIC->language();
 
   48        $this->ctrl = 
$DIC->ctrl();
 
   49        $this->
user = $DIC->user();
 
   58        parent::setNode($a_node);               
 
   59        $this->q_node = $a_node->first_child();         
 
   69        if (is_object($this->q_node)) {
 
   70            $this->q_node->set_attribute(
"QRef", $a_questionreference);
 
   81        if (is_object($this->q_node)) {
 
   82            return $this->q_node->get_attribute(
"QRef", $a_questionreference);
 
   90    public function create(&$a_pg_obj, $a_hier_id)
 
   94        $this->q_node = $this->dom->create_element(
"Question");
 
   95        $this->q_node = $this->node->append_child($this->q_node);
 
   96        $this->q_node->set_attribute(
"QRef", 
"");
 
  107        include_once 
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
 
  108        include_once 
"./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
 
  110        $duplicate_id = $question->copyObject(0, $question->getTitle());
 
  112        $duplicate->setObjId(0);
 
  161        require_once 
'Modules/TestQuestionPool/classes/questions/class.ilAssSelfAssessmentQuestionFormatter.php';
 
  166        $this->q_node->set_attribute(
"QRef", 
"il__qst_" . $duplicate_id);
 
  175        return array(
"ed_insert_pcqst", 
"empty_question", 
"pc_qst");
 
  186    public static function afterPageUpdate($a_page, DOMDocument $a_domdoc, $a_xml, $a_creation)
 
  192        include_once(
"./Services/Link/classes/class.ilInternalLink.php");
 
  195            "DELETE FROM page_question WHERE page_parent_type = %s " .
 
  196            " AND page_id = %s AND page_lang = %s",
 
  197            array(
"text", 
"integer", 
"text"),
 
  198            array($a_page->getParentType(), $a_page->getId(), $a_page->getLanguage())
 
  201        $xpath = 
new DOMXPath($a_domdoc);
 
  202        $nodes = $xpath->query(
'//Question');
 
  204        foreach ($nodes as 
$node) {
 
  205            $q_ref = 
$node->getAttribute(
"QRef");
 
  208            if (!($inst_id > 0)) {
 
  211                    $q_ids[$q_id] = $q_id;
 
  215        foreach ($q_ids as $qid) {
 
  217                "INSERT INTO page_question (page_parent_type, page_id, page_lang, question_id)" .
 
  218                " VALUES (%s,%s,%s,%s)",
 
  219                array(
"text", 
"integer", 
"text", 
"integer"),
 
  220                array($a_page->getParentType(), $a_page->getId(), $a_page->getLanguage(), $qid)
 
  237            "DELETE FROM page_question WHERE page_parent_type = %s " .
 
  238            " AND page_id = %s AND page_lang = %s",
 
  239            array(
"text", 
"integer", 
"text"),
 
  240            array($a_page->getParentType(), $a_page->getId(), $a_page->getLanguage())
 
  254            "SELECT * FROM page_question WHERE page_parent_type = %s " .
 
  255            " AND page_id = %s AND page_lang = %s",
 
  256            array(
"text", 
"integer", 
"text"),
 
  257            array($a_parent_type, $a_page_id, $a_lang)
 
  261            $q_ids[] = $rec[
"question_id"];
 
  280            "SELECT * FROM page_question " .
 
  281            " WHERE question_id = " . 
$ilDB->quote($a_q_id, 
"integer")
 
  283        while ($rec = 
$ilDB->fetchAssoc($set)) {
 
  284            if ($a_parent_type == 
"" || $rec[
"page_parent_type"] == $a_parent_type) {
 
  285                return array(
"page_id" => $rec[
"page_id"], 
"parent_type" => $rec[
"page_parent_type"]);
 
  300        if ($this->
getPage()->getPageConfig()->getEnableSelfAssessment()) {
 
  302            $q_ids = $this->
getPage()->getQuestionIds();
 
  303            if (
sizeof($q_ids)) {
 
  304                include_once 
"./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
 
  305                foreach ($q_ids as $q_id) {
 
  308                    if (is_object($q_gui->object) && !$q_gui->object->isComplete()) {
 
  309                        $a_output = str_replace(
 
  310                            "{{{{{Question;il__qst_" . $q_id . 
"}}}}}",
 
  311                            "<i>" . 
$lng->txt(
"cont_empty_question") . 
"</i>",
 
  320                require_once 
'./Modules/Scorm2004/classes/class.ilQuestionExporter.php';
 
  322                if (!self::$initial_done) {
 
  323                    $a_output = 
"<script>var ScormApi=null; var questions = new Array();</script>" . $a_output;
 
  324                    self::$initial_done = 
true;
 
  329            $qhtml = $this->
getPage()->getPageConfig()->getQuestionHTML();
 
  332            if (!is_array($qhtml) || count($qhtml) == 0) {
 
  334                $q_ids = $this->
getPage()->getQuestionIds();
 
  335                if (
sizeof($q_ids)) {
 
  336                    foreach ($q_ids as $k) {
 
  337                        $a_output = str_replace(
"{{{{{Question;il__qst_$k" . 
"}}}}}", 
" " . 
$lng->txt(
"copg_questions_not_supported_here"), $a_output);
 
  343        if (is_array($qhtml)) {
 
  344            foreach ($qhtml as $k => $h) {
 
  345                $a_output = str_replace(
"{{{{{Question;il__qst_$k" . 
"}}}}}", 
" " . $h, $a_output);
 
  357        self::$initial_done = 
false;
 
  367        if ($this->
getPage()->getPageConfig()->getEnableSelfAssessment()) {
 
  368            $js_files[] = 
"./Modules/Scorm2004/scripts/questions/pure.js";
 
  369            $js_files[] = 
"./Modules/Scorm2004/scripts/questions/question_handling.js";
 
  370            $js_files[] = 
'Modules/TestQuestionPool/js/ilAssMultipleChoice.js';
 
  371            $js_files[] = 
"Modules/TestQuestionPool/js/ilMatchingQuestion.js";
 
  373            foreach ($this->
getPage()->getQuestionIds() as $qId) {
 
  375                $js_files = array_merge($js_files, $qstGui->getPresentationJavascripts());
 
  380            && $a_mode != 
"offline") {
 
  381            $js_files[] = 
"./Services/COPage/js/ilCOPageQuestionHandler.js";
 
  392        if ($this->
getPage()->getPageConfig()->getEnableSelfAssessment()) {
 
  393            return array(
"./Modules/Scorm2004/templates/default/question_handling.css",
 
  394                "Modules/TestQuestionPool/templates/default/test_javascript.css",
 
  395                'Modules/Test/templates/default/ta.css');
 
  410        if ($this->
getPage()->getPageConfig()->getEnableSelfAssessment()) {
 
  412                && $a_mode != 
"offline") {
 
  413                $ilCtrl->setParameterByClass(strtolower(get_class($this->
getPage())) . 
"gui", 
"page_id", $this->
getPage()->getId());
 
  414                $url = 
$ilCtrl->getLinkTargetByClass(strtolower(get_class($this->
getPage())) . 
"gui", 
"processAnswer", 
"", 
true, 
false);
 
  415                $code[] = 
"ilCOPageQuestionHandler.initCallback('" . 
$url . 
"');";
 
  418            if ($this->
getPage()->getPageConfig()->getDisableDefaultQuestionFeedback()) {
 
  419                $code[] = 
"ilias.questions.default_feedback = false;";
 
  425        $get_stored_tries = $this->
getPage()->getPageConfig()->getUseStoredQuestionTries();
 
  426        if ($get_stored_tries) {
 
  427            $q_ids = $this->
getPage()->getQuestionIds();
 
  428            if (count($q_ids) > 0) {
 
  429                foreach ($q_ids as $q_id) {
 
  430                    include_once(
"./Services/COPage/classes/class.ilPageQuestionProcessor.php");
 
  432                    $code[] = 
"ilias.questions.initAnswer(" . $q_id . 
", " . (int) $as[
"try"] . 
", " . ($as[
"passed"] ? 
"true" : 
"null") . 
");";
 
  453            $a_lang = 
$ilUser->getLanguage();
 
  458                        ilias.questions.txt.wrong_answers = "' . 
$lng->txtlng(
"content", 
"cont_wrong_answers", $a_lang) . 
'"; 
  459                        ilias.questions.txt.wrong_answers_single = "' . 
$lng->txtlng(
"content", 
"cont_wrong_answers_single", $a_lang) . 
'"; 
  460                        ilias.questions.txt.tries_remaining = "' . 
$lng->txtlng(
"content", 
"cont_tries_remaining", $a_lang) . 
'"; 
  461                        ilias.questions.txt.please_try_again = "' . 
$lng->txtlng(
"content", 
"cont_please_try_again", $a_lang) . 
'"; 
  462                        ilias.questions.txt.all_answers_correct = "' . 
$lng->txtlng(
"content", 
"cont_all_answers_correct", $a_lang) . 
'"; 
  463                        ilias.questions.txt.enough_answers_correct = "' . 
$lng->txtlng(
"content", 
"cont_enough_answers_correct", $a_lang) . 
'"; 
  464                        ilias.questions.txt.nr_of_tries_exceeded = "' . 
$lng->txtlng(
"content", 
"cont_nr_of_tries_exceeded", $a_lang) . 
'"; 
  465                        ilias.questions.txt.correct_answers_separator = "' . 
$lng->txtlng(
"assessment", 
"or", $a_lang) . 
'"; 
  466                        ilias.questions.txt.correct_answers_shown = "' . 
$lng->txtlng(
"content", 
"cont_correct_answers_shown", $a_lang) . 
'"; 
  467                        ilias.questions.txt.correct_answers_also = "' . 
$lng->txtlng(
"content", 
"cont_correct_answers_also", $a_lang) . 
'"; 
  468                        ilias.questions.txt.correct_answer_also = "' . 
$lng->txtlng(
"content", 
"cont_correct_answer_also", $a_lang) . 
'"; 
  469                        ilias.questions.txt.ov_all_correct = "' . 
$lng->txtlng(
"content", 
"cont_ov_all_correct", $a_lang) . 
'"; 
  470                        ilias.questions.txt.ov_some_correct = "' . 
$lng->txtlng(
"content", 
"cont_ov_some_correct", $a_lang) . 
'"; 
  471                        ilias.questions.txt.ov_wrong_answered = "' . 
$lng->txtlng(
"content", 
"cont_ov_wrong_answered", $a_lang) . 
'"; 
  472                        ilias.questions.txt.please_select = "' . 
$lng->txtlng(
"content", 
"cont_please_select", $a_lang) . 
'"; 
  473                        ilias.questions.txt.ov_preview = "' . 
$lng->txtlng(
"content", 
"cont_ov_preview", $a_lang) . 
'"; 
  474                        ilias.questions.txt.submit_answers = "' . 
$lng->txtlng(
"content", 
"cont_submit_answers", $a_lang) . 
'"; 
  475                        ilias.questions.refresh_lang(); 
  484        require_once 
'./Modules/Scorm2004/classes/class.ilQuestionExporter.php';
 
  485        $q_ids = $this->
getPage()->getQuestionIds();
 
  487        if (count($q_ids) > 0) {
 
  488            foreach ($q_ids as $q_id) {
 
  491                if ($a_mode == 
"offline") {
 
  492                    if ($this->
getPage()->getParentType() == 
"sahs") {
 
  493                        $image_path = 
"./objects/";
 
  495                    if ($this->
getPage()->getParentType() == 
"lm") {
 
  496                        $image_path = 
"./assessment/0/" . $q_id . 
"/images/";
 
  500                $js[$q_id] = $q_exporter->exportQuestion($q_id, $image_path, $a_mode);
 
An exception for terminatinating execution or to throw for unit testing.
static _getQuestionGUI($question_type, $question_id=-1)
Creates a question gui representation and returns the alias to the question gui note: please do not u...
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
static _extractObjIdOfTarget($a_target)
Extract object id out of target.
static _extractInstOfTarget($a_target)
Extract installation id out of target.
static _getPageForQuestionId($a_q_id, $a_parent_type="")
Get page for question id.
getQuestionJsOfPage($a_no_interaction, $a_mode)
Get question js.
setNode($a_node)
Set node.
static beforePageDelete($a_page)
Before page is being deleted.
getOnloadCode($a_mode)
Get on load code.
init()
Init page content component.
getCssFiles($a_mode)
Get css files.
getJavascriptFiles($a_mode)
Get Javascript files.
static getJSTextInitCode($a_lang)
Get js txt init code.
static resetInitialState()
Reset initial state (for exports)
static getLangVars()
Get lang vars needed for editing.
getQuestionReference()
Get Question Reference.
copyPoolQuestionIntoPage($a_q_id, $a_hier_id)
Copy question from pool into page.
modifyPageContentPostXsl($a_output, $a_mode, $a_abstract_only=false)
@inheritDoc
setQuestionReference($a_questionreference)
Set Question Reference.
static _getQuestionIdsForPage($a_parent_type, $a_page_id, $a_lang="-")
Get all questions of a page.
create(&$a_pg_obj, $a_hier_id)
Create Question Element.
static afterPageUpdate($a_page, DOMDocument $a_domdoc, $a_xml, $a_creation)
After page has been updated (or created)
createPageContentNode($a_set_this_node=true)
Create page content node (always use this method first when adding a new element)
setType($a_type)
Set Type.
static getAnswerStatus($a_q_id, $a_user_id=0)
Get statistics for question.
Scorm 2004 Question Exporter.
static questionsJS(array $a_qids=null)
foreach($_POST as $key=> $value) $res