Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.
/mod/scorm/ -> lib.php (source)

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

(no description)

Copyright: 1999 onwards Martin Dougiamas {@link http://moodle.com}
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 1848 lines (66 kb)
Included or required: 1 time
Referenced: 5 times
Includes or requires: 1 file
 mod/scorm/deprecatedlib.php

Defines 45 functions


Functions that are not part of a class:

scorm_status_options($withstrings = false)   X-Ref
Return an array of status options

Optionally with translated strings

return: array
param: bool    $with_strings   (optional)

scorm_add_instance($scorm, $mform=null)   X-Ref
Given an object containing all the necessary data,
(defined by the form in mod_form.php) this function
will create a new instance and return the id number
of the new instance.

return: int new instance id
param: object $scorm Form data
param: object $mform

scorm_update_instance($scorm, $mform=null)   X-Ref
Given an object containing all the necessary data,
(defined by the form in mod_form.php) this function
will update an existing instance with new data.

return: bool
param: object $scorm Form data
param: object $mform

scorm_delete_instance($id)   X-Ref
Given an ID of an instance of this module,
this function will permanently delete the instance
and any data that depends on it.

return: boolean
param: int $id Scorm instance id

scorm_user_outline($course, $user, $mod, $scorm)   X-Ref
Return a small object with summary information about what a
user has done with a given particular instance of this module
Used for user activity reports.

return: mixed
param: int $course Course id
param: int $user User id
param: int $mod
param: int $scorm The scorm id

scorm_user_complete($course, $user, $mod, $scorm)   X-Ref
Print a detailed representation of what a user has done with
a given particular instance of this module, for user activity reports.

return: boolean
param: object $course
param: object $user
param: object $mod
param: object $scorm

scorm_cron_scheduled_task()   X-Ref
Function to be run periodically according to the moodle Tasks API
This function searches for things that need to be done, such
as sending out mail, toggling flags etc ...

return: boolean

scorm_get_user_grades($scorm, $userid=0)   X-Ref
Return grade for given user or all users.

return: array array of grades, false if none
param: int $scormid id of scorm
param: int $userid optional user id, 0 means all users

scorm_update_grades($scorm, $userid=0, $nullifnone=true)   X-Ref
Update grades in central gradebook

param: object $scorm
param: int $userid specific user only, 0 mean all
param: bool $nullifnone

scorm_grade_item_update($scorm, $grades=null)   X-Ref
Update/create grade item for given scorm

return: object grade_item
param: object $scorm object with extra cmidnumber
param: mixed $grades optional array/object of grade(s); 'reset' means reset grades in gradebook

scorm_grade_item_delete($scorm)   X-Ref
Delete grade item for given scorm

return: object grade_item
param: object $scorm object

scorm_get_view_actions()   X-Ref
List the actions that correspond to a view of this module.
This is used by the participation report.

Note: This is not used by new logging system. Event with
crud = 'r' and edulevel = LEVEL_PARTICIPATING will
be considered as view action.

return: array

scorm_get_post_actions()   X-Ref
List the actions that correspond to a post of this module.
This is used by the participation report.

Note: This is not used by new logging system. Event with
crud = ('c' || 'u' || 'd') and edulevel = LEVEL_PARTICIPATING
will be considered as post action.

return: array

scorm_option2text($scorm)   X-Ref

return: object $scorm
param: object $scorm

scorm_reset_course_form_definition(&$mform)   X-Ref
Implementation of the function for printing the form elements that control
whether the course reset functionality affects the scorm.

param: object $mform form passed by reference

scorm_reset_course_form_defaults($course)   X-Ref
Course reset form defaults.

return: array

scorm_reset_gradebook($courseid, $type='')   X-Ref
Removes all grades from gradebook

param: int $courseid
param: string optional type

scorm_reset_userdata($data)   X-Ref
Actual implementation of the reset course functionality, delete all the
scorm attempts for course $data->courseid.

return: array status array
param: object $data the data submitted from the reset course.

scorm_get_file_areas($course, $cm, $context)   X-Ref
Lists all file areas current user may browse

return: array
param: object $course
param: object $cm
param: object $context

scorm_get_file_info($browser, $areas, $course, $cm, $context, $filearea, $itemid, $filepath, $filename)   X-Ref
File browsing support for SCORM file areas

return: file_info instance or null if not found
param: file_browser $browser file browser instance
param: array $areas file areas
param: stdClass $course course object
param: stdClass $cm course module object
param: stdClass $context context object
param: string $filearea file area
param: int $itemid item ID
param: string $filepath file path
param: string $filename file name

scorm_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options=array()   X-Ref
Serves scorm content, introduction images and packages. Implements needed access control ;-)

