ILIAS  release_7 Revision v7.30-3-g800a261c036
ilSCORM2004SeqTemplate Class Reference

Class ilSCORM2004Chapter. More...

+ Inheritance diagram for ilSCORM2004SeqTemplate:
+ Collaboration diagram for ilSCORM2004SeqTemplate:

Public Member Functions

 __construct ($a_identifier)
 
 getMetadataProperties ()
 function getMetadataProperties More...
 
 getIdentifier ()
 function getIdentifier More...
 
 insertTemplateForObjectAtParent ($a_object, $a_parent, $a_target)
 
 importTemplate ($a_target, $a_object, $a_parent, $node)
 function import Template More...
 
 insert ($a_insert_node=false)
 
 getSeqNodeId ()
 
 getId ()
 
 setSeqNodeId ($a_seqnodeid)
 
 setId ($a_id)
 
- Public Member Functions inherited from ilSCORM2004SeqNode
 __construct ()
 Constructor @access public. More...
 
 getNodeName ()
 
 getTreenodeId ()
 
 setNodeName ($a_nodeName)
 
 setTreenodeId ($a_treenodeId)
 
 insert ()
 
 update ($a_seq_node_id)
 

Static Public Member Functions

static availableTemplates ()
 
static getFileNameForIdentifier ($a_identifier)
 
static templateForChapter ($a_chapter_id)
 

Data Fields

const SEQ_TEMPLATE_DIR = './Modules/Scorm2004/templates/editor/seq_templates'
 
const SEQ_TEMPLATE_XSL = './Modules/Scorm2004/templates/editor/seq_templates/xsl/normalize_seqtemplate.xsl'
 
const SEQ_TEMPLATE_XSD = './Modules/Scorm2004/templates/editor/seq_templates/xsd/seq_template.xsd'
 

Private Member Functions

 generateObjIds ($a_dom)
 

Private Attributes

 $template
 
 $template_file
 
 $normalized_template
 
 $tree_node
 
 $diagnostic = array()
 
 $parentchapter = true
 
 $importId
 
 $id = null
 
 $seqNodeId = null
 
 $sahs_sc13_treeId = null
 
 $importid
 

Additional Inherited Members

- Protected Attributes inherited from ilSCORM2004SeqNode
 $db = null
 

Detailed Description

Class ilSCORM2004Chapter.

Sequencing Template class for SCORM 2004 Editing

Author
Hendrik Holtmann holtm.nosp@m.ann@.nosp@m.me.co.nosp@m.m
Version
$Id$

Definition at line 20 of file class.ilSCORM2004SeqTemplate.php.

Constructor & Destructor Documentation

◆ __construct()

ilSCORM2004SeqTemplate::__construct (   $a_identifier)

Definition at line 41 of file class.ilSCORM2004SeqTemplate.php.

42 {
43 global $DIC;
44
45 $this->db = $DIC->database();
46
48 $this->setNodeName("seqtemplate");
49
50 if ($a_identifier == null) {
51 return;
52 }
53 $t_file = self::getFileNameForIdentifier($a_identifier);
54
55 $this->template = new DOMDocument;
56 $this->template->async = false;
57
58
59 //look for template in lang_dir, fallback to en
60 $test = self::SEQ_TEMPLATE_DIR . "/" . $_SESSION["lang"] . "/" . $t_file;
61 if (file_exists($test)) {
62 $this->template_file = $test;
63 } else {
64 $this->template_file = self::SEQ_TEMPLATE_DIR . "/en/" . $t_file;
65 }
66 if (!@$this->template->load($this->template_file)) {
67 $this->diagnostic[] = 'Template not wellformed';
68 $test = $this->template->saveXML();
69 return false;
70 } else {
71 return true;
72 }
73 }
$test
Definition: Utf8Test.php:84
$_SESSION["AccountId"]
static getFileNameForIdentifier($a_identifier)
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References $_SESSION, $DIC, $test, ILIAS\GlobalScreen\Provider\__construct(), getFileNameForIdentifier(), and ilSCORM2004SeqNode\setNodeName().

+ Here is the call graph for this function:

Member Function Documentation

◆ availableTemplates()

static ilSCORM2004SeqTemplate::availableTemplates ( )
static

Definition at line 95 of file class.ilSCORM2004SeqTemplate.php.

