Class ilObjSCORM2004LearningModule. More...
Inheritance diagram for ilObjSCORM2004LearningModule:
Collaboration diagram for ilObjSCORM2004LearningModule:Public Member Functions | |
| ilObjSCORM2004LearningModule ($a_id=0, $a_call_by_reference=true) | |
| Constructor public. | |
| validate ($directory) | |
| Validate all XML-Files in a SCOM-Directory. | |
| readObject () | |
| read manifest file public | |
| fixReload () | |
| convert_1_2_to_2004 ($manifest) | |
| getTrackedUsers () | |
| get all tracked items of current user | |
| deleteTrackingDataOfUsers ($a_users) | |
| get all tracked items of current user | |
| getTrackedItems () | |
| get all tracked items of current user | |
| getTrackingDataAgg ($a_sco_id) | |
| _ISODurationToCentisec ($str) | |
| convert ISO 8601 Timeperiods to centiseconds ta | |
| _getTrackingItems ($a_obj_id) | |
| get all tracking items of scorm object | |
Static Public Member Functions | |
| static | _getStatus ($a_obj_id, $a_user_id) |
| static | _getSatisfied ($a_obj_id, $a_user_id) |
| static | _getMeasure ($a_obj_id, $a_user_id) |
| static | _lookupItemTitle ($a_node_id) |
Data Fields | |
| $validator | |
| const | CONVERT_XSL = './Modules/Scorm2004/templates/xsl/op/scorm12To2004.xsl' |
| const | WRAPPER_HTML = './Modules/Scorm2004/scripts/converter/GenericRunTimeWrapper1.0_aadlc/GenericRunTimeWrapper.htm' |
| const | WRAPPER_JS = './Modules/Scorm2004/scripts/converter/GenericRunTimeWrapper1.0_aadlc/SCOPlayerWrapper.js' |
Class ilObjSCORM2004LearningModule.
Definition at line 35 of file class.ilObjSCORM2004LearningModule.php.
| static ilObjSCORM2004LearningModule::_getMeasure | ( | $ | a_obj_id, | |
| $ | a_user_id | |||
| ) | [static] |
Definition at line 552 of file class.ilObjSCORM2004LearningModule.php.
{
global $ilDB;
$q = "SELECT * FROM cmi_gobjective ".
" WHERE scope_id = ".$ilDB->quote($a_obj_id).
" AND objective_id = ".$ilDB->quote("-course_overall_status-").
" AND user_id = ".$ilDB->quote($a_user_id);
$status_set = $ilDB->query($q);
if ($status_rec = $status_set->fetchRow(DB_FETCHMODE_ASSOC))
{
return $status_rec["measure"];
}
return false;
}
| static ilObjSCORM2004LearningModule::_getSatisfied | ( | $ | a_obj_id, | |
| $ | a_user_id | |||
| ) | [static] |
Definition at line 533 of file class.ilObjSCORM2004LearningModule.php.
{
global $ilDB;
$q = "SELECT * FROM cmi_gobjective ".
" WHERE scope_id = ".$ilDB->quote($a_obj_id).
" AND objective_id = ".$ilDB->quote("-course_overall_status-").
" AND user_id = ".$ilDB->quote($a_user_id);
$status_set = $ilDB->query($q);
if ($status_rec = $status_set->fetchRow(DB_FETCHMODE_ASSOC))
{
return $status_rec["satisfied"];
}
return false;
}
| static ilObjSCORM2004LearningModule::_getStatus | ( | $ | a_obj_id, | |
| $ | a_user_id | |||
| ) | [static] |
Definition at line 514 of file class.ilObjSCORM2004LearningModule.php.
{
global $ilDB;
$q = "SELECT * FROM cmi_gobjective ".
" WHERE scope_id = ".$ilDB->quote($a_obj_id).
" AND objective_id = ".$ilDB->quote("-course_overall_status-").
" AND user_id = ".$ilDB->quote($a_user_id);
$status_set = $ilDB->query($q);
if ($status_rec = $status_set->fetchRow(DB_FETCHMODE_ASSOC))
{
return $status_rec["status"];
}
return false;
}
| ilObjSCORM2004LearningModule::_getTrackingItems | ( | $ | a_obj_id | ) |
get all tracking items of scorm object
currently a for learning progress only
static
Reimplemented from ilObjSCORMLearningModule.
Definition at line 481 of file class.ilObjSCORM2004LearningModule.php.
References $res.
Referenced by ilLPCollections::_getPossibleSAHSItems().
{
global $ilDB;
$q = "SELECT cp_item.* ".
" FROM cp_node, cp_item WHERE slm_id = ".
$ilDB->quote($a_obj_id).
" AND cp_node.cp_node_id = cp_item.cp_node_id ".
" ORDER BY cp_node.cp_node_id ";
$item_set = $ilDB->query($q);
$items = array();
while ($item_rec = $item_set->fetchRow(DB_FETCHMODE_ASSOC))
{
$s2 = $ilDB->query("SELECT cp_resource.* ".
" FROM cp_node, cp_resource WHERE slm_id = ".
$ilDB->quote($a_obj_id).
" AND cp_node.cp_node_id = cp_resource.cp_node_id ".
" AND cp_resource.id = ".$ilDB->quote($item_rec["resourceId"]));
if ($res = $s2->fetchRow(DB_FETCHMODE_ASSOC))
{
if ($res["scormType"] == "sco")
{
$items[] = array("id" => $item_rec["cp_node_id"],
"title" => $item_rec["title"]);
}
}
}
return $items;
}
Here is the caller graph for this function:| ilObjSCORM2004LearningModule::_ISODurationToCentisec | ( | $ | str | ) |
convert ISO 8601 Timeperiods to centiseconds ta
static
Definition at line 419 of file class.ilObjSCORM2004LearningModule.php.
{
$aV = array(0, 0, 0, 0, 0, 0);
$bErr = false;
$bTFound = false;
if (strpos($str,"P") != 0) {
$bErr = true;
}
if (!$bErr) {
$aT = array("Y", "M", "D", "H", "M", "S");
$p = 0;
$i = 0;
$str = substr($str,1);
for ($i = 0; $i < count($aT); $i++) {
if (strpos($str,"T")===0) {
$str = substr($str,1);
$i = max($i, 3);
$bTFound = true;
}
$p = strpos($str,$aT[$i]);
if ($p > -1) {
if ($i == 1 && strpos($str,"T") > -1 && strpos($str,"T") < $p) {
continue;
}
if ($aT[$i] == "S") {
$aV[$i] = substr($str,0, $p);
} else {
$aV[$i] = intval(substr($str,0, $p));
}
if (!is_numeric($aV[$i])) {
$bErr = true;
break;
} else if ($i > 2 && !$bTFound) {
$bErr = true;
break;
}
$str = substr($str,$p + 1);
}
}
if (!$bErr && strlen($str) != 0) {
$bErr = true;
}
}
if ($bErr) {
return;
}
return $aV[0] * 3155760000 + $aV[1] * 262980000 + $aV[2] * 8640000 + $aV[3] * 360000 + $aV[4] * 6000 + round($aV[5] * 100);
}
| static ilObjSCORM2004LearningModule::_lookupItemTitle | ( | $ | a_node_id | ) | [static] |
Definition at line 571 of file class.ilObjSCORM2004LearningModule.php.
Referenced by ilLPStatusSCORM::_getStatusInfo(), getTrackedItems(), and ilObjSCORM2004LearningModuleGUI::showTrackingItem().
{
global $ilDB;
$r = $ilDB->query("SELECT * FROM cp_item ".
" WHERE cp_node_id = ".$ilDB->quote($a_node_id));
if ($i = $r->fetchRow(DB_FETCHMODE_ASSOC))
{
return $i["title"];
}
return "";
}
Here is the caller graph for this function:| ilObjSCORM2004LearningModule::convert_1_2_to_2004 | ( | $ | manifest | ) |
Definition at line 237 of file class.ilObjSCORM2004LearningModule.php.
References $ilLog, $ret, fixReload(), and ilObjSAHSLearningModule::getDataDirectory().
Referenced by readObject().
{
global $ilDB, $ilLog;
##check manifest-file for version. Check for schemaversion as this is a required element for SCORM 2004
##accept 2004 3rd Edition an CAM 1.3 as valid schemas
//set variables
$this->packageFolder=$this->getDataDirectory();
$this->imsmanifestFile=$manifest;
$doc = new DomDocument();
//fix reload errors before loading
$this->fixReload();
$doc->load($this->imsmanifestFile);
$elements = $doc->getElementsByTagName("schemaversion");
$schema=$elements->item(0)->nodeValue;
if (strtolower($schema)=="cam 1.3" || strtolower($schema)=="2004 3rd edition") {
//no conversion
$this->converted=false;
return true;
} else {
$this->converted=true;
//convert to SCORM 2004
//check for broken SCORM 1.2 manifest file (missing organization default-common error in a lot of manifest files)
$organizations = $doc->getElementsByTagName("organizations");
$default=$organizations->item(0)->getAttribute("default");
if ($default=="" || $default==null) {
//lookup identifier
$organization = $doc->getElementsByTagName("organization");
$ident=$organization->item(0)->getAttribute("identifier");
$organizations->item(0)->setAttribute("default",$ident);
}
//validate the fixed mainfest. If it's still not valid, don't transform an throw error
//first copy wrappers
$wrapperdir=$this->packageFolder."/GenericRunTimeWrapper1.0_aadlc";
mkdir($wrapperdir);
copy(self::WRAPPER_HTML,$wrapperdir."/GenericRunTimeWrapper.htm");
copy(self::WRAPPER_JS,$wrapperdir."/SCOPlayerWrapper.js");
//backup manifestfile
$this->backupManifest=$this->packageFolder."/imsmanifest.xml.back";
$ret=copy($this->imsmanifestFile,$this->backupManifest);
//transform manifest file
$this->totransform = $doc;
$ilLog->write("SCORM: about to transform to SCORM 2004");
$xsl = new DOMDocument;
$xsl->async = false;
$xsl->load(self::CONVERT_XSL);
$prc = new XSLTProcessor;
$r = @$prc->importStyleSheet($xsl);
file_put_contents($this->imsmanifestFile, $prc->transformToXML($this->totransform));
$ilLog->write("SCORM: Transoformation completed");
return true;
}
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilObjSCORM2004LearningModule::deleteTrackingDataOfUsers | ( | $ | a_users | ) |
get all tracked items of current user
Definition at line 332 of file class.ilObjSCORM2004LearningModule.php.
References $user, and ilObject::getId().
{
global $ilDB;
foreach($a_users as $user)
{
$q = "DELETE FROM cmi_node WHERE user_id = ".$ilDB->quote($user).
" AND cp_node_id IN (SELECT cp_node_id FROM cp_node WHERE slm_id = ".
$ilDB->quote($this->getId()).")";
$ilDB->query($q);
}
}
Here is the call graph for this function:| ilObjSCORM2004LearningModule::fixReload | ( | ) |
Definition at line 228 of file class.ilObjSCORM2004LearningModule.php.
References $out.
Referenced by convert_1_2_to_2004().
{
$out = file_get_contents($this->imsmanifestFile);
$check ='/xmlns="http:\/\/www.imsglobal.org\/xsd\/imscp_v1p1"/';
$replace="xmlns=\"http://www.imsproject.org/xsd/imscp_rootv1p1p2\"";
$out=preg_replace($check, $replace, $out);
file_put_contents($this->imsmanifestFile, $out);
}
Here is the caller graph for this function:| ilObjSCORM2004LearningModule::getTrackedItems | ( | ) |
get all tracked items of current user
Reimplemented from ilObjSCORMLearningModule.
Definition at line 346 of file class.ilObjSCORM2004LearningModule.php.
References _lookupItemTitle(), and ilObject::getId().
{
global $ilUser, $ilDB, $ilUser;
$query = "SELECT DISTINCT cmi_node.cp_node_id AS id".
" FROM cp_node, cmi_node WHERE slm_id = ".
$ilDB->quote($this->getId()).
" AND cp_node.cp_node_id = cmi_node.cp_node_id ".
" ORDER BY cp_node.cp_node_id ";
$sco_set = $ilDB->query($query);
$items = array();
while($sco_rec = $sco_set->fetchRow(DB_FETCHMODE_ASSOC))
{
$item['id']=$sco_rec["id"];
$item['title']=self::_lookupItemTitle($sco_rec["id"]);
$items[count($items)] =$item;
}
return $items;
}
Here is the call graph for this function:| ilObjSCORM2004LearningModule::getTrackedUsers | ( | ) |
get all tracked items of current user
Definition at line 307 of file class.ilObjSCORM2004LearningModule.php.
References ilObjUser::_lookupLogin(), ilObjUser::_lookupName(), and ilObject::getId().
{
global $ilUser, $ilDB, $ilUser;
$query = "SELECT DISTINCT user_id FROM cmi_node, cp_node WHERE".
" cmi_node.cp_node_id = cp_node.cp_node_id ".
" AND cp_node.slm_id = ".$ilDB->quote($this->getId());
$sco_set = $ilDB->query($query);
$items = array();
while($sco_rec = $sco_set->fetchRow(DB_FETCHMODE_ASSOC))
{
$name = ilObjUser::_lookupName($sco_rec["user_id"]);
$items[] = array("user_full_name" => $name["lastname"].", ".
$name["firstname"]." [".ilObjUser::_lookupLogin($sco_rec["user_id"])."]",
"user_id" => $sco_rec["user_id"]);
}
return $items;
}
Here is the call graph for this function:| ilObjSCORM2004LearningModule::getTrackingDataAgg | ( | $ | a_sco_id | ) |
Reimplemented from ilObjSCORMLearningModule.
Definition at line 370 of file class.ilObjSCORM2004LearningModule.php.
References $_GET, $data, ilFormat::_secondsToString(), and formatDate().
{
global $ilDB;
// get all users with any tracking data
$query = "SELECT DISTINCT user_id FROM cmi_node WHERE".
" cp_node_id = ".$ilDB->quote($_GET["obj_id"]);
$user_set = $ilDB->query($query);
$data = array();
while($user_rec = $user_set->fetchRow(DB_FETCHMODE_ASSOC))
{
$query = "SELECT *,UNIX_TIMESTAMP(TIMESTAMP) AS last_access FROM cmi_node WHERE".
" cp_node_id = ".$ilDB->quote($_GET["obj_id"]).
" AND user_id =".$ilDB->quote($user_rec["user_id"]);
$data_set = $ilDB->query($query);
$score = $time = $status = "";
while($data_rec = $data_set->fetchRow(DB_FETCHMODE_ASSOC))
{
if ($data_rec["success_status"]!="") {
$status = $data_rec["success_status"];
} else {
if ($data_rec["completion_status"]=="") {
$status="unknown";
} else {
$status = $data_rec["completion_status"];
}
}
$time = ilFormat::_secondsToString(self::_ISODurationToCentisec($data_rec["session_time"])/100);
$score = $data_rec["raw"];
$last_access=ilFormat::formatDate(date("Y-m-d H:i:s", $data_rec["last_access"]));
}
$data[] = array("user_id" => $user_rec["user_id"],
"score" => $score, "time" => $time, "status" => $status,"last_access"=>$last_access);
}
return $data;
}
Here is the call graph for this function:| ilObjSCORM2004LearningModule::ilObjSCORM2004LearningModule | ( | $ | a_id = 0, |
|
| $ | a_call_by_reference = true | |||
| ) |
Constructor public.
| integer | reference_id or object_id | |
| boolean | treat the id as reference_id (true) or object_id (false) |
Definition at line 50 of file class.ilObjSCORM2004LearningModule.php.
References ilObject::ilObject().
{
$this->type = "sahs";
parent::ilObject($a_id,$a_call_by_reference);
}
Here is the call graph for this function:| ilObjSCORM2004LearningModule::readObject | ( | ) |
read manifest file public
Reimplemented from ilObjSCORMLearningModule.
Definition at line 75 of file class.ilObjSCORM2004LearningModule.php.
References ilObject::$ilias, ilObject::$lng, convert_1_2_to_2004(), ilObjSAHSLearningModule::getDataDirectory(), ilObject::getId(), ilObjSCORMLearningModule::getValidationSummary(), seems_not_utf8(), and validate().
{
global $ilias, $lng ,$ilDB;
//check for MYSQL 4.1 and json_encode,json_decode
if (!function_exists('json_encode') || !function_exists('json_decode') || !$ilDB->isMysql4_1OrHigher()) {
$ilias->raiseError($lng->txt('scplayer_phpmysqlcheck'),$ilias->error_obj->WARNING);
}
// the seems_utf8($str) function
include_once("include/inc.utf8checker.php");
$needs_convert = false;
// convert imsmanifest.xml file in iso to utf8 if needed
// include_once("include/inc.convertcharset.php");
$manifest_file = $this->getDataDirectory()."/imsmanifest.xml";
// check if manifestfile exists and space left on device...
$check_for_manifest_file = is_file($manifest_file);
// if no manifestfile
if (!$check_for_manifest_file)
{
$this->ilias->raiseError($this->lng->txt("Manifestfile $manifest_file not found!"), $this->ilias->error_obj->MESSAGE);
return;
}
if ($check_for_manifest_file)
{
$manifest_file_array = file($manifest_file);
foreach($manifest_file_array as $mfa)
{
if (seems_not_utf8($mfa))
{
$needs_convert = true;
break;
}
}
// to copy the file we need some extraspace, counted in bytes *2 ... we need 2 copies....
$estimated_manifest_filesize = filesize($manifest_file) * 2;
// i deactivated this, because it seems to fail on some windows systems (see bug #1795)
//$check_disc_free = disk_free_space($this->getDataDirectory()) - $estimated_manifest_filesize;
$check_disc_free = 2;
}
// if $manifest_file needs to be converted to UTF8
if ($needs_convert)
{
// if file exists and enough space left on device
if ($check_for_manifest_file && ($check_disc_free > 1))
{
// create backup from original
if (!copy($manifest_file, $manifest_file.".old"))
{
echo "Failed to copy $manifest_file...<br>\n";
}
// read backupfile, convert each line to utf8, write line to new file
// php < 4.3 style
$f_write_handler = fopen($manifest_file.".new", "w");
$f_read_handler = fopen($manifest_file.".old", "r");
while (!feof($f_read_handler))
{
$zeile = fgets($f_read_handler);
//echo mb_detect_encoding($zeile);
fputs($f_write_handler, utf8_encode($zeile));
}
fclose($f_read_handler);
fclose($f_write_handler);
// copy new utf8-file to imsmanifest.xml
if (!copy($manifest_file.".new", $manifest_file))
{
echo "Failed to copy $manifest_file...<br>\n";
}
if (!@is_file($manifest_file))
{
$this->ilias->raiseError($this->lng->txt("cont_no_manifest"),
$this->ilias->error_obj->WARNING);
}
}
else
{
// gives out the specific error
if (!($check_disc_free > 1))
$this->ilias->raiseError($this->lng->txt("Not enough space left on device!"),$this->ilias->error_obj->MESSAGE);
return;
}
}
else
{
// check whether file starts with BOM (that confuses some sax parsers, see bug #1795)
$hmani = fopen($manifest_file, "r");
$start = fread($hmani, 3);
if (strtolower(bin2hex($start)) == "efbbbf")
{
$f_write_handler = fopen($manifest_file.".new", "w");
while (!feof($hmani))
{
$n = fread($hmani, 900);
fputs($f_write_handler, $n);
}
fclose($f_write_handler);
fclose($hmani);
// copy new utf8-file to imsmanifest.xml
if (!copy($manifest_file.".new", $manifest_file))
{
echo "Failed to copy $manifest_file...<br>\n";
}
}
else
{
fclose($hmani);
}
}
//validate the XML-Files in the SCORM-Package
if ($_POST["validate"] == "y")
{
if (!$this->validate($this->getDataDirectory()))
{
$this->ilias->raiseError("<b>Validation Error(s):</b><br>".$this->getValidationSummary(),
$this->ilias->error_obj->WARNING);
}
}
//check for SCORM 1.2
$this->convert_1_2_to_2004($manifest_file);
// start SCORM 2004 package parser/importer
include_once ("./Modules/Scorm2004/classes/ilSCORM13Package.php");
$newPack = new ilSCORM13Package();
return $newPack->il_import($this->getDataDirectory(),$this->getId(),$this->ilias,$_POST["validate"]);
}
Here is the call graph for this function:| ilObjSCORM2004LearningModule::validate | ( | $ | directory | ) |
Validate all XML-Files in a SCOM-Directory.
public
Reimplemented from ilObjSCORMLearningModule.
Definition at line 63 of file class.ilObjSCORM2004LearningModule.php.
Referenced by readObject().
{
//$this->validator =& new ilObjSCORMValidator($directory);
//$returnValue = $this->validator->validate();
return true;
}
Here is the caller graph for this function:| ilObjSCORM2004LearningModule::$validator |
Reimplemented from ilObjSCORMLearningModule.
Definition at line 37 of file class.ilObjSCORM2004LearningModule.php.
| const ilObjSCORM2004LearningModule::CONVERT_XSL = './Modules/Scorm2004/templates/xsl/op/scorm12To2004.xsl' |
Definition at line 40 of file class.ilObjSCORM2004LearningModule.php.
| const ilObjSCORM2004LearningModule::WRAPPER_HTML = './Modules/Scorm2004/scripts/converter/GenericRunTimeWrapper1.0_aadlc/GenericRunTimeWrapper.htm' |
Definition at line 41 of file class.ilObjSCORM2004LearningModule.php.
| const ilObjSCORM2004LearningModule::WRAPPER_JS = './Modules/Scorm2004/scripts/converter/GenericRunTimeWrapper1.0_aadlc/SCOPlayerWrapper.js' |
Definition at line 42 of file class.ilObjSCORM2004LearningModule.php.
1.7.1