Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.
/mod/lti/ -> lib.php (source)

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

This file contains a library of functions and constants for the lti module

Author: Marc Alier
Author: Jordi Piguillem
Author: Nikolas Galanis
Author: Chris Scribner
Copyright: 2009 Marc Alier, Jordi Piguillem, Nikolas Galanis
Copyright: 2009 Universitat Politecnica de Catalunya http://www.upc.edu
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 794 lines (28 kb)
Included or required:0 times
Referenced: 7 times
Includes or requires: 0 files

Defines 28 functions


Functions that are not part of a class:

lti_supports($feature)   X-Ref
List of features supported in URL module

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

lti_add_instance($lti, $mform)   X-Ref
Given an object containing all the necessary data,
(defined by the form in mod.html) this function
will create a new instance and return the id number
of the new instance.

param: object $instance An object from the form in mod.html
return: int The id of the newly inserted basiclti record

lti_update_instance($lti, $mform)   X-Ref
Given an object containing all the necessary data,
(defined by the form in mod.html) this function
will update an existing instance with new data.

param: object $instance An object from the form in mod.html
return: boolean Success/Fail

lti_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 Id of the module instance
return: boolean Success/Failure

lti_get_shortcuts($defaultitem)   X-Ref
Return aliases of this activity. LTI should have an alias for each configured tool type
This is so you can add an external tool types directly to the activity chooser

param: stdClass $defaultitem default item that would be added to the activity chooser if this callback was not present.
return: array An array of aliases for this activity. Each element is an object with same list of properties as $defaultitem,

lti_get_course_content_items(\core_course\local\entity\content_item $defaultmodulecontentitem, \stdClass $user,\stdClass $course)   X-Ref
Return the preconfigured tools which are configured for inclusion in the activity picker.

param: \core_course\local\entity\content_item $defaultmodulecontentitem reference to the content item for the LTI module.
param: \stdClass $user the user object, to use for cap checks if desired.
param: stdClass $course the course to scope items to.
return: array the array of content items.

mod_lti_get_all_content_items(\core_course\local\entity\content_item $defaultmodulecontentitem)   X-Ref
Return all content items which can be added to any course.

param: \core_course\local\entity\content_item $defaultmodulecontentitem
return: array the array of content items.

lti_get_coursemodule_info($coursemodule)   X-Ref
Given a coursemodule object, this function returns the extra
information needed to print this activity in various places.
For this module we just need to support external urls as
activity icons

param: stdClass $coursemodule
return: cached_cm_info info

lti_user_outline($course, $user, $mod, $basiclti)   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->time = the time they did it
$return->info = a short text description

return: null

lti_user_complete($course, $user, $mod, $basiclti)   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

lti_print_recent_activity($course, $isteacher, $timestart)   X-Ref
Given a course and a time, this module should find recent activity
that has occurred in basiclti activities and print it out.
Return true if there was output, or false is there was none.

return: boolean

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

return: boolean

lti_grades($basicltiid)   X-Ref
Must return an array of grades for a given instance of this module,
indexed by user.  It also returns a maximum allowed grade.

Example:
$return->grades = array of grades;
$return->maxgrade = maximum allowed grade;

return $return;

param: int $basicltiid ID of an instance of this module
return: mixed Null or object with an array of grades and with the maximum grade

lti_scale_used()   X-Ref


lti_scale_used_anywhere($scaleid)   X-Ref
Checks if scale is being used by any instance of basiclti.
This function was added in 1.9

This is used to find out if scale used anywhere
param: $scaleid int
return: boolean True if the scale is used by any basiclti

lti_install()   X-Ref
Execute post-install custom actions for the module
This function was added in 1.9

return: boolean true if success, false on error

lti_uninstall()   X-Ref
Execute post-uninstall custom actions for the module
This function was added in 1.9

return: boolean true if success, false on error

lti_get_lti_types()   X-Ref
Returns available Basic LTI types

return: array of basicLTI types

lti_get_lti_types_from_proxy_id($toolproxyid)   X-Ref
Returns available Basic LTI types that match the given
tool proxy id

param: int $toolproxyid Tool proxy id
return: array of basicLTI types

lti_grade_item_update($basiclti, $grades = null)   X-Ref
Create grade item for given basiclti

param: object $basiclti object with extra cmidnumber
param: mixed optional array/object of grade(s); 'reset' means reset grades in gradebook
return: int 0 if ok, error code otherwise

lti_update_grades($basiclti, $userid=0, $nullifnone=true)   X-Ref
Update activity grades

param: stdClass $basiclti The LTI instance
param: int      $userid Specific user only, 0 means all.
param: bool     $nullifnone Not used

lti_grade_item_delete($basiclti)   X-Ref
Delete grade item for given basiclti

param: object $basiclti object
return: object basiclti

lti_get_post_actions()   X-Ref
Log post actions

return: array

lti_get_view_actions()   X-Ref
Log view actions

return: array

lti_view($lti, $course, $cm, $context)   X-Ref
Mark the activity completed (if required) and trigger the course_module_viewed event.

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

lti_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_lti_get_fontawesome_icon_map()   X-Ref
Get icon mapping for font-awesome.


mod_lti_core_calendar_provide_event_action(calendar_event $event,\core_calendar\action_factory $factory,int $userid = 0)   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 to use for all capability checks, etc. Set to 0 for current user (default).
return: \core_calendar\local\event\entities\action_interface|null