return: bool false if file not found, does not return if found - just send the file
param: stdClass $course course object
param: stdClass $cm course module object
param: stdClass $context context object
param: string $filearea file area
param: array $args extra arguments
param: bool $forcedownload whether or not force download
param: array $options additional options affecting the file serving

scorm_supports($feature)   X-Ref

return: mixed True if module supports feature, false if not, null if doesn't know or string for the module purpose.
param: string $feature FEATURE_xx constant for requested feature

scorm_debug_log_filename($type, $scoid)   X-Ref
Get the filename for a temp log file

return: string The filename as an absolute path
param: string $type - type of log(aicc,scorm12,scorm13) used as prefix for filename
param: integer $scoid - scoid of object this log entry is for

scorm_debug_log_write($type, $text, $scoid)   X-Ref
writes log output to a temp log file

param: string $type - type of log(aicc,scorm12,scorm13) used as prefix for filename
param: string $text - text to be written to file.
param: integer $scoid - scoid of object this log entry is for.

scorm_debug_log_remove($type, $scoid)   X-Ref
Remove debug log file

return: boolean True if the file is successfully deleted, false otherwise
param: string $type - type of log(aicc,scorm12,scorm13) used as prefix for filename
param: integer $scoid - scoid of object this log entry is for

scorm_print_overview()   X-Ref


scorm_page_type_list($pagetype, $parentcontext, $currentcontext)   X-Ref
Return a list of page types

param: string $pagetype current page type
param: stdClass $parentcontext Block's parent context
param: stdClass $currentcontext Current context of block

scorm_version_check($scormversion, $version='')   X-Ref
Returns the SCORM version used.

return: Scorm version.
param: string $scormversion comes from $scorm->version
param: string $version one of the defined vars SCORM_12, SCORM_13, SCORM_AICC (or empty)

scorm_dndupload_register()   X-Ref
Register the ability to handle drag and drop file uploads

return: array containing details of the files / types the mod can handle

scorm_dndupload_handle($uploadinfo)   X-Ref
Handle a file that has been uploaded

return: int instance id of the newly created mod
param: object $uploadinfo details of the file / content that has been uploaded