96 {
97 global $DIC;
98
99 $ilDB = $DIC->database();
100 $arr_templates = array();
101 $query = "SELECT * FROM sahs_sc13_seq_templts ORDER BY identifier";
102 $result = $ilDB->query($query);
103 while ($row = $ilDB->fetchAssoc($result)) {
104 if ($row['identifier'] != "pretestpost") { //temporarily deactivated
105 array_push($arr_templates, new ilScorm2004SeqTemplate($row['identifier']));
106 }
107 }
108 return $arr_templates;
109 }
$result
$query
global $ilDB

References $DIC, $ilDB, $query, and $result.

Referenced by ilObjSCORM2004LearningModuleGUI\insertScenarioGUI().

+ Here is the caller graph for this function:

◆ generateObjIds()

ilSCORM2004SeqTemplate::generateObjIds (   $a_dom)
private

Definition at line 234 of file class.ilSCORM2004SeqTemplate.php.

235 {
236 }

◆ getFileNameForIdentifier()

static ilSCORM2004SeqTemplate::getFileNameForIdentifier (   $a_identifier)
static

Definition at line 287 of file class.ilSCORM2004SeqTemplate.php.

288 {
289 global $DIC;
290
291 $ilDB = $DIC->database();
292 $query = "SELECT * FROM sahs_sc13_seq_templts WHERE identifier = " .
293 $ilDB->quote($a_identifier, "text");
294 $obj_set = $ilDB->query($query);
295 $obj_rec = $ilDB->fetchAssoc($obj_set);
296 return $obj_rec["fileName"]; // fixed, switch to all lowercase fields and tables in the future for mdb2 compliance
297 return $obj_rec["filename"];
298 }

References $DIC, $ilDB, and $query.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ getId()

ilSCORM2004SeqTemplate::getId ( )

Definition at line 266 of file class.ilSCORM2004SeqTemplate.php.

References $id.

◆ getIdentifier()

ilSCORM2004SeqTemplate::getIdentifier ( )

function getIdentifier

Returns
get identifier for template
Author
Hendrik Holtmann

Definition at line 118 of file class.ilSCORM2004SeqTemplate.php.

119 {
120 $seqtemplate = $this->template->getElementsByTagName("seqTemplate");
121 return $seqtemplate->item(0)->getAttribute("identifier");
122 ;
123 }

◆ getMetadataProperties()

ilSCORM2004SeqTemplate::getMetadataProperties ( )

function getMetadataProperties

Returns
hash of metadata for the template
Author
Hendrik Holtmann

Definition at line 82 of file class.ilSCORM2004SeqTemplate.php.

83 {
84 $array_metad = array();
85 $metadata = $this->template->getElementsByTagName("metadata");
86 $nodes = $metadata->item(0)->childNodes;
87 for ($i = 0; $i < $nodes->length; $i++) {
88 $curNode = $nodes->item($i);
89 $array_metad[$curNode->localName] = $curNode->nodeValue;
90 }
91 return $array_metad;
92 }
$i
Definition: metadata.php:24

References $i.

◆ getSeqNodeId()

ilSCORM2004SeqTemplate::getSeqNodeId ( )

Definition at line 261 of file class.ilSCORM2004SeqTemplate.php.

References $seqNodeId.

◆ importTemplate()

ilSCORM2004SeqTemplate::importTemplate (   $a_target,
  $a_object,
  $a_parent,
  $node 
)

function import Template

Returns
success of import
Author
Hendrik Holtmann

Definition at line 140 of file class.ilSCORM2004SeqTemplate.php.

