5 require_once(
"./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Item.php");
6 require_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Chapter.php");
7 require_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004SeqChapter.php");
8 require_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Sco.php");
23 const SEQ_TEMPLATE_DIR =
'./Modules/Scorm2004/templates/editor/seq_templates';
24 const SEQ_TEMPLATE_XSL =
'./Modules/Scorm2004/templates/editor/seq_templates/xsl/normalize_seqtemplate.xsl';
25 const SEQ_TEMPLATE_XSD =
'./Modules/Scorm2004/templates/editor/seq_templates/xsd/seq_template.xsd';
48 if ($a_identifier==null) {
return;}
51 $this->
template =
new DOMDocument;
52 $this->
template->async =
false;
57 if (file_exists(
$test))
59 $this->template_file =
$test;
61 $this->template_file = self::SEQ_TEMPLATE_DIR.
"/en/".$t_file;
63 if (!@$this->template->load($this->template_file))
65 $this->diagnostic[] =
'Template not wellformed';
66 $test = $this->
template->saveXML();
82 $array_metad = array();
83 $metadata = $this->
template->getElementsByTagName(
"metadata");
84 $nodes = $metadata->item(0)->childNodes;
85 for ($i = 0; $i < $nodes->length; $i++ ) {
86 $curNode = $nodes->item($i);
87 $array_metad[$curNode->localName] = $curNode->nodeValue;
96 $arr_templates = array();
97 $query =
"SELECT * FROM sahs_sc13_seq_templts ORDER BY identifier";
101 if(
$row[
'identifier']!=
"pretestpost") {
102 array_push($arr_templates,
new ilScorm2004SeqTemplate(
$row[
'identifier']));
105 return $arr_templates;
117 $seqtemplate = $this->
template->getElementsByTagName(
"seqTemplate");
118 return $seqtemplate->item(0)->getAttribute(
"identifier");;
124 $this->importId = uniqid();
125 return $this->
importTemplate($a_target,$a_object,$a_parent, $this->template->getElementsByTagName(
"item")->item(0));
139 switch($node->getAttribute(
'type'))
142 if ($this->parentchapter==
true)
148 $chap->setTitle($node->getElementsByTagName(
"title")->item(0)->nodeValue);
149 $chap->setSLMId($a_object->getId());
151 $this->sahs_sc13_treeId = $chap->getId();
154 if ($this->parentchapter==
true)
156 $ilDB->manipulate(
"INSERT INTO sahs_sc13_seq_assign (identifier, sahs_sc13_tree_node_id) VALUES ".
157 "(".$ilDB->quote($this->getIdentifier(),
"text").
",".
158 $ilDB->quote($this->sahs_sc13_treeId,
"integer").
")");
159 $this->parentchapter =
false;
161 $new_id = $chap->getId();
165 $sco->setTitle($node->getElementsByTagName(
"title")->item(0)->nodeValue);
166 $sco->setSLMId($a_object->getId());
167 $sco->create(
false,
true);
168 $this->sahs_sc13_treeId = $sco->getId();
170 $new_id = $sco->getId();
174 $seq_node = $node->getElementsByTagName(
"sequencing")->item(0);
176 $obj_node = $seq_node->getElementsByTagName(
"objectives")->item(0);
179 foreach ($obj_node->childNodes as $objchild ) {
180 if ($objchild->nodeName ===
"objective" || $objchild->nodeName ===
"primaryObjective") {
181 $title = $objchild->getAttribute(
'objectiveID');
182 $objchild->setAttribute(
"title",
$title);
189 $seq_item->setTreeNodeId($this->sahs_sc13_treeId);
190 $seq_item->setImportid($this->importId);
191 $seq_item->setNocopy($seq_node->getAttribute(
'nocopy'));
192 $seq_item->setNodelete($seq_node->getAttribute(
'nodelete'));
193 $seq_item->setNomove($seq_node->getAttribute(
'nomove'));
195 $seq_doc =
new DOMDocument();
196 $toadd = $seq_doc->importNode($seq_node,
true);
197 $seq_doc->appendChild($toadd);
202 $xpath_obj =
new DOMXPath($seq_doc);
204 $found_nodes = $xpath_obj->query(
'//@objectiveID | //@referencedObjective | //@targetObjectiveID');
205 for ($i=0; $i<$found_nodes->length; $i++) {
207 $val = $found_nodes->item($i)->value;
209 if ($found_nodes->item($i)->name ==
"targetObjectiveID") {
212 $val = strtolower(preg_replace(
'/ +/',
'_',$val).
"_".$uid);
213 $element = $found_nodes->item($i)->ownerElement;
214 $element->setAttribute($found_nodes->item($i)->name,$val);
217 $seq_item->setDom($seq_doc);
221 foreach($node->childNodes as $child)
222 {
if ($child->nodeName ===
"item") {
242 if ($a_insert_node==
true) {$this->
setSeqNodeId(parent::insert());}
243 $sql =
"INSERT INTO sahs_sc13_seq_templ (seqnodeid,id)".
245 $this->db->quote($this->seqNodeId,
"integer").
",".
246 $this->db->quote($this->
id,
"text").
");";
247 $result = $this->db->manipulate($sql);
273 $this->seqNodeId = $a_seqnodeid;
286 $query =
"SELECT * FROM sahs_sc13_seq_templts WHERE identifier = ".
287 $ilDB->quote($a_identifier,
"text");
288 $obj_set = $ilDB->query(
$query);
289 $obj_rec = $ilDB->fetchAssoc($obj_set);
290 return $obj_rec[
"fileName"];
291 return $obj_rec[
"filename"];
298 $query =
"SELECT * FROM sahs_sc13_seq_assign WHERE sahs_sc13_tree_node_id = ".
299 $ilDB->quote($a_chapter_id,
"integer");
300 $obj_set = $ilDB->query(
$query);
301 $obj_rec = $ilDB->fetchAssoc($obj_set);
302 if ($obj_rec[
'identifier']) {
303 $template =
new ilScorm2004SeqTemplate($obj_rec[
'identifier']);