Moodle APIs 4.3
Moodle 4.3.6 (Build: 20240812)

Functions

object lesson_add_instance ($data, $mform)
 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.
 
 lesson_check_updates_since (cm_info $cm, $from, $filter=array())
 
stdClass lesson_cron ()
 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 ...
 
object lesson_delete_instance ($id)
 Given an ID of an instance of this module, this function will permanently delete the instance and any data that depends on it.
 
 lesson_extend_settings_navigation (settings_navigation $settings, navigation_node $lessonnode)
 This function extends the settings navigation block for the site.
 
 lesson_get_coursemodule_info ($coursemodule)
 Add a get_coursemodule_info function in case any lesson type wants to add 'extra' information for the course (see resource).
 
 lesson_get_file_areas ()
 Returns an array of file areas.
 
stdClass lesson_get_file_info ($browser, $areas, $course, $cm, $context, $filearea, $itemid, $filepath, $filename)
 Returns a file_info_stored object for the file being requested here.
 
 lesson_get_group_override_priorities ($lessonid)
 Calculates the priorities of timeopen and timeclose values for group overrides for a lesson.
 
 lesson_get_import_export_formats ($type)
 Get list of available import or export formats.
 
 lesson_get_post_actions ()
 List the actions that correspond to a post of this module.
 
stdClass lesson_get_user_grades ($lesson, $userid=0)
 Return grade for given user or all users.
 
 lesson_get_view_actions ()
 List the actions that correspond to a view of this module.
 
 lesson_grade_item_update ($lesson, $grades=null)
 Create grade item for given lesson.
 
 lesson_page_type_list ($pagetype, $parentcontext, $currentcontext)
 Return a list of page types.
 
 lesson_pluginfile ($course, $cm, $context, $filearea, $args, $forcedownload, array $options=array())
 Serves the lesson attachments.
 
 lesson_print_overview ()
 
object lesson_process_post_save (&$lesson)
 Runs any processes that must be run after a lesson insert/update.
 
object lesson_process_pre_save (&$lesson)
 Runs any processes that must run before a lesson insert/update.
 
 lesson_refresh_events ($courseid=0, $instance=null, $cm=null)
 This standard function will check all instances of this module and make sure there are up-to-date events created for each of them.
 
 lesson_reset_course_form_defaults ($course)
 Course reset form defaults.
 
 lesson_reset_course_form_definition (&$mform)
 Implementation of the function for printing the form elements that control whether the course reset functionality affects the lesson.
 
stdClass lesson_reset_gradebook ($courseid, $type='')
 Removes all grades from gradebook.
 
stdClass lesson_reset_userdata ($data)
 Actual implementation of the reset course functionality, delete all the lesson attempts for course $data->courseid.
 
 lesson_supports ($feature)
 @uses FEATURE_GROUPS @uses FEATURE_GROUPINGS @uses FEATURE_MOD_INTRO @uses FEATURE_COMPLETION_TRACKS_VIEWS @uses FEATURE_GRADE_HAS_GRADE @uses FEATURE_GRADE_OUTCOMES
 
 lesson_update_events ($lesson, $override=null)
 This function updates the events associated to the lesson.
 
 lesson_update_grades ($lesson, $userid=0, $nullifnone=true)
 Update grades in central gradebook.
 
object lesson_update_instance ($data, $mform)
 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.
 
 lesson_update_media_file ($lessonid, $context, $draftitemid)
 Update the lesson activity to include any file that was uploaded, or if there is none, set the mediafile field to blank.
 
object lesson_user_complete ($course, $user, $mod, $lesson)
 Print a detailed representation of what a user has done with a given particular instance of this module, for user activity reports.
 
object lesson_user_outline ($course, $user, $mod, $lesson)
 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.
 
 mod_lesson_cm_info_dynamic (cm_info $cm)
 Sets dynamic information about a course module.
 
 mod_lesson_core_calendar_event_timestart_updated (\calendar_event $event, stdClass $lesson)
 This function will update the lesson module according to the event that has been modified.
 
 mod_lesson_core_calendar_get_event_action_string (string $eventtype)
 Callback to fetch the activity event type lang string.
 
 mod_lesson_core_calendar_get_valid_event_timestart_range (\calendar_event $event, stdClass $instance)
 This function calculates the minimum and maximum cutoff values for the timestart of the given event.
 
 mod_lesson_core_calendar_provide_event_action (calendar_event $event, core_calendar\action_factory $factory, int $userid=0)
 This function receives a calendar event and returns the action associated with it, or null if there is none.
 
 mod_lesson_get_completion_active_rule_descriptions ($cm)
 Callback which returns human-readable strings describing the active completion custom rules for the module instance.
 
 mod_lesson_get_fontawesome_icon_map ()
 Get icon mapping for font-awesome.
 

Variables

const LESSON_EVENT_TYPE_CLOSE 'close'
 
const LESSON_EVENT_TYPE_OPEN 'open'
 