141 {
143
144 switch ($node->getAttribute('type')) {
145 case "lesson":
146 if ($this->parentchapter == true) {
147 $chap = new ilSCORM2004SeqChapter($a_object);
148 } else {
149 $chap = new ilSCORM2004Chapter($a_object);
150 }
151 $chap->setTitle($node->getElementsByTagName("title")->item(0)->nodeValue);
152 $chap->setSLMId($a_object->getId());
153 $chap->create();
154 $this->sahs_sc13_treeId = $chap->getId();
155 ilSCORM2004Node::putInTree($chap, $a_parent, $a_target);
156 $a_parent = $this->sahs_sc13_treeId;
157 if ($this->parentchapter == true) {
158 $ilDB->manipulate("INSERT INTO sahs_sc13_seq_assign (identifier, sahs_sc13_tree_node_id) VALUES " .
159 "(" . $ilDB->quote($this->getIdentifier(), "text") . "," .
160 $ilDB->quote($this->sahs_sc13_treeId, "integer") . ")");
161 $this->parentchapter = false;
162 }
163 $new_id = $chap->getId();
164 break;
165 case "sco":
166 $sco = new ilSCORM2004Sco($a_object);
167 $sco->setTitle($node->getElementsByTagName("title")->item(0)->nodeValue);
168 $sco->setSLMId($a_object->getId());
169 $sco->create(false, true);
170 $this->sahs_sc13_treeId = $sco->getId();
171 ilSCORM2004Node::putInTree($sco, $a_parent, $a_target);
172 $new_id = $sco->getId();
173 break;
174 }
175
176 $seq_node = $node->getElementsByTagName("sequencing")->item(0);
177
178 $obj_node = $seq_node->getElementsByTagName("objectives")->item(0);
179 //addtitle
180 if ($obj_node) {
181 foreach ($obj_node->childNodes as $objchild) {
182 if ($objchild->nodeName === "objective" || $objchild->nodeName === "primaryObjective") {
183 $title = $objchild->getAttribute('objectiveID');
184 $objchild->setAttribute("title", $title);
185 // $i++;
186 }
187 }
188 }
189
190 $seq_item = new ilSCORM2004Item();
191 $seq_item->setTreeNodeId($this->sahs_sc13_treeId);
192 $seq_item->setImportid($this->importId);
193 $seq_item->setNocopy($seq_node->getAttribute('nocopy'));
194 $seq_item->setNodelete($seq_node->getAttribute('nodelete'));
195 $seq_item->setNomove($seq_node->getAttribute('nomove'));
196
197 $seq_doc = new DOMDocument();
198 $toadd = $seq_doc->importNode($seq_node, true);
199 $seq_doc->appendChild($toadd);
200
201 //generate Unique ObjectiveIDs for context
202
203 //@targetObjectiveID
204 $xpath_obj = new DOMXPath($seq_doc);
205
206 $found_nodes = $xpath_obj->query('//@objectiveID | //@referencedObjective | //@targetObjectiveID');
207 for ($i = 0; $i < $found_nodes->length; $i++) {
208 $element = null;
209 $val = $found_nodes->item($i)->value;
211 if ($found_nodes->item($i)->name == "targetObjectiveID") {
212 $uid = $this->importId;
213 }
214 $val = strtolower(preg_replace('/ +/', '_', $val) . "_" . $uid);
215 $element = $found_nodes->item($i)->ownerElement;
216 $element->setAttribute($found_nodes->item($i)->name, $val);
217 }
218
219 $seq_item->setDom($seq_doc);
220
221 $seq_item->insert();
222
223 foreach ($node->childNodes as $child) {
224 if ($child->nodeName === "item") {
225 $this->importTemplate($a_target, $a_object, $a_parent, $child);
226 }
227 }
228
229 return $new_id;
230 }
Class ilSCORM2004Chapter.
Class ilSCORM2004Condition.
static putInTree($a_obj, $a_parent_id="", $a_target_node_id="")
put this object into content object tree
Class ilSCORM2004Sco.
Class ilSCORM2004Chapter.
importTemplate($a_target, $a_object, $a_parent, $node)
function import Template

References ilSCORM2004SeqNode\$db, $i, $ilDB, $importId, $sahs_sc13_treeId, importTemplate(), and ilSCORM2004Node\putInTree().

Referenced by importTemplate(), and insertTemplateForObjectAtParent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ insert()

ilSCORM2004SeqTemplate::insert (   $a_insert_node = false)

Definition at line 242 of file class.ilSCORM2004SeqTemplate.php.

243 {
244 if ($a_insert_node == true) {
245 $this->setSeqNodeId(parent::insert());
246 }
247 $sql = "INSERT INTO sahs_sc13_seq_templ (seqnodeid,id)" .
248 " values(" .
249 $this->db->quote($this->seqNodeId, "integer") . "," .
250 $this->db->quote($this->id, "text") . ");";
251 $result = $this->db->manipulate($sql);
252 return true;
253 }

References $result, and setSeqNodeId().

+ Here is the call graph for this function:

◆ insertTemplateForObjectAtParent()

ilSCORM2004SeqTemplate::insertTemplateForObjectAtParent (   $a_object,
  $a_parent,
  $a_target 
)

Definition at line 126 of file class.ilSCORM2004SeqTemplate.php.

127 {
128 $this->importId = uniqid();
129 return $this->importTemplate($a_target, $a_object, $a_parent, $this->template->getElementsByTagName("item")->item(0));
130 }

