|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 // This file is part of Moodle - http://moodle.org/ 00003 // 00004 // Moodle is free software: you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation, either version 3 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // Moodle is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00016 00024 require_once 'cc_version1.php'; 00025 00026 00031 class cc_version11 extends cc_version1 { 00032 const webcontent = 'webcontent'; 00033 const questionbank = 'imsqti_xmlv1p2/imscc_xmlv1p1/question-bank'; 00034 const assessment = 'imsqti_xmlv1p2/imscc_xmlv1p1/assessment'; 00035 const associatedcontent = 'associatedcontent/imscc_xmlv1p1/learning-application-resource'; 00036 const discussiontopic = 'imsdt_xmlv1p1'; 00037 const weblink = 'imswl_xmlv1p1'; 00038 const basiclti = 'imsbasiclti_xmlv1p0'; 00039 00040 public static $checker = array(self::webcontent, 00041 self::assessment, 00042 self::associatedcontent, 00043 self::discussiontopic, 00044 self::questionbank, 00045 self::weblink, 00046 self::basiclti); 00047 00054 public function valid($type) { 00055 return in_array($type, self::$checker); 00056 } 00057 00058 public function __construct() { 00059 $this->ccnamespaces = array('imscc' => 'http://www.imsglobal.org/xsd/imsccv1p1/imscp_v1p1', 00060 'lomimscc' => 'http://ltsc.ieee.org/xsd/imsccv1p1/LOM/manifest' , 00061 'lom' => 'http://ltsc.ieee.org/xsd/imsccv1p1/LOM/resource' , 00062 'xsi' => 'http://www.w3.org/2001/XMLSchema-instance' 00063 ); 00064 00065 $this->ccnsnames = array('imscc' => 'http://www.imsglobal.org/profile/cc/ccv1p1/ccv1p1_imscp_v1p2_v1p0.xsd' , 00066 'lomimscc' => 'http://www.imsglobal.org/profile/cc/ccv1p1/LOM/ccv1p1_lommanifest_v1p0.xsd', 00067 'lom' => 'http://www.imsglobal.org/profile/cc/ccv1p1/LOM/ccv1p1_lomresource_v1p0.xsd' 00068 ); 00069 00070 $this->ccversion = '1.1.0'; 00071 $this->camversion = '1.1.0'; 00072 $this->_generator = 'Moodle 2 Common Cartridge generator'; 00073 } 00074 00075 protected function update_items($items, DOMDocument &$doc, DOMElement &$xmlnode) { 00076 foreach ($items as $key => $item) { 00077 $itemnode = $doc->createElementNS($this->ccnamespaces['imscc'], 'item'); 00078 $this->update_attribute($doc, 'identifier' , $key , $itemnode); 00079 $this->update_attribute($doc, 'identifierref', $item->identifierref, $itemnode); 00080 if (!is_null($item->title)) { 00081 $titlenode = $doc->createElementNS($this->ccnamespaces['imscc'], 00082 'title', 00083 $item->title); 00084 $itemnode->appendChild($titlenode); 00085 } 00086 if ($item->has_child_items()) { 00087 $this->update_items($item->childitems, $doc, $itemnode); 00088 } 00089 $xmlnode->appendChild($itemnode); 00090 } 00091 } 00092 00093 }