Detailed Description

Function Documentation

◆ lesson_add_instance()

object lesson_add_instance ( $data,
$mform )

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.

@global object

Parameters
object$lessonLesson post data from the form
Return values
int

◆ lesson_cron()

stdClass lesson_cron ( )

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 values
booltrue

◆ lesson_delete_instance()

object lesson_delete_instance ( $id)

Given an ID of an instance of this module, this function will permanently delete the instance and any data that depends on it.

Parameters
int$id
Return values
bool

◆ lesson_extend_settings_navigation()

lesson_extend_settings_navigation ( settings_navigation $settings,
navigation_node $lessonnode )

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

Parameters
settings_navigation$settings
navigation_node$lessonnode

◆ lesson_get_coursemodule_info()

lesson_get_coursemodule_info ( $coursemodule)

Add a get_coursemodule_info function in case any lesson 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.

Parameters
stdClass$coursemoduleThe coursemodule object (record).
Return values
cached_cm_infoAn object on information that the courses will know about (most noticeably, an icon).

◆ lesson_get_file_areas()

lesson_get_file_areas ( )

Returns an array of file areas.

Return values
arraya list of available file areas

◆ lesson_get_file_info()

stdClass lesson_get_file_info ( $browser,
$areas,
$course,
$cm,
$context,
$filearea,
$itemid,
$filepath,
$filename )

Returns a file_info_stored object for the file being requested here.

$CFG

Parameters
file_browser$browserfile browser instance
array$areasfile areas
stdClass$coursecourse object
stdClass$cmcourse module object
stdClass$contextcontext object
string$fileareafile area
int$itemiditem ID
string$filepathfile path
string$filenamefile name
Return values
file_info_stored

◆ lesson_get_group_override_priorities()

lesson_get_group_override_priorities ( $lessonid)

Calculates the priorities of timeopen and timeclose values for group overrides for a lesson.

Parameters
int$lessonidThe lesson ID.
Return values
array|nullArray of group override priorities for open and close times. Null if there are no group overrides.

◆ lesson_get_import_export_formats()

lesson_get_import_export_formats ( $type)

Get list of available import or export formats.

Copied and modified from lib/questionlib.php

Parameters
string$type'import' if import list, otherwise export list assumed
Return values
arraysorted list of import/export formats available

◆ lesson_get_post_actions()

lesson_get_post_actions ( )

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 values
array

◆ lesson_get_user_grades()

stdClass lesson_get_user_grades ( $lesson,
$userid = 0 )

Return grade for given user or all users.

@global object

Parameters
int$lessonidid of lesson
int$useridoptional user id, 0 means all users
Return values
arrayarray of grades, false if none

◆ lesson_get_view_actions()

lesson_get_view_actions ( )

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 values
array

◆ lesson_grade_item_update()

lesson_grade_item_update ( $lesson,
$grades = null )

Create grade item for given lesson.

@uses GRADE_TYPE_VALUE @uses GRADE_TYPE_NONE

Parameters
object$lessonobject with extra cmidnumber
array | object$gradesoptional array/object of grade(s); 'reset' means reset grades in gradebook
Return values
int0 if ok, error code otherwise

◆ lesson_page_type_list()

lesson_page_type_list ( $pagetype,
$parentcontext,
$currentcontext )

Return a list of page types.

Parameters
string$pagetypecurrent page type
stdClass$parentcontextBlock's parent context
stdClass$currentcontextCurrent context of block

◆ lesson_pluginfile()

lesson_pluginfile ( $course,
$cm,
$context,
$filearea,
$args,
$forcedownload,
array $options = array() )

Serves the lesson attachments.

Implements needed access control ;-)

Parameters
stdClass$coursecourse object
stdClass$cmcourse module object
stdClass$contextcontext object
string$fileareafile area
array$argsextra arguments
bool$forcedownloadwhether or not force download
array$optionsadditional options affecting the file serving
Return values
boolfalse if file not found, does not return if found - justsend the file

◆ lesson_print_overview()

lesson_print_overview ( )
Deprecated
since Moodle 3.3, when the block_course_overview block was removed.

◆ lesson_process_post_save()

object lesson_process_post_save ( & $lesson)

Runs any processes that must be run after a lesson insert/update.

Parameters
object$lessonLesson form data
Return values
void

◆ lesson_process_pre_save()

object lesson_process_pre_save ( & $lesson)

Runs any processes that must run before a lesson insert/update.

Parameters
object$lessonLesson form data
Return values
void

◆ lesson_refresh_events()

lesson_refresh_events ( $courseid = 0,
$instance = null,
$cm = null )

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 lesson event in the site is checked, else only lesson events belonging to the course specified are checked. This function is used, in its new format, by restore_refresh_events()

Parameters
int$courseid
int | stdClass$instanceLesson module instance or ID.
int | stdClass$cmCourse module object or ID (not used in this module).
Return values
bool

◆ lesson_reset_course_form_defaults()

