/** * Copy question from pool into page * * @param * @return */ function copyPoolQuestionIntoPage($a_q_id, $a_hier_id) { include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php"; include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php"; $question = assQuestion::_instanciateQuestion($a_q_id); $duplicate_id = $question->copyObject(0, $question->getTitle()); $duplicate = assQuestion::_instanciateQuestion($duplicate_id); $duplicate->setObjId(0); // we remove everything not supported by the non-tiny self // assessment question editor $q = $duplicate->getQuestion(); // we try to save all latex tags $try = true; $ls = '<span class="latex">'; $le = '</span>'; while ($try) { // search position of start tag $pos1 = strpos($q, $ls); if (is_int($pos1)) { $pos2 = strpos($q, $le, $pos1); if (is_int($pos2)) { // both found: replace end tag $q = substr($q, 0, $pos2) . "[/tex]" . substr($q, $pos2 + 7); $q = substr($q, 0, $pos1) . "[tex]" . substr($q, $pos1 + 20); } else { $try = false; } } else { $try = false; } } $tags = assQuestionGUI::getSelfAssessmentTags(); $tstr = ""; foreach ($tags as $t) { $tstr .= "<" . $t . ">"; } $q = ilUtil::secureString($q, true, $tstr); // self assessment uses nl2br, not p $duplicate->setQuestion($q); $duplicate->saveQuestionDataToDb(); $this->q_node->set_attribute("QRef", "il__qst_" . $duplicate_id); }