ILIAS  Release_4_1_x_branch Revision 61804
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilSCORM13Package Class Reference
+ Collaboration diagram for ilSCORM13Package:

Public Member Functions

 __construct ($packageId=null)
 load ($packageId)
 rollback ()
 exportZIP ()
 exportXML ()
 Export as internal XML.
 il_import ($packageFolder, $packageId, $ilias, $validate, $reimport=false)
 Imports an extracted SCORM 2004 module from ilias-data dir into database.
 il_importSco ($packageId, $sco_id, $packageFolder)
 Imports an extracted SCORM 2004 module from ilias-data dir into database.
 il_importLM ($slm, $packageFolder)
 importGlossary ($slm, $packageFolder)
 dbImportLM ($node, $parent_id)
 jsonNode ($node, &$sink)
 Helper for UploadAndImport Recursively copies values from XML into PHP array for export as json Elements are translated into sub array, attributes into literals.
 dbImportSco ($slm, $sco)
 dbImport ($node, &$lft=1, $depth=1, $parent=0)
 dbAddNew ()
 add new sahs and package record
 removeCMIData ()
 removeCPData ()
 dbRemoveAll ()
 transform ($inputdoc, $xslfile, $outputpath=null)
 validate ($doc, $schema)

Static Public Member Functions

static _removeTrackingDataForUser ($user_id)

Data Fields

const DB_ENCODE_XSL = './Modules/Scorm2004/templates/xsl/op/op-scorm13.xsl'
const CONVERT_XSL = './Modules/Scorm2004/templates/xsl/op/scorm12To2004.xsl'
const DB_DECODE_XSL = './Modules/Scorm2004/templates/xsl/op/op-scorm13-revert.xsl'
const VALIDATE_XSD = './Modules/Scorm2004/templates/xsd/op/op-scorm13.xsd'
const WRAPPER_HTML = './Modules/Scorm2004/scripts/converter/GenericRunTimeWrapper1.0_aadlc/GenericRunTimeWrapper.htm'
const WRAPPER_JS = './Modules/Scorm2004/scripts/converter/GenericRunTimeWrapper1.0_aadlc/SCOPlayerWrapper.js'
 $imsmanifest
 $manifest
 $diagnostic
 $status
 $packageId
 $packageName
 $packageHash
 $userId

Private Member Functions

 setProgress ($progress, $msg= '')

Private Attributes

 $packageFile
 $packageFolder
 $packagesFolder
 $packageData
 $slm
 $slm_tree
 $idmap = array()
 $progress = 0.0

Static Private Attributes

static $elements

Detailed Description

Constructor & Destructor Documentation

ilSCORM13Package::__construct (   $packageId = null)

Definition at line 74 of file ilSCORM13Package.php.

References $GLOBALS, $packageId, and load().

{
$this->packagesFolder = IL_OP_PACKAGES_FOLDER;
$this->load($packageId);
$this->userId = $GLOBALS['USER']['usr_id'];
}

+ Here is the call graph for this function:

Member Function Documentation

static ilSCORM13Package::_removeTrackingDataForUser (   $user_id)
static

Definition at line 1089 of file ilSCORM13Package.php.

References $data, $ilDB, $query, and $res.

Referenced by ilObjUser\delete().

{
global $ilDB;
//get all cmi_nodes to delete
$res = $ilDB->queryF('
SELECT cmi_node.cmi_node_id
FROM cmi_node, cp_node
WHERE cmi_node.cp_node_id = cp_node.cp_node_id AND cmi_node.user_id = %s',
array('integer'),
array($user_id)
);
$cmi_nodes = array();
while($data = $ilDB->fetchAssoc($res))
{
$cmi_node_values[] = $data['cmi_node_id'];
}
//get all cmi_interaction_nodes to delete
$res = $ilDB->queryF('
SELECT cmi_interaction.cmi_interaction_id
FROM cmi_interaction, cmi_node, cp_node
WHERE (cmi_node.user_id = %s
AND cmi_node.cp_node_id = cp_node.cp_node_id
AND cmi_node.cmi_node_id = cmi_interaction.cmi_node_id)',
array('integer'),
array($user_id)
);
$cmi_inodes = array();
while($data = $ilDB->fetchAssoc($res))
{
$cmi_inode_values[] = $data['cmi_interaction_id'];
}
//delete data in dependent tables
//response
$query = 'DELETE FROM cmi_correct_response WHERE '
. $ilDB->in('cmi_correct_response.cmi_interaction_id', $cmi_inode_values, false, 'integer');
$ilDB->manipulate($query);
//objective interaction
$query = 'DELETE FROM cmi_objective WHERE '
. $ilDB->in('cmi_objective.cmi_interaction_id', $cmi_inode_values, false, 'integer');
$ilDB->manipulate($query);
//objective
$query = 'DELETE FROM cmi_objective WHERE '
. $ilDB->in('cmi_objective.cmi_node_id', $cmi_node_values, false, 'integer');
$ilDB->manipulate($query);
//interaction
$query = 'DELETE FROM cmi_interaction WHERE '
. $ilDB->in('cmi_interaction.cmi_node_id', $cmi_node_values, false, 'integer');
$ilDB->manipulate($query);
//comment
$query = 'DELETE FROM cmi_comment WHERE '
. $ilDB->in('cmi_comment.cmi_node_id', $cmi_node_values, false, 'integer');
$ilDB->manipulate($query);
//node
$query = 'DELETE FROM cmi_node WHERE '
. $ilDB->in('cmi_node.cmi_node_id', $cmi_node_values, false, 'integer');
$ilDB->manipulate($query);
//gobjective
$ilDB->manipulateF(
'DELETE FROM cmi_gobjective WHERE user_id = %s',
array('integer'),
array($user_id)
);
}

+ Here is the caller graph for this function:

ilSCORM13Package::dbAddNew ( )

add new sahs and package record

Definition at line 889 of file ilSCORM13Package.php.

References $ilDB.

