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.
/mod/scorm/ -> lib.php (source)

Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402] [Versions 401 and 402] [Versions 402 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: 1847 lines (66 kb)
Included or required: 1 time
Referenced: 3 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

param: bool    $with_strings   (optional)
return: array

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.

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

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.

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

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.

param: int $id Scorm instance id
return: boolean

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.

param: stdClass $course Course object
param: stdClass $user User
param: stdClass $mod
param: stdClass $scorm The scorm
return: mixed

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.

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

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.

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

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

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

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

param: object $scorm object
return: object grade_item

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

param: object $scorm
return: 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: MoodleQuickForm $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.

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

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

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

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

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
return: file_info instance or null if not found

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

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
return: bool false if file not found, does not return if found - just send the file

scorm_supports($feature)   X-Ref

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

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

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
return: string The filename as an absolute path

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

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
return: boolean True if the file is successfully deleted, false otherwise

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.

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

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

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

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

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

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.

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
return: stdClass an object with the different type of areas indicating if they were updated or not

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.

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

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.

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

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.

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

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.

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

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']
]

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

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.

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

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

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

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

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