ILIAS  release_8 Revision v8.24
ilObjSCORM2004LearningModule Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilObjSCORM2004LearningModule:
+ Collaboration diagram for ilObjSCORM2004LearningModule:

Public Member Functions

 __construct (int $a_id=0, bool $a_call_by_reference=true)
 Constructor. More...
 
 setImportSequencing (bool $a_val)
 Set import sequencing. More...
 
 getImportSequencing ()
 Get import sequencing. More...
 
 readObject ()
 read manifest file More...
 
 fixReload ()
 
 convert_1_2_to_2004 (string $manifest)
 
 deleteTrackingDataOfUsers (array $a_users)
 
 getTrackedItems ()
 get all tracked items of current user More...
 
 getTrackingDataAgg (int $a_user_id, ?bool $raw=false)
 
 getAttemptsForUser (int $a_user_id)
 get number of atttempts for a certain user and package More...
 
 getModuleVersionForUser (int $a_user_id)
 get module version that tracking data for a user was recorded on More...
 
 importSuccess (string $a_file)
 
- Public Member Functions inherited from ilObjSCORMLearningModule
 __construct (int $a_id=0, bool $a_call_by_reference=true)
 Constructor. More...
 
 getTrackingItems ()
 
 readObject ()
 read manifest file More...
 
 setLearningProgressSettingsAtUpload ()
 set settings for learning progress determination per default at upload More...
 
 getTrackedItems ()
 get all tracked items of current user More...
 
 getTrackedUsers (string $a_search)
 
 getAttemptsForUsers ()
 Get attempts for all users. More...
 
 getAttemptsForUser (int $a_user_id)
 get number of attempts for a certain user and package More...
 
 getModuleVersionForUsers ()
 Get module version for users. More...
 
 getModuleVersionForUser (int $a_user_id)
 get module version that tracking data for a user was recorded on More...
 
 getTrackingDataPerUser (int $a_sco_id, int $a_user_id)
 Get tracking data per user. More...
 
 getTrackingDataAgg (int $a_user_id)
 
 getTrackingDataAggSco (int $a_sco_id)
 
 exportSelected (bool $a_all, array $a_users=array())
 Export selected user tracking data @global ilObjUser $ilUser. More...
 
 importTrackingData (string $a_file)
 
 importSuccess (string $a_file)
 
 importSuccessForSahsUser (int $user_id, string $last_access, int $status, ?int $attempts=null, ?int $percentage_completed=null, ?int $sco_total_time_sec=null)
 
 get_user_id (string $a_login)
 
 getUserIdEmail (string $a_mail)
 assumes that only one account exists for a mailadress More...
 
 sendExportFile (string $a_header, string $a_content)
 send export file to browser More...
 
 getAllScoIds ()
 
 getStatusForUser (int $a_user, array $a_allScoIds, bool $a_numerical=false)
 
 getCourseCompletionForUser (int $a_user)
 
 getLastVisited (int $user_id)
 
 deleteTrackingDataOfUsers (array $a_users)
 
- Public Member Functions inherited from ilObjSAHSLearningModule
 __construct (int $a_id=0, bool $a_call_by_reference=true)
 Constructor. More...
 
 create (bool $upload=false)
 create file based lm More...
 
 read ()
 read object More...
 
 getEditable ()
 
 setTries (int $a_tries)
 Set default tries for questions. More...
 
 getTries ()
 
 setLocalization (string $a_val)
 
 getLocalization ()
 
 getDiskUsage ()
 Gets the disk usage of the object in bytes. More...
 
 createDataDirectory ()
 creates data directory for package files ("./data/lm_data/lm_<id>") More...
 
 getDataDirectory (?string $mode="filesystem")
 get data directory of lm More...
 
 getAPIAdapterName ()
 get api adapter name More...
 
 setAPIAdapterName (string $a_api)
 set api adapter name More...
 
 getAPIFunctionsPrefix ()
 get api functions prefix More...
 
 setAPIFunctionsPrefix (string $a_prefix)
 set api functions prefix More...
 
 getCreditMode ()
 get credit mode More...
 
 setCreditMode (string $a_credit_mode)
 set credit mode More...
 
 setDefaultLessonMode (string $a_lesson_mode)
 set default lesson mode More...
 
 getDefaultLessonMode ()
 get default lesson mode More...
 
 getStyleSheetId ()
 get ID of assigned style sheet object More...
 
 setStyleSheetId (int $a_style_id)
 set ID of assigned style sheet object More...
 
 setAutoReview (bool $a_auto_review)
 set auto review as true/false for SCORM 1.2 More...
 
 getAutoReview ()
 get auto review as true/false for SCORM 1.2 More...
 
 setAutoReviewChar (?string $a_auto_review)
 set auto review as Char for SCORM 2004 More...
 
 getAutoReviewChar ()
 get auto review as Char for SCORM 2004 More...
 
 getMaxAttempt ()
 
 setMaxAttempt (int $a_max_attempt)
 
 getModuleVersion ()
 
 getAssignedGlossary ()
 
 setAssignedGlossary (int $a_assigned_glossary)
 
 setModuleVersion (int $a_module_version)
 
 getSession ()
 
 setSession (bool $a_session)
 
 getNoMenu ()
 disable menu More...
 
 setNoMenu (bool $a_no_menu)
 disable menu More...
 
 getHideNavig ()
 hide navigation tree More...
 
 setHideNavig (bool $a_hide_navig)
 disable menu More...
 
 getCacheDeactivated ()
 BrowserCacheDisabled for SCORM 2004 / ENABLE_JS_DEBUG. More...
 
 getSessionDeactivated ()
 sessionDisabled for SCORM 2004 More...
 
 getDebugActivated ()
 debugActivated More...
 
 getIe_force_render ()
 force Internet Explorer to render again after some Milliseconds - useful for learning Modules with a lot of iframes or frames and IE >=10 More...
 
 setIe_force_render (bool $a_ie_force_render)
 
 getFourth_Edition ()
 SCORM 2004 4th edition features. More...
 
 setFourth_edition (bool $a_fourth_edition)
 
 getSequencing ()
 
 setSequencing (bool $a_sequencing)
 
 getInteractions ()
 
 setInteractions (bool $a_interactions)
 
 getObjectives ()
 
 setObjectives (bool $a_objectives)
 
 getComments ()
 
 setComments (bool $a_comments)
 
 getTime_from_lms ()
 
 setTime_from_lms (bool $a_time_from_lms)
 
 getCheck_values ()
 
 setCheck_values (bool $a_check_values)
 
 getDebug ()
 
 setDebug (bool $a_debug)
 
 setAutoContinue (bool $a_auto_continue)
 
 getAutoContinue ()
 
 getAuto_last_visited ()
 
 setAuto_last_visited (bool $a_auto_last_visited)
 
 setAutoSuspend (bool $a_auto_suspend)
 
 getAutoSuspend ()
 
 getOpenMode ()
 open_mode 0: in Tab/new Window like in previous versions 1: in iFrame with width=100% and heigth=100% 2: in iFrame with specified width and height 3: 4: 5: in new Window without specified width and height 6: in new Window with specified width and height More...
 
 setOpenMode (int $a_open_mode)
 
 getWidth ()
 
 setWidth (int $a_width)
 
 getHeight ()
 
 setHeight (int $a_height)
 
 getMasteryScore ()
 
 setMasteryScore (?int $a_mastery_score)
 
 checkMasteryScoreValues ()
 check mastery_score / min_normalized_measure of SCOs (SCORM 1.2) / objectives (SCORM 2004) More...
 
 getMasteryScoreValues ()
 
 getIdSetting ()
 
 setIdSetting (int $a_id_setting)
 
 getNameSetting ()
 
 setNameSetting (int $a_name_setting)
 
 update ()
 
 setSubType (string $a_sub_type)
 
 getSubType ()
 
 delete ()
 delete SCORM learning module and all related data More...
 
 getPointsInPercent ()
 Returns the points in percent for the learning module This is called by the certificate generator if [SCORM_POINTS] is inserted. More...
 
 getMaxPoints ()
 Returns score.max for the learning module, refered to the last sco where score.max is set. More...
 
 populateByDirectoy (string $a_dir, string $a_filename="")
 Populate by directory. More...
 
 getApiStudentId ()
 Get cmi.core.student_id / cmi.learner_id for API. More...
 
 getApiStudentName ()
 Get cmi.core.student_name / cmi.learner_name for API note: 'lastname, firstname' is required for SCORM 1.2; 9 = no name to hide student_name for external content. More...
 
 getViewButton ()
 get button for view More...
 