scorm_set_completion($scorm, $userid, $completionstate = COMPLETION_COMPLETE, $grades = array()   X-Ref
Sets activity completion state

param: object $scorm object
param: int $userid User ID
param: int $completionstate Completion state
param: array $grades grades array of users with grades - used when $userid = 0

scorm_validate_package($file)   X-Ref
Check that a Zip file contains a valid SCORM package

return: array empty if no issue is found. Array of error message otherwise
param: $file stored_file a Zip file.

scorm_check_mode($scorm, &$newattempt, &$attempt, $userid, &$mode)   X-Ref
Check and set the correct mode and attempt when entering a SCORM package.

param: object $scorm object
param: string $newattempt should a new attempt be generated here.
param: int $attempt the attempt number this is for.
param: int $userid the userid of the user.
param: string $mode the current mode that has been selected.

scorm_view($scorm, $course, $cm, $context)   X-Ref
Trigger the course_module_viewed event.

param: stdClass $scorm        scorm object
param: stdClass $course     course object
param: stdClass $cm         course module object
param: stdClass $context    context object

scorm_check_updates_since(cm_info $cm, $from, $filter = array()   X-Ref
Check if the module has any update that affects the current user since a given time.

return: stdClass an object with the different type of areas indicating if they were updated or not
param: cm_info $cm course module data
param: int $from the time to check updates from
param: array $filter  if we need to check only specific updates

mod_scorm_get_fontawesome_icon_map()   X-Ref
Get icon mapping for font-awesome.


scorm_refresh_events($courseid = 0, $instance = null, $cm = null)   X-Ref
This standard function will check all instances of this module
and make sure there are up-to-date events created for each of them.
If courseid = 0, then every scorm event in the site is checked, else
only scorm events belonging to the course specified are checked.

return: bool
param: int $courseid
param: int|stdClass $instance scorm module instance or ID.
param: int|stdClass $cm Course module object or ID.

mod_scorm_core_calendar_provide_event_action(calendar_event $event,\core_calendar\action_factory $factory, $userid = null)   X-Ref
This function receives a calendar event and returns the action associated with it, or null if there is none.

This is used by block_myoverview in order to display the event appropriately. If null is returned then the event
is not displayed on the block.

return: \core_calendar\local\event\entities\action_interface|null
param: calendar_event $event
param: \core_calendar\action_factory $factory
param: int $userid User id override

scorm_get_coursemodule_info($coursemodule)   X-Ref
Add a get_coursemodule_info function in case any SCORM type wants to add 'extra' information
for the course (see resource).

Given a course_module object, this function returns any "extra" information that may be needed
when printing this activity in a course listing.  See get_array_of_activities() in course/lib.php.

return: cached_cm_info An object on information that the courses
param: stdClass $coursemodule The coursemodule object (record).

mod_scorm_get_completion_active_rule_descriptions($cm)   X-Ref
Callback which returns human-readable strings describing the active completion custom rules for the module instance.

return: array $descriptions the array of descriptions for the custom rules.
param: cm_info|stdClass $cm object with fields ->completion and ->customdata['customcompletionrules']

mod_scorm_core_calendar_event_timestart_updated(\calendar_event $event, \stdClass $scorm)   X-Ref
This function will update the scorm module according to the
event that has been modified.

It will set the timeopen or timeclose value of the scorm instance
according to the type of event provided.

param: \calendar_event $event
param: stdClass $scorm The module instance to get the range from

mod_scorm_core_calendar_get_valid_event_timestart_range(\calendar_event $event, \stdClass $instance)   X-Ref
This function calculates the minimum and maximum cutoff values for the timestart of
the given event.

It will return an array with two values, the first being the minimum cutoff value and
the second being the maximum cutoff value. Either or both values can be null, which
indicates there is no minimum or maximum, respectively.

If a cutoff is required then the function must return an array containing the cutoff
timestamp and error string to display to the user if the cutoff value is violated.

A minimum and maximum cutoff return value will look like:
[
[1505704373, 'The date must be after this date'],
[1506741172, 'The date must be before this date']
]

return: array Returns an array with min and max date.
param: \calendar_event $event The calendar event to get the time range for
param: \stdClass $instance The module instance to get the range from

mod_scorm_get_path_from_pluginfile(string $filearea, array $args)   X-Ref
Given an array with a file path, it returns the itemid and the filepath for the defined filearea.

return: array The itemid and the filepath inside the $args path, for the defined filearea.
param: string $filearea The filearea.
param: array  $args The path (the part after the filearea and before the filename).

mod_scorm_core_calendar_get_event_action_string(string $eventtype)   X-Ref
Callback to fetch the activity event type lang string.

return: lang_string The event type lang string.
param: string $eventtype The event type.

scorm_extend_settings_navigation(settings_navigation $settings, navigation_node $scormnode)   X-Ref
This function extends the settings navigation block for the site.

It is safe to rely on PAGE here as we will only ever be within the module
context when this is called

return: void
param: settings_navigation $settings navigation_node object.
param: navigation_node $scormnode navigation_node object.