/** * @return iQuestionCondition */ public function getQuestion() { if ($this->question === null && $this->questionId) { require_once 'Modules/TestQuestionPool/classes/class.assQuestion.php'; $this->question = assQuestion::_instantiateQuestion($this->questionId); } return $this->question; }
private function purgeQuestionIds($questionIds) { require_once 'Modules/TestQuestionPool/classes/class.assQuestion.php'; foreach ($questionIds as $questionId) { $question = assQuestion::_instantiateQuestion($questionId); $question->delete($questionId); } }
/** * Replaces existing question content elements with * new copies */ function newQuestionCopies(&$temp_dom) { // Get question IDs $path = "//Question"; $xpc = xpath_new_context($temp_dom); $res =& xpath_eval($xpc, $path); $q_ids = array(); include_once "./Services/Link/classes/class.ilInternalLink.php"; for ($i = 0; $i < count($res->nodeset); $i++) { $qref = $res->nodeset[$i]->get_attribute("QRef"); $inst_id = ilInternalLink::_extractInstOfTarget($qref); $q_id = ilInternalLink::_extractObjIdOfTarget($qref); if (!($inst_id > 0)) { if ($q_id > 0) { include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php"; $question = assQuestion::_instantiateQuestion($q_id); // check due to #16557 if (is_object($question)) { // check if page for question exists // due to a bug in early 4.2.x version this is possible if (!ilPageObject::_exists("qpl", $q_id)) { $question->createPageObject(); } // now copy this question and change reference to // new question id $duplicate_id = $question->duplicate(false); $res->nodeset[$i]->set_attribute("QRef", "il__qst_" . $duplicate_id); } } } } }
private function syncOriginalCmd() { $questionId = (int) $_POST['question_id']; if ($this->isTestQuestion($questionId) && $this->isSyncOriginalPossibleAndAllowed($questionId)) { $question = assQuestion::_instantiateQuestion($questionId); $question->syncSkillAssignments($question->getObjId(), $question->getId(), $question->lookupParentObjId($question->getOriginalId()), $question->getOriginalId()); ilUtil::sendSuccess($this->lng->txt('qpl_qst_skl_assign_synced_to_orig'), true); } $this->ctrl->redirect($this, self::CMD_SHOW_SKILL_QUEST_ASSIGNS); }
function exportXMLPageObjects($a_target_dir, &$a_xml_writer, $a_inst, &$expLog) { global $ilBench; include_once "./Modules/Scorm2004/classes/class.ilSCORM2004PageNode.php"; include_once "./Modules/Scorm2004/classes/class.ilSCORM2004Page.php"; $tree = new ilTree($this->slm_id); $tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node'); $tree->setTreeTablePK("slm_id"); $pages = $tree->getSubTree($tree->getNodeData($this->getId()), true, 'page'); foreach ($pages as $page) { $expLog->write(date("[y-m-d H:i:s] ") . "Page Object " . $page["obj_id"]); // export xml to writer object $page_obj = new ilSCORM2004Page($page["obj_id"]); $page_obj->exportXML($a_xml_writer, "normal", $a_inst); //collect media objects $mob_ids = $page_obj->getMediaObjectIds(); foreach ($mob_ids as $mob_id) { $this->mob_ids[$mob_id] = $mob_id; } // collect all file items $file_ids = $page_obj->getFileItemIds(); foreach ($file_ids as $file_id) { $this->file_ids[$file_id] = $file_id; } include_once "./Services/COPage/classes/class.ilPCQuestion.php"; $q_ids = ilPCQuestion::_getQuestionIdsForPage("sahs", $page["obj_id"]); if (count($q_ids) > 0) { include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php"; foreach ($q_ids as $q_id) { $q_obj = assQuestion::_instantiateQuestion($q_id); // see #16557 if (is_object($q_obj)) { $qti_file = fopen($a_target_dir . "/qti_" . $q_id . ".xml", "w"); fwrite($qti_file, $q_obj->toXML()); fclose($qti_file); } } } unset($page_obj); } }