- Public Member Functions inherited from ilObject
 __construct (int $id=0, bool $reference=true)
 
 withReferences ()
 determines whether objects are referenced or not (got ref ids or not) More...
 
 processAutoRating ()
 
 read ()
 
 getId ()
 
 setId (int $id)
 
 setRefId (int $ref_id)
 
 getRefId ()
 
 getType ()
 
 setType (string $type)
 
 getPresentationTitle ()
 get presentation title Normally same as title Overwritten for sessions More...
 
 getTitle ()
 
 getUntranslatedTitle ()
 Get untranslated object title WebDAV needs to access the untranslated title of an object. More...
 
 setTitle (string $title)
 
 getDescription ()
 
 setDescription (string $desc)
 
 getLongDescription ()
 get object long description (stored in object_description) More...
 
 getImportId ()
 
 setImportId (string $import_id)
 
 setOfflineStatus (bool $status)
 
 getOfflineStatus ()
 
 supportsOfflineHandling ()
 
 getOwner ()
 
 getOwnerName ()
 get full name of object owner More...
 
 setOwner (int $usr_id)
 
 getCreateDate ()
 Get create date in YYYY-MM-DD HH-MM-SS format. More...
 
 getLastUpdateDate ()
 Get last update date in YYYY-MM-DD HH-MM-SS format. More...
 
 create ()
 note: title, description and type should be set when this function is called More...
 
 update ()
 
 MDUpdateListener (string $element)
 Metadata update listener. More...
 
 createMetaData ()
 
 updateMetaData ()
 
 deleteMetaData ()
 
 updateOwner ()
 update owner of object in db More...
 
 putInTree (int $parent_ref_id)
 maybe this method should be in tree object!? More...
 
 setPermissions (int $parent_ref_id)
 
 setParentRolePermissions (int $parent_ref_id)
 Initialize the permissions of parent roles (local roles of categories, global roles...) This method is overwritten in e.g. More...
 
 createReference ()
 creates reference for object More...
 
 countReferences ()
 
 delete ()
 delete object or referenced object (in the case of a referenced object, object data is only deleted if last reference is deleted) This function removes an object entirely from system!! More...
 
 initDefaultRoles ()
 init default roles settings Purpose of this function is to create a local role folder and local roles, that are needed depending on the object type. More...
 
 applyDidacticTemplate (int $tpl_id)
 
 getXMLZip ()
 
 getHTMLDirectory ()
 
 appendCopyInfo (int $target_id, int $copy_id)
 Prepend Copy info if object with same name exists in that container. More...
 
 cloneDependencies (int $target_id, int $copy_id)
 Clone object dependencies. More...
 
 cloneMetaData (ilObject $target_obj)
 Copy meta data. More...
 
 selfOrParentWithRatingEnabled ()
 
 getPossibleSubObjects (bool $filter=true)
 get all possible sub objects of this type the object can decide which types of sub objects are possible jut in time overwrite if the decision distinguish from standard model More...
 

Static Public Member Functions

static _lookupLastAccess (int $a_obj_id, int $a_usr_id)
 Return the last access timestamp for a given user. More...
 
static _ISODurationToCentisec (string $str)
 convert ISO 8601 Timeperiods to centiseconds More...
 
static getQuantityOfSCOs (int $a_slm_id)
 
static _getCourseCompletionForUser (int $a_id, int $a_user)
 Get the completion of a SCORM module for a given user. More...
 
static _getUniqueScaledScoreForUser (int $a_id, int $a_user)
 Get the Unique Scaled Score of a course Conditions: Only one SCO may set cmi.score.scaled. More...
 
static _getTrackingItems (int $a_obj_id)
 get all tracking items of scorm object currently a for learning progress only More...
 
static _getStatus (int $a_obj_id, int $a_user_id)
 
static _getSatisfied (int $a_obj_id, int $a_user_id)
 
static _getMeasure (int $a_obj_id, int $a_user_id)
 
static _lookupItemTitle (int $a_node_id)
 
static _getMaxScoreForUser (int $a_id, int $a_user)
 Returns score.max for the learning module, refered to the last sco where score.max is set. More...
 
static _getScores2004ForUser (int $a_cp_node_id, int $a_user)
 
- Static Public Member Functions inherited from ilObjSCORMLearningModule
static _getTrackingItems (int $a_obj_id)
 get all tracking items of scorm object More...
 
static _getAllScoIds (int $a_id)
 Get an array of id's for all Sco's in the module. More...
 
static _getStatusForUser (int $a_id, int $a_user, array $a_allScoIds, bool $a_numerical=false)
 Get the status of a SCORM module for a given user. More...
 
static _getCourseCompletionForUser (int $a_id, int $a_user)
 Get the completion of a SCORM module for a given user. More...
 
static _removeTrackingDataForUser (int $user_id)
 to be called from IlObjUser More...
 
static _getScoresForUser (int $a_item_id, int $a_user_id)
 
- Static Public Member Functions inherited from ilObjSAHSLearningModule
static getAffectiveLocalization (int $a_id)
 Get affective localization. More...
 
static _lookupSubType (int $a_obj_id)
 lookup subtype id (scorm, ) More...
 
static _getTries (int $a_id)
 obsolet? More...
 
static getScormModulesForGlossary (int $a_glo_id)
 Get SCORM modules that assign a certain glossary. More...
 
static lookupAssignedGlossary (int $a_slm_id)
 Get SCORM modules that assign a certain glossary. More...
 
- Static Public Member Functions inherited from ilObject
static _lookupObjIdByImportId (string $import_id)
 Get (latest) object id for an import id. More...
 
static _lookupImportId (int $obj_id)
 
static _lookupOwnerName (int $owner_id)
 Lookup owner name for owner id. More...
 
static _getIdForImportId (string $import_id)
 
static _getAllReferences (int $id)
 get all reference ids for object ID More...
 
static _lookupTitle (int $obj_id)
 
static lookupOfflineStatus (int $obj_id)
 Lookup offline status using objectDataCache. More...
 
static _lookupOwner (int $obj_id)
 Lookup owner user ID for object ID. More...
 
static _getIdsForTitle (string $title, string $type='', bool $partial_match=false)
 
static _lookupDescription (int $obj_id)
 
static _lookupLastUpdate (int $obj_id, bool $formatted=false)
 
static _getLastUpdateOfObjects (array $obj_ids)
 
static _lookupObjId (int $ref_id)
 
static _setDeletedDate (int $ref_id, int $deleted_by)
 
static setDeletedDates (array $ref_ids, int $user_id)
 
static _resetDeletedDate (int $ref_id)
 
static _lookupDeletedDate (int $ref_id)
 
static _writeTitle (int $obj_id, string $title)
 write title to db (static) More...
 
static _writeDescription (int $obj_id, string $desc)
 write description to db (static) More...
 
