123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311 |
- <?php
- require_once 'learnpathItem.class.php';
- class scormItem extends learnpathItem{
- public $identifier = '';
- public $identifierref = '';
- public $isvisible = '';
- public $parameters = '';
- public $title = '';
- public $sub_items = array();
- public $metadata;
-
-
-
- public $max_time_allowed = '00:00:00';
-
- public $timelimitaction = '';
- public $datafromlms = '';
- public $mastery_score = '';
- public $scorm_contact;
-
- public function __construct($type='manifest',&$element) {
- if(isset($element))
- {
- $v = substr(phpversion(),0,1);
- if($v == 4){
- switch($type){
- case 'db':
- parent::__construct($element,api_get_user_id());
- $this->scorm_contact = false;
-
- return false;
- case 'manifest':
- default:
-
- $children = $element->children();
- foreach($children as $a => $dummy)
- {
- $child =& $children[$a];
- switch($child->type)
- {
- case XML_ELEMENT_NODE:
- switch($child->tagname){
- case 'title':
- $tmp_children = $child->children();
- if(count($tmp_children)==1 and $tmp_children[0]->content!='' )
- {
- $this->title = $tmp_children[0]->content;
- }
- break;
- case 'maxtimeallowed':
- $tmp_children = $child->children();
- if(count($tmp_children)==1 and $tmp_children[0]->content!='' )
- {
- $this->max_time_allowed = $tmp_children[0]->content;
- }
- break;
- case 'prerequisites':
- $tmp_children = $child->children();
- if(count($tmp_children)==1 and $tmp_children[0]->content!='' )
- {
- $this->prereq_string = $tmp_children[0]->content;
- }
- break;
- case 'timelimitaction':
- $tmp_children = $child->children();
- if(count($tmp_children)==1 and $tmp_children[0]->content!='' )
- {
- $this->timelimitaction = $tmp_children[0]->content;
- }
- break;
- case 'datafromlms':
- $tmp_children = $child->children();
- if(count($tmp_children)==1 and $tmp_children[0]->content!='' )
- {
- $this->datafromlms = $tmp_children[0]->content;
- }
- break;
- case 'masteryscore':
- $tmp_children = $child->children();
- if(count($tmp_children)==1 and $tmp_children[0]->content!='' )
- {
- $this->mastery_score = $tmp_children[0]->content;
- }
- break;
- case 'item':
- $oItem = new scormItem('manifest',$child);
- if($oItem->identifier != ''){
- $this->sub_items[$oItem->identifier] = $oItem;
- }
- break;
- case 'metadata':
- $this->metadata = new scormMetadata('manifest',$child);
- break;
- }
- break;
- case XML_TEXT_NODE:
-
- break;
- }
- }
- $attributes = $element->attributes();
-
- foreach($attributes as $a1 => $dummy)
- {
- $attrib =& $attributes[$a1];
- switch($attrib->name){
- case 'identifier':
- $this->identifier = $attrib->value;
- break;
- case 'identifierref':
- $this->identifierref = $attrib->value;
- break;
- case 'isvisible':
- $this->isvisible = $attrib->value;
- break;
- case 'parameters':
- $this->parameters = $attrib->value;
- break;
- }
- }
- return true;
- }
- }elseif($v == 5){
-
- switch($type){
- case 'db':
- parent::__construct($element,api_get_user_id());
- $this->scorm_contact = false;
-
- return false;
- case 'manifest':
- default:
-
- $children = $element->childNodes;
- foreach($children as $child)
- {
- switch($child->nodeType)
- {
- case XML_ELEMENT_NODE:
- switch($child->tagName){
- case 'title':
- $tmp_children = $child->childNodes;
-
- if($tmp_children->length==1 and $child->firstChild->nodeValue!='' )
- {
- $this->title = $child->firstChild->nodeValue;
- }
- break;
- case 'max_score':
- if($tmp_children->length==1 and $child->firstChild->nodeValue!='' ) {
- $this->max_score = $child->firstChild->nodeValue;
- }
- break;
- case 'maxtimeallowed':
- case 'adlcp:maxtimeallowed':
- $tmp_children = $child->childNodes;
-
- if($tmp_children->length==1 and $child->firstChild->nodeValue!='' )
- {
- $this->max_time_allowed = $child->firstChild->nodeValue;
- }
- break;
- case 'prerequisites':
- case 'adlcp:prerequisites':
- $tmp_children = $child->childNodes;
-
- if($tmp_children->length==1 and $child->firstChild->nodeValue!='' )
- {
- $this->prereq_string = $child->firstChild->nodeValue;
- }
- break;
- case 'timelimitaction':
- case 'adlcp:timelimitaction':
- $tmp_children = $child->childNodes;
-
- if($tmp_children->length==1 and $child->firstChild->nodeValue!='' )
- {
- $this->timelimitaction = $child->firstChild->nodeValue;
- }
- break;
- case 'datafromlms':
- case 'adlcp:datafromlms':
- case 'adlcp:launchdata':
- $tmp_children = $child->childNodes;
-
- if($tmp_children->length==1 and $child->firstChild->nodeValue!='' )
- {
- $this->datafromlms = $child->firstChild->nodeValue;
- }
- break;
- case 'masteryscore':
- case 'adlcp:masteryscore':
- $tmp_children = $child->childNodes;
-
- if($tmp_children->length==1 and $child->firstChild->nodeValue!='' )
- {
- $this->mastery_score = $child->firstChild->nodeValue;
- }
- break;
- case 'item':
- $oItem = new scormItem('manifest',$child);
- if($oItem->identifier != ''){
- $this->sub_items[$oItem->identifier] = $oItem;
- }
- break;
- case 'metadata':
- $this->metadata = new scormMetadata('manifest',$child);
- break;
- }
- break;
- case XML_TEXT_NODE:
-
- break;
- }
- }
- if($element->hasAttributes()){
- $attributes = $element->attributes;
-
- foreach($attributes as $attrib)
- {
- switch($attrib->name){
- case 'identifier':
- $this->identifier = $attrib->value;
- break;
- case 'identifierref':
- $this->identifierref = $attrib->value;
- break;
- case 'isvisible':
- $this->isvisible = $attrib->value;
- break;
- case 'parameters':
- $this->parameters = $attrib->value;
- break;
- }
- }
- }
- return true;
- }
- }else{
-
- return false;
- }
- }
- return false;
- }
-
- public function get_flat_list(&$list,&$abs_order,$rel_order=1,$level=0) {
- $list[] = array(
- 'abs_order' => $abs_order,
- 'datafromlms' => $this->datafromlms,
- 'identifier' => $this->identifier,
- 'identifierref' => $this->identifierref,
- 'isvisible' => $this->isvisible,
- 'level' => $level,
- 'masteryscore' => $this->mastery_score,
- 'maxtimeallowed' => $this->max_time_allowed,
- 'metadata' => $this->metadata,
- 'parameters' => $this->parameters,
- 'prerequisites' => (!empty($this->prereq_string)?$this->prereq_string:''),
- 'rel_order' => $rel_order,
- 'timelimitaction' => $this->timelimitaction,
- 'title' => $this->title,
- 'max_score' => $this->max_score
- );
- $abs_order++;
- $i = 1;
- foreach($this->sub_items as $id => $dummy)
- {
- $oSubitem =& $this->sub_items[$id];
- $oSubitem->get_flat_list($list,$abs_order,$i,$level+1);
- $i++;
- }
- }
-
- public function save($from_outside=true,$prereqs_complete=false) {
- parent::save($from_outside,$prereqs_complete);
-
- $this->scorm_contact = true;
- if(!$this->scorm_contact){
-
- }
- }
- }
- ?>
|