Public Member Functions | Data Fields

ilObjSCORMLearningModule Class Reference

Inheritance diagram for ilObjSCORMLearningModule:
Collaboration diagram for ilObjSCORMLearningModule:

Public Member Functions

 ilObjSCORMLearningModule ($a_id=0, $a_call_by_reference=true)
 Constructor public.
 validate ($directory)
 Validate all XML-Files in a SCOM-Directory.
 getValidationSummary ()
 getTrackingItems ()
 _getTrackingItems ($a_obj_id)
 get all tracking items of scorm object static
 readObject ()
 read manifest file public
 getTrackedItems ()
 get all tracked items of current user
 getTrackingDataPerUser ($a_sco_id, $a_user_id)
 getTrackingDataAgg ($a_sco_id)

Data Fields

 $validator

Detailed Description

Definition at line 39 of file class.ilObjSCORMLearningModule.php.


Member Function Documentation

ilObjSCORMLearningModule::_getTrackingItems ( a_obj_id  ) 

get all tracking items of scorm object static

Reimplemented in ilObjAICCLearningModule.

Definition at line 97 of file class.ilObjSCORMLearningModule.php.

References $tree.

Referenced by ilLPCollections::_getPossibleSAHSItems(), and getTrackingItems().

        {
                include_once("content/classes/SCORM/class.ilSCORMTree.php");
                $tree = new ilSCORMTree($a_obj_id);
                $root_id = $tree->readRootId();

                $items = array();
                $childs = $tree->getSubTree($tree->getNodeData($root_id));
                foreach($childs as $child)
                {
                        if($child["type"] == "sit")
                        {
                                include_once("content/classes/SCORM/class.ilSCORMItem.php");
                                $sc_item =& new ilSCORMItem($child["obj_id"]);
                                if ($sc_item->getIdentifierRef() != "")
                                {
                                        $items[count($items)] =& $sc_item;
                                }
                        }
                }

                return $items;
        }

Here is the caller graph for this function:

ilObjSCORMLearningModule::getTrackedItems (  ) 

get all tracked items of current user

Reimplemented in ilObjAICCLearningModule.

Definition at line 263 of file class.ilObjSCORMLearningModule.php.

References $query, and ilObject::getId().

        {
                global $ilUser, $ilDB, $ilUser;

                $query = "SELECT DISTINCT sco_id FROM scorm_tracking WHERE".
                        " obj_id = ".$ilDB->quote($this->getId());

                $sco_set = $ilDB->query($query);

                $items = array();
                while($sco_rec = $sco_set->fetchRow(DB_FETCHMODE_ASSOC))
                {
                        include_once("content/classes/SCORM/class.ilSCORMItem.php");
                        $sc_item =& new ilSCORMItem($sco_rec["sco_id"]);
                        if ($sc_item->getIdentifierRef() != "")
                        {
                                $items[count($items)] =& $sc_item;
                        }
                }

                return $items;
        }

Here is the call graph for this function:

ilObjSCORMLearningModule::getTrackingDataAgg ( a_sco_id  ) 

Definition at line 306 of file class.ilObjSCORMLearningModule.php.

References $data, $query, $user_set, and ilObject::getId().

        {
                global $ilDB;

                // get all users with any tracking data
                $query = "SELECT DISTINCT user_id FROM scorm_tracking WHERE".
                        " obj_id = ".$ilDB->quote($this->getId()).
                        " AND sco_id = ".$ilDB->quote($a_sco_id);
                        //" ORDER BY user_id, lvalue";
                $user_set = $ilDB->query($query);

                $data = array();
                while($user_rec = $user_set->fetchRow(DB_FETCHMODE_ASSOC))
                {
                        $query = "SELECT * FROM scorm_tracking WHERE".
                                " obj_id = ".$ilDB->quote($this->getId()).
                                " AND sco_id = ".$ilDB->quote($a_sco_id).
                                " AND user_id =".$ilDB->quote($user_rec["user_id"]).
                                " AND (lvalue =".$ilDB->quote("cmi.core.lesson_status").
                                " OR lvalue =".$ilDB->quote("cmi.core.total_time").
                                " OR lvalue =".$ilDB->quote("cmi.core.score.raw").")";
                        $data_set = $ilDB->query($query);
                        $score = $time = $status = "";
                        while($data_rec = $data_set->fetchRow(DB_FETCHMODE_ASSOC))
                        {
                                switch($data_rec["lvalue"])
                                {
                                        case "cmi.core.lesson_status":
                                                $status = $data_rec["rvalue"];
                                                break;

                                        case "cmi.core.total_time":
                                                $time = $data_rec["rvalue"];
                                                break;

                                        case "cmi.core.score.raw":
                                                $score = $data_rec["rvalue"];
                                                break;
                                }
                        }

                        $data[] = array("user_id" => $user_rec["user_id"],
                                "score" => $score, "time" => $time, "status" => $status);
                }

                return $data;
        }