static _writeImportId (int $obj_id, string $import_id)
 write import id to db (static) More...
 
static _lookupType (int $id, bool $reference=false)
 
static _isInTrash (int $ref_id)
 
static _hasUntrashedReference (int $obj_id)
 checks whether an object has at least one reference that is not in trash More...
 
static _lookupObjectId (int $ref_id)
 
static _getObjectsDataForType (string $type, bool $omit_trash=false)
 get all objects of a certain type More...
 
static _exists (int $id, bool $reference=false, ?string $type=null)
 checks if an object exists in object_data More...
 
static _getObjectsByType (string $obj_type="", int $owner=null)
 
static _prepareCloneSelection (array $ref_ids, string $new_type, bool $show_path=true)
 Prepare copy wizard object selection. More...
 
static _getIcon (int $obj_id=0, string $size="big", string $type="", bool $offline=false)
 Get icon for repository item. More...
 
static collectDeletionDependencies (array &$deps, int $ref_id, int $obj_id, string $type, int $depth=0)
 Collect deletion dependencies. More...
 
static getDeletionDependencies (int $obj_id)
 Get deletion dependencies. More...
 
static getLongDescriptions (array $obj_ids)
 
static getAllOwnedRepositoryObjects (int $user_id)
 
static fixMissingTitles ($type, array &$obj_title_map)
 Try to fix missing object titles. More...
 
static _lookupCreationDate (int $obj_id)
 
static _getObjectTypeIdByTitle (string $type, \ilDBInterface $ilDB=null)
 

Data Fields

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'
 
- Data Fields inherited from ilObject
const TITLE_LENGTH = 255
 
const DESC_LENGTH = 128
 
const LONG_DESC_LENGTH = 4000
 
const TABLE_OBJECT_DATA = "object_data"
 
array $objectList
 
string $untranslatedTitle
 

Protected Attributes

ilObjUser $user
 
ilTabsGUI $tabs
 
bool $import_sequencing = false
 
string $imsmanifestFile
 
- Protected Attributes inherited from ilObjSAHSLearningModule
bool $sequencing = false
 
string $localization = ""
 
string $mastery_score_values = ""
 
int $tries = 0
 
string $api_adapter = 'API'
 
- Protected Attributes inherited from ilObject
ilLogger $obj_log
 
ILIAS $ilias
 
ilObjectDefinition $obj_definition
 
ilDBInterface $db
 
ilLogger $log
 
ilErrorHandling $error
 
ilTree $tree
 
ilAppEventHandler $app_event_handler
 
ilRbacAdmin $rbac_admin
 
ilRbacReview $rbac_review
 
ilObjUser $user
 
ilLanguage $lng
 
int $id
 
bool $referenced
 
bool $call_by_reference
 
int $max_title = self::TITLE_LENGTH
 
int $max_desc = self::DESC_LENGTH
 
bool $add_dots = true
 
int $ref_id = null
 
string $type = ""
 
string $title = ""
 
bool $offline = false
 
string $desc = ""
 
string $long_desc = ""
 
int $owner = 0
 
string $create_date = ""
 
string $last_update = ""
 
string $import_id = ""
 
bool $register = false
 

Additional Inherited Members

- Protected Member Functions inherited from ilObject
 doMDUpdateListener (string $a_element)
 
 beforeMDUpdateListener (string $a_element)
 
 doCreateMetaData ()
 
 beforeCreateMetaData ()
 
 doUpdateMetaData ()
 
 beforeUpdateMetaData ()
 
 doDeleteMetaData ()
 
 beforeDeleteMetaData ()
 
 handleAutoRating ()
 
 hasAutoRating ()
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class ilObjSCORM2004LearningModule

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e

Definition at line 26 of file class.ilObjSCORM2004LearningModule.php.

Constructor & Destructor Documentation

◆ __construct()

ilObjSCORM2004LearningModule::__construct ( int  $a_id = 0,
bool  $a_call_by_reference = true 
)

Constructor.

Parameters
integerreference_id or object_id
booleantreat the id as reference_id (true) or object_id (false)

Reimplemented from ilObjSCORMLearningModule.

Definition at line 45 of file class.ilObjSCORM2004LearningModule.php.

