Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
Files | Namespaces | Classes | Functions | Variables
mod_lesson

Files

file  access.php
 Capability definitions for the lesson module.
 
file  activity.php
 Search area for mod_lesson activities.
 
file  activity_base.php
 Activity base class.
 
file  backup_lesson_activity_task.class.php
 This file contains the backup task for the lesson module.
 
file  backup_lesson_stepslib.php
 This file contains the backup structure for the lesson module.
 
file  branchtable.php
 Branch Table.
 
file  cluster.php
 Cluster.
 
file  cognitive_depth.php
 Cognitive depth indicator - lesson.
 
file  content_page_viewed.php
 The mod_lesson content page viewed event class.
 
file  course_module_instance_list_viewed.php
 The mod_lesson instance list viewed event.
 
file  course_module_viewed.php
 The mod_lesson course module viewed event.
 
file  editpage_form.php
 Generic forms used for page selection.
 
file  endofbranch.php
 End of branch table.
 
file  endofcluster.php
 End of cluster.
 
file  essay.php
 Essay.
 
file  essay_assessed.php
 The mod_lesson essay assessed event.
 
file  essay_attempt_viewed.php
 The mod_lesson essay attempt viewed event.
 
file  essay_form.php
 Essay grading form.
 
file  events.php
 Add event handlers for the lesson.
 
file  external.php
 Lesson external API.
 
file  file_info.php
 File browsing support.
 
file  format.php
 format.php - Default format class for file imports/exports.
 
file  group_observers.php
 Group observers.
 
file  group_override_created.php
 The mod_lesson group override created event.
 
file  group_override_deleted.php
 The mod_lesson group override deleted event.
 
file  group_override_updated.php
 The mod_lesson group override updated event.
 
file  helper.php
 Lesson's numeric helper lib.
 
file  highscore_added.php
 The mod_lesson highscore added event.
 
file  highscores_viewed.php
 The mod_lesson highscores viewed.
 
file  import_form.php
 Form used to select a file and file format for the import.
 
file  lesson_ended.php
 The mod_lesson lesson ended event.
 
file  lesson_restarted.php
 The mod_lesson lesson restarted event class.
 
file  lesson_resumed.php
 The mod_lesson lesson resumed event class.
 
file  lesson_started.php
 The mod_lesson lesson started event.
 
file  lesson_summary_exporter.php
 Class for exporting partial lesson data.
 
file  lib.php
 Provides support for the conversion of moodle1 backup to the moodle2 format.
 
file  lib.php
 Standard library of functions and constants for lesson.
 
file  lib.php
 mod_lesson data generator.
 
file  locallib.php
 Local library file for Lesson.
 
file  log.php
 Definition of log events.
 
file  matching.php
 Matching.
 
file  messages.php
 Defines message providers (types of messages being sent)
 
file  mod_form.php
 Form to define a new instance of lesson or edit an instance.
 
file  multichoice.php
 Multichoice.
 
file  numerical.php
 Numerical.
 
file  override_form.php
 Settings form for overrides in the lesson module.
 
file  page_created.php
 The mod_lesson page_added event class.
 
file  page_deleted.php
 The mod_lesson page_added event class.
 
file  page_moved.php
 The mod_lesson page_moved event class.
 
file  page_updated.php
 The mod_lesson page_added event class.
 
file  provider.php
 Data provider.
 
file  question_answered.php
 The mod_lesson true / false question answered event class.
 
file  question_viewed.php
 The mod_lesson true / false question viewed event class.
 
file  renderer.php
 Moodle renderer used to display special elements of the lesson module.
 
file  restore_lesson_activity_task.class.php
 @subpackage backup-moodle2
 
file  restore_lesson_stepslib.php
 @subpackage backup-moodle2
 
file  services.php
 Lesson external functions and service definitions.
 
file  settings.php
 Settings used by the lesson module, were moved from mod_edit.
 
file  shortanswer.php
 Short answer.
 
file  social_breadth.php
 Social breadth indicator - lesson.
 
file  tabs.php
 Sets up the tabs used by the lesson pages for teachers.
 
file  truefalse.php
 True/false.
 
file  upgrade.php
 This file keeps track of upgrades to the lesson module.
 
file  user_override_created.php
 The mod_lesson user override created event.
 
file  user_override_deleted.php
 The mod_lesson user override deleted event.
 
file  user_override_updated.php
 The mod_lesson user override updated event.
 
file  version.php
 Version information.
 
file  view_form.php
 Lesson page without answers.
 

Namespaces

namespace  mod_lesson
  
 
namespace  mod_lesson\analytics\indicator
  
 
namespace  mod_lesson\event
  
 
namespace  mod_lesson\external
  
 
namespace  mod_lesson\local\numeric
  
 
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  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\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\essay_assessed
 
class  mod_lesson\event\essay_attempt_viewed
 The mod_lesson essay attempt 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\page_created
 
class  mod_lesson\event\page_deleted
 
class  mod_lesson\event\page_moved
 
class  mod_lesson\event\page_updated
 
class  mod_lesson\event\question_answered
 
class  mod_lesson\event\question_viewed
 
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\privacy\provider
 Data provider class. More...
 