Here is the call graph for this function:

ilObjSCORMLearningModule::getTrackingDataPerUser ( a_sco_id,
a_user_id 
)

Definition at line 286 of file class.ilObjSCORMLearningModule.php.

References $data, $query, and ilObject::getId().

        {
                global $ilDB;

                $query = "SELECT * FROM scorm_tracking WHERE".
                        " obj_id = ".$ilDB->quote($this->getId()).
                        " AND sco_id = ".$ilDB->quote($a_sco_id).
                        " AND user_id = ".$ilDB->quote($a_user_id).
                        " ORDER BY lvalue";
                $data_set = $ilDB->query($query);

                $data = array();
                while($data_rec = $data_set->fetchRow(DB_FETCHMODE_ASSOC))
                {
                        $data[] = $data_rec;
                }

                return $data;
        }

Here is the call graph for this function:

ilObjSCORMLearningModule::getTrackingItems (  ) 

Reimplemented in ilObjAICCLearningModule.

Definition at line 87 of file class.ilObjSCORMLearningModule.php.

References _getTrackingItems(), and ilObject::getId().

Here is the call graph for this function:

ilObjSCORMLearningModule::getValidationSummary (  ) 

Definition at line 78 of file class.ilObjSCORMLearningModule.php.

Referenced by readObject().

        {
                if(is_object($this->validator))
                {
                        return $this->validator->getSummary();
                }
                return "";
        }

Here is the caller graph for this function:

ilObjSCORMLearningModule::ilObjSCORMLearningModule ( a_id = 0,
a_call_by_reference = true 
)

Constructor public.

Parameters:
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.ilObjSCORMLearningModule.php.

References ilObject::ilObject().

        {
                $this->type = "sahs";
                parent::ilObject($a_id,$a_call_by_reference);
/*
                if ($a_id == 0)
                {
                        $new_meta =& new ilMetaData();
                        $this->assignMetaData($new_meta);
                }
*/

        }

Here is the call graph for this function:

ilObjSCORMLearningModule::readObject (  ) 

read manifest file public

Reimplemented in ilObjAICCLearningModule.

Definition at line 125 of file class.ilObjSCORMLearningModule.php.

References $_POST, ilObjSAHSLearningModule::getDataDirectory(), getValidationSummary(), seems_not_utf8(), and validate().

        {
                // 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);
                        }
                }

                // start SCORM package parser
                include_once ("content/classes/SCORM/class.ilSCORMPackageParser.php");
                // todo determine imsmanifest.xml path here...
                $slmParser = new ilSCORMPackageParser($this, $manifest_file);
                $slmParser->startParsing();
                return $slmParser->getPackageTitle();
        }

Here is the call graph for this function:

ilObjSCORMLearningModule::validate ( directory  ) 

Validate all XML-Files in a SCOM-Directory.

public

Returns:
boolean true if all XML-Files are wellfomred and valid

Definition at line 71 of file class.ilObjSCORMLearningModule.php.

Referenced by readObject().

        {
                $this->validator =& new ilObjSCORMValidator($directory);
                $returnValue = $this->validator->validate();
                return $returnValue;
        }

Here is the caller graph for this function:


Field Documentation

ilObjSCORMLearningModule::$validator

Reimplemented from ilObjSAHSLearningModule.

Definition at line 41 of file class.ilObjSCORMLearningModule.php.


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