46 {
47 global $DIC;
48
49 $this->lng = $DIC->language();
50 $this->error = $DIC["ilErr"];
51 $this->db = $DIC->database();
52 $this->log = ilLoggerFactory::getLogger('sc13');
53 $this->user = $DIC->user();
54 $this->tabs = $DIC->tabs();
55 $this->type = "sahs";
56 parent::__construct($a_id, $a_call_by_reference);
57 }
error(string $a_errmsg)
static getLogger(string $a_component_id)
Get component logger.
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), error(), ilLoggerFactory\getLogger(), ILIAS\Repository\lng(), ILIAS\Repository\tabs(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ _getCourseCompletionForUser()

static ilObjSCORM2004LearningModule::_getCourseCompletionForUser ( int  $a_id,
int  $a_user 
)
static

Get the completion of a SCORM module for a given user.

Returns
boolean Completion status

Reimplemented from ilObjSCORMLearningModule.

Definition at line 684 of file class.ilObjSCORM2004LearningModule.php.

684 : bool
685 {
686 global $DIC;
687
688 $ilDB = $DIC->database();
689 $ilUser = $DIC->user();
690 $scos = array();
691 //get all SCO's of the object
692
693 $val_set = $ilDB->queryF(
694 '
695 SELECT cp_node.cp_node_id FROM cp_node,cp_resource,cp_item
696 WHERE cp_item.cp_node_id = cp_node.cp_node_id
697 AND cp_item.resourceid = cp_resource.id
698 AND scormtype = %s
699 AND nodename = %s
700 AND cp_node.slm_id = %s',
701 array('text','text','integer'),
702 array('sco' ,'item',$a_id)
703 );
704 while ($val_rec = $ilDB->fetchAssoc($val_set)) {
705 $scos[] = $val_rec['cp_node_id'];
706 }
707
708 $scos_c = $scos;
709 //copy SCO_array
710 //check if all SCO's are completed
711 foreach ($scos as $i => $value) {
712 $val_set = $ilDB->queryF(
713 '
714 SELECT * FROM cmi_node
715 WHERE (user_id= %s
716 AND cp_node_id= %s
717 AND (completion_status = %s OR success_status = %s))',
718 array('integer','integer','text','text'),
719 array($a_user, $value,'completed','passed')
720 );
721
722 if ($ilDB->numRows($val_set) > 0) {
723 //delete from array
724 $key = array_search($value, $scos_c);
725 unset($scos_c[$key]);
726 }
727 }
728 //check for completion
729 if (count($scos_c) == 0) {
730 $completion = true;
731 } else {
732 $completion = false;
733 }
734 return $completion;
735 }
$ilUser
Definition: imgupload.php:34
$i
Definition: metadata.php:41
string $key
Consumer key/client ID value.
Definition: System.php:193

References $DIC, $i, $ilDB, $ilUser, and ILIAS\LTI\ToolProvider\$key.

◆ _getMaxScoreForUser()

static ilObjSCORM2004LearningModule::_getMaxScoreForUser ( int  $a_id,
int  $a_user 
)
static

Returns score.max for the learning module, refered to the last sco where score.max is set.

Definition at line 925 of file class.ilObjSCORM2004LearningModule.php.

925 : ?float
926 {
927 global $DIC;
928
929 $ilDB = $DIC->database();
930
931 $scos = array();
932
933 $result = $ilDB->query(
934 'SELECT cp_node.cp_node_id '
935 . 'FROM cp_node, cp_resource, cp_item '
936 . 'WHERE cp_item.cp_node_id = cp_node.cp_node_id '
937 . 'AND cp_item.resourceId = cp_resource.id '
938 . 'AND scormType = ' . $ilDB->quote('sco', 'text') . ' '
939 . 'AND nodeName = ' . $ilDB->quote('item', 'text') . ' '
940 . 'AND cp_node.slm_id = ' . $ilDB->quote($a_id, 'integer') . ' '
941 . 'GROUP BY cp_node.cp_node_id'
942 );
943
944 while ($row = $ilDB->fetchAssoc($result)) {
945 $scos[] = $row['cp_node_id'];
946 }
947
948 $set = 0; //numbers of SCO that set cmi.score.scaled
949 $max = null;
950 foreach ($scos as $i => $value) {
951 $res = $ilDB->queryF(
952 'SELECT c_max FROM cmi_node WHERE (user_id = %s AND cp_node_id = %s)',
953 array('integer', 'integer'),
954 array($a_user, $value)
955 );
956
957 if ($ilDB->numRows($res) > 0) {
958 $row = $ilDB->fetchAssoc($res);
959 if ($row['c_max'] != null) {
960 $set++;
961 $max = $row['c_max'];
962 }
963 }
964 }
965 return ($set == 1) ? $max : null;
966 }
$res
Definition: ltiservices.php:69

References $DIC, $i, $ilDB, and $res.

Referenced by ilObjSAHSLearningModule\getMaxPoints().

+ Here is the caller graph for this function:

◆ _getMeasure()

static ilObjSCORM2004LearningModule::_getMeasure ( int  $a_obj_id,
int  $a_user_id 
)
static
Returns
float|bool

Definition at line 879 of file class.ilObjSCORM2004LearningModule.php.

880 {
881 global $DIC;
882
883 $ilDB = $DIC->database();
884
885 $status_set = $ilDB->queryF(
886 '
887 SELECT * FROM cmi_gobjective
888 WHERE scope_id = %s
889 AND objective_id = %s
890 AND user_id = %s',
891 array('integer','text','integer'),
892 array($a_obj_id,'-course_overall_status-',$a_user_id)
893 );
894
895 if ($status_rec = $ilDB->fetchAssoc($status_set)) {
896 return (float) $status_rec["measure"];
897 }
898
899 return false;
900 }

References $DIC, and $ilDB.

◆ _getSatisfied()

static ilObjSCORM2004LearningModule::_getSatisfied ( int  $a_obj_id,
int  $a_user_id 
)
static
Returns
string|bool

Definition at line 852 of file class.ilObjSCORM2004LearningModule.php.

853 {
854 global $DIC;
855
856 $ilDB = $DIC->database();
857
858
859 $status_set = $ilDB->queryF(
860 '
861 SELECT * FROM cmi_gobjective
862 WHERE scope_id = %s
863 AND objective_id = %s
864 AND user_id = %s',
865 array('integer','text','integer'),
866 array($a_obj_id,'-course_overall_status-',$a_user_id)
867 );
868
869 if ($status_rec = $ilDB->fetchAssoc($status_set)) {
870 return $status_rec["satisfied"];
871 }
872
873 return false;
874 }

References $DIC, and $ilDB.

◆ _getScores2004ForUser()

static ilObjSCORM2004LearningModule::_getScores2004ForUser ( int  $a_cp_node_id,
int  $a_user 
)
static
Returns
array<string, mixed>

Definition at line 971 of file class.ilObjSCORM2004LearningModule.php.

971 : array
972 {
973 global $DIC;
974
975 $ilDB = $DIC->database();
976 $retAr = array("raw" => null, "max" => null, "scaled" => null);
977 $val_set = $ilDB->queryF(
978 "SELECT c_raw, c_max, scaled FROM cmi_node WHERE (user_id = %s AND cp_node_id = %s)",
979 array('integer', 'integer'),
980 array($a_user, $a_cp_node_id)
981 );
982 if ($val_set->numRows() > 0) {
983 $val_rec = $ilDB->fetchAssoc($val_set);
984 $retAr["raw"] = $val_rec['c_raw'];
985 $retAr["max"] = $val_rec['c_max'];
986 $retAr["scaled"] = $val_rec['scaled'];
987 if ($val_rec['scaled'] == null && $val_rec['c_raw'] != null && $val_rec['c_max'] != null) {
988 $retAr["scaled"] = ($val_rec['c_raw'] / $val_rec['c_max']);
989 }
990 }
991 return $retAr;
992 }

References $DIC, and $ilDB.

Referenced by ilLPCollectionOfSCOs\getScoresForUserAndCP_Node_Id().

+ Here is the caller graph for this function:

◆ _getStatus()

static ilObjSCORM2004LearningModule::_getStatus ( int  $a_obj_id,
int  $a_user_id 
)
static
Returns
string|bool

Definition at line 826 of file class.ilObjSCORM2004LearningModule.php.

827 {
828 global $DIC;
829
830 $ilDB = $DIC->database();
831
832 $status_set = $ilDB->queryF(
833 '
834 SELECT * FROM cmi_gobjective
835 WHERE scope_id = %s
836 AND objective_id = %s
837 AND user_id = %s',
838 array('integer','text','integer'),
839 array($a_obj_id,'-course_overall_status-',$a_user_id)
840 );
841
842 if ($status_rec = $ilDB->fetchAssoc($status_set)) {
843 return $status_rec["status"];
844 }
845
846 return false;
847 }

References $DIC, and $ilDB.

◆ _getTrackingItems()

static ilObjSCORM2004LearningModule::_getTrackingItems ( int  $a_obj_id)
static

get all tracking items of scorm object currently a for learning progress only

Returns
array<int, array<string, mixed>>

Reimplemented from ilObjSCORMLearningModule.

Definition at line 783 of file class.ilObjSCORM2004LearningModule.php.

783 : array
784 {
785 global $DIC;
786
787 $ilDB = $DIC->database();
788
789
790 $item_set = $ilDB->queryF(
791 '
792 SELECT cp_item.* FROM cp_node, cp_item WHERE slm_id = %s
793 AND cp_node.cp_node_id = cp_item.cp_node_id
794 ORDER BY cp_node.cp_node_id ',
795 array('integer'),
796 array($a_obj_id)
797 );
798
799 $items = array();
800 while ($item_rec = $ilDB->fetchAssoc($item_set)) {
801 $s2 = $ilDB->queryF(
802 '
803 SELECT cp_resource.* FROM cp_node, cp_resource
804 WHERE slm_id = %s
805 AND cp_node.cp_node_id = cp_resource.cp_node_id
806 AND cp_resource.id = %s ',
807 array('integer','text'),
808 array($a_obj_id,$item_rec["resourceid"])
809 );
810
811
812 if ($res = $ilDB->fetchAssoc($s2)) {
813 if ($res["scormtype"] === "sco") {
814 $items[] = array("id" => $item_rec["cp_node_id"],
815 "title" => $item_rec["title"]);
816 }
817 }
818 }
819
820 return $items;
821 }

References $DIC, $ilDB, and $res.

Referenced by ilLPCollectionOfSCOs\getPossibleItems().

+ Here is the caller graph for this function:

◆ _getUniqueScaledScoreForUser()

static ilObjSCORM2004LearningModule::_getUniqueScaledScoreForUser ( int  $a_id,
int  $a_user 
)
static

Get the Unique Scaled Score of a course Conditions: Only one SCO may set cmi.score.scaled.

Returns
float scaled score, -1 if not unique

Definition at line 742 of file class.ilObjSCORM2004LearningModule.php.

742 : float
743 {
744 global $DIC;
745
746 $ilDB = $DIC->database();
747 $ilUser = $DIC->user();
748 $scos = array();
749
750 $val_set = $ilDB->queryF(
751 "SELECT cp_node.cp_node_id FROM cp_node,cp_resource,cp_item WHERE" .
752 " cp_item.cp_node_id=cp_node.cp_node_id AND cp_item.resourceId = cp_resource.id AND scormType='sco' AND nodeName='item' AND cp_node.slm_id = %s GROUP BY cp_node.cp_node_id",
753 array('integer'),
754 array($a_id)
755 );
756 while ($val_rec = $ilDB->fetchAssoc($val_set)) {
757 $scos[] = $val_rec['cp_node_id'];
758 }
759 $set = 0; //numbers of SCO that set cmi.score.scaled
760 $scaled = null;
761 foreach ($scos as $i => $iValue) {
762 $val_set = $ilDB->queryF(
763 "SELECT scaled FROM cmi_node WHERE (user_id = %s AND cp_node_id = %s)",
764 array('integer', 'integer'),
765 array($a_user, $scos[$i])
766 );
767 if ($val_set->numRows() > 0) {
768 $val_rec = $ilDB->fetchAssoc($val_set);
769 if ($val_rec['scaled'] != null) {
770 $set++;
771 $scaled = $val_rec['scaled'];
772 }
773 }
774 }
775 return ($set == 1) ? $scaled : -1;
776 }

References $DIC, $i, $ilDB, and $ilUser.

Referenced by ilObjSAHSLearningModule\getPointsInPercent().

+ Here is the caller graph for this function:

◆ _ISODurationToCentisec()

static ilObjSCORM2004LearningModule::_ISODurationToCentisec ( string  $str)
static

convert ISO 8601 Timeperiods to centiseconds

Definition at line 610 of file class.ilObjSCORM2004LearningModule.php.

610 : float
611 {
612 $aV = array(0, 0, 0, 0, 0, 0);
613 $bErr = false;
614 $bTFound = false;
615 if (strpos($str, "P") != 0) {
616 $bErr = true;
617 }
618 if (!$bErr) {
619 $aT = array("Y", "M", "D", "H", "M", "S");
620 $p = 0;
621 $i = 0;
622 $str = substr($str, 1);
623 for ($i = 0, $max = count($aT); $i < $max; $i++) {
624 if (strpos($str, "T") === 0) {
625 $str = substr($str, 1);
626 $i = max($i, 3);
627 $bTFound = true;
628 }
629 $p = strpos($str, $aT[$i]);
630
631 if ($p > -1) {
632 if ($i == 1 && strpos($str, "T") > -1 && strpos($str, "T") < $p) {
633 continue;
634 }
635 if ($aT[$i] === "S") {
636 $aV[$i] = substr($str, 0, $p);
637 } else {
638 $aV[$i] = intval(substr($str, 0, $p));
639 }
640 if (!is_numeric($aV[$i])) {
641 $bErr = true;
642 break;
643 }
644
645 if ($i > 2 && !$bTFound) {
646 $bErr = true;
647 break;
648 }
649 $str = substr($str, $p + 1);
650 }
651 }
652 if (!$bErr && strlen($str) != 0) {
653 $bErr = true;
654 }
655 }
656
657 if ($bErr) {
658 return 0;
659 }
660 return $aV[0] * 3_155_760_000 + $aV[1] * 262_980_000 + $aV[2] * 8_640_000 + $aV[3] * 360000 + $aV[4] * 6000 + round($aV[5] * 100);
661 }

References $i.

Referenced by ilCmiXapiHighscoreReport\fetchTotalDuration(), ilSCORM2004Tracking\getSumTotalTimeSecondsFromScos(), and getTrackingDataAgg().

+ Here is the caller graph for this function:

◆ _lookupItemTitle()

static ilObjSCORM2004LearningModule::_lookupItemTitle ( int  $a_node_id)
static

Definition at line 902 of file class.ilObjSCORM2004LearningModule.php.

902 : string
903 {
904 global $DIC;
905
906 $ilDB = $DIC->database();
907
908 $r = $ilDB->queryF(
909 '
910 SELECT * FROM cp_item
911 WHERE cp_node_id = %s',
912 array('integer'),
913 array($a_node_id)
914 );
915
916 if ($i = $ilDB->fetchAssoc($r)) {
917 return $i["title"];
918 }
919 return "";
920 }

References $DIC, $i, and $ilDB.

Referenced by ilLPStatusSCORM\_getStatusInfo(), getTrackedItems(), and getTrackingDataAgg().

+ Here is the caller graph for this function:

◆ _lookupLastAccess()

static ilObjSCORM2004LearningModule::_lookupLastAccess ( int  $a_obj_id,
int  $a_usr_id 
)
static

Return the last access timestamp for a given user.

Definition at line 287 of file class.ilObjSCORM2004LearningModule.php.

287 : ?string
288 {
289 global $DIC;
290
291 $ilDB = $DIC->database();
292
293 $result = $ilDB->queryF(
294 '
295 SELECT MAX(c_timestamp) last_access
296 FROM cmi_node, cp_node
297 WHERE cmi_node.cp_node_id = cp_node.cp_node_id
298 AND cp_node.slm_id = %s
299 AND user_id = %s
300 GROUP BY c_timestamp',
301 array('integer', 'integer'),
302 array($a_obj_id, $a_usr_id)
303 );
304 if ($ilDB->numRows($result)) {
305 $row = $ilDB->fetchAssoc($result);
306 return (string) $row["last_access"];
307 }
308
309 return null;
310 }

References $DIC, and $ilDB.

◆ convert_1_2_to_2004()

ilObjSCORM2004LearningModule::convert_1_2_to_2004 ( string  $manifest)

Definition at line 210 of file class.ilObjSCORM2004LearningModule.php.

210 : void
211 {
212 $ilLog = $this->log;
213
214 ##check manifest-file for version. Check for schemaversion as this is a required element for SCORM 2004
215 ##accept 2004 3rd Edition an CAM 1.3 as valid schemas
216
217 //set variables
218 $packageFolder = $this->getDataDirectory();
219 $this->imsmanifestFile = $manifest;
220 $doc = new DomDocument();
221
222 //fix reload errors before loading
223 $this->fixReload();
224 $doc->load($this->imsmanifestFile);
225 $elements = $doc->getElementsByTagName("schemaversion");
226 $schema = "";
227 if (isset($elements->item(0)->nodeValue)) {
228 $schema = $elements->item(0)->nodeValue;
229 }
230 if (strtolower(trim($schema)) === "cam 1.3" || strtolower(trim($schema)) === "2004 3rd edition" || strtolower(trim($schema)) === "2004 4th edition") {
231 //no conversion
232 return;
233 }
234
235 //convert to SCORM 2004
236
237 //check for broken SCORM 1.2 manifest file (missing organization default-common error in a lot of manifest files)
238 $organizations = $doc->getElementsByTagName("organizations");
239 //first check if organizations is in manifest
240 if ($organizations->item(0) == null) {
241 die("organizations missing in manifest");
242 }
243 $default = $organizations->item(0)->getAttribute("default");
244 if ($default == "" || $default == null) {
245 //lookup identifier
246 $organization = $doc->getElementsByTagName("organization");
247 $item = $organization->item(0);
248 if ($item !== null) {
249 $ident = $item->getAttribute("identifier");
250 $organizations->item(0)->setAttribute("default", $ident);
251 }
252 }
253
254 //validate the fixed mainfest. If it's still not valid, don't transform an throw error
255
256
257 //first copy wrappers
258 $wrapperdir = $packageFolder . "/GenericRunTimeWrapper1.0_aadlc";
259 if (!mkdir($wrapperdir) && !is_dir($wrapperdir)) {
260 throw new \RuntimeException(sprintf('Directory "%s" was not created', $wrapperdir));
261 }
262 copy(self::WRAPPER_HTML, $wrapperdir . "/GenericRunTimeWrapper.htm");
263 copy(self::WRAPPER_JS, $wrapperdir . "/SCOPlayerWrapper.js");
264
265 //backup manifestfile
266 $backupManifest = $packageFolder . "/imsmanifest.xml.back";
267 $ret = copy($this->imsmanifestFile, $backupManifest);
268
269 //transform manifest file
270 $totransform = $doc;
271 $ilLog->debug("SCORM: about to transform to SCORM 2004");
272
273 $xsl = new DOMDocument();
274 $xsl->async = false;
275 $xsl->load(self::CONVERT_XSL);
276 $prc = new XSLTProcessor();
277 $r = @$prc->importStyleSheet($xsl);
278
279 file_put_contents($this->imsmanifestFile, $prc->transformToXML($totransform));
280
281 $ilLog->debug("SCORM: Transformation completed");
282 }
getDataDirectory(?string $mode="filesystem")
get data directory of lm
ilLogger $log

References ilObject\$log, fixReload(), and ilObjSAHSLearningModule\getDataDirectory().

Referenced by readObject().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteTrackingDataOfUsers()

ilObjSCORM2004LearningModule::deleteTrackingDataOfUsers ( array  $a_users)

Reimplemented from ilObjSCORMLearningModule.

Definition at line 312 of file class.ilObjSCORM2004LearningModule.php.

312 : void
313 {
316
317 foreach ($a_users as $user) {
320 }
321 }
static _deleteReadEventsForUsers(int $a_obj_id, array $a_user_ids)
static _updateStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj=null, bool $a_percentage=false, bool $a_force_raise=false)
ilDBInterface $db
static removeCMIDataForUserAndPackage(int $user_id, int $packageId)