class  mod_lesson\search\activity
 Search area for mod_lesson activities. More...
 
class  mod_lesson_external
 
class  mod_lesson_file_info
 File browsing support class. More...
 
class  mod_lesson_generator
 
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. More...
 
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. More...
 
 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. More...
 
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 ... More...
 
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. More...
 
 lesson_display_teacher_warning ($lesson)
 Any other lesson functions go here. More...
 
 lesson_displayleftif ($lesson)
 Determines if a user can view the left menu. More...
 
 lesson_extend_settings_navigation ($settings, $lessonnode)
 This function extends the settings navigation block for the site. More...
 
 lesson_get_completion_state ($course, $cm, $userid, $type)
 Obtains the automatic completion state for this lesson based on any conditions in lesson settings. More...
 
 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). More...
 
 lesson_get_file_areas ()
 
stdClass lesson_get_file_info ($browser, $areas, $course, $cm, $context, $filearea, $itemid, $filepath, $filename)
 
 lesson_get_group_override_priorities ($lessonid)
 Calculates the priorities of timeopen and timeclose values for group overrides for a lesson. More...
 
 lesson_get_import_export_formats ($type)
 Get list of available import or export formats. More...
 
object lesson_get_media_html ($lesson, $context)
 This is a function used to detect media types and generate html code. More...
 
 lesson_get_overview_report_table_and_data (lesson $lesson, $currentgroup)
 Return the overview report table and data. More...
 
 lesson_get_post_actions ()
 List the actions that correspond to a post of this module. More...
 
 lesson_get_user_deadline ($courseid)
 Return user's deadline for all lessons in a course, hereby taking into account group and user overrides. More...
 
 lesson_get_user_detailed_report_data (lesson $lesson, $userid, $attempt)
 Return information about one user attempt (including answers) More...
 
stdClass lesson_get_user_grades ($lesson, $userid=0)
 Return grade for given user or all users. More...
 
 lesson_get_view_actions ()
 List the actions that correspond to a view of this module. More...
 
 lesson_grade ($lesson, $ntries, $userid=0)
 Calculates a user's grade for a lesson. More...
 
 lesson_grade_item_update ($lesson, $grades=null)
 
 lesson_import_question_files ($field, $data, $answer, $contextid)
 Import files embedded into answer or response. More...
 
 lesson_mediafile_block_contents ($cmid, $lesson)
 If there is a media file associated with this lesson, return a block_contents that displays it. More...
 
 lesson_menu_block_contents ($cmid, $lesson)
 If left menu is turned on, then this will print the menu in a block. More...
 
 lesson_page_type_list ($pagetype, $parentcontext, $currentcontext)
 Return a list of page types. More...
 
 lesson_pluginfile ($course, $cm, $context, $filearea, $args, $forcedownload, array $options=array())
 
 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. More...
 
object lesson_process_post_save (&$lesson)
 Runs any processes that must be run after a lesson insert/update. More...
 
object lesson_process_pre_save (&$lesson)
 Runs any processes that must run before a lesson insert/update. More...
 
 lesson_random_question_jump ($lesson, $pageid)
 Handles the random jump between a branch table and end of branch or end of lesson (LESSON_RANDOMPAGE). More...
 
 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. More...
 
 lesson_reset_course_form_defaults ($course)
 Course reset form defaults. More...
 
 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. More...
 
stdClass lesson_reset_gradebook ($courseid, $type='')
 Removes all grades from gradebook. More...
 
stdClass lesson_reset_userdata ($data)
 Actual implementation of the reset course functionality, delete all the lesson attempts for course $data->courseid. More...
 
 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. More...
 
 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 More...
 
 lesson_unseen_branch_jump ($lesson, $userid)
 Handles the unseen branch table jump. More...
 
 lesson_unseen_question_jump ($lesson, $user, $pageid)
 Interprets the LESSON_UNSEENBRANCHPAGE jump. More...
 
 lesson_update_events ($lesson, $override=null)
 This function updates the events associated to the lesson. More...
 
 lesson_update_grades ($lesson, $userid=0, $nullifnone=true)
 
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. More...
 
 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. More...
 
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. More...
 
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. More...
 
 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. More...
 
 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. More...
 
 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. More...
 
 mod_lesson_get_completion_active_rule_descriptions ($cm)
 Callback which returns human-readable strings describing the active completion custom rules for the module instance. More...
 
 mod_lesson_get_fontawesome_icon_map ()
 Get icon mapping for font-awesome.
 
stdClass xmldb_lesson_upgrade ($oldversion)
 $CFG @global moodle_database $DB More...
 

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.
 
 $functions
 
 $logs
 
 $messageproviders
 
 $observers
 
 $plugin = 2020060900
 
 $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. More...
 
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 = 2020061500
 

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.

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,
  $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.

Parameters
object$courseCourse
object$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_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_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_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
$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

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

◆ $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_LOGGEDIN + MESSAGE_DEFAULT_LOGGEDOFF,
),
)
)
const MESSAGE_DEFAULT_LOGGEDIN
Define contants for messaging default settings population.
Definition: lib.php:44

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