Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 402 and 403]

Library of internal classes and functions for module SCORM

Copyright: 1999 onwards Roberto Pinna
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 2501 lines (98 kb)
Included or required: 1 time
Referenced: 25 times
Includes or requires: 1 file
 mod/scorm/lib.php

Defines 1 class

scorm_package_file_info:: (57 methods):
  get_parent()
  get_visible_name()
  scorm_get_popup_options_array()
  scorm_get_grade_method_array()
  scorm_get_what_grade_array()
  scorm_get_skip_view_array()
  scorm_get_hidetoc_array()
  scorm_get_updatefreq_array()
  scorm_get_popup_display_array()
  scorm_get_navigation_display_array()
  scorm_get_attempts_array()
  scorm_get_attemptstatus_array()
  scorm_get_forceattempt_array()
  scorm_parse()
  scorm_array_search()
  scorm_repeater()
  scorm_external_link()
  scorm_get_sco()
  scorm_get_scoes()
  scorm_insert_track()
  scorm_has_tracks()
  scorm_get_tracks()
  scorm_format_interactions()
  scorm_get_sco_runtime()
  scorm_grade_user_attempt()
  scorm_grade_user()
  scorm_count_launchable()
  scorm_get_last_attempt()
  scorm_get_first_attempt()
  scorm_get_last_completed_attempt()
  scorm_get_all_attempts()
  scorm_print_launch()
  scorm_simple_play()
  scorm_get_count_users()
  scorm_reconstitute_array_element()
  scorm_element_cmp()
  scorm_get_attempt_status()
  scorm_get_attempt_count()
  scorm_debugging()
  scorm_delete_responses()
  scorm_delete_attempt()
  scorm_format_duration()
  scorm_get_toc_object()
  scorm_get_toc_get_parent_child()
  scorm_format_toc_for_treeview()
  scorm_format_toc_for_droplist()
  scorm_get_toc()
  scorm_get_adlnav_json()
  scorm_check_url()
  scorm_isset()
  scorm_check_launchable_sco()
  scorm_get_availability_status()
  scorm_require_available()
  scorm_get_sco_and_launch_url()
  scorm_launch_sco()
  scorm_eval_prerequisites()
  scorm_update_calendar()


Class: scorm_package_file_info  - X-Ref


get_parent()   X-Ref
No description

get_visible_name()   X-Ref
No description

scorm_get_popup_options_array()   X-Ref
Returns an array of the popup options for SCORM and each options default value

return: array an array of popup options as the key and their defaults as the value

scorm_get_grade_method_array()   X-Ref
Returns an array of the array of what grade options

return: array an array of what grade options

scorm_get_what_grade_array()   X-Ref
Returns an array of the array of what grade options

return: array an array of what grade options

scorm_get_skip_view_array()   X-Ref
Returns an array of the array of skip view options

return: array an array of skip view options

scorm_get_hidetoc_array()   X-Ref
Returns an array of the array of hide table of contents options

return: array an array of hide table of contents options

scorm_get_updatefreq_array()   X-Ref
Returns an array of the array of update frequency options

return: array an array of update frequency options

scorm_get_popup_display_array()   X-Ref
Returns an array of the array of popup display options

return: array an array of popup display options

scorm_get_navigation_display_array()   X-Ref
Returns an array of the array of navigation buttons display options

return: array an array of navigation buttons display options

scorm_get_attempts_array()   X-Ref
Returns an array of the array of attempt options

return: array an array of attempt options

scorm_get_attemptstatus_array()   X-Ref
Returns an array of the attempt status options

return: array an array of attempt status options

scorm_get_forceattempt_array()   X-Ref
Returns an array of the force attempt options

return: array an array of attempt options

scorm_parse($scorm, $full)   X-Ref
Extracts scrom package, sets up all variables.
Called whenever scorm changes

param: object $scorm instance - fields are updated and changes saved into database
param: bool $full force full update if true
return: void

scorm_array_search($item, $needle, $haystacks, $strict=false)   X-Ref
No description

scorm_repeater($what, $times)   X-Ref
No description

scorm_external_link($link)   X-Ref
No description

scorm_get_sco($id, $what=SCO_ALL)   X-Ref
Returns an object containing all datas relative to the given sco ID

param: integer $id The sco ID
return: mixed (false if sco id does not exists)

