Moodle APIs 4.3
Moodle 4.3.6 (Build: 20240812)
mod_lesson

Topics

 backup
 
 
 event
 
 
 external
 
 
 grade
 
 
 log
 
 
 test
 
 

Directories

directory analytics
  
 
directory backup
  
 
directory local
  
 

Namespaces

namespace  mod_lesson
  
 
namespace  mod_lesson\analytics\indicator
 Activity base class.
 
namespace  mod_lesson\cache
  
 
namespace  mod_lesson\completion
  
 
namespace  mod_lesson\event
 The mod_lesson content page viewed event class.
 
namespace  mod_lesson\external
 Class for exporting partial lesson data.
 
namespace  mod_lesson\local\numeric
 Lesson's numeric helper lib.
 
namespace  mod_lesson\output
 Output the actionbar for this activity.
 
namespace  mod_lesson\privacy
 Data provider.
 
namespace  mod_lesson\search
 Search area for mod_lesson activities.
 

Classes

class  backup_lesson_activity_structure_step
 This file contains the backup structure for the lesson module. 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
 Activity custom completion subclass for the lesson activity. More...
 
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
 The mod_lesson group override created event class. More...
 
class  mod_lesson\event\group_override_deleted
 The mod_lesson group override deleted event class. More...
 
class  mod_lesson\event\group_override_updated
 The mod_lesson group override updated event class. More...
 
class  mod_lesson\event\highscore_added
 The mod_lesson highscore added event class. More...
 
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
 The mod_lesson user override created event class. More...
 
class  mod_lesson\event\user_override_deleted
 The mod_lesson user override deleted event class. More...
 
class  mod_lesson\event\user_override_updated
 The mod_lesson user override updated event class. More...
 
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_file_info
 File browsing support 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.
 
 lesson_clock_block_contents ($cmid, $lesson, $timer, $page)
 If a timed lesson and not a teacher, then return a block_contents containing the clock.
 
 lesson_display_teacher_warning ($lesson)
 Any other lesson functions go here.
 
 lesson_displayleftif ($lesson)
 Determines if a user can view the left menu.
 
 lesson_get_completion_state ()
 List of deprecated mod_lesson functions.
 
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_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)
 
 lesson_grade ($lesson, $ntries, $userid=0)
 Calculates a user's grade for a 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_process_group_deleted_in_course ($courseid, $groupid=null)
 Logic to happen when a/some group(s) has/have been deleted in a course.
 
 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_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_unseen_branch_jump ($lesson, $userid)
 Handles the unseen branch table jump.
 
 lesson_unseen_question_jump ($lesson, $user, $pageid)
 Interprets the LESSON_UNSEENBRANCHPAGE jump.
 
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
 
 $messageproviders
 Defines message providers (types of messages being sent)
 
 $plugin = 2023100400
 
 $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_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 = 2023100900
 

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_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_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_get_completion_state()

lesson_get_completion_state ( )

List of deprecated mod_lesson functions.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
Deprecated
since Moodle 3.11

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

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

◆ $messageproviders

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

Defines message providers (types of messages being sent)

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

◆ LESSON_THISPAGE

const LESSON_THISPAGE 0

Include the files that are required by this module.

This page