{
global $ilDB;
//$this->packageId = 100;
//return true;
//ilSCORM13DB::getRecord('sahs_lm', array());
// $this->packageId = ilSCORM13DB::getRecord('sahs_lm', array());
/* ilSCORM13DB::setRecord('cp_package', array(
'obj_id' => $this->packageId,
'xmldata' => $x->asXML(),
'jsdata' => json_encode($j),
), 'obj_id');
*/
$ilDB->insert('cp_package', array(
'obj_id' => array('integer', $this->packageId),
'xmldata' => array('clob', $x->asXML()),
'jsdata' => array('clob', json_encode($j))
));
return true;
}
ilSCORM13Package::dbImport (   $node,
$lft = 1,
  $depth = 1,
  $parent = 0 
)

Definition at line 692 of file ilSCORM13Package.php.

References $ilDB, $query, and $res.

Referenced by il_import().

{
global $ilDB;
switch ($node->nodeType)
{
case XML_DOCUMENT_NODE:
// insert into cp_package
/*ilSCORM13DB::setRecord('cp_package', array(
'obj_id' => $this->packageId,
'identifier' => $this->packageName,
'persistPreviousAttempts' => 0,
'settings' => '',
));*/
$res = $ilDB->queryF(
'SELECT * FROM cp_package WHERE obj_id = %s AND c_identifier = %s',
array('integer', 'text'),
array($this->packageId, $this->packageName)
);
if($num_rows = $ilDB->numRows($res))
{
$query = 'UPDATE cp_package '
. 'SET persistprevattempts = %s, c_settings = %s '
. 'WHERE obj_id = %s AND c_identifier= %s';
$ilDB->manipulateF(
array('integer', 'text', 'integer', 'text'),
array(0, NULL, $this->packageId, $this->packageName)
);
}
else
{
$query = 'INSERT INTO cp_package (obj_id, c_identifier, persistprevattempts, c_settings) '
. 'VALUES (%s, %s, %s, %s)';
$ilDB->manipulateF(
array('integer','text','integer', 'text'),
array($this->packageId, $this->packageName, 0, NULL)
);
}
// run sub nodes
$this->dbImport($node->documentElement); // RECURSION
break;
case XML_ELEMENT_NODE:
if ($node->nodeName==='manifest')
{
if ($node->getAttribute('uri')=="")
{
// default URI is md5 hash of zip file, i.e. packageHash
$node->setAttribute('uri', 'md5:' . $this->packageHash);
}
}
$cp_node_id = $ilDB->nextId('cp_node');
$query = 'INSERT INTO cp_node (cp_node_id, slm_id, nodename) '
. 'VALUES (%s, %s, %s)';
$ilDB->manipulateF(
array('integer', 'integer', 'text'),
array($cp_node_id, $this->packageId, $node->nodeName)
);
$query = 'INSERT INTO cp_tree (child, depth, lft, obj_id, parent, rgt) '
. 'VALUES (%s, %s, %s, %s, %s, %s)';
$ilDB->manipulateF(
array('integer', 'integer', 'integer', 'integer', 'integer', 'integer'),
array($cp_node_id, $depth, $lft++, $this->packageId, $parent, 0)
);
// insert into cp_*
//$a = array('cp_node_id' => $cp_node_id);
$names = array('cp_node_id');
$values = array($cp_node_id);
$types = array('integer');
foreach ($node->attributes as $attr)
{
switch(strtolower($attr->name))
{
case 'completionsetbycontent': $names[] = 'completionbycontent';break;
case 'objectivesetbycontent': $names[] = 'objectivebycontent';break;
case 'type': $names[] = 'c_type';break;
case 'mode': $names[] = 'c_mode';break;
case 'language': $names[] = 'c_language';break;
case 'condition': $names[] = 'c_condition';break;
case 'operator': $names[] = 'c_operator';break;
case 'condition': $names[] = 'c_condition';break;
case 'readnormalizedmeasure': $names[] = 'readnormalmeasure';break;
case 'writenormalizedmeasure': $names[] = 'writenormalmeasure';break;
case 'minnormalizedmeasure': $names[] = 'minnormalmeasure';break;
case 'primary': $names[] = 'c_primary';break;
case 'minnormalizedmeasure': $names[] = 'minnormalmeasure';break;
case 'persistpreviousattempts': $names[] = 'persistprevattempts';break;
case 'identifier': $names[] = 'c_identifier';break;
case 'settings': $names[] = 'c_settings';break;
case 'activityabsolutedurationlimit': $names[] = 'activityabsdurlimit';break;
case 'activityexperienceddurationlimit': $names[] = 'activityexpdurlimit';break;
case 'attemptabsolutedurationlimit': $names[] = 'attemptabsdurlimit';break;
case 'measuresatisfactionifactive': $names[] = 'measuresatisfactive';break;
case 'objectivemeasureweight': $names[] = 'objectivemeasweight';break;
case 'requiredforcompleted': $names[] = 'requiredcompleted';break;
case 'requiredforincomplete': $names[] = 'requiredincomplete';break;
case 'requiredfornotsatisfied': $names[] = 'requirednotsatisfied';break;
case 'rollupobjectivesatisfied': $names[] = 'rollupobjectivesatis';break;
case 'rollupprogresscompletion': $names[] = 'rollupprogcompletion';break;
case 'usecurrentattemptobjectiveinfo': $names[] = 'usecurattemptobjinfo';break;
case 'usecurrentattemptprogressinfo': $names[] = 'usecurattemptproginfo';break;
default: $names[] = strtolower($attr->name);break;
}
if(in_array($names[count($names) - 1],
array('flow', 'completionbycontent',
'objectivebycontent', 'rollupobjectivesatis',
'tracked', 'choice',
'choiceexit', 'satisfiedbymeasure',
'c_primary', 'constrainchoice',
'forwardonly', 'global_to_system',
'writenormalmeasure', 'writesatisfiedstatus',
'readnormalmeasure', 'readsatisfiedstatus',
'preventactivation', 'measuresatisfactive',
'reorderchildren', 'usecurattemptproginfo',
'usecurattemptobjinfo', 'rollupprogcompletion')))
{
if($attr->value == 'true')
$values[] = 1;
else if ($attr->value == 'false')
$values[] = 0;
else
$values[] = (int)$attr->value;
}
else
{
$values[] = $attr->value;
}
if( in_array($names[count($names) - 1],
array('objectivesglobtosys', 'attemptlimit',
'flow', 'completionbycontent',
'objectivebycontent', 'rollupobjectivesatis',
'tracked', 'choice',
'choiceexit', 'satisfiedbymeasure',
'c_primary', 'constrainchoice',
'forwardonly', 'global_to_system',
'writenormalmeasure', 'writesatisfiedstatus',
'readnormalmeasure', 'readsatisfiedstatus',
'preventactivation', 'measuresatisfactive',
'reorderchildren', 'usecurattemptproginfo',
'usecurattemptobjinfo', 'rollupprogcompletion')))
$types[] = 'integer';
else if ( in_array($names[count($names) - 1],
array('jsdata', 'xmldata', 'activitytree', 'data')))
$types[] = 'clob';
else if ( in_array($names[count($names) - 1],
array('objectivemeasweight')))
$types[] = 'float';
else
$types[] = 'text';
}
// we have to change the insert method because of clob fields ($ilDB->manipulate does not work here)
$insert_data = array();
foreach($names as $key => $db_field)
{
$insert_data[$db_field] = array($types[$key], trim($values[$key]));
}
$ilDB->insert('cp_'.strtolower($node->nodeName), $insert_data);
$node->setAttribute('foreignId', $cp_node_id);
$this->idmap[$node->getAttribute('id')] = $cp_node_id;
// run sub nodes
foreach($node->childNodes as $child)
{
$this->dbImport($child, $lft, $depth + 1, $cp_node_id); // RECURSION
}
// update cp_tree (rgt value for pre order walk in sql tree)
$query = 'UPDATE cp_tree SET rgt = %s WHERE child = %s';
$ilDB->manipulateF(
array('integer', 'integer'),
array($lft++, $cp_node_id)
);
break;
}
}