lesson_reset_course_form_defaults ( $course)

Course reset form defaults.

Parameters
object$course
Return values
array

◆ lesson_reset_course_form_definition()

lesson_reset_course_form_definition ( & $mform)

Implementation of the function for printing the form elements that control whether the course reset functionality affects the lesson.

Parameters
MoodleQuickForm$mformform passed by reference

◆ lesson_reset_gradebook()

stdClass lesson_reset_gradebook ( $courseid,
$type = '' )

Removes all grades from gradebook.

@global object

Parameters
int$courseid
stringoptional type

◆ lesson_reset_userdata()

stdClass lesson_reset_userdata ( $data)

Actual implementation of the reset course functionality, delete all the lesson attempts for course $data->courseid.

@global object

Parameters
object$datathe data submitted from the reset course.
Return values
arraystatus array

◆ lesson_supports()

lesson_supports ( $feature)

@uses FEATURE_GROUPS @uses FEATURE_GROUPINGS @uses FEATURE_MOD_INTRO @uses FEATURE_COMPLETION_TRACKS_VIEWS @uses FEATURE_GRADE_HAS_GRADE @uses FEATURE_GRADE_OUTCOMES

Parameters
string$featureFEATURE_xx constant for requested feature
Return values
mixedTrue if module supports feature, false if not, null if doesn't know or string for the module purpose.

◆ lesson_update_events()

lesson_update_events ( $lesson,
$override = null )

This function updates the events associated to the lesson.

If $override is non-zero, then it updates only the events associated with the specified override.

@uses LESSON_MAX_EVENT_LENGTH

Parameters
object$lessonthe lesson object.
object$override(optional) limit to a specific override

◆ lesson_update_grades()

lesson_update_grades ( $lesson,
$userid = 0,
$nullifnone = true )

Update grades in central gradebook.

Parameters
object$lesson
int$useridspecific user only, 0 means all
bool$nullifnone

◆ lesson_update_instance()

object lesson_update_instance ( $data,
$mform )

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.

Parameters
object$lessonLesson post data from the form
Return values
boolean

◆ lesson_update_media_file()

lesson_update_media_file ( $lessonid,
$context,
$draftitemid )

Update the lesson activity to include any file that was uploaded, or if there is none, set the mediafile field to blank.

Parameters
int$lessonidthe lesson id
stdClass$contextthe context
int$draftitemidthe draft item

◆ lesson_user_complete()

object lesson_user_complete ( $course,
$user,
$mod,
$lesson )

Print a detailed representation of what a user has done with a given particular instance of this module, for user activity reports.

Parameters
object$course
object$user
object$mod
object$lesson
Return values
bool

◆ lesson_user_outline()

object lesson_user_outline ( $course,
$user,
$mod,
$lesson )

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

Parameters
object$course
object$user
object$mod
object$lesson
Return values
object

◆ mod_lesson_cm_info_dynamic()

mod_lesson_cm_info_dynamic ( cm_info $cm)

Sets dynamic information about a course module.

This function is called from cm_info when displaying the module

Parameters
cm_info$cm

◆ mod_lesson_core_calendar_event_timestart_updated()

mod_lesson_core_calendar_event_timestart_updated ( \calendar_event $event,
stdClass $lesson )

This function will update the lesson module according to the event that has been modified.

It will set the available or deadline value of the lesson instance according to the type of event provided.

Exceptions
moodle_exception
Parameters
calendar_event$event
stdClass$lessonThe module instance to get the range from

◆ mod_lesson_core_calendar_get_event_action_string()

mod_lesson_core_calendar_get_event_action_string ( string $eventtype)

Callback to fetch the activity event type lang string.

Parameters
string$eventtypeThe event type.
Return values
lang_stringThe event type lang string.

◆ mod_lesson_core_calendar_get_valid_event_timestart_range()

mod_lesson_core_calendar_get_valid_event_timestart_range ( \calendar_event $event,
stdClass $instance )

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 due date must be after the start date'], [1506741172, 'The due date must be before the cutoff date'] ]

Parameters
calendar_event$eventThe calendar event to get the time range for
stdClass$instanceThe module instance to get the range from
Return values
array

◆ mod_lesson_core_calendar_provide_event_action()

mod_lesson_core_calendar_provide_event_action ( calendar_event $event,
core_calendar\action_factory $factory,
int $userid = 0 )

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.

Parameters
calendar_event$event
core_calendar\action_factory$factory
int$useridUser id to use for all capability checks, etc. Set to 0 for current user (default).
Return values
core_calendar\local\event\entities\action_interface|null

◆ mod_lesson_get_completion_active_rule_descriptions()

mod_lesson_get_completion_active_rule_descriptions ( $cm)

Callback which returns human-readable strings describing the active completion custom rules for the module instance.

Parameters
cm_info | stdClass$cmobject with fields ->completion and ->customdata['customcompletionrules']
Return values
array\$descriptionsthe array of descriptions for the custom rules.