scorm_get_scoes($id, $organisation=false)   X-Ref
Returns an object (array) containing all the scoes data related to the given sco ID

param: integer $id The sco ID
param: integer $organisation an organisation ID - defaults to false if not required
return: mixed (false if there are no scoes or an array)

scorm_insert_track($userid, $scormid, $scoid, $attempt, $element, $value, $forcecompleted=false, $trackdata = null)   X-Ref
No description

scorm_has_tracks($scormid, $userid)   X-Ref
simple quick function to return true/false if this user has tracks in this scorm

param: integer $scormid The scorm ID
param: integer $userid the users id
return: boolean (false if there are no tracks)

scorm_get_tracks($scoid, $userid, $attempt='')   X-Ref
No description

scorm_format_interactions($trackdata)   X-Ref
helper function to return a formatted list of interactions for reports.

param: array $trackdata the records from scorm_scoes_track table
return: object formatted list of interactions

scorm_get_sco_runtime($scormid, $scoid, $userid, $attempt=1)   X-Ref
No description

scorm_grade_user_attempt($scorm, $userid, $attempt=1)   X-Ref
No description

scorm_grade_user($scorm, $userid)   X-Ref
No description

scorm_count_launchable($scormid, $organization='')   X-Ref
No description

scorm_get_last_attempt($scormid, $userid)   X-Ref
Returns the last attempt used - if no attempts yet, returns 1 for first attempt

param: int $scormid the id of the scorm.
param: int $userid the id of the user.
return: int The attempt number to use.

scorm_get_first_attempt($scormid, $userid)   X-Ref
Returns the first attempt used - if no attempts yet, returns 1 for first attempt.

param: int $scormid the id of the scorm.
param: int $userid the id of the user.
return: int The first attempt number.

scorm_get_last_completed_attempt($scormid, $userid)   X-Ref
Returns the last completed attempt used - if no completed attempts yet, returns 1 for first attempt

param: int $scormid the id of the scorm.
param: int $userid the id of the user.
return: int The attempt number to use.

scorm_get_all_attempts($scormid, $userid)   X-Ref
Returns the full list of attempts a user has made.

param: int $scormid the id of the scorm.
param: int $userid the id of the user.
return: array array of attemptids

scorm_print_launch($user, $scorm, $action, $cm)   X-Ref
Displays the entry form and toc if required.

param: stdClass $user   user object
param: stdClass $scorm  scorm object
param: string   $action base URL for the organizations select box
param: stdClass $cm     course module object

scorm_simple_play($scorm, $user, $context, $cmid)   X-Ref
No description

scorm_get_count_users($scormid, $groupingid=null)   X-Ref
No description

scorm_reconstitute_array_element($sversion, $userdata, $elementname, $children)   X-Ref
Build up the JavaScript representation of an array element

param: string $sversion SCORM API version
param: array $userdata User track data
param: string $elementname Name of array element to get values for
param: array $children list of sub elements of this array element that also need instantiating
return: Javascript array elements

scorm_element_cmp($a, $b)   X-Ref
Build up the JavaScript representation of an array element

param: string $a left array element
param: string $b right array element
return: comparator - 0,1,-1

scorm_get_attempt_status($user, $scorm, $cm='')   X-Ref
Generate the user attempt status string

param: object $user Current context user
param: object $scorm a moodle scrom object - mdl_scorm
return: string - Attempt status string

scorm_get_attempt_count($userid, $scorm, $returnobjects = false, $ignoremissingcompletion = false)   X-Ref
Get SCORM attempt count

param: object $user Current context user
param: object $scorm a moodle scrom object - mdl_scorm
param: bool $returnobjects if true returns a object with attempts, if false returns count of attempts.
param: bool $ignoremissingcompletion - ignores attempts that haven't reported a grade/completion.
return: int - no. of attempts so far

scorm_debugging($scorm)   X-Ref
Figure out with this is a debug situation

param: object $scorm a moodle scrom object - mdl_scorm
return: boolean - debugging true/false

scorm_delete_responses($attemptids, $scorm)   X-Ref
Delete Scorm tracks for selected users

param: array $attemptids list of attempts that need to be deleted
param: stdClass $scorm instance
return: bool true deleted all responses, false failed deleting an attempt - stopped here

