Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
mod_lesson

Namespaces

namespace  mod_lesson
  
 
namespace  mod_lesson\analytics\indicator
  
 
namespace  mod_lesson\cache
  
 
namespace  mod_lesson\completion
  
 
namespace  mod_lesson\event
  
 
namespace  mod_lesson\external
  
 
namespace  mod_lesson\local\numeric
  
 
namespace  mod_lesson\output
  
 
namespace  mod_lesson\privacy
  
 
namespace  mod_lesson\search
  
 

Classes

class  backup_lesson_activity_structure_step
 Structure step class that informs a backup task how to backup the lesson module. More...
 
class  backup_lesson_activity_task
 Provides the steps to perform one complete backup of the Lesson instance. More...
 
class  behat_mod_lesson_behat
 
class  behat_mod_lesson_generator
 Behat data generator for mod_lesson. More...
 
class  essay_grading_form
 Essay grading form. More...
 
class  lesson
 
class  lesson_add_page_form_base
 Abstract class that page type's MUST inherit from. More...
 
class  lesson_add_page_form_branchtable
 
class  lesson_add_page_form_cluster
 
class  lesson_add_page_form_endofbranch
 
class  lesson_add_page_form_endofcluster
 
class  lesson_add_page_form_essay
 
class  lesson_add_page_form_matching
 
class  lesson_add_page_form_multichoice
 
class  lesson_add_page_form_numerical
 
class  lesson_add_page_form_selection
 Question selection form. More...
 
class  lesson_add_page_form_shortanswer
 
class  lesson_add_page_form_truefalse
 
class  lesson_add_page_form_unknown
 Dummy class to represent an unknown question type and direct to the selection form. More...
 
class  lesson_base
 Abstract class to provide a core functions to the all lesson classes. More...
 
class  lesson_display_answer_form_essay
 
class  lesson_display_answer_form_matching
 
class  lesson_display_answer_form_multichoice_multianswer
 
class  lesson_display_answer_form_multichoice_singleanswer
 
class  lesson_display_answer_form_numerical
 
class  lesson_display_answer_form_shortanswer
 
class  lesson_display_answer_form_truefalse
 
class  lesson_import_form
 Form used to select a file and file format for the import. More...
 
class  lesson_override_form
 Form for editing settings overrides. More...
 
class  lesson_page
 
class  lesson_page_answer
 
class  lesson_page_type_branchtable
 
class  lesson_page_type_cluster
 
class  lesson_page_type_endofbranch
 
class  lesson_page_type_endofcluster
 
class  lesson_page_type_essay
 
class  lesson_page_type_manager
 A management class for page types. More...
 
class  lesson_page_type_matching
 
class  lesson_page_type_multichoice
 
class  lesson_page_type_numerical
 
class  lesson_page_type_shortanswer
 
class  lesson_page_type_truefalse
 
class  lesson_page_without_answers
 Include formslib if it has not already been included. More...
 
class  mod_lesson\analytics\indicator\activity_base
 Activity base class. More...
 
class  mod_lesson\analytics\indicator\cognitive_depth
 Cognitive depth indicator - lesson. More...
 
class  mod_lesson\analytics\indicator\social_breadth
 Social breadth indicator - lesson. More...
 
class  mod_lesson\cache\overrides
 Class lesson_overrides. More...
 
class  mod_lesson\completion\custom_completion
 
class  mod_lesson\dates
 Class for fetching the important dates in mod_lesson for a given module instance and a user. More...
 
class  mod_lesson\event\content_page_viewed
 The mod_lesson content page viewed event class. More...
 
class  mod_lesson\event\course_module_instance_list_viewed
 The mod_lesson instance list viewed event class. More...
 
class  mod_lesson\event\course_module_viewed
 The mod_lesson course module viewed event class. More...
 
class  mod_lesson\event\group_override_created
 
class  mod_lesson\event\group_override_deleted
 
class  mod_lesson\event\group_override_updated
 
class  mod_lesson\event\highscore_added
 
class  mod_lesson\event\highscores_viewed
 The mod_lesson highscores viewed class. More...
 
class  mod_lesson\event\lesson_ended
 The mod_lesson lesson ended event class. More...
 
class  mod_lesson\event\lesson_restarted
 The mod_lesson lesson restarted event class. More...
 
class  mod_lesson\event\lesson_resumed
 The mod_lesson lesson resumed event class. More...
 
class  mod_lesson\event\lesson_started
 The mod_lesson lesson started event class. More...
 
class  mod_lesson\event\user_override_created
 
class  mod_lesson\event\user_override_deleted
 
class  mod_lesson\event\user_override_updated
 
class  mod_lesson\external\lesson_summary_exporter
 Class for exporting partial lesson data (some fields are only viewable by admins). More...
 
class  mod_lesson\group_observers
 Group observers class. More...
 
class  mod_lesson\local\numeric\helper
 Lesson numeric page helper. More...
 
class  mod_lesson\output\edit_action_area
 Output the actionbar for this activity. More...
 
class  mod_lesson\output\edit_action_buttons
 Output the action buttons for this activity. More...
 
class  mod_lesson\output\override_action_menu
 Output the override action menu for this activity. More...
 
class  mod_lesson\output\report_action_menu
 Output the report action menu for this activity. More...
 
class  mod_lesson\privacy\provider
 Data provider class. More...
 
class  mod_lesson\search\activity
 Search area for mod_lesson activities. More...
 
class  mod_lesson_external
 Lesson external functions. More...
 
class  mod_lesson_file_info
 File browsing support class. More...
 
class  mod_lesson_generator
 mod_lesson data generator class. More...
 
class  mod_lesson_mod_form
 
class  mod_lesson_renderer
 
class  moodle1_mod_lesson_handler
 Lesson conversion handler. More...
 
class  qformat_based_on_xml
 Since the lesson module tries to re-use the question bank import classes in a crazy way, this is necessary to stop things breaking. More...
 
class  qformat_default
 Base class for question import and export formats. More...
 
class  restore_lesson_activity_structure_step
 Define all the restore steps that will be used by the restore_lesson_activity_task. More...
 
class  restore_lesson_activity_task
 lesson restore task that provides all the settings and steps to perform one complete restore of the activity More...
 

Functions

 lesson_add_fake_blocks ($page, $cm, $lesson, $timer=null)
 
 lesson_add_header_buttons ($cm, $context, $extraeditbuttons=false, $lessonpageid=null)
 Adds header buttons to the page for the lesson.
 
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())
 
 lesson_clock_block_contents ($cmid, $lesson, $timer, $page)
 If a timed lesson and not a teacher, then return a block_contents containing the clock.
 
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_display_teacher_warning ($lesson)
 Any other lesson functions go here.
 
 lesson_displayleftif ($lesson)
 Determines if a user can view the left menu.
 
 lesson_extend_settings_navigation (settings_navigation $settings, navigation_node $lessonnode)
 This function extends the settings navigation block for the site.
 
 lesson_get_completion_state ($course, $cm, $userid, $type)
 Obtains the automatic completion state for this lesson based on any conditions in lesson settings.
 
 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.
 
object lesson_get_media_html ($lesson, $context)
 This is a function used to detect media types and generate html code.
 
 lesson_get_overview_report_table_and_data (lesson $lesson, $currentgroup)
 Return the overview report table and data.
 
 lesson_get_post_actions ()
 List the actions that correspond to a post of this module.
 
 lesson_get_user_deadline ($courseid)
 Return user's deadline for all lessons in a course, hereby taking into account group and user overrides.
 
 lesson_get_user_detailed_report_data (lesson $lesson, $userid, $attempt)
 Return information about one user attempt (including answers)
 
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 ($lesson, $ntries, $userid=0)
 Calculates a user's grade for a lesson.
 
 lesson_grade_item_update ($lesson, $grades=null)
 Create grade item for given lesson.
 
 lesson_import_question_files ($field, $data, $answer, $contextid)
 Import files embedded into answer or response.
 
 lesson_mediafile_block_contents ($cmid, $lesson)
 If there is a media file associated with this lesson, return a block_contents that displays it.
 
 lesson_menu_block_contents ($cmid, $lesson)
 If left menu is turned on, then this will print the menu in a block.
 
 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 ()
 
 lesson_process_group_deleted_in_course ($courseid, $groupid=null)
 Logic to happen when a/some group(s) has/have been deleted in a course.
 
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_random_question_jump ($lesson, $pageid)
 Handles the random jump between a branch table and end of branch or end of lesson (LESSON_RANDOMPAGE).
 
 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_save_question_options ($question, $lesson, $contextid)
 Given some question info and some data about the the answers this function parses, organises and saves the question.
 
 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_unseen_branch_jump ($lesson, $userid)
 Handles the unseen branch table jump.
 
 lesson_unseen_question_jump ($lesson, $user, $pageid)
 Interprets the LESSON_UNSEENBRANCHPAGE jump.
 
 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.
 
stdClass xmldb_lesson_upgrade ($oldversion)
 $CFG @global moodle_database $DB
 

Variables

 $attemptscount = $DB->count_records('lesson_grades', array('lessonid'=>$lesson->id))
 user attempt count for reports link hover (completed attempts - much faster)
 
 $capabilities
 
global $DB
 This file to be included so we can assume config.php has already been included.
 
 $definitions
 
 $functions
 
 $logs
 
 $messageproviders
 
 $observers
 
 $plugin = 2023041800
 
 $row [] = new tabobject('view', "$CFG->wwwroot/mod/lesson/view.php?id=$cm->id", get_string('preview', 'lesson'), get_string('previewlesson', 'lesson', format_string($lesson->name)))
 
if(empty( $lesson)) if(!isset($currenttab)) if(!isset( $cm)) if(!isset($course)) $tabs = $row = $inactive = $activated = array()
 
if(has_capability( 'mod/lesson:viewreports', $context)) if(has_capability('mod/lesson:grade', $context)) $tabs [] = $row
 
$plugin component = 'mod_lesson'
 
$plugin cron = 0
 
const LESSON_ANSWER_HTML "HTML"
 Answer format is HTML.
 
const LESSON_CLUSTERJUMP -80
 Cluster Jump.
 
const LESSON_EOL -9
 End of Lesson.
 
const LESSON_EVENT_TYPE_CLOSE 'close'
 
const LESSON_EVENT_TYPE_OPEN 'open'
 
const LESSON_MAX_EVENT_LENGTH "432000"
 LESSON_MAX_EVENT_LENGTH = 432000 ; 5 days maximum.
 
const LESSON_NEXTPAGE -1
 Jump to Next Page.
 
const LESSON_OTHER_ANSWERS "@#wronganswer#@"
 Placeholder answer for all other answers.
 
const LESSON_PAGE_BRANCHTABLE "20"
 Branch Table page.
 
const LESSON_PAGE_CLUSTER "30"
 Start of Cluster page.
 
const LESSON_PAGE_ENDOFBRANCH "21"
 End of Branch page.
 
const LESSON_PAGE_ENDOFCLUSTER "31"
 End of Cluster page.
 
const LESSON_PAGE_ESSAY "10"
 Essay question type.
 
const LESSON_PAGE_MATCHING "5"
 Matching question type.
 
const LESSON_PAGE_MULTICHOICE "3"
 Multichoice question type.
 
const LESSON_PAGE_NUMERICAL "8"
 Numerical question type.
 
const LESSON_PAGE_SHORTANSWER "1"
 Short answer question type.
 
const LESSON_PAGE_TRUEFALSE "2"
 True/False question type.
 
const LESSON_PREVIOUSPAGE -40
 Jump to Previous Page.
 
const LESSON_RANDOMBRANCH -70
 Jump to a random Branch.
 
const LESSON_RANDOMPAGE -60
 Jump to a random page within a branch and end of branch or end of lesson.
 
const LESSON_THISPAGE 0
 Include the files that are required by this module.
 
const LESSON_UNANSWEREDPAGE 2
 Next page -> any page not answered correctly.
 
const LESSON_UNDEFINED -99
 Undefined.
 
const LESSON_UNSEENBRANCHPAGE -50
 Jump to an unseen page within a branch and end of branch or end of lesson.
 
const LESSON_UNSEENPAGE 1
 Next page -> any page not seen before.
 
$plugin version = 2023042400
 

Detailed Description

Function Documentation

◆ lesson_add_fake_blocks()

lesson_add_fake_blocks ( $page,
$cm,
$lesson,
$timer = null )
Parameters
$cm
$lesson
$page
Return values
unknown_type

◆ lesson_add_header_buttons()

lesson_add_header_buttons ( $cm,
$context,
$extraeditbuttons = false,
$lessonpageid = null )

Adds header buttons to the page for the lesson.

Deprecated
since Moodle 4.0 in favour of tertiary navigation.
Todo
MDL-73545 This will be deleted in Moodle 4.4
Parameters
object$cm
object$context
bool$extraeditbuttons
int$lessonpageid

◆ 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_clock_block_contents()

lesson_clock_block_contents ( $cmid,
$lesson,
$timer,
$page )

If a timed lesson and not a teacher, then return a block_contents containing the clock.

Parameters
int$cmidCourse Module ID for this lesson
object$lessonFull lesson record object
object$timerFull timer record object
Return values
block_contents

◆ 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_display_teacher_warning()

lesson_display_teacher_warning ( $lesson)

Any other lesson functions go here.

Each of them must have a name that starts with lesson_ Checks to see if a LESSON_CLUSTERJUMP or a LESSON_UNSEENBRANCHPAGE is used in a lesson.

This function is only executed when a teacher is checking the navigation for a lesson.

Parameters
stdClass$lessonId of the lesson that is to be checked.
Return values
booleanTrue or false.

◆ lesson_displayleftif()

lesson_displayleftif ( $lesson)

Determines if a user can view the left menu.

The determining factor is whether a user has a grade greater than or equal to the lesson setting of displayleftif

Parameters
object$lessonLesson object of the current lesson
Return values
boolean0 if the user cannot see, or $lesson->displayleft to keep displayleft unchanged

◆ 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_completion_state()

lesson_get_completion_state ( $course,
$cm,
$userid,
$type )

Obtains the automatic completion state for this lesson based on any conditions in lesson settings.

Deprecated
since Moodle 3.11
Todo
MDL-71196 Final deprecation in Moodle 4.3
See also
mod_lesson\completion\custom_completion
Parameters
stdClass$courseCourse
cm_info | stdClass$cmcourse-module
int$useridUser ID
bool$typeType of comparison (or/and; can be used as return value if no conditions)
Return values
boolTrue if completed, false if not, $type if conditions not set.

◆ 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_media_html()

object lesson_get_media_html ( $lesson,
$context )

This is a function used to detect media types and generate html code.

$CFG @global object $PAGE

Parameters
object$lesson
object$context
Return values
string\$codethe html code of media

◆ lesson_get_overview_report_table_and_data()

lesson_get_overview_report_table_and_data ( lesson $lesson,
$currentgroup )

Return the overview report table and data.

Parameters
lesson$lessonlesson instance
mixed$currentgroupfalse if not group used, 0 for all groups, group id (int) to filter by that groups
Return values
mixedfalse if there is no information otherwise html_table and stdClass with the table and data
Since
Moodle 3.3

◆ 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_deadline()

lesson_get_user_deadline ( $courseid)

Return user's deadline for all lessons in a course, hereby taking into account group and user overrides.

Parameters
int$courseidthe course id.
Return values
objectAn object with of all lessonsids and close unixdates in this course, taking into account the most lenient overrides, if existing and 0 if no close date is set.

◆ lesson_get_user_detailed_report_data()

lesson_get_user_detailed_report_data ( lesson $lesson,
$userid,
$attempt )

Return information about one user attempt (including answers)

Parameters
lesson$lessonlesson instance
int$useridthe user id
int$attemptthe attempt number
Return values
arraythe user answers (array) and user data stats (object)
Since
Moodle 3.3

◆ 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()

lesson_grade ( $lesson,
$ntries,
$userid = 0 )

Calculates a user's grade for a lesson.

Parameters
object$lessonThe lesson that the user is taking.
int$retriesThe attempt number.
int$useridId of the user (optional, default current user).
Return values
object{ nquestions => number of questions answered attempts => number of question attempts total => max points possible earned => points earned by student grade => calculated percentage grade nmanual => number of manually graded questions manualpoints => point value for manually graded questions }

◆ 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_import_question_files()

lesson_import_question_files ( $field,
$data,
$answer,
$contextid )

Import files embedded into answer or response.

Parameters
string$fieldnfield name (answer or response)
array$dataimported data
object$answeranswer object
int$contextid

◆ lesson_mediafile_block_contents()

lesson_mediafile_block_contents ( $cmid,
$lesson )

If there is a media file associated with this lesson, return a block_contents that displays it.

Parameters
int$cmidCourse Module ID for this lesson
object$lessonFull lesson record object
Return values
block_contents

◆ lesson_menu_block_contents()

lesson_menu_block_contents ( $cmid,
$lesson )

If left menu is turned on, then this will print the menu in a block.

Parameters
int$cmidCourse Module ID for this lesson
lesson$lessonFull lesson record object
Return values
void

◆ 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_group_deleted_in_course()

lesson_process_group_deleted_in_course ( $courseid,
$groupid = null )

Logic to happen when a/some group(s) has/have been deleted in a course.

Parameters
int$courseidThe course ID.
int$groupidThe group id if it is known
Return values
void

◆ 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_random_question_jump()

lesson_random_question_jump ( $lesson,
$pageid )

Handles the random jump between a branch table and end of branch or end of lesson (LESSON_RANDOMPAGE).

Parameters
lesson$lesson
int$pageidThe id of the page that we are jumping from (?)
Return values
intThe pageid of a random page that is within a branch table

◆ 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_save_question_options()

lesson_save_question_options ( $question,
$lesson,
$contextid )

Given some question info and some data about the the answers this function parses, organises and saves the question.

This is only used when IMPORTING questions and is only called from format.php Lifted from mod/quiz/lib.php -

  1. all reference to oldanswers removed
  2. all reference to quiz_multichoice table removed
  3. In shortanswer questions usecase is store in the qoption field
  4. In numeric questions store the range as two answers
  5. truefalse options are ignored
  6. For multichoice questions with more than one answer the qoption field is true
Parameters
object$questionContains question data like question, type and answers.
object$lesson
int$contextid
Return values
objectReturns $result->error or $result->notice.

◆ 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_unseen_branch_jump()

lesson_unseen_branch_jump ( $lesson,
$userid )

Handles the unseen branch table jump.

Parameters
lesson$lesson
int$useridUser id.
Return values
intWill return the page id of a branch table or end of lesson

◆ lesson_unseen_question_jump()

lesson_unseen_question_jump ( $lesson,
$user,
$pageid )

Interprets the LESSON_UNSEENBRANCHPAGE jump.

will return the pageid of a random unseen page that is within a branch

Parameters
lesson$lesson
int$useridId of the user.
int$pageidId of the page from which we are jumping.
Return values
intId of the next page.

◆ 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.

◆ xmldb_lesson_upgrade()

stdClass xmldb_lesson_upgrade ( $oldversion)

$CFG @global moodle_database $DB

Parameters
int$oldversion
Return values
bool

Variable Documentation

◆ $definitions

$definitions
Initial value:
= [
'overrides' => [
'mode' => cache_store::MODE_APPLICATION,
'simplekeys' => true,
'datasource' => '\mod_lesson\cache\overrides',
],
]

◆ $logs

$logs
Initial value:
= array(
array('module'=>'lesson', 'action'=>'start', 'mtable'=>'lesson', 'field'=>'name'),
array('module'=>'lesson', 'action'=>'end', 'mtable'=>'lesson', 'field'=>'name'),
array('module'=>'lesson', 'action'=>'view', 'mtable'=>'lesson_pages', 'field'=>'title'),
)

◆ $messageproviders

$messageproviders
Initial value:
= array (
'graded_essay' => array (
'defaults' => array(
'airnotifier' => MESSAGE_PERMITTED + MESSAGE_DEFAULT_ENABLED,
),
)
)

◆ $observers

$observers
Initial value:
= array(
array(
'eventname' => '\core\event\course_reset_started',
'callback' => '\mod_lesson\group_observers::course_reset_started',
),
array(
'eventname' => '\core\event\course_reset_ended',
'callback' => '\mod_lesson\group_observers::course_reset_ended',
),
array(
'eventname' => '\core\event\group_deleted',
'callback' => '\mod_lesson\group_observers::group_deleted'
),
)

◆ LESSON_THISPAGE

const LESSON_THISPAGE 0

Include the files that are required by this module.

This page