References ilObject\$db, $ilDB, $user, ilChangeEvent\_deleteReadEventsForUsers(), ilLPStatusWrapper\_updateStatus(), ilObject\getId(), and ilSCORM2004DeleteData\removeCMIDataForUserAndPackage().

Referenced by importSuccess().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fixReload()

ilObjSCORM2004LearningModule::fixReload ( )

Definition at line 200 of file class.ilObjSCORM2004LearningModule.php.

200 : void
201 {
202 $out = file_get_contents($this->imsmanifestFile);
203 $check = '/xmlns="http:\/\/www.imsglobal.org\/xsd\/imscp_v1p1"/';
204 $replace = "xmlns=\"http://www.imsproject.org/xsd/imscp_rootv1p1p2\"";
205 $out = preg_replace($check, $replace, $out);
206 file_put_contents($this->imsmanifestFile, $out);
207 }
$out
Definition: buildRTE.php:24
$check
Definition: buildRTE.php:81

References $check, and $out.

Referenced by convert_1_2_to_2004().

+ Here is the caller graph for this function:

◆ getAttemptsForUser()

ilObjSCORM2004LearningModule::getAttemptsForUser ( int  $a_user_id)

get number of atttempts for a certain user and package

Reimplemented from ilObjSCORMLearningModule.

Definition at line 429 of file class.ilObjSCORM2004LearningModule.php.

429 : int
430 {
432 $val_set = $ilDB->queryF(
433 'SELECT package_attempts FROM sahs_user WHERE user_id = %s AND obj_id = %s',
434 array('integer','integer'),
435 array($a_user_id, $this->getId())
436 );
437
438 $val_rec = $ilDB->fetchAssoc($val_set);
439
440 if ($val_rec["package_attempts"] == null) {
441 $val_rec["package_attempts"] = 0;
442 }
443
444 return (int) $val_rec["package_attempts"];
445 }

References ilObject\$db, $ilDB, and ilObject\getId().

+ Here is the call graph for this function:

◆ getImportSequencing()

ilObjSCORM2004LearningModule::getImportSequencing ( )

Get import sequencing.

Returns
boolean import sequencing information

Definition at line 74 of file class.ilObjSCORM2004LearningModule.php.

References $import_sequencing.

◆ getModuleVersionForUser()

ilObjSCORM2004LearningModule::getModuleVersionForUser ( int  $a_user_id)

get module version that tracking data for a user was recorded on

Reimplemented from ilObjSCORMLearningModule.

Definition at line 450 of file class.ilObjSCORM2004LearningModule.php.

450 : string
451 {
453 $val_set = $ilDB->queryF(
454 'SELECT module_version FROM sahs_user WHERE user_id = %s AND obj_id = %s',
455 array('integer','integer'),
456 array($a_user_id, $this->getId())
457 );
458
459 $val_rec = $ilDB->fetchAssoc($val_set);
460
461 if ($val_rec["module_version"] == null) {
462 $val_rec["module_version"] = "";
463 }
464 return $val_rec["module_version"];
465 }

References ilObject\$db, $ilDB, and ilObject\getId().

+ Here is the call graph for this function:

◆ getQuantityOfSCOs()

static ilObjSCORM2004LearningModule::getQuantityOfSCOs ( int  $a_slm_id)
static

Definition at line 663 of file class.ilObjSCORM2004LearningModule.php.

663 : int
664 {
665 global $DIC;
666 $val_set = $DIC->database()->queryF(
667 '
668 SELECT distinct(cp_node.cp_node_id) FROM cp_node,cp_resource,cp_item
669 WHERE cp_item.cp_node_id = cp_node.cp_node_id
670 AND cp_item.resourceid = cp_resource.id
671 AND scormtype = %s
672 AND nodename = %s
673 AND cp_node.slm_id = %s ',
674 array('text','text','integer'),
675 array('sco','item',$a_slm_id)
676 );
677 return $DIC->database()->numRows($val_set);
678 }

References $DIC.

◆ getTrackedItems()

ilObjSCORM2004LearningModule::getTrackedItems ( )

get all tracked items of current user

Returns
array<int, array<string, mixed>>

Reimplemented from ilObjSCORMLearningModule.

Definition at line 328 of file class.ilObjSCORM2004LearningModule.php.

328 : array
329 {
333
334 $sco_set = $ilDB->queryF(
335 '
336 SELECT DISTINCT cmi_node.cp_node_id id
337 FROM cp_node, cmi_node
338 WHERE slm_id = %s
339 AND cp_node.cp_node_id = cmi_node.cp_node_id
340 ORDER BY cmi_node.cp_node_id ',
341 array('integer'),
342 array($this->getId())
343 );
344
345 $items = array();
346
347 while ($sco_rec = $ilDB->fetchAssoc($sco_set)) {
348 $item['id'] = $sco_rec["id"];
349 $item['title'] = self::_lookupItemTitle((int) $sco_rec["id"]);
350 $items[] = $item;
351 }
352 return $items;
353 }

References ilObject\$db, $ilDB, $ilUser, $user, _lookupItemTitle(), and ilObject\getId().

+ Here is the call graph for this function:

◆ getTrackingDataAgg()

ilObjSCORM2004LearningModule::getTrackingDataAgg ( int  $a_user_id,
?bool  $raw = false 
)
Exceptions
ilDateTimeException
Returns
array<int|string, mixed[]>

Definition at line 359 of file class.ilObjSCORM2004LearningModule.php.

359 : array
360 {
362
363 $scos = array();
364 $data = array();
365 //get all SCO's of this object
366
367 $val_set = $ilDB->queryF(
368 'SELECT cp_node_id FROM cp_node
369 WHERE nodename = %s
370 AND cp_node.slm_id = %s',
371 array('text', 'integer'),
372 array('item',$this->getId())
373 );
374 while ($val_rec = $ilDB->fetchAssoc($val_set)) {
375 $scos[] = $val_rec['cp_node_id'];
376 }
377
378 foreach ($scos as $sco) {
379 $data_set = $ilDB->queryF(
380 '
381 SELECT c_timestamp last_access, total_time, success_status, completion_status,
382 c_raw, scaled, cp_node_id
383 FROM cmi_node
384 WHERE cp_node_id = %s
385 AND user_id = %s',
386 array('integer','integer'),
387 array($sco,$a_user_id)
388 );
389
390 while ($data_rec = $ilDB->fetchAssoc($data_set)) {
391 if ($data_rec["success_status"] != "" && $data_rec["success_status"] !== "unknown") {
392 $status = $data_rec["success_status"];
393 } else {
394 if ($data_rec["completion_status"] == "") {
395 $status = "unknown";
396 } else {
397 $status = $data_rec["completion_status"];
398 }
399 }
400 if (!$raw) {
401 $time = ilDatePresentation::secondsToString((int) round(self::_ISODurationToCentisec($data_rec["total_time"]) / 100));
402 $score = "";
403 if ($data_rec["c_raw"] != null) {
404 $score = $data_rec["c_raw"];
405 if ($data_rec["scaled"] != null) {
406 $score .= " = ";
407 }
408 }
409 if ($data_rec["scaled"] != null) {
410 $score .= ($data_rec["scaled"] * 100) . "%";
411 }
412 $title = self::_lookupItemTitle((int) $data_rec["cp_node_id"]);
413 $last_access = ilDatePresentation::formatDate(new ilDateTime($data_rec['last_access'], IL_CAL_DATETIME));
414 $data[] = array("sco_id" => $data_rec["cp_node_id"],
415 "score" => $score, "time" => $time, "status" => $status,"last_access" => $last_access,"title" => $title);
416 } else {
417 $data_rec["total_time"] = self::_ISODurationToCentisec($data_rec["total_time"]) / 100;
418 $data[$data_rec["cp_node_id"]] = $data_rec;
419 }
420 }
421 }
422
423 return $data;
424 }
const IL_CAL_DATETIME
static secondsToString(int $seconds, bool $force_with_seconds=false, ?ilLanguage $a_lng=null)
converts seconds to string: Long: 7 days 4 hour(s) ...
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
@classDescription Date and time handling
static _ISODurationToCentisec(string $str)
convert ISO 8601 Timeperiods to centiseconds
string $title

References $data, ilObject\$db, $ilDB, ilObject\$title, _ISODurationToCentisec(), _lookupItemTitle(), ilDatePresentation\formatDate(), ilObject\getId(), IL_CAL_DATETIME, and ilDatePresentation\secondsToString().

+ Here is the call graph for this function:

◆ importSuccess()

ilObjSCORM2004LearningModule::importSuccess ( string  $a_file)

Reimplemented from ilObjSCORMLearningModule.

Definition at line 467 of file class.ilObjSCORM2004LearningModule.php.

467 : bool
468 {
471 $scos = array();
472 $olp = ilObjectLP::getInstance($this->getId());
473 $collection = $olp->getCollectionInstance();
474 if ($collection) {
475 $scos = $collection->getItems();
476 }
477
478 $fhandle = fopen($a_file, "rb");//changed from r to rb
479
480 $obj_id = $this->getID();
481 $users = array();
482 $usersToDelete = array();
483 $fields = fgetcsv($fhandle, 4096, ';');
484 while (($csv_rows = fgetcsv($fhandle, 4096, ";")) !== false) {
485 $user_id = 0;
486 $data = array_combine($fields, $csv_rows);
487 //no check the format - sufficient to import users
488 if (isset($data["Login"])) {
489 $user_id = $this->get_user_id($data["Login"]);
490 }
491 if (isset($data["login"])) {
492 $user_id = $this->get_user_id($data["login"]);
493 }
494 //add mail in future
495 if (isset($data["user"]) && is_numeric($data["user"])) {
496 $user_id = (int) $data["user"];
497 }
498 if ($user_id > 0) {
499 $last_access = ilUtil::now();
500 if (isset($data['Date'])) {
501 $date_ex = explode('.', $data['Date']);
502 $last_access = implode('-', array($date_ex[2], $date_ex[1], $date_ex[0]));
503 }
504 if (isset($data['LastAccess'])) {
505 $last_access = $data['LastAccess'];
506 }
507
509
510 if (isset($data["Status"])) {
511 if (is_numeric($data["Status"])) {
512 $status = $data["Status"];
513 } elseif ($data["Status"] == ilLPStatus::LP_STATUS_NOT_ATTEMPTED) {
515 } elseif ($data["Status"] == ilLPStatus::LP_STATUS_IN_PROGRESS) {
517 } elseif ($data["Status"] == ilLPStatus::LP_STATUS_FAILED) {
519 }
520 }
521 $attempts = null;
522 if (isset($data["Attempts"])) {
523 $attempts = (int) $data["Attempts"];
524 }
525
526 $percentage_completed = 0;
528 $percentage_completed = 100;
529 } elseif (isset($data['percentageCompletedSCOs'])) {
530 $percentage_completed = (int) $data['percentageCompletedSCOs'];
531 }
532
533 $sco_total_time_sec = null;
534 if (isset($data['SumTotal_timeSeconds'])) {
535 $sco_total_time_sec = (int) $data['SumTotal_timeSeconds'];
536 }
537
539 $usersToDelete[] = $user_id;
540 } else {
541 $this->importSuccessForSahsUser($user_id, $last_access, $status, $attempts, $percentage_completed, $sco_total_time_sec);
542 $users[] = $user_id;
543 }
544
546 foreach ($scos as $sco_id) {
547 $res = $ilDB->queryF(
548 '
549 SELECT completion_status, success_status, user_id FROM cmi_node WHERE cp_node_id = %s AND user_id = %s',
550 array('integer','integer'),
551 array($sco_id,$user_id)
552 );
553
554 if (!$ilDB->numRows($res)) {
555 $nextId = $ilDB->nextId('cmi_node');
556 $val_set = $ilDB->manipulateF(
557 'INSERT INTO cmi_node
558 (cp_node_id,user_id,completion_status,c_timestamp,cmi_node_id)
559 VALUES(%s,%s,%s,%s,%s)',
560 array('integer','integer','text','timestamp','integer'),
561 array($sco_id,$user_id,'completed',$last_access,$nextId)
562 );
563 } else {
564 $doUpdate = false;
565 while ($row = $ilDB->fetchAssoc($res)) {
566 if (($row["completion_status"] === "completed" && $row["success_status"] !== "failed") || $row["success_status"] === "passed") {
567 if ($doUpdate != true) {
568 $doUpdate = false;
569 } //note for issue if there are 2 entries for same sco_id
570 } else {
571 $doUpdate = true;
572 }
573 }
574 if ($doUpdate == true) {
575 $ilDB->update(
576 'cmi_node',
577 array(
578 'completion_status' => array('text', 'completed'),
579 'success_status' => array('text', ''),
580 'suspend_data' => array('text', ''),
581 'c_timestamp' => array('timestamp', $last_access)
582 ),
583 array(
584 'user_id' => array('integer', $user_id),
585 'cp_node_id' => array('integer', $sco_id)
586 )
587 );
588 }
589 }
590 }
591 }
592 } else {
593 //echo "Warning! User $csv_rows[0] does not exist in ILIAS. Data for this user was skipped.\n";
594 }
595 }
596
597 if (count($usersToDelete) > 0) {
598 // include_once("./Services/Tracking/classes/class.ilLPMarks.php");
599 // ilLPMarks::_deleteForUsers($this->getId(), $usersToDelete);
600 $this->deleteTrackingDataOfUsers($usersToDelete);
601 }
603
604 return true;
605 }
static _refreshStatus(int $a_obj_id, ?array $a_users=null)
const LP_STATUS_COMPLETED_NUM
const LP_STATUS_FAILED
const LP_STATUS_IN_PROGRESS_NUM
const LP_STATUS_NOT_ATTEMPTED_NUM
const LP_STATUS_FAILED_NUM
const LP_STATUS_NOT_ATTEMPTED
const LP_STATUS_IN_PROGRESS
importSuccessForSahsUser(int $user_id, string $last_access, int $status, ?int $attempts=null, ?int $percentage_completed=null, ?int $sco_total_time_sec=null)
static getInstance(int $obj_id)
static now()
Return current timestamp in Y-m-d H:i:s format.

References $data, ilObject\$db, $ilDB, $ilUser, $res, $user, ilLPStatusWrapper\_refreshStatus(), deleteTrackingDataOfUsers(), ilObjSCORMLearningModule\get_user_id(), ilObject\getId(), ilObjectLP\getInstance(), ilObjSCORMLearningModule\importSuccessForSahsUser(), ILIAS\Repository\int(), ilLPStatus\LP_STATUS_COMPLETED_NUM, ilLPStatus\LP_STATUS_FAILED, ilLPStatus\LP_STATUS_FAILED_NUM, ilLPStatus\LP_STATUS_IN_PROGRESS, ilLPStatus\LP_STATUS_IN_PROGRESS_NUM, ilLPStatus\LP_STATUS_NOT_ATTEMPTED, ilLPStatus\LP_STATUS_NOT_ATTEMPTED_NUM, and ilUtil\now().

+ Here is the call graph for this function:

◆ readObject()

ilObjSCORM2004LearningModule::readObject ( )

read manifest file

Reimplemented from ilObjSCORMLearningModule.

Definition at line 82 of file class.ilObjSCORM2004LearningModule.php.

82 : string
83 {
84 global $DIC;
87
88 //check for json_encode,json_decode
89 if (!function_exists('json_encode') || !function_exists('json_decode')) {
90 $ilErr->raiseError($lng->txt('scplayer_phpmysqlcheck'), $ilErr->WARNING);
91 }
92
93 $needs_convert = false;
94
95 // convert imsmanifest.xml file in iso to utf8 if needed
96
97 $manifest_file = $this->getDataDirectory() . "/imsmanifest.xml";
98
99 // check if manifestfile exists and space left on device...
100 $check_for_manifest_file = is_file($manifest_file);
101
102
103
104 // if no manifestfile
105 if (!$check_for_manifest_file) {
106 $ilErr->raiseError($this->lng->txt("Manifestfile $manifest_file not found!"), $ilErr->MESSAGE);
107 return "";
108 }
109
110
111 if ($check_for_manifest_file) {
112 $manifest_file_array = file($manifest_file);
113
114 foreach ($manifest_file_array as $mfa) {
115 // if (seems_not_utf8($mfa))
116 if (@iconv('UTF-8', 'UTF-8', $mfa) != $mfa) {
117 $needs_convert = true;
118 break;
119 }
120 }
121
122
123
124 // to copy the file we need some extraspace, counted in bytes *2 ... we need 2 copies....
125 $estimated_manifest_filesize = filesize($manifest_file) * 2;
126
127 // i deactivated this, because it seems to fail on some windows systems (see bug #1795)
128 //$check_disc_free = disk_free_space($this->getDataDirectory()) - $estimated_manifest_filesize;
129 $check_disc_free = 2;
130 }
131
132
133 // if $manifest_file needs to be converted to UTF8
134 if ($needs_convert) {
135 // if file exists and enough space left on device
136 if ($check_for_manifest_file && ($check_disc_free > 1)) {
137
138 // create backup from original
139 if (!copy($manifest_file, $manifest_file . ".old")) {
140 echo "Failed to copy $manifest_file...<br>\n";
141 }
142
143 // read backupfile, convert each line to utf8, write line to new file
144 // php < 4.3 style
145 $f_write_handler = fopen($manifest_file . ".new", "w");
146 $f_read_handler = fopen($manifest_file . ".old", "r");
147 while (!feof($f_read_handler)) {
148 $zeile = fgets($f_read_handler);
149 //echo mb_detect_encoding($zeile);
150 fwrite($f_write_handler, utf8_encode($zeile));
151 }
152 fclose($f_read_handler);
153 fclose($f_write_handler);
154
155 // copy new utf8-file to imsmanifest.xml
156 if (!copy($manifest_file . ".new", $manifest_file)) {
157 echo "Failed to copy $manifest_file...<br>\n";
158 }
159
160 if (!@is_file($manifest_file)) {
161 $ilErr->raiseError($this->lng->txt("cont_no_manifest"), $ilErr->WARNING);
162 }
163 } else {
164 // gives out the specific error
165
166 if (!($check_disc_free > 1)) {
167 $ilErr->raiseError($this->lng->txt("Not enough space left on device!"), $ilErr->MESSAGE);
168 }
169 return "";
170 }
171 } else {
172 // check whether file starts with BOM (that confuses some sax parsers, see bug #1795)
173 $hmani = fopen($manifest_file, "r");
174 $start = fread($hmani, 3);
175 if (strtolower(bin2hex($start)) === "efbbbf") {
176 $f_write_handler = fopen($manifest_file . ".new", "w");
177 while (!feof($hmani)) {
178 $n = fread($hmani, 900);
179 fwrite($f_write_handler, $n);
180 }
181 fclose($f_write_handler);
182 fclose($hmani);
183
184 // copy new utf8-file to imsmanifest.xml
185 if (!copy($manifest_file . ".new", $manifest_file)) {
186 echo "Failed to copy $manifest_file...<br>\n";
187 }
188 } else {
189 fclose($hmani);
190 }
191 }
192
193 //check for SCORM 1.2
194 $this->convert_1_2_to_2004($manifest_file);
195
196 return (new ilSCORM13Package())->il_import($this->getDataDirectory(), $this->getId());
197 }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
ilLanguage $lng
ilErrorHandling $error
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ilErr
Definition: raiseError.php:17

References $DIC, ilObject\$error, $ilErr, ilObject\$lng, convert_1_2_to_2004(), ilObjSAHSLearningModule\getDataDirectory(), ilObject\getId(), ILIAS\Repository\lng(), and ilLanguage\txt().

+ Here is the call graph for this function:

◆ setImportSequencing()

ilObjSCORM2004LearningModule::setImportSequencing ( bool  $a_val)

Set import sequencing.

Parameters
boolean$a_valimport sequencing information

Definition at line 64 of file class.ilObjSCORM2004LearningModule.php.

64 : void
65 {
66 $this->import_sequencing = $a_val;
67 }

Field Documentation

◆ $import_sequencing

bool ilObjSCORM2004LearningModule::$import_sequencing = false
protected

Definition at line 32 of file class.ilObjSCORM2004LearningModule.php.

Referenced by getImportSequencing().

◆ $imsmanifestFile

string ilObjSCORM2004LearningModule::$imsmanifestFile
protected

Definition at line 34 of file class.ilObjSCORM2004LearningModule.php.

◆ $tabs

ilTabsGUI ilObjSCORM2004LearningModule::$tabs
protected

Definition at line 30 of file class.ilObjSCORM2004LearningModule.php.

◆ $user

ilObjUser ilObjSCORM2004LearningModule::$user
protected

◆ CONVERT_XSL

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

Definition at line 36 of file class.ilObjSCORM2004LearningModule.php.

◆ WRAPPER_HTML

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

Definition at line 37 of file class.ilObjSCORM2004LearningModule.php.

◆ WRAPPER_JS

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

Definition at line 38 of file class.ilObjSCORM2004LearningModule.php.


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