+ Here is the caller graph for this function:

ilSCORM13Package::dbImportLM (   $node,
  $parent_id 
)

Definition at line 387 of file ilSCORM13Package.php.

References ilSCORM2004Item\insert(), ilSCORM2004Node\putInTree(), ilTree\setTreeTablePK(), and ilSaxParser\startParsing().

Referenced by il_importLM().

{
switch($node->getName())
{
case "manifest":
$this->slm_tree =& new ilTree($this->slm->getId());
$this->slm_tree->setTreeTablePK("slm_id");
$this->slm_tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
$this->slm_tree->addTree($this->slm->getId(), 1);
//add seqinfo for rootNode
include_once ("./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Sequencing.php");
$seq_info = new ilSCORM2004Sequencing($this->slm->getId(),true);
$seq_info->insert();
if(file_exists($this->packageFolder . '/' . 'index.xml'))
{
$doc = simplexml_load_file($this->packageFolder . '/' . 'index.xml');
$l = $doc->xpath ( "/ContentObject/MetaData" );
if($l[0])
{
include_once 'Services/MetaData/classes/class.ilMDXMLCopier.php';
$mdxml =& new ilMDXMLCopier($l[0]->asXML(),$this->slm->getId(),$this->slm->getId(),$this->slm->getType());
$mdxml->startParsing();
$mdxml->getMDObject()->update();
}
}
break;
case "organization":
$this->slm->title=$node->title;
break;
case "item":
$a = $node->attributes();
if(preg_match("/il_\d+_chap_\d+/",$a['identifier']))
{
$chap=& new ilSCORM2004Chapter($this->slm);
$chap->setTitle($node->title);
$chap->setSLMId($this->slm->getId());
$chap->create(true);
$parent_id=$chap->getId();
$doc = simplexml_load_file($this->packageFolder . '/' . 'index.xml');
$l = $doc->xpath ( "/ContentObject/StructureObject/MetaData[General/Identifier/@Entry='".$a['identifier']."']" );
if($l[0])
{
include_once 'Services/MetaData/classes/class.ilMDXMLCopier.php';
$mdxml =& new ilMDXMLCopier($l[0]->asXML(),$this->slm->getId(),$chap->getId(),$chap->getType());
$mdxml->startParsing();
$mdxml->getMDObject()->update();
}
}
if(preg_match("/il_\d+_sco_(\d+)/",$a['identifier'], $match))
{
$sco = new ilSCORM2004Sco($this->slm);
$sco->setTitle($node->title);
$sco->setSLMId($this->slm->getId());
$sco->create(true);
ilSCORM2004Node::putInTree($sco, $parent_id, "");
$newPack = new ilSCORM13Package();
$newPack->il_importSco($this->slm->getId(),$sco->getId(),$this->packageFolder."/".$match[1]);
$parent_id = $sco->getId();
}
break;
}
//if($node->nodeType==XML_ELEMENT_NODE)
{
foreach($node->children() as $child)
{
$this->dbImportLM($child,$parent_id);
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilSCORM13Package::dbImportSco (   $slm,
  $sco 
)

Definition at line 492 of file ilSCORM13Package.php.

References $d, $filename, $path, $result, $slm, $t, ilObjMediaObject\_getDirectory(), ilUtil\getDir(), ilObjMediaObject\getMimeType(), IL_MO_PARSE_QTI, IL_MO_VERIFY_QTI, ilSCORM2004Node\putInTree(), ilFileUtils\recursive_dirscan(), ilUtil\renameExecutables(), ilSaxParser\startParsing(), ilUtil\stripSlashes(), and ilFileUtils\utf8_encode().

Referenced by il_importSco().

{
$qtis = array();
$d = ilUtil::getDir ( $this->packageFolder );
foreach ( $d as $f ) {
//continue;
if ($f [type] == 'file' && substr ( $f [entry], 0, 4 ) == 'qti_') {
include_once "./Services/QTI/classes/class.ilQTIParser.php";
include_once "./Modules/Test/classes/class.ilObjTest.php";
$qtiParser = new ilQTIParser ( $this->packageFolder . "/" . $f [entry], IL_MO_VERIFY_QTI, 0, "" );
$result = $qtiParser->startParsing ();
$founditems = & $qtiParser->getFoundItems ();
// die(print_r($founditems));
foreach ( $founditems as $qp ) {
$newObj = new ilObjTest ( 0, true );
// This creates a lot of invalid repository objects for each question
// question are not repository objects (see e.g. table object_data), alex 29 Sep 2009
// $newObj->setType ( $qp ['type'] );
// $newObj->setTitle ( $qp ['title'] );
// $newObj->create ( true );
// $newObj->createReference ();
// $newObj->putInTree ($_GET ["ref_id"]);
// $newObj->setPermissions ( $sco->getId ());
// $newObj->notify ("new", $_GET["ref_id"], $sco->getId (), $_GET["ref_id"], $newObj->getRefId () );
// $newObj->mark_schema->flush ();
$qtiParser = new ilQTIParser ( $this->packageFolder . "/" . $f [entry], IL_MO_PARSE_QTI, 0, "" );
$qtiParser->setTestObject ( $newObj );
$result = $qtiParser->startParsing ();
// $newObj->saveToDb ();
$qtis = array_merge($qtis, $qtiParser->getImportMapping());
}
}
}
//exit;
include_once 'class.ilSCORM2004Page.php';
$doc = new SimpleXMLElement($this->imsmanifest->saveXml());
$l = $doc->xpath ( "/ContentObject/MetaData" );
if($l[0])
{
include_once 'Services/MetaData/classes/class.ilMDXMLCopier.php';
$mdxml =& new ilMDXMLCopier($l[0]->asXML(),$slm->getId(),$sco->getId(),$sco->getType());
$mdxml->startParsing();
$mdxml->getMDObject()->update();
}
$l = $doc->xpath("/ContentObject/PageObject");
foreach ( $l as $page_xml )
{
$tnode = $page_xml->xpath ( 'MetaData/General/Title' );
$page = new ilSCORM2004PageNode ( $slm );
$page->setTitle ( $tnode [0] );
$page->setSLMId ( $slm->getId () );
$page->create (true);
ilSCORM2004Node::putInTree ( $page, $sco->getId (), $target );
$pmd = $page_xml->xpath ("MetaData");
if($pmd[0])
{
include_once 'Services/MetaData/classes/class.ilMDXMLCopier.php';
$mdxml =& new ilMDXMLCopier($pmd[0]->asXML(),$slm->getId(),$page->getId(),$page->getType());
$mdxml->startParsing();
$mdxml->getMDObject()->update();
}
$tnode = $page_xml->xpath("//MediaObject/MediaAlias");
foreach($tnode as $ttnode)
{
include_once './Services/MediaObjects/classes/class.ilObjMediaObject.php';
$OriginId = $ttnode[OriginId];
$medianodes = $doc->xpath("//MediaObject[MetaData/General/Identifier/@Entry='".$OriginId ."']");
$medianode = $medianodes[0];
if($medianode)
{
$media_object = new ilObjMediaObject ( );
$media_object->setTitle ($medianode->MetaData->General->Title);
$media_object->setDescription ($medianode->MetaData->General->Description);
$media_object->create (false);
$mmd = $medianode->xpath ("MetaData");
if($mmd[0])
{
include_once 'Services/MetaData/classes/class.ilMDXMLCopier.php';
$mdxml =& new ilMDXMLCopier($mmd[0]->asXML(),0,$media_object->getId(),$media_object->getType());
$mdxml->startParsing();
$mdxml->getMDObject()->update();
}
// determine and create mob directory, move uploaded file to directory
$media_object->createDirectory ();
$mob_dir = ilObjMediaObject::_getDirectory ( $media_object->getId () );
foreach ( $medianode->MediaItem as $xMediaItem )
{
$media_item = & new ilMediaItem ( );
$media_object->addMediaItem ( $media_item );
$media_item->setPurpose($xMediaItem[Purpose]);
$media_item->setFormat($xMediaItem->Format );
$media_item->setLocation($xMediaItem->Location);
$media_item->setLocationType($xMediaItem->Location[Type]);
$media_item->setWidth ( $xMediaItem->Layout[Width]);
$media_item->setHeight ( $xMediaItem->Layout[Height]);
$media_item->setHAlign($xMediaItem->Layout[HorizontalAlign]);
if($media_item->getLocationType()=="LocalFile")
{
$tmp_name = $this->packageFolder."/objects/".$OriginId."/".$xMediaItem->Location;
copy($tmp_name, $mob_dir."/".$xMediaItem->Location);
}
}
// alex: fixed media import: these lines have been
// behind the next curly bracket which makes it fail
// when no medianode is given. (id=0 -> fatal error)
$media_object->update(true);
$ttnode [OriginId] = "il__mob_" . $media_object->getId ();
}
}
include_once("./Modules/File/classes/class.ilObjFile.php");
include_once("./Services/Utilities/classes/class.ilFileUtils.php");
include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
$intlinks = $page_xml->xpath("//IntLink");
//die($intlinks);
//if($intlinks )
{
foreach ( $intlinks as $intlink )
{
if($intlink[Type]!="File") continue;
$path = $this->packageFolder."/objects/".str_replace('dfile','file',$intlink[Target]);
if(!is_dir($path )) continue;
$ffiles = array();
$filename = $ffiles[file][0];
$fileObj = new ilObjFile();
$fileObj->setType("file");
// better use this, mime_content_type is deprecated
$fileObj->setFileType(ilObjMediaObject::getMimeType($path. "/" . $filename));
$fileObj->setFileSize(filesize($path. "/" . $filename));
$fileObj->create();
$fileObj->createReference();
//$fileObj->putInTree($_GET["ref_id"]);
//$fileObj->setPermissions($slm->getId ());
$fileObj->createDirectory();
$fileObj->storeUnzipedFile($path."/" .$filename,ilFileUtils::utf8_encode(ilUtil::stripSlashes($filename)));
$intlink[Target]="il__dfile_".$fileObj->getId();
}
}
$fileitems = $page_xml->xpath("//FileItem/Identifier");
//if($intlinks )
{
foreach ( $fileitems as $fileitem )
{
$path = $this->packageFolder."/objects/".$fileitem[Entry];
if(!is_dir($path )) continue;
$ffiles = array();
$filename = $ffiles[file][0];
$fileObj = new ilObjFile();
$fileObj->setType("file");
// better use this, mime_content_type is deprecated
$fileObj->setFileType(ilObjMediaObject::getMimeType($path. "/" . $filename));
$fileObj->setFileSize(filesize($path. "/" . $filename));
$fileObj->create();
$fileObj->createReference();
//$fileObj->putInTree($_GET["ref_id"]);
//$fileObj->setPermissions($slm->getId ());
$fileObj->createDirectory();
$fileObj->storeUnzipedFile($path."/" .$filename,ilFileUtils::utf8_encode(ilUtil::stripSlashes($filename)));
$fileitem[Entry]="il__file_".$fileObj->getId();
}
}
$pagex = new ilSCORM2004Page($page->getId());
$ddoc = new DOMDocument();
$ddoc->async = false;
$ddoc->preserveWhiteSpace = false;
$ddoc->formatOutput = false;
$ddoc->loadXML($page_xml->asXML());
$xpath = new DOMXPath($ddoc);
$tnode = $xpath->query('PageContent');
$t = "<PageObject>";
foreach($tnode as $ttnode)
$t .= $ddoc->saveXML($ttnode);
$t .="</PageObject>";
foreach ($qtis as $old=>$q)
$t = str_replace($old,'il__qst_'.$q['pool'], $t);
$pagex->setXMLContent($t);
$pagex->updateFromXML();
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilSCORM13Package::dbRemoveAll ( )

Definition at line 1032 of file ilSCORM13Package.php.

References removeCMIData(), and removeCPData().

Referenced by il_import(), and rollback().

{
//dont change order of calls
$this->removeCMIData();
$this->removeCPData();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilSCORM13Package::exportXML ( )

Export as internal XML.

Definition at line 124 of file ilSCORM13Package.php.

References $ilDB, $res, and $row.

{
global $ilDB;
header('content-type: text/xml');
header('content-disposition: attachment; filename="manifest.xml"');
//$row = ilSCORM13DB::getRecord("cp_package", "obj_id",$this->packageId);
$res = $ilDB->queryF(
'SELECT xmldata FROM cp_package WHERE obj_id = %s',
array('integer'),
array($this->packageId)
);
$row = $ilDB->fetchAssoc($res);
print($row['xmldata']);
}
ilSCORM13Package::exportZIP ( )

Definition at line 114 of file ilSCORM13Package.php.

{
header('content-type: application/zip');
header('content-disposition: attachment; filename="' . basename($this->packageFile) . '"');
readfile($this->packageFile);
}
ilSCORM13Package::il_import (   $packageFolder,
  $packageId,
  $ilias,
  $validate,
  $reimport = false 
)

Imports an extracted SCORM 2004 module from ilias-data dir into database.

public

Returns
string title of package

Definition at line 149 of file ilSCORM13Package.php.

References $ilDB, $ilErr, $ilLog, $packageFolder, $packageId, ilObject\_lookupType(), dbImport(), dbRemoveAll(), jsonNode(), transform(), and validate().

{
global $ilDB, $ilLog, $ilErr;
if ($reimport === true) {
$this->packageId = $packageId;
$this->dbRemoveAll();
}
$this->packageFolder=$packageFolder;
$this->packageId=$packageId;
$this->imsmanifestFile = $this->packageFolder . '/' . 'imsmanifest.xml';
//step 1 - parse Manifest-File and validate
$this->imsmanifest = new DOMDocument;
$this->imsmanifest->async = false;
if (!@$this->imsmanifest->load($this->imsmanifestFile))
{
$this->diagnostic[] = 'XML not wellformed';
return false;
}
//step 2 tranform
$this->manifest = $this->transform($this->imsmanifest, self::DB_ENCODE_XSL);
if (!$this->manifest)
{
$this->diagnostic[] = 'Cannot transform into normalized manifest';
return false;
}
//step 3 validation -just for normalized XML
if ($validate=="y") {
if (!$this->validate($this->manifest, self::VALIDATE_XSD))
{
$ilErr->raiseError("<b>The uploaded SCORM 1.2 / SCORM 2004 is not valid. You can try to import the package without the validation option checked on your own risk. </b><br><br>Validation Error(s):</b><br> Normalized XML is not conform to ". self::VALIDATE_XSD,
$ilErr->MESSAGE);
}
}
$this->dbImport($this->manifest);
if(file_exists($this->packageFolder . '/' . 'index.xml'))
{
$doc = simplexml_load_file($this->packageFolder . '/' . 'index.xml');
$l = $doc->xpath ("/ContentObject/MetaData" );
if($l[0])
{
include_once 'Services/MetaData/classes/class.ilMDXMLCopier.php';
$mdxml->startParsing();
$mdxml->getMDObject()->update();
}
}
//step 5
$x = simplexml_load_string($this->manifest->saveXML());
$x['persistPreviousAttempts'] = $this->packageData['persistprevattempts'];
$x['online'] = $this->packageData['c_online'];
$x['defaultLessonMode'] = $this->packageData['default_lesson_mode'];
$x['credit'] = $this->packageData['credit'];
$x['autoReview'] = $this->packageData['auto_review'];
$j = array();
// first read resources into flat array to resolve item/identifierref later
$r = array();
foreach ($x->resource as $xe)
{
$r[strval($xe['id'])] = $xe;
unset($xe);
}
// iterate through items and set href and scoType as activity attributes
foreach ($x->xpath('//*[local-name()="item"]') as $xe)
{
// get reference to resource and set href accordingly
if ($b = $r[strval($xe['resourceId'])])
{
$xe['href'] = strval($b['base']) . strval($b['href']);
unset($xe['resourceId']);
if (strval($b['scormType'])=='sco') $xe['sco'] = true;
}
}
// iterate recursivly through activities and build up simple php object
// with items and associated sequencings
// top node is the default organization which is handled as an item
self::jsonNode($x->organization, $j['item']);
foreach($x->sequencing as $s)
{
self::jsonNode($s, $j['sequencing'][]);
}
// combined manifest+resources xml:base is set as organization base
$j['item']['base'] = strval($x['base']);
// package folder is base to whole playing process
$j['base'] = $packageFolder . '/';
$j['foreignId'] = floatval($x['foreignId']); // manifest cp_node_id for associating global (package wide) objectives
$j['id'] = strval($x['id']); // manifest id for associating global (package wide) objectives
//last step - build ADL Activity tree
$act = new SeqTreeBuilder();
$adl_tree = $act->buildNodeSeqTree($this->imsmanifestFile);
$ilDB->update('cp_package',
array(
'xmldata' => array('clob', $x->asXML()),
'jsdata' => array('clob', json_encode($j)),
'activitytree' => array('clob', json_encode($adl_tree['tree'])),
'global_to_system' => array('integer', (int)$adl_tree['global'])
),
array(
'obj_id' => array('integer', (int)$this->packageId)
)
);
return $j['item']['title'];
}

+ Here is the call graph for this function:

ilSCORM13Package::il_importLM (   $slm,
  $packageFolder 
)

Definition at line 332 of file ilSCORM13Package.php.

References $ilDB, $ilLog, $packageFolder, $slm, dbImportLM(), and importGlossary().

{
global $ilDB, $ilLog;
$this->packageFolder=$packageFolder;
$this->packageId=$slm->getId();
$this->imsmanifestFile = $this->packageFolder . '/' . 'imsmanifest.xml';
$this->imsmanifest = new DOMDocument;
$this->imsmanifest->async = false;
$this->slm = $slm;
if (!@$this->imsmanifest->load($this->imsmanifestFile))
{
$this->diagnostic[] = 'XML not wellformed';
return false;
}
$this->dbImportLM(simplexml_import_dom($this->imsmanifest->documentElement),$this->slm);
if(is_dir($packageFolder."/glossary"))
{
$this->importGlossary($slm,$packageFolder."/glossary");
}
//die($slm->title);
return $slm->title;
}

+ Here is the call graph for this function:

ilSCORM13Package::il_importSco (   $packageId,
  $sco_id,
  $packageFolder 
)

Imports an extracted SCORM 2004 module from ilias-data dir into database.

public

Returns
string title of package

Definition at line 270 of file ilSCORM13Package.php.

References $ilDB, $ilLog, $packageFolder, $packageId, $slm, and dbImportSco().

{
global $ilDB, $ilLog;
$this->packageFolder=$packageFolder;
$this->packageId=$packageId;
$this->imsmanifestFile = $this->packageFolder . '/' . 'index.xml';
$this->imsmanifest = new DOMDocument;
$this->imsmanifest->async = false;
if (!@$this->imsmanifest->load($this->imsmanifestFile))
{
$this->diagnostic[] = 'XML not wellformed';
return false;
}
$sco = new ilSCORM2004Sco($slm,$sco_id);
$this->dbImportSco($slm,$sco);
// import sco.xml
$sco_xml_file = $this->packageFolder . '/sco.xml';
if (is_file($sco_xml_file))
{
$scodoc = new DOMDocument;
$scodoc->async = false;
if (!@$scodoc->load($sco_xml_file))
{
$this->diagnostic[] = 'XML of sco.xml not wellformed';
return false;
}
//$doc = new SimpleXMLElement($scodoc->saveXml());
//$l = $doc->xpath("/sco/objective");
$xpath = new DOMXPath($scodoc);
$nodes = $xpath->query("/sco/objective");
foreach($nodes as $node)
{
$t_node = $node->firstChild;
if (is_object($t_node))
{
$objective_text = $t_node->textContent;
if (trim($objective_text) != "")
{
$objs = $sco->getObjectives();
foreach ($objs as $o)
{
$mappings = $o->getMappings();
if ($mappings == null)
{
$ob = new ilScorm2004Objective($sco->getId(), $o->getId());
$ob->setObjectiveID($objective_text);
$ob->updateObjective();
}
}
}
}
}
}
return "";
}

+ Here is the call graph for this function:

ilSCORM13Package::importGlossary (   $slm,
  $packageFolder 
)

Definition at line 356 of file ilSCORM13Package.php.

References $_GET, $packageFolder, and $slm.

Referenced by il_importLM().

{
global $ilias;
// create and insert object in objecttree
include_once("./Modules/Glossary/classes/class.ilObjGlossary.php");
$newObj = new ilObjGlossary();
$newObj->setType('glo');
$newObj->setTitle('');
$newObj->create(true);
$newObj->createReference();
$newObj->putInTree($_GET["ref_id"]);
$newObj->setPermissions($_GET["ref_id"]);
$newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
$xml_file = $packageFolder."/glossary.xml";
// check whether xml file exists within zip file
if (!is_file($xml_file))
{
return;
}
include_once ("./Modules/LearningModule/classes/class.ilContObjParser.php");
$contParser = new ilContObjParser($newObj, $xml_file, $packageFolder);
$contParser->startParsing();
$newObj->update();
//ilObject::_writeImportId($newObj->getId(), $newObj->getImportId());
$slm->setAssignedGlossary($newObj->getId());
$slm->update();
}

+ Here is the caller graph for this function:

ilSCORM13Package::jsonNode (   $node,
$sink 
)

Helper for UploadAndImport Recursively copies values from XML into PHP array for export as json Elements are translated into sub array, attributes into literals.

Parameters
xmlelement to process
referenceto array object where to copy values
Returns
void

Definition at line 475 of file ilSCORM13Package.php.

Referenced by il_import().

{
foreach ($node->attributes() as $k => $v)
{
// cast to boolean and number if possible
$v = strval($v);
if ($v==="true") $v = true;
else if ($v==="false") $v = false;
else if (is_numeric($v)) $v = (float) $v;
$sink[$k] = $v;
}
foreach ($node->children() as $name => $child)
{
self::jsonNode($child, $sink[$name][]); // RECURSION
}
}

+ Here is the caller graph for this function:

ilSCORM13Package::load (   $packageId)

Definition at line 81 of file ilSCORM13Package.php.

References $ilDB, and $packageId.

Referenced by __construct().

{
global $ilDB;
if (!is_numeric($packageId))
{
return false;
}
$lm_set = $ilDB->queryF('SELECT * FROM sahs_lm WHERE id = %s', array('integer'), array($packageId));
$lm_data = $ilDB->fetchAssoc($lm_set);
$pg_set = $ilDB->queryF('SELECT * FROM cp_package WHERE obj_id = %s', array('integer'), array($packageId));
$pg_data = $ilDB->fetchAssoc($lm_set);
$this->packageData = array_merge($lm_data, $pg_data);
$this->packageId = $packageId;
$this->packageFolder = $this->packagesFolder . '/' . $packageId;
$this->packageFile = $this->packageFolder . '.zip';
$this->imsmanifestFile = $this->packageFolder . '/' . 'imsmanifest.xml';
return true;
}

+ Here is the caller graph for this function:

ilSCORM13Package::removeCMIData ( )

Definition at line 914 of file ilSCORM13Package.php.

References $data, $ilDB, $query, $res, and ilLPStatusWrapper\_refreshStatus().

Referenced by dbRemoveAll().

{
global $ilDB;
//cmi nodes
$cmi_nodes = array();
$res = $ilDB->queryF('
SELECT cmi_node.cmi_node_id
FROM cmi_node, cp_node
WHERE cp_node.slm_id = %s AND cmi_node.cp_node_id = cp_node.cp_node_id',
array('integer'),
array($this->packageId)
);
while($data = $ilDB->fetchAssoc($res))
{
$cmi_node_values[] = $data['cmi_node_id'];
}
//cmi interaction nodes
$cmi_inodes = array();
$res = $ilDB->queryF('
SELECT cmi_interaction.cmi_interaction_id
FROM cmi_interaction, cmi_node, cp_node
WHERE (cp_node.slm_id = %s
AND cmi_node.cp_node_id = cp_node.cp_node_id
AND cmi_node.cmi_node_id = cmi_interaction.cmi_node_id)',
array('integer'),
array($this->packageId)
);
while($data = $ilDB->fetchAssoc($res))
{
$cmi_inode_values[] = $data['cmi_interaction_id'];
}
//response
$query = 'DELETE FROM cmi_correct_response WHERE '
. $ilDB->in('cmi_correct_response.cmi_interaction_id', $cmi_inode_values, false, 'integer');
$ilDB->manipulate($query);
//objective interaction
$query = 'DELETE FROM cmi_objective WHERE '
. $ilDB->in('cmi_objective.cmi_interaction_id', $cmi_inode_values, false, 'integer');
$ilDB->manipulate($query);
//objective
$query = 'DELETE FROM cmi_objective WHERE '
. $ilDB->in('cmi_objective.cmi_node_id', $cmi_node_values, false, 'integer');
$ilDB->manipulate($query);
//interaction
$query = 'DELETE FROM cmi_interaction WHERE '
. $ilDB->in('cmi_interaction.cmi_node_id', $cmi_node_values, false, 'integer');
$ilDB->manipulate($query);
//comment
$query = 'DELETE FROM cmi_comment WHERE '
. $ilDB->in('cmi_comment.cmi_node_id', $cmi_node_values, false, 'integer');
$ilDB->manipulate($query);
//node
$query = 'DELETE FROM cmi_node WHERE '
. $ilDB->in('cmi_node.cmi_node_id', $cmi_node_values, false, 'integer');
$ilDB->manipulate($query);
include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilSCORM13Package::removeCPData ( )

Definition at line 985 of file ilSCORM13Package.php.

References $data, $ilDB, $ilLog, $in, $res, and $t.

Referenced by dbRemoveAll().

{
global $ilDB, $ilLog;
//get relevant nodes
$cp_nodes = array();
$res = $ilDB->queryF(
'SELECT cp_node.cp_node_id FROM cp_node WHERE cp_node.slm_id = %s',
array('integer'),
array($this->packageId)
);
while($data = $ilDB->fetchAssoc($res))
{
$cp_nodes[] = $data['cp_node_id'];
}
//remove package data
foreach(self::$elements['cp'] as $t)
{
$t = 'cp_' . $t;
$in = $ilDB->in(strtolower($t).'.cp_node_id', $cp_nodes, false, 'integer');
$ilDB->manipulate('DELETE FROM '.strtolower($t).' WHERE '.$in);
}
// remove CP structure entries in tree and node
$ilDB->manipulateF(
'DELETE FROM cp_tree WHERE cp_tree.obj_id = %s',
array('integer'),
array($this->packageId)
);
$ilDB->manipulateF(
'DELETE FROM cp_node WHERE cp_node.slm_id = %s',
array('integer'),
array($this->packageId)
);
// remove general package entry
$ilDB->manipulateF(
'DELETE FROM cp_package WHERE cp_package.obj_id = %s',
array('integer'),
array($this->packageId)
);
}

+ Here is the caller graph for this function:

ilSCORM13Package::rollback ( )

Definition at line 103 of file ilSCORM13Package.php.

References dbRemoveAll(), and setProgress().

{
$this->setProgress(0, 'Rolling back...');
$this->dbRemoveAll();
if (is_dir($this->packageFolder))
dir_delete($this->packageFolder);
if (is_file($this->packageFile))
@unlink($this->packageFile);
$this->setProgress(0, 'Roll back finished: Ok. ');
}

+ Here is the call graph for this function:

ilSCORM13Package::setProgress (   $progress,
  $msg = '' 
)
private

Definition at line 461 of file ilSCORM13Package.php.

References $progress.

Referenced by rollback().

{
$this->progress = $progress;
$this->diagnostic[] = $msg;
}

+ Here is the caller graph for this function:

ilSCORM13Package::transform (   $inputdoc,
  $xslfile,
  $outputpath = null 
)

Definition at line 1039 of file ilSCORM13Package.php.

Referenced by il_import().

{
$xsl = new DOMDocument;
$xsl->async = false;
if (!@$xsl->load($xslfile))
{
die('ERROR: load StyleSheet ' . $xslfile);
}
$prc = new XSLTProcessor;
$r = @$prc->importStyleSheet($xsl);
if (false===@$prc->importStyleSheet($xsl))
{
die('ERROR: importStyleSheet ' . $xslfile);
}
if ($outputpath)
{
file_put_contents($outputpath, $prc->transformToXML($inputdoc));
}
else
{
return $prc->transformToDoc($inputdoc);
}
}

+ Here is the caller graph for this function:

ilSCORM13Package::validate (   $doc,
  $schema 
)

Definition at line 1063 of file ilSCORM13Package.php.

Referenced by il_import().

{
libxml_use_internal_errors(true);
$return = @$doc->schemaValidate($schema);
if (!$return)
{
$levels = array(
LIBXML_ERR_ERROR => 'Error',
LIBXML_ERR_FATAL => 'Fatal Error'
);
foreach (libxml_get_errors() as $error)
{
$level = $levels[$error->level];
if (isset($level))
{
$message = trim($error->message);
$this->diagnostic[] = "XSLT $level (Line $error->line) $message";
}
}
libxml_clear_errors();
}
libxml_use_internal_errors(false);
return $return;
}

+ Here is the caller graph for this function:

Field Documentation

ilSCORM13Package::$diagnostic

Definition at line 39 of file ilSCORM13Package.php.

ilSCORM13Package::$elements
staticprivate
Initial value:
array(
'cp' => array(
'manifest',
'organization',
'item',
'hideLMSUI',
'resource',
'file',
'dependency',
'sequencing',
'rule',
'auxilaryResource',
'condition',
'mapinfo',
'objective',
),
'cmi' => array(
'comment',
'correct_response',
'interaction',
'node',
'objective',
),
)

Definition at line 49 of file ilSCORM13Package.php.

ilSCORM13Package::$idmap = array()
private

Definition at line 46 of file ilSCORM13Package.php.

ilSCORM13Package::$imsmanifest

Definition at line 37 of file ilSCORM13Package.php.

ilSCORM13Package::$manifest

Definition at line 38 of file ilSCORM13Package.php.

ilSCORM13Package::$packageData
private

Definition at line 33 of file ilSCORM13Package.php.

ilSCORM13Package::$packageFile
private

Definition at line 30 of file ilSCORM13Package.php.

ilSCORM13Package::$packageFolder
private

Definition at line 31 of file ilSCORM13Package.php.

Referenced by il_import(), il_importLM(), il_importSco(), and importGlossary().

ilSCORM13Package::$packageHash

Definition at line 43 of file ilSCORM13Package.php.

ilSCORM13Package::$packageId

Definition at line 41 of file ilSCORM13Package.php.

Referenced by __construct(), il_import(), il_importSco(), and load().

ilSCORM13Package::$packageName

Definition at line 42 of file ilSCORM13Package.php.

ilSCORM13Package::$packagesFolder
private

Definition at line 32 of file ilSCORM13Package.php.

ilSCORM13Package::$progress = 0.0
private

Definition at line 47 of file ilSCORM13Package.php.

Referenced by setProgress().

ilSCORM13Package::$slm
private

Definition at line 34 of file ilSCORM13Package.php.

Referenced by dbImportSco(), il_importLM(), il_importSco(), and importGlossary().

ilSCORM13Package::$slm_tree
private

Definition at line 35 of file ilSCORM13Package.php.

ilSCORM13Package::$status

Definition at line 40 of file ilSCORM13Package.php.

ilSCORM13Package::$userId

Definition at line 44 of file ilSCORM13Package.php.

const ilSCORM13Package::CONVERT_XSL = './Modules/Scorm2004/templates/xsl/op/scorm12To2004.xsl'

Definition at line 22 of file ilSCORM13Package.php.

const ilSCORM13Package::DB_DECODE_XSL = './Modules/Scorm2004/templates/xsl/op/op-scorm13-revert.xsl'

Definition at line 23 of file ilSCORM13Package.php.

const ilSCORM13Package::DB_ENCODE_XSL = './Modules/Scorm2004/templates/xsl/op/op-scorm13.xsl'

Definition at line 21 of file ilSCORM13Package.php.

const ilSCORM13Package::VALIDATE_XSD = './Modules/Scorm2004/templates/xsd/op/op-scorm13.xsd'

Definition at line 24 of file ilSCORM13Package.php.

const ilSCORM13Package::WRAPPER_HTML = './Modules/Scorm2004/scripts/converter/GenericRunTimeWrapper1.0_aadlc/GenericRunTimeWrapper.htm'

Definition at line 26 of file ilSCORM13Package.php.

const ilSCORM13Package::WRAPPER_JS = './Modules/Scorm2004/scripts/converter/GenericRunTimeWrapper1.0_aadlc/SCOPlayerWrapper.js'

Definition at line 27 of file ilSCORM13Package.php.


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