References importTemplate().

+ Here is the call graph for this function:

◆ setId()

ilSCORM2004SeqTemplate::setId (   $a_id)

Definition at line 280 of file class.ilSCORM2004SeqTemplate.php.

281 {
282 $this->id = $a_id;
283 }

◆ setSeqNodeId()

ilSCORM2004SeqTemplate::setSeqNodeId (   $a_seqnodeid)

Definition at line 275 of file class.ilSCORM2004SeqTemplate.php.

276 {
277 $this->seqNodeId = $a_seqnodeid;
278 }

Referenced by insert().

+ Here is the caller graph for this function:

◆ templateForChapter()

static ilSCORM2004SeqTemplate::templateForChapter (   $a_chapter_id)
static

Definition at line 300 of file class.ilSCORM2004SeqTemplate.php.

301 {
302 global $DIC;
303
304 $ilDB = $DIC->database();
305 $template = null;
306 $query = "SELECT * FROM sahs_sc13_seq_assign WHERE sahs_sc13_tree_node_id = " .
307 $ilDB->quote($a_chapter_id, "integer");
308 $obj_set = $ilDB->query($query);
309 $obj_rec = $ilDB->fetchAssoc($obj_set);
310 if ($obj_rec['identifier']) {
311 $template = new ilScorm2004SeqTemplate($obj_rec['identifier']);
312 }
313 return $template;
314 }

References $DIC, $ilDB, $query, and $template.

Referenced by ilSCORM2004ChapterGUI\showProperties().

+ Here is the caller graph for this function:

Field Documentation

◆ $diagnostic

ilSCORM2004SeqTemplate::$diagnostic = array()
private

Definition at line 31 of file class.ilSCORM2004SeqTemplate.php.

◆ $id

ilSCORM2004SeqTemplate::$id = null
private

Definition at line 36 of file class.ilSCORM2004SeqTemplate.php.

Referenced by getId().

◆ $importId

ilSCORM2004SeqTemplate::$importId
private

Definition at line 33 of file class.ilSCORM2004SeqTemplate.php.

Referenced by importTemplate().

◆ $importid

ilSCORM2004SeqTemplate::$importid
private

Definition at line 39 of file class.ilSCORM2004SeqTemplate.php.

◆ $normalized_template

ilSCORM2004SeqTemplate::$normalized_template
private

Definition at line 29 of file class.ilSCORM2004SeqTemplate.php.

◆ $parentchapter

ilSCORM2004SeqTemplate::$parentchapter = true
private

Definition at line 32 of file class.ilSCORM2004SeqTemplate.php.

◆ $sahs_sc13_treeId

ilSCORM2004SeqTemplate::$sahs_sc13_treeId = null
private

Definition at line 38 of file class.ilSCORM2004SeqTemplate.php.

Referenced by importTemplate().

◆ $seqNodeId

ilSCORM2004SeqTemplate::$seqNodeId = null
private

Definition at line 37 of file class.ilSCORM2004SeqTemplate.php.

Referenced by getSeqNodeId().

◆ $template

ilSCORM2004SeqTemplate::$template
private

Definition at line 27 of file class.ilSCORM2004SeqTemplate.php.

Referenced by templateForChapter().

◆ $template_file

ilSCORM2004SeqTemplate::$template_file
private

Definition at line 28 of file class.ilSCORM2004SeqTemplate.php.

◆ $tree_node

ilSCORM2004SeqTemplate::$tree_node
private

Definition at line 30 of file class.ilSCORM2004SeqTemplate.php.

◆ SEQ_TEMPLATE_DIR

const ilSCORM2004SeqTemplate::SEQ_TEMPLATE_DIR = './Modules/Scorm2004/templates/editor/seq_templates'

◆ SEQ_TEMPLATE_XSD

const ilSCORM2004SeqTemplate::SEQ_TEMPLATE_XSD = './Modules/Scorm2004/templates/editor/seq_templates/xsd/seq_template.xsd'

Definition at line 24 of file class.ilSCORM2004SeqTemplate.php.

◆ SEQ_TEMPLATE_XSL

const ilSCORM2004SeqTemplate::SEQ_TEMPLATE_XSL = './Modules/Scorm2004/templates/editor/seq_templates/xsl/normalize_seqtemplate.xsl'

Definition at line 23 of file class.ilSCORM2004SeqTemplate.php.


The documentation for this class was generated from the following file: