ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ilObjSCORM2004LearningModule Class Reference

Class ilObjSCORM2004LearningModule. 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)
 Return the last access timestamp for a given user. More...
 
 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 ilObjUser $ilUser. More...
 
 importTrackingData (string $a_file)
 
 importSuccess (string $a_file)
 
 importSuccessForSahsUser (int $user_id, ?DateTimeImmutable $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 ()
 Set Editable. More...
 
 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 ("./public/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...
 
 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 ()
 offlineMode More...
 
 setDebug (bool $a_debug)
 
 setAutoContinue (bool $a_auto_continue)
 debug pw More...
 
 getAutoContinue ()
 
 getAuto_last_visited ()
 
 setAuto_last_visited (bool $a_auto_last_visited)
 
 setAutoSuspend (bool $a_auto_suspend)
 Set sequencing expert mode. More...
 
 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
 getObjectProperties ()
 
 flushObjectProperties ()
 
 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 $description)
 
 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, int $new_obj_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 getIconForType (string $type)
 
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 = '../components/ILIAS/Scorm2004/templates/xsl/op/scorm12To2004.xsl'
 
const WRAPPER_HTML = '../components/ILIAS/Scorm2004/scripts/converter/GenericRunTimeWrapper1.0_aadlc/GenericRunTimeWrapper.htm'
 
const WRAPPER_JS = '../components/ILIAS/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'
 
ILIAS DI UIServices $ui
 
- 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
 
LOMServices $lom_services
 
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 = ""
 
string $desc = ""
 
string $long_desc = ""
 
int $owner = 0
 
string $create_date = ""
 
string $last_update = ""
 
string $import_id = ""
 
bool $register = false
 

Private Attributes

string $packageFolder
 
string $backupManifest
 
DomDocument $totransform
 

Additional Inherited Members

- Protected Member Functions inherited from ilObjSCORMLearningModule
 kindlyToDateTime (string $format, string $maybe_datetime, ?DateTimeImmutable $default=null)
 
- Protected Member Functions inherited from ilObject
 doMDUpdateListener (string $a_element)
 
 beforeMDUpdateListener (string $a_element)
 
 doCreateMetaData ()
 
 beforeCreateMetaData ()
 
 doUpdateMetaData ()
 
 beforeUpdateMetaData ()
 
 doDeleteMetaData ()
 
 beforeDeleteMetaData ()
 
 handleAutoRating ()
 
 hasAutoRating ()
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

Constructor.

Parameters
integer$a_idreference_id or object_id
boolean$a_call_by_referencetreat the id as reference_id (true) or object_id (false)

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

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

50  {
51  global $DIC;
52 
53  $this->lng = $DIC->language();
54  $this->error = $DIC["ilErr"];
55  $this->db = $DIC->database();
56  $this->log = ilLoggerFactory::getLogger('sc13');
57  $this->user = $DIC->user();
58  $this->tabs = $DIC->tabs();
59  $this->type = "sahs";
60  parent::__construct($a_id, $a_call_by_reference);
61  }
static getLogger(string $a_component_id)
Get component logger.
global $DIC
Definition: shib_login.php:26
__construct(Container $dic, ilPlugin $plugin)
+ 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

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

References $DIC, and $ilDB.

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

◆ _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 920 of file class.ilObjSCORM2004LearningModule.php.

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

Referenced by ilObjSAHSLearningModule\getMaxPoints().

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

◆ _getMeasure()

static ilObjSCORM2004LearningModule::_getMeasure ( int  $a_obj_id,
int  $a_user_id 
)
static

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

References $DIC, and $ilDB.

874  : float|bool
875  {
876  global $DIC;
877 
878  $ilDB = $DIC->database();
879 
880  $status_set = $ilDB->queryF(
881  '
882  SELECT * FROM cmi_gobjective
883  WHERE scope_id = %s
884  AND objective_id = %s
885  AND user_id = %s',
886  array('integer','text','integer'),
887  array($a_obj_id,'-course_overall_status-',$a_user_id)
888  );
889 
890  if ($status_rec = $ilDB->fetchAssoc($status_set)) {
891  return (float) $status_rec["measure"];
892  }
893 
894  return false;
895  }
global $DIC
Definition: shib_login.php:26

◆ _getSatisfied()

static ilObjSCORM2004LearningModule::_getSatisfied ( int  $a_obj_id,
int  $a_user_id 
)
static

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

References $DIC, and $ilDB.

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

◆ _getScores2004ForUser()

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

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

References $DIC, $ilDB, and null.

Referenced by ilLPCollectionOfSCOs\getScoresForUserAndCP_Node_Id().

966  : array
967  {
968  global $DIC;
969 
970  $ilDB = $DIC->database();
971  $retAr = array("raw" => null, "max" => null, "scaled" => null);
972  $val_set = $ilDB->queryF(
973  "SELECT c_raw, c_max, scaled FROM cmi_node WHERE (user_id = %s AND cp_node_id = %s)",
974  array('integer', 'integer'),
975  array($a_user, $a_cp_node_id)
976  );
977  if ($val_set->numRows() > 0) {
978  $val_rec = $ilDB->fetchAssoc($val_set);
979  $retAr["raw"] = $val_rec['c_raw'];
980  $retAr["max"] = $val_rec['c_max'];
981  $retAr["scaled"] = $val_rec['scaled'];
982  if ($val_rec['scaled'] == null && $val_rec['c_raw'] != null && $val_rec['c_max'] != null) {
983  $retAr["scaled"] = ($val_rec['c_raw'] / $val_rec['c_max']);
984  }
985  }
986  return $retAr;
987  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
global $DIC
Definition: shib_login.php:26
+ Here is the caller graph for this function:

◆ _getStatus()

static ilObjSCORM2004LearningModule::_getStatus ( int  $a_obj_id,
int  $a_user_id 
)
static

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

References $DIC, and $ilDB.

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

◆ _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>>

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

References $DIC, $ilDB, and $res.

Referenced by ilLPCollectionOfSCOs\getPossibleItems().

787  : array
788  {
789  global $DIC;
790 
791  $ilDB = $DIC->database();
792 
793 
794  $item_set = $ilDB->queryF(
795  '
796  SELECT cp_item.* FROM cp_node, cp_item WHERE slm_id = %s
797  AND cp_node.cp_node_id = cp_item.cp_node_id
798  ORDER BY cp_node.cp_node_id ',
799  array('integer'),
800  array($a_obj_id)
801  );
802 
803  $items = array();
804  while ($item_rec = $ilDB->fetchAssoc($item_set)) {
805  $s2 = $ilDB->queryF(
806  '
807  SELECT cp_resource.* FROM cp_node, cp_resource
808  WHERE slm_id = %s
809  AND cp_node.cp_node_id = cp_resource.cp_node_id
810  AND cp_resource.id = %s ',
811  array('integer','text'),
812  array($a_obj_id,$item_rec["resourceid"])
813  );
814 
815 
816  if ($res = $ilDB->fetchAssoc($s2)) {
817  if ($res["scormtype"] === "sco") {
818  $items[] = array("id" => $item_rec["cp_node_id"],
819  "title" => $item_rec["title"]);
820  }
821  }
822  }
823 
824  return $items;
825  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:26
+ 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 746 of file class.ilObjSCORM2004LearningModule.php.

References $DIC, $ilDB, and null.

Referenced by ilObjSAHSLearningModule\getPointsInPercent().

746  : float
747  {
748  global $DIC;
749 
750  $ilDB = $DIC->database();
751  $ilUser = $DIC->user();
752  $scos = array();
753 
754  $val_set = $ilDB->queryF(
755  "SELECT cp_node.cp_node_id FROM cp_node,cp_resource,cp_item WHERE" .
756  " 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",
757  array('integer'),
758  array($a_id)
759  );
760  while ($val_rec = $ilDB->fetchAssoc($val_set)) {
761  $scos[] = $val_rec['cp_node_id'];
762  }
763  $set = 0; //numbers of SCO that set cmi.score.scaled
764  $scaled = null;
765  foreach ($scos as $i => $iValue) {
766  $val_set = $ilDB->queryF(
767  "SELECT scaled FROM cmi_node WHERE (user_id = %s AND cp_node_id = %s)",
768  array('integer', 'integer'),
769  array($a_user, $scos[$i])
770  );
771  if ($val_set->numRows() > 0) {
772  $val_rec = $ilDB->fetchAssoc($val_set);
773  if ($val_rec['scaled'] != null) {
774  $set++;
775  $scaled = $val_rec['scaled'];
776  }
777  }
778  }
779  return ($set == 1) ? $scaled : -1;
780  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
global $DIC
Definition: shib_login.php:26
+ Here is the caller graph for this function:

◆ _ISODurationToCentisec()

static ilObjSCORM2004LearningModule::_ISODurationToCentisec ( string  $str)
static

convert ISO 8601 Timeperiods to centiseconds

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

Referenced by ilSCORM2004TrackingItems\exportSelectedCore(), ilSCORM2004TrackingItems\exportSelectedInteractions(), ilCmiXapiHighscoreReport\fetchTotalDuration(), ilSCORM2004Tracking\getSumTotalTimeSecondsFromScos(), and ilSCORM2004TrackingItems\tracInteractionUser().

614  : float
615  {
616  $aV = array(0, 0, 0, 0, 0, 0);
617  $bErr = false;
618  $bTFound = false;
619  if (strpos($str, "P") != 0) {
620  $bErr = true;
621  }
622  if (!$bErr) {
623  $aT = array("Y", "M", "D", "H", "M", "S");
624  $p = 0;
625  $i = 0;
626  $str = substr($str, 1);
627  for ($i = 0, $max = count($aT); $i < $max; $i++) {
628  if (strpos($str, "T") === 0) {
629  $str = substr($str, 1);
630  $i = max($i, 3);
631  $bTFound = true;
632  }
633  $p = strpos($str, $aT[$i]);
634 
635  if ($p > -1) {
636  if ($i == 1 && strpos($str, "T") > -1 && strpos($str, "T") < $p) {
637  continue;
638  }
639  if ($aT[$i] === "S") {
640  $aV[$i] = substr($str, 0, $p);
641  } else {
642  $aV[$i] = intval(substr($str, 0, $p));
643  }
644  if (!is_numeric($aV[$i])) {
645  $bErr = true;
646  break;
647  }
648 
649  if ($i > 2 && !$bTFound) {
650  $bErr = true;
651  break;
652  }
653  $str = substr($str, $p + 1);
654  }
655  }
656  if (!$bErr && strlen($str) != 0) {
657  $bErr = true;
658  }
659  }
660 
661  if ($bErr) {
662  return 0;
663  }
664  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);
665  }
+ Here is the caller graph for this function:

◆ _lookupItemTitle()

static ilObjSCORM2004LearningModule::_lookupItemTitle ( int  $a_node_id)
static

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

References $DIC, $ilDB, and $r.

Referenced by ilLPStatusSCORM\_getStatusInfo().

897  : string
898  {
899  global $DIC;
900 
901  $ilDB = $DIC->database();
902 
903  $r = $ilDB->queryF(
904  '
905  SELECT * FROM cp_item
906  WHERE cp_node_id = %s',
907  array('integer'),
908  array($a_node_id)
909  );
910 
911  if ($i = $ilDB->fetchAssoc($r)) {
912  return $i["title"];
913  }
914  return "";
915  }
global $DIC
Definition: shib_login.php:26
$r
+ 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 293 of file class.ilObjSCORM2004LearningModule.php.

References $DIC, $ilDB, and null.

293  : ?string
294  {
295  global $DIC;
296 
297  $ilDB = $DIC->database();
298 
299  $result = $ilDB->queryF(
300  '
301  SELECT MAX(c_timestamp) last_access
302  FROM cmi_node, cp_node
303  WHERE cmi_node.cp_node_id = cp_node.cp_node_id
304  AND cp_node.slm_id = %s
305  AND user_id = %s
306  GROUP BY c_timestamp',
307  array('integer', 'integer'),
308  array($a_obj_id, $a_usr_id)
309  );
310  if ($ilDB->numRows($result)) {
311  $row = $ilDB->fetchAssoc($result);
312  return (string) $row["last_access"];
313  }
314 
315  return null;
316  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
global $DIC
Definition: shib_login.php:26

◆ convert_1_2_to_2004()

ilObjSCORM2004LearningModule::convert_1_2_to_2004 ( string  $manifest)

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

References ilObject\$db, $ilDB, ilObject\$log, $r, fixReload(), ilObjSAHSLearningModule\getDataDirectory(), and null.

Referenced by readObject().

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

◆ deleteTrackingDataOfUsers()

ilObjSCORM2004LearningModule::deleteTrackingDataOfUsers ( array  $a_users)

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

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

Referenced by importSuccess().

318  : void
319  {
320  $ilDB = $this->db;
322 
323  foreach ($a_users as $user) {
325  ilLPStatusWrapper::_updateStatus($this->getId(), $user);
326  }
327  }
ilDBInterface $db
static _deleteReadEventsForUsers(int $a_obj_id, array $a_user_ids)
static removeCMIDataForUserAndPackage(int $user_id, int $packageId)
static _updateStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj=null, bool $a_percentage=false, bool $a_force_raise=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fixReload()

ilObjSCORM2004LearningModule::fixReload ( )

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

References $check, and $out.

Referenced by convert_1_2_to_2004().

203  : void
204  {
205  $out = file_get_contents($this->imsmanifestFile);
206  $check = '/xmlns="http:\/\/www.imsglobal.org\/xsd\/imscp_v1p1"/';
207  $replace = "xmlns=\"http://www.imsproject.org/xsd/imscp_rootv1p1p2\"";
208  $out = preg_replace($check, $replace, $out);
209  file_put_contents($this->imsmanifestFile, $out);
210  }
$out
Definition: buildRTE.php:24
$check
Definition: buildRTE.php:81
+ 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

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

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

435  : int
436  {
437  $ilDB = $this->db;
438  $val_set = $ilDB->queryF(
439  'SELECT package_attempts FROM sahs_user WHERE user_id = %s AND obj_id = %s',
440  array('integer','integer'),
441  array($a_user_id, $this->getId())
442  );
443 
444  $val_rec = $ilDB->fetchAssoc($val_set);
445 
446  if ($val_rec["package_attempts"] == null) {
447  $val_rec["package_attempts"] = 0;
448  }
449 
450  return (int) $val_rec["package_attempts"];
451  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
ilDBInterface $db
+ Here is the call graph for this function:

◆ getImportSequencing()

ilObjSCORM2004LearningModule::getImportSequencing ( )

Get import sequencing.

Returns
boolean import sequencing information

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

References $import_sequencing.

78  : bool
79  {
81  }

◆ getModuleVersionForUser()

ilObjSCORM2004LearningModule::getModuleVersionForUser ( int  $a_user_id)

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

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

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

456  : string
457  {
458  $ilDB = $this->db;
459  $val_set = $ilDB->queryF(
460  'SELECT module_version FROM sahs_user WHERE user_id = %s AND obj_id = %s',
461  array('integer','integer'),
462  array($a_user_id, $this->getId())
463  );
464 
465  $val_rec = $ilDB->fetchAssoc($val_set);
466 
467  if ($val_rec["module_version"] == null) {
468  $val_rec["module_version"] = "";
469  }
470  return $val_rec["module_version"];
471  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
ilDBInterface $db
+ Here is the call graph for this function:

◆ getQuantityOfSCOs()

static ilObjSCORM2004LearningModule::getQuantityOfSCOs ( int  $a_slm_id)
static

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

References $DIC.

Referenced by ilSCORM2004StoreData\persistCMIData().

667  : int
668  {
669  global $DIC;
670  $val_set = $DIC->database()->queryF(
671  '
672  SELECT distinct(cp_node.cp_node_id) FROM cp_node,cp_resource,cp_item
673  WHERE cp_item.cp_node_id = cp_node.cp_node_id
674  AND cp_item.resourceid = cp_resource.id
675  AND scormtype = %s
676  AND nodename = %s
677  AND cp_node.slm_id = %s ',
678  array('text','text','integer'),
679  array('sco','item',$a_slm_id)
680  );
681  return $DIC->database()->numRows($val_set);
682  }
global $DIC
Definition: shib_login.php:26
+ Here is the caller graph for this function:

◆ getTrackedItems()

ilObjSCORM2004LearningModule::getTrackedItems ( )

get all tracked items of current user

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

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

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

334  : array
335  {
336  $ilUser = $this->user;
337  $ilDB = $this->db;
338  $ilUser = $this->user;
339 
340  $sco_set = $ilDB->queryF(
341  '
342  SELECT DISTINCT cmi_node.cp_node_id id
343  FROM cp_node, cmi_node
344  WHERE slm_id = %s
345  AND cp_node.cp_node_id = cmi_node.cp_node_id
346  ORDER BY cmi_node.cp_node_id ',
347  array('integer'),
348  array($this->getId())
349  );
350 
351  $items = array();
352 
353  while ($sco_rec = $ilDB->fetchAssoc($sco_set)) {
354  $item['id'] = $sco_rec["id"];
355  $item['title'] = self::_lookupItemTitle((int) $sco_rec["id"]);
356  $items[] = $item;
357  }
358  return $items;
359  }
ilDBInterface $db
+ 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 365 of file class.ilObjSCORM2004LearningModule.php.

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

365  : array
366  {
367  $ilDB = $this->db;
368 
369  $scos = array();
370  $data = array();
371  //get all SCO's of this object
372 
373  $val_set = $ilDB->queryF(
374  'SELECT cp_node_id FROM cp_node
375  WHERE nodename = %s
376  AND cp_node.slm_id = %s',
377  array('text', 'integer'),
378  array('item',$this->getId())
379  );
380  while ($val_rec = $ilDB->fetchAssoc($val_set)) {
381  $scos[] = $val_rec['cp_node_id'];
382  }
383 
384  foreach ($scos as $sco) {
385  $data_set = $ilDB->queryF(
386  '
387  SELECT c_timestamp last_access, total_time, success_status, completion_status,
388  c_raw, scaled, cp_node_id
389  FROM cmi_node
390  WHERE cp_node_id = %s
391  AND user_id = %s',
392  array('integer','integer'),
393  array($sco,$a_user_id)
394  );
395 
396  while ($data_rec = $ilDB->fetchAssoc($data_set)) {
397  if ($data_rec["success_status"] != "" && $data_rec["success_status"] !== "unknown") {
398  $status = $data_rec["success_status"];
399  } else {
400  if ($data_rec["completion_status"] == "") {
401  $status = "unknown";
402  } else {
403  $status = $data_rec["completion_status"];
404  }
405  }
406  if (!$raw) {
407  $time = ilDatePresentation::secondsToString((int) round(self::_ISODurationToCentisec($data_rec["total_time"]) / 100));
408  $score = "";
409  if ($data_rec["c_raw"] != null) {
410  $score = $data_rec["c_raw"];
411  if ($data_rec["scaled"] != null) {
412  $score .= " = ";
413  }
414  }
415  if ($data_rec["scaled"] != null) {
416  $score .= ($data_rec["scaled"] * 100) . "%";
417  }
418  $title = self::_lookupItemTitle((int) $data_rec["cp_node_id"]);
419  $last_access = ilDatePresentation::formatDate(new ilDateTime($data_rec['last_access'], IL_CAL_DATETIME));
420  $data[] = array("sco_id" => $data_rec["cp_node_id"],
421  "score" => $score, "time" => $time, "status" => $status,"last_access" => $last_access,"title" => $title);
422  } else {
423  $data_rec["total_time"] = self::_ISODurationToCentisec($data_rec["total_time"]) / 100;
424  $data[$data_rec["cp_node_id"]] = $data_rec;
425  }
426  }
427  }
428 
429  return $data;
430  }
string $title
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) ...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
ilDBInterface $db
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
+ Here is the call graph for this function:

◆ importSuccess()

ilObjSCORM2004LearningModule::importSuccess ( string  $a_file)

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

References $data, ilObject\$db, $ilDB, $res, $user, $user_id, ilLPStatusWrapper\_refreshStatus(), deleteTrackingDataOfUsers(), ilObjSCORMLearningModule\get_user_id(), ilObject\getId(), ilObjectLP\getInstance(), ilObjSCORMLearningModule\importSuccessForSahsUser(), ILIAS\Repository\int(), ilObjSCORMLearningModule\kindlyToDateTime(), 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 null.

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

◆ readObject()

ilObjSCORM2004LearningModule::readObject ( )

read manifest file

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

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

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

68  : void
69  {
70  $this->import_sequencing = $a_val;
71  }

Field Documentation

◆ $backupManifest

string ilObjSCORM2004LearningModule::$backupManifest
private

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

◆ $import_sequencing

bool ilObjSCORM2004LearningModule::$import_sequencing = false
protected

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

Referenced by getImportSequencing().

◆ $imsmanifestFile

string ilObjSCORM2004LearningModule::$imsmanifestFile
protected

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

◆ $packageFolder

string ilObjSCORM2004LearningModule::$packageFolder
private

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

◆ $tabs

ilTabsGUI ilObjSCORM2004LearningModule::$tabs
protected

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

◆ $totransform

DomDocument ilObjSCORM2004LearningModule::$totransform
private

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

◆ $user

ilObjUser ilObjSCORM2004LearningModule::$user
protected

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

Referenced by getTrackedItems(), and importSuccess().

◆ CONVERT_XSL

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

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

◆ WRAPPER_HTML

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

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

◆ WRAPPER_JS

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

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


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