ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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)
 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 ("./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)
 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'
 
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
 
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

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 28 of file class.ilObjSCORM2004LearningModule.php.

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 50 of file class.ilObjSCORM2004LearningModule.php.

References $DIC, ILIAS\MetaData\Repository\Validation\Data\__construct(), ilLoggerFactory\getLogger(), ILIAS\Repository\lng(), ILIAS\Repository\tabs(), and ILIAS\Repository\user().

51  {
52  global $DIC;
53 
54  $this->lng = $DIC->language();
55  $this->error = $DIC["ilErr"];
56  $this->db = $DIC->database();
57  $this->log = ilLoggerFactory::getLogger('sc13');
58  $this->user = $DIC->user();
59  $this->tabs = $DIC->tabs();
60  $this->type = "sahs";
61  parent::__construct($a_id, $a_call_by_reference);
62  }
static getLogger(string $a_component_id)
Get component logger.
global $DIC
Definition: feed.php:28
__construct(VocabulariesInterface $vocabularies)
+ 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 689 of file class.ilObjSCORM2004LearningModule.php.

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

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

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

References $DIC, $ilDB, and $res.

Referenced by ilObjSAHSLearningModule\getMaxPoints().

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

◆ _getMeasure()

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

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

References $DIC, and $ilDB.

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

◆ _getSatisfied()

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

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

References $DIC, and $ilDB.

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

◆ _getScores2004ForUser()

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

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

References $DIC, and $ilDB.

Referenced by ilLPCollectionOfSCOs\getScoresForUserAndCP_Node_Id().

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

◆ _getStatus()

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

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

References $DIC, and $ilDB.

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

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

References $DIC, $ilDB, and $res.

Referenced by ilLPCollectionOfSCOs\getPossibleItems().

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

References $DIC, and $ilDB.

Referenced by ilObjSAHSLearningModule\getPointsInPercent().

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

◆ _ISODurationToCentisec()

static ilObjSCORM2004LearningModule::_ISODurationToCentisec ( string  $str)
static

convert ISO 8601 Timeperiods to centiseconds

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

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

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

◆ _lookupItemTitle()

static ilObjSCORM2004LearningModule::_lookupItemTitle ( int  $a_node_id)
static

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

References $DIC, $ilDB, and $r.

Referenced by ilLPStatusSCORM\_getStatusInfo().

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

References $DIC, and $ilDB.

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

◆ convert_1_2_to_2004()

ilObjSCORM2004LearningModule::convert_1_2_to_2004 ( string  $manifest)

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

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

Referenced by readObject().

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

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

Referenced by importSuccess().

319  : void
320  {
321  $ilDB = $this->db;
323 
324  foreach ($a_users as $user) {
326  ilLPStatusWrapper::_updateStatus($this->getId(), $user);
327  }
328  }
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 204 of file class.ilObjSCORM2004LearningModule.php.

References $check, and $out.

Referenced by convert_1_2_to_2004().

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

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

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

◆ getImportSequencing()

ilObjSCORM2004LearningModule::getImportSequencing ( )

Get import sequencing.

Returns
boolean import sequencing information

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

References $import_sequencing.

79  : bool
80  {
82  }

◆ getModuleVersionForUser()

ilObjSCORM2004LearningModule::getModuleVersionForUser ( int  $a_user_id)

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

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

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

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

◆ getQuantityOfSCOs()

static ilObjSCORM2004LearningModule::getQuantityOfSCOs ( int  $a_slm_id)
static

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

References $DIC.

Referenced by ilSCORM2004StoreData\persistCMIData().

668  : int
669  {
670  global $DIC;
671  $val_set = $DIC->database()->queryF(
672  '
673  SELECT distinct(cp_node.cp_node_id) FROM cp_node,cp_resource,cp_item
674  WHERE cp_item.cp_node_id = cp_node.cp_node_id
675  AND cp_item.resourceid = cp_resource.id
676  AND scormtype = %s
677  AND nodename = %s
678  AND cp_node.slm_id = %s ',
679  array('text','text','integer'),
680  array('sco','item',$a_slm_id)
681  );
682  return $DIC->database()->numRows($val_set);
683  }
global $DIC
Definition: feed.php:28
+ 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 335 of file class.ilObjSCORM2004LearningModule.php.

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

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

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

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

◆ importSuccess()

ilObjSCORM2004LearningModule::importSuccess ( string  $a_file)

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

References $data, ilObject\$db, $ilDB, $res, $user, 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, and ilLPStatus\LP_STATUS_NOT_ATTEMPTED_NUM.

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

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

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

Field Documentation

◆ $backupManifest

string ilObjSCORM2004LearningModule::$backupManifest
private

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

◆ $import_sequencing

bool ilObjSCORM2004LearningModule::$import_sequencing = false
protected

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

Referenced by getImportSequencing().

◆ $imsmanifestFile

string ilObjSCORM2004LearningModule::$imsmanifestFile
protected

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

◆ $packageFolder

string ilObjSCORM2004LearningModule::$packageFolder
private

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

◆ $tabs

ilTabsGUI ilObjSCORM2004LearningModule::$tabs
protected

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

◆ $totransform

DomDocument ilObjSCORM2004LearningModule::$totransform
private

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

◆ $user

ilObjUser ilObjSCORM2004LearningModule::$user
protected

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

Referenced by getTrackedItems(), and importSuccess().

◆ CONVERT_XSL

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

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

◆ WRAPPER_HTML

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

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

◆ WRAPPER_JS

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

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


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