예제 #1
0
 /**
  * Class constructor. Depending of the type of construction called ('db' or 'manifest'), will create a scormItem
  * object from database records or from the array given as second parameter
  * @param	string	Type of construction needed ('db' or 'config', default = 'config')
  * @param	mixed	Depending on the type given, DB id for the lp_item or parameters array
  */
 public function aiccItem($type = 'config', $params = array(), $course_id = null)
 {
     if (isset($params)) {
         switch ($type) {
             case 'db':
                 parent::__construct($params, api_get_user_id(), $course_id);
                 $this->aicc_contact = false;
                 //TODO: Implement this way of metadata object creation.
                 return false;
             case 'config':
                 // Do the same as the default.
             // Do the same as the default.
             default:
                 //if($first_item->type == XML_ELEMENT_NODE) this is already check prior to the call to this function
                 foreach ($params as $a => $value) {
                     switch ($a) {
                         case 'system_id':
                             $this->identifier = Database::escape_string(strtolower($value));
                             break;
                         case 'type':
                             $this->au_type = Database::escape_string($value);
                             break;
                         case 'command_line':
                             $this->command_line = Database::escape_string($value);
                             break;
                         case 'max_time_allowed':
                             $this->maxtimeallowed = Database::escape_string($value);
                             break;
                         case 'time_limit_action':
                             $this->timelimitaction = Database::escape_string($value);
                             break;
                         case 'max_score':
                             $this->max_score = Database::escape_string($value);
                             break;
                         case 'core_vendor':
                             $this->core_vendor = Database::escape_string($value);
                             break;
                         case 'system_vendor':
                             $this->system_vendor = Database::escape_string($value);
                             break;
                         case 'file_name':
                             $this->path = Database::escape_string($value);
                             break;
                         case 'mastery_score':
                             $this->masteryscore = Database::escape_string($value);
                             break;
                         case 'web_launch':
                             $this->parameters = Database::escape_string($value);
                             break;
                     }
                 }
                 return true;
         }
     }
     return false;
 }
예제 #2
0
    /**
     * Class constructor. Depending of the type of construction called ('db' or 'manifest'), will create a scormItem
     * object from database records or from the DOM element given as parameter
     * @param	string	$type Type of construction needed ('db' or 'manifest', default = 'manifest')
     * @param	mixed	$element Depending on the type given, DB id for the lp_item or reference to the DOM element
     * @param int $course_id
     */
    public function __construct($type = 'manifest', &$element, $course_id = '')
    {
        if (isset($element)) {
            // Parsing using PHP5 DOMXML methods.
            switch ($type) {
                case 'db':
                    parent::__construct($element, api_get_user_id(), $course_id);
                    $this->scorm_contact = false;
                    // TODO: Implement this way of metadata object creation.
                    return false;
                case 'manifest': // Do the same as the default.
                default:
                    //if ($first_item->type == XML_ELEMENT_NODE) this is already check prior to the call to this function.
                    $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 && $child->firstChild->nodeValue != '') {
                                            $this->title = $child->firstChild->nodeValue;
                                        }
                                        break;
                                    case 'max_score':
                                        if ($tmp_children->length == 1 && $child->firstChild->nodeValue != '') {
                                            $this->max_score = $child->firstChild->nodeValue;
                                        }
                                        break;
                                    case 'maxtimeallowed':
                                    case 'adlcp:maxtimeallowed':
                                        $tmp_children = $child->childNodes;
                                        if ($tmp_children->length == 1 && $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 && $child->firstChild->nodeValue != '') {
                                            $this->prereq_string = $child->firstChild->nodeValue;
                                        }
                                        break;
                                    case 'timelimitaction':
                                    case 'adlcp:timelimitaction':
                                        $tmp_children = $child->childNodes;
                                        if ($tmp_children->length == 1 && $child->firstChild->nodeValue != '') {
                                            $this->timelimitaction = $child->firstChild->nodeValue;
                                        }
                                        break;
                                    case 'datafromlms':
                                    case 'adlcp:datafromlms':
                                    case 'adlcp:launchdata': //in some cases (Wouters)
                                        $tmp_children = $child->childNodes;
                                        if ($tmp_children->length == 1 && $child->firstChild->nodeValue != '') {
                                            $this->datafromlms = $child->firstChild->nodeValue;
                                        }
                                        break;
                                    case 'masteryscore':
                                    case 'adlcp:masteryscore':
                                        $tmp_children = $child->childNodes;
                                        if ($tmp_children->length == 1 && $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:
                                // This case is actually treated by looking into ELEMENT_NODEs above.
                                break;
                        }
                    }
                    if ($element->hasAttributes()) {
                        $attributes = $element->attributes;
                        //$keep_href = '';
                        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;
            }
            // End parsing using PHP5 DOMXML methods.
        }

        return false;
    }