scorm_delete_attempt($userid, $scorm, $attemptid)   X-Ref
Delete Scorm tracks for selected users

param: int $userid ID of User
param: stdClass $scorm Scorm object
param: int $attemptid user attempt that need to be deleted
return: bool true suceeded

scorm_format_duration($duration)   X-Ref
Converts SCORM duration notation to human-readable format
The function works with both SCORM 1.2 and SCORM 2004 time formats

param: $duration string SCORM duration
return: string human-readable date/time

scorm_get_toc_object($user, $scorm, $currentorg='', $scoid='', $mode='normal', $attempt='',$play=false, $organizationsco=null)   X-Ref
No description

scorm_get_toc_get_parent_child(&$result, $currentorg)   X-Ref
No description

scorm_format_toc_for_treeview($user, $scorm, $scoes, $usertracks, $cmid, $toclink=TOCJSLINK, $currentorg='',$attempt='', $play=false, $organizationsco=null, $children=false)   X-Ref
No description

scorm_format_toc_for_droplist($scorm, $scoes, $usertracks, $currentorg='', $organizationsco=null,$children=false, $level=0, $tocmenus=array()   X-Ref
No description

scorm_get_toc($user, $scorm, $cmid, $toclink=TOCJSLINK, $currentorg='', $scoid='', $mode='normal',$attempt='', $play=false, $tocheader=false)   X-Ref
No description

scorm_get_adlnav_json($scoes, &$adlnav = array()   X-Ref
No description

scorm_check_url($url)   X-Ref
Check for the availability of a resource by URL.

Check is performed using an HTTP HEAD call.

param: $url string A valid URL
return: bool|string True if no issue is found. The error string message, otherwise

scorm_isset($userdata, $param, $ifempty = '')   X-Ref
Check for a parameter in userdata and return it if it's set
or return the value from $ifempty if its empty

param: stdClass $userdata Contains user's data
param: string $param parameter that should be checked
param: string $ifempty value to be replaced with if $param is not set
return: string value from $userdata->$param if its not empty, or $ifempty

scorm_check_launchable_sco($scorm, $scoid)   X-Ref
Check if the current sco is launchable
If not, find the next launchable sco

param: stdClass $scorm Scorm object
param: integer $scoid id of scorm_scoes record.
return: integer scoid of correct sco to launch or empty if one cannot be found, which will trigger first sco.

scorm_get_availability_status($scorm, $checkviewreportcap = false, $context = null, $userid = null)   X-Ref
Check if a SCORM is available for the current user.

param: stdClass  $scorm            SCORM record
param: boolean $checkviewreportcap Check the scorm:viewreport cap
param: stdClass  $context          Module context, required if $checkviewreportcap is set to true
param: int  $userid                User id override
return: array                       status (available or not and possible warnings)

scorm_require_available($scorm, $checkviewreportcap = false, $context = null)   X-Ref
Requires a SCORM package to be available for the current user.

param: stdClass  $scorm            SCORM record
param: boolean $checkviewreportcap Check the scorm:viewreport cap
param: stdClass  $context          Module context, required if $checkviewreportcap is set to true

scorm_get_sco_and_launch_url($scorm, $scoid, $context)   X-Ref
Return a SCO object and the SCO launch URL

param: stdClass $scorm SCORM object
param: int $scoid The SCO id in database
param: stdClass $context context object
return: array the SCO object and URL

scorm_launch_sco($scorm, $sco, $cm, $context, $scourl)   X-Ref
Trigger the scorm_launched event.

param: stdClass $scorm   scorm object
param: stdClass $sco     sco object
param: stdClass $cm      course module object
param: stdClass $context context object
param: string $scourl    SCO URL

scorm_eval_prerequisites($prerequisites, $usertracks)   X-Ref
This is really a little language parser for AICC_SCRIPT
evaluates the expression and returns a boolean answer
see 2.3.2.5.1. Sequencing/Navigation Today  - from the SCORM 1.2 spec (CAM).
Also used by AICC packages.

param: string $prerequisites the aicc_script prerequisites expression
param: array  $usertracks the tracked user data of each SCO visited
return: boolean

scorm_update_calendar(stdClass $scorm, $cmid)   X-Ref
Update the calendar entries for this scorm activity.

param: stdClass $scorm the row from the database table scorm.
param: int $cmid The coursemodule id
return: bool