Search moodle.org's
Developer Documentation

See Release Notes

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

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

Local library file for Lesson.  These are non-standard functions that are used only by Lesson.

Copyright: 1999 onwards Martin Dougiamas {@link http://moodle.com}
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or late
File Size: 5371 lines (214 kb)
Included or required:0 times
Referenced: 19 times
Includes or requires: 0 files

Defines 7 classes

lesson_add_page_form_base:: (10 methods):
  custom_definition()
  get_answer_format()
  get_response_format()
  is_standard()
  definition()
  add_jumpto()
  add_score()
  add_answer()
  add_response()
  construction_override()

lesson:: (59 methods):
  __construct()
  create()
  load()
  delete()
  delete_override()
  delete_all_overrides()
  is_participant()
  show_only_active_users()
  update_effective_access()
  get_messages()
  get_attempts()
  get_content_pages_viewed()
  get_firstpage()
  get_lastpage()
  get_firstpageid()
  get_lastpageid()
  get_next_page()
  add_message()
  is_accessible()
  start_timer()
  update_timer()
  stop_timer()
  has_pages()
  link_for_activitylink()
  load_page()
  load_all_pages()
  duplicate_page()
  copy_page_files()
  jumpto_is_correct()
  time_remaining()
  cluster_jump()
  get_sub_pages_of()
  is_sub_page_of_type()
  resort_pages()
  get_context()
  set_cm()
  get_cm()
  set_courserecord()
  get_courserecord()
  can_manage()
  get_time_restriction_status()
  get_password_restriction_status()
  get_dependencies_restriction_status()
  is_in_review_mode()
  get_last_page_seen()
  count_user_retries()
  left_during_timed_session()
  set_module_viewed()
  get_user_timers()
  check_time()
  add_messages_on_page_view()
  get_ongoing_score_message()
  calculate_progress()
  prepare_page_and_contents()
  calculate_new_page_on_jump()
  process_page_responses()
  add_messages_on_page_process()
  process_eol_page()
  get_last_attempt()

lesson_base:: (5 methods):
  __construct()
  __set()
  __get()
  __isset()
  properties()

lesson_page:: (40 methods):
  create()
  load()
  delete()
  move()
  get_answers()
  get_lesson()
  get_type()
  record_attempt()
  format_answer()
  format_response()
  get_jump_name()
  __construct()
  earned_score()
  callback_on_view()
  save_answers_files()
  rewrite_answers_urls()
  update()
  add_page_link()
  is_unseen()
  is_unanswered()
  create_answers()
  check_answer()
  on_after_write_attempt()
  has_option()
  max_answers()
  properties()
  get_jumptooptions()
  get_contents()
  get_displayinmenublock()
  option_description_string()
  display_answers()
  get_grayout()
  stats()
  report_answers()
  get_jumps()
  requires_manual_grading()
  override_next_page()
  valid_page_and_view()
  get_files()
  update_form_data()

lesson_page_answer:: (3 methods):
  load()
  create()
  get_files()

lesson_page_type_manager:: (8 methods):
  get()
  load_lesson_types()
  get_page_type_strings()
  get_page_type_idstring()
  load_page()
  check_page_order()
  load_all_pages()
  get_page_form()

requested:: (1 method):
  get_add_page_type_links()

Defines 1 function


Class: lesson_add_page_form_base  - X-Ref

Abstract class that page type's MUST inherit from.

This is the abstract class that ALL add page type forms must extend.
You will notice that all but two of the methods this class contains are final.
Essentially the only thing that extending classes can do is extend custom_definition.
OR if it has a special requirement on creation it can extend construction_override

custom_definition()   X-Ref
Each page type can and should override this to add any custom elements to
the basic form that they want


get_answer_format()   X-Ref
Returns answer format used by question type.


get_response_format()   X-Ref
Returns response format used by question type.


is_standard()   X-Ref
Used to determine if this is a standard page or a special page

return: bool

definition()   X-Ref
Add the required basic elements to the form.

This method adds the basic elements to the form including title and contents
and then calls custom_definition();

add_jumpto($name, $label=null, $selected=LESSON_NEXTPAGE)   X-Ref
Convenience function: Adds a jumpto select element

param: string $name
param: string|null $label
param: int $selected The page to select by default

add_score($name, $label=null, $value=null)   X-Ref
Convenience function: Adds a score input element

param: string $name
param: string|null $label
param: mixed $value The default value

add_answer($count, $label = null, $required = false, $format= '', array $help = [])   X-Ref
Convenience function: Adds an answer editor

param: int $count The count of the element to add
param: string $label, null means default
param: bool $required
param: string $format
param: array $help Add help text via the addHelpButton. Must be an array which contains the string identifier and
return: void

add_response($count, $label = null, $required = false)   X-Ref
Convenience function: Adds an response editor

param: int $count The count of the element to add
param: string $label, null means default
param: bool $required
return: void

construction_override($pageid, lesson $lesson)   X-Ref
A function that gets called upon init of this object by the calling script.

This can be used to process an immediate action if required. Currently it
is only used in special cases by non-standard page types.

return: bool

Class: lesson  - X-Ref

Class representation of a lesson

This class is used the interact with, and manage a lesson once instantiated.
If you need to fetch a lesson object you can do so by calling

<code>
lesson::load($lessonid);
// or
$lessonrecord = $DB->get_record('lesson', $lessonid);
$lesson = new lesson($lessonrecord);
</code>

The class itself extends lesson_base as all classes within the lesson module should

These properties are from the database
__construct($properties, $cm = null, $course = null)   X-Ref
Constructor method

param: object $properties
param: stdClass $cm course module object
param: stdClass $course course object

create($properties)   X-Ref
Simply generates a lesson object given an array/object of properties
Overrides {@see lesson_base->create()}

param: object|array $properties
return: lesson

load($lessonid)   X-Ref
Generates a lesson object from the database given its id

param: int $lessonid
return: lesson

delete()   X-Ref
Deletes this lesson from the database


delete_override($overrideid)   X-Ref
Deletes a lesson override from the database and clears any corresponding calendar events

param: int $overrideid The id of the override being deleted
return: bool true on success

delete_all_overrides()   X-Ref
Deletes all lesson overrides from the database and clears any corresponding calendar events


is_participant($userid)   X-Ref
Checks user enrollment in the current course.

param: int $userid
return: null|stdClass user record

show_only_active_users()   X-Ref
Check is only active users in course should be shown.

return: bool true if only active users should be shown.

update_effective_access($userid)   X-Ref
Updates the lesson properties with override information for a user.

Algorithm:  For each lesson setting, if there is a matching user-specific override,
then use that otherwise, if there are group-specific overrides, return the most
lenient combination of them.  If neither applies, leave the quiz setting unchanged.

Special case: if there is more than one password that applies to the user, then
lesson->extrapasswords will contain an array of strings giving the remaining
passwords.

param: int $userid The userid.

get_messages()   X-Ref
Fetches messages from the session that may have been set in previous page
actions.

<code>
// Do not call this method directly instead use
$lesson->messages;
</code>

return: array

get_attempts($retries, $correct=false, $pageid=null, $userid=null)   X-Ref
Get all of the attempts for the current user.

param: int $retries
param: bool $correct Optional: only fetch correct attempts
param: int $pageid Optional: only fetch attempts at the given page
param: int $userid Optional: defaults to the current user if not set
return: array|false

get_content_pages_viewed($lessonattempt, $userid = null, $sort = '', $fields = '*')   X-Ref
Get a list of content pages (formerly known as branch tables) viewed in the lesson for the given user during an attempt.

param: int $lessonattempt the lesson attempt number (also known as retries)
param: int $userid        the user id to retrieve the data from
param: string $sort          an order to sort the results in (a valid SQL ORDER BY parameter)
param: string $fields        a comma separated list of fields to return
return: array of pages

get_firstpage()   X-Ref
Returns the first page for the lesson or false if there isn't one.

This method should be called via the magic method __get();
<code>
$firstpage = $lesson->firstpage;
</code>

return: lesson_page|bool Returns the lesson_page specialised object or false

get_lastpage()   X-Ref
Returns the last page for the lesson or false if there isn't one.

This method should be called via the magic method __get();
<code>
$lastpage = $lesson->lastpage;
</code>

return: lesson_page|bool Returns the lesson_page specialised object or false

get_firstpageid()   X-Ref
Returns the id of the first page of this lesson. (prevpageid = 0)

return: int

get_lastpageid()   X-Ref
Returns the id of the last page of this lesson. (nextpageid = 0)

return: int

get_next_page($nextpageid)   X-Ref
Gets the next page id to display after the one that is provided.

param: int $nextpageid
return: bool

add_message($message, $class="notifyproblem", $align='center')   X-Ref
Sets a message against the session for this lesson that will displayed next
time the lesson processes messages

param: string $message
param: string $class
param: string $align
return: bool

is_accessible()   X-Ref
Check if the lesson is accessible at the present time

return: bool True if the lesson is accessible, false otherwise

start_timer()   X-Ref
Starts the lesson time for the current user

return: bool Returns true

update_timer($restart=false, $continue=false, $endreached =false)   X-Ref
Updates the timer to the current time and returns the new timer object

param: bool $restart If set to true the timer is restarted
param: bool $continue If set to true AND $restart=true then the timer
return: stdClass The new timer

stop_timer()   X-Ref
Updates the timer to the current time then stops it by unsetting the user var

return: bool Returns true

has_pages()   X-Ref
Checks to see if the lesson has pages


link_for_activitylink()   X-Ref
Returns the link for the related activity

return: string

load_page($pageid)   X-Ref
Loads the requested page.

This function will return the requested page id as either a specialised
lesson_page object OR as a generic lesson_page.
If the page has been loaded previously it will be returned from the pages
array, otherwise it will be loaded from the database first

param: int $pageid
return: lesson_page A lesson_page object or an object that extends it

load_all_pages()   X-Ref
Loads ALL of the pages for this lesson

return: array An array containing all pages from this lesson

duplicate_page($pageid)   X-Ref
Duplicate the lesson page.

param: int $pageid Page ID of the page to duplicate.
return: void.

copy_page_files($filearea, $itemid, $newitemid, $contextid)   X-Ref
Copy the files from one page to another.

param: string $filearea Area that the files are stored.
param: int $itemid Item ID.
param: int $newitemid The item ID for the new page.
param: int $contextid Context ID for this page.
return: void.

jumpto_is_correct($pageid, $jumpto)   X-Ref
Determines if a jumpto value is correct or not.

returns true if jumpto page is (logically) after the pageid page or
if the jumpto value is a special value.  Returns false in all other cases.

param: int $pageid Id of the page from which you are jumping from.
param: int $jumpto The jumpto number.
return: boolean True or false after a series of tests.

time_remaining($starttime)   X-Ref
Returns the time a user has remaining on this lesson

param: int $starttime Starttime timestamp
return: string

cluster_jump($pageid, $userid=null)   X-Ref
Interprets LESSON_CLUSTERJUMP jumpto value.

This will select a page randomly
and the page selected will be inbetween a cluster page and end of clutter or end of lesson
and the page selected will be a page that has not been viewed already
and if any pages are within a branch table or end of branch then only 1 page within
the branch table or end of branch will be randomly selected (sub clustering).

param: int $pageid Id of the current page from which we are jumping from.
param: int $userid Id of the user.
return: int The id of the next page.

get_sub_pages_of($pageid, array $ends)   X-Ref
Finds all pages that appear to be a subtype of the provided pageid until
an end point specified within $ends is encountered or no more pages exist

param: int $pageid
param: array $ends An array of LESSON_PAGE_* types that signify an end of
return: array An array of specialised lesson_page objects

is_sub_page_of_type($pageid, array $types, array $ends)   X-Ref
Checks to see if the specified page[id] is a subpage of a type specified in
the $types array, until either there are no more pages of we find a type
corresponding to that of a type specified in $ends

param: int $pageid The id of the page to check
param: array $types An array of types that would signify this page was a subpage
param: array $ends An array of types that mean this is not a subpage
return: bool

resort_pages($pageid, $after)   X-Ref
Move a page resorting all other pages.

param: int $pageid
param: int $after
return: void

get_context()   X-Ref
Return the lesson context object.

return: stdClass context

set_cm($cm)   X-Ref
Set the lesson course module object.

param: stdClass $cm course module objct

get_cm()   X-Ref
Return the lesson course module object.

return: stdClass course module

set_courserecord($course)   X-Ref
Set the lesson course object.

param: stdClass $course course objct

get_courserecord()   X-Ref
Return the lesson course object.

return: stdClass course

can_manage()   X-Ref
Check if the user can manage the lesson activity.

return: bool true if the user can manage the lesson

get_time_restriction_status()   X-Ref
Check if time restriction is applied.

return: mixed false if  there aren't restrictions or an object with the restriction information

get_password_restriction_status($userpassword)   X-Ref
Check if password restriction is applied.

param: string $userpassword the user password to check (if the restriction is set)
return: mixed false if there aren't restrictions or an object with the restriction information

get_dependencies_restriction_status()   X-Ref
Check if dependencies restrictions are applied.

return: mixed false if there aren't restrictions or an object with the restriction information

is_in_review_mode()   X-Ref
Check if the lesson is in review mode. (The user already finished it and retakes are not allowed).

return: bool true if is in review mode

get_last_page_seen($retriescount)   X-Ref
Return the last page the current user saw.

param: int $retriescount the number of retries for the lesson (the last retry number).
return: mixed false if the user didn't see the lesson or the last page id

count_user_retries($userid)   X-Ref
Return the number of retries in a lesson for a given user.

param: int $userid the user id
return: int the retries count

left_during_timed_session($retriescount)   X-Ref
Check if a user left a timed session.

param: int $retriescount the number of retries for the lesson (the last retry number).
return: true if the user left the timed session

set_module_viewed()   X-Ref
Trigger module viewed event and set the module viewed for completion.


get_user_timers($userid = null, $sort = '', $fields = '*', $limitfrom = 0, $limitnum = 0)   X-Ref
Return the timers in the current lesson for the given user.

param: int      $userid    the user id
param: string   $sort      an order to sort the results in (optional, a valid SQL ORDER BY parameter).
param: string   $fields    a comma separated list of fields to return
param: int      $limitfrom return a subset of records, starting at this point (optional).
param: int      $limitnum  return a subset comprising this many records in total (optional, required if $limitfrom is set).
return: array    list of timers for the given user in the lesson

check_time($timer)   X-Ref
Check if the user is out of time in a timed lesson.

param: stdClass $timer timer object
return: bool True if the user is on time, false is the user ran out of time

add_messages_on_page_view(lesson_page $page, $reviewmode)   X-Ref
Add different informative messages to the given page.

param: lesson_page $page page object
param: reviewmode $bool whether we are in review mode or not

get_ongoing_score_message()   X-Ref
Get the ongoing score message for the user (depending on the user permission and lesson settings).

return: str the ongoing score message

calculate_progress()   X-Ref
Calculate the progress of the current user in the lesson.

return: int the progress (scale 0-100)

prepare_page_and_contents($pageid, $lessonoutput, $reviewmode, $redirect = true)   X-Ref
Calculate the correct page and prepare contents for a given page id (could be a page jump id).

param: int $pageid the given page id
param: mod_lesson_renderer $lessonoutput the lesson output rendered
param: bool $reviewmode whether we are in review mode or not
param: bool $redirect  Optional, default to true. Set to false to avoid redirection and return the page to redirect.
return: array the page object and contents

calculate_new_page_on_jump(lesson_page $page, $newpageid)   X-Ref
This returns a real page id to jump to (or LESSON_EOL) after processing page responses.

param: lesson_page $page      lesson page
param: int         $newpageid the new page id
return: int the real page to jump to (or end of lesson)

process_page_responses(lesson_page $page)   X-Ref
Process page responses.

param: lesson_page $page page object

add_messages_on_page_process(lesson_page $page, $result, $reviewmode)   X-Ref
Add different informative messages to the given page.

param: lesson_page $page page object
param: stdClass $result the page processing result object
param: bool $reviewmode whether we are in review mode or not

process_eol_page($outoftime)   X-Ref
Process and return all the information for the end of lesson page.

param: string $outoftime used to check to see if the student ran out of time
return: stdclass an object with all the page data ready for rendering

get_last_attempt(array $attempts)   X-Ref
Returns the last "legal" attempt from the list of student attempts.

param: array $attempts The list of student attempts.
return: stdClass The updated fom data.

Class: lesson_base  - X-Ref

Abstract class to provide a core functions to the all lesson classes

This class should be abstracted by ALL classes with the lesson module to ensure
that all classes within this module can be interacted with in the same way.

This class provides the user with a basic properties array that can be fetched
or set via magic methods, or alternatively by defining methods get_blah() or
set_blah() within the extending object.

__construct($properties)   X-Ref
The constructor

param: stdClass $properties

__set($key, $value)   X-Ref
Magic property method

Attempts to call a set_$key method if one exists otherwise falls back
to simply set the property

param: string $key
param: mixed $value

__get($key)   X-Ref
Magic get method

Attempts to call a get_$key method to return the property and ralls over
to return the raw property

param: str $key
return: mixed

__isset($key)   X-Ref
Stupid PHP needs an isset magic method if you use the get magic method and
still want empty calls to work.... blah ~!

param: string $key
return: bool

properties()   X-Ref
Fetches all of the properties of the object

return: stdClass

Class: lesson_page  - X-Ref

Abstract class representation of a page associated with a lesson.

This class should MUST be extended by all specialised page types defined in
mod/lesson/pagetypes/.
There are a handful of abstract methods that need to be defined as well as
severl methods that can optionally be defined in order to make the page type
operate in the desired way

Database properties
create($properties, lesson $lesson, $context, $maxbytes)   X-Ref
Creates a new lesson_page within the database and returns the correct pagetype
object to use to interact with the new lesson

param: object $properties
param: lesson $lesson
return: lesson_page Specialised object that extends lesson_page

load($id, lesson $lesson)   X-Ref
This method loads a page object from the database and returns it as a
specialised object that extends lesson_page

param: int $id
param: lesson $lesson
return: lesson_page Specialised lesson_page object

delete()   X-Ref
Deletes a lesson_page from the database as well as any associated records.

return: bool

move($nextpageid=null, $prevpageid=null)   X-Ref
Moves a page by updating its nextpageid and prevpageid values within
the database

param: int $nextpageid
param: int $prevpageid

get_answers()   X-Ref
Returns the answers that are associated with this page in the database

return: array

get_lesson()   X-Ref
Returns the lesson this page is associated with

return: lesson

get_type()   X-Ref
Returns the type of page this is. Not to be confused with page type

return: int

record_attempt($context)   X-Ref
Records an attempt at this page

param: stdClass $context
return: stdClass Returns the result of the attempt

format_answer($answer, $context, $answerformat, $options = [])   X-Ref
Formats the answer. Override for custom formatting.

param: string $answer
param: context $context
param: int $answerformat
return: string Returns formatted string

format_response($response, $context, $responseformat, $answerid, $options)   X-Ref
Formats the response

param: string $response
param: context $context
param: int $responseformat
param: int $answerid
param: stdClass $options
return: string Returns formatted string

get_jump_name($jumpto)   X-Ref
Returns the string for a jump name

param: int $jumpto Jump code or page ID
return: string

__construct($properties, lesson $lesson)   X-Ref
Constructor method

param: object $properties
param: lesson $lesson

earned_score($answers, $attempt)   X-Ref
Returns the score for the attempt
This may be overridden by page types that require manual grading

param: array $answers
param: object $attempt
return: int

callback_on_view($canmanage, $redirect = true)   X-Ref
This is a callback method that can be override and gets called when ever a page
is viewed

param: bool $canmanage True if the user has the manage cap
param: bool $redirect  Optional, default to true. Set to false to avoid redirection and return the page to redirect.
return: mixed

save_answers_files($context, $maxbytes, &$answer, $answereditor = '', $responseeditor = '')   X-Ref
save editor answers files and update answer record

param: object $context
param: int $maxbytes
param: object $answer
param: object $answereditor
param: object $responseeditor

rewrite_answers_urls($answer, $rewriteanswer = true)   X-Ref
Rewrite urls in response and optionality answer of a question answer

param: object $answer
param: bool $rewriteanswer must rewrite answer
return: object answer with rewritten urls

update($properties, $context = null, $maxbytes = null)   X-Ref
Updates a lesson page and its answers within the database

param: object $properties
return: bool

add_page_link($previd)   X-Ref
Can be set to true if the page requires a static link to create a new instance
instead of simply being included in the dropdown

param: int $previd
return: bool

is_unseen($param)   X-Ref
Returns true if a page has been viewed before

param: array|int $param Either an array of pages that have been seen or the
return: bool

is_unanswered($nretakes)   X-Ref
Checks to see if a page has been answered previously

param: int $nretakes
return: bool

create_answers($properties)   X-Ref
Creates answers within the database for this lesson_page. Usually only ever
called when creating a new page instance

param: object $properties
return: array

check_answer()   X-Ref
This method MUST be overridden by all question page types, or page types that
wish to score a page.

The structure of result should always be the same so it is a good idea when
overriding this method on a page type to call
<code>
$result = parent::check_answer();
</code>
before modifying it as required.

return: stdClass

on_after_write_attempt($attempt, $result)   X-Ref
Do any post persistence processing logic of an attempt. E.g. in cases where we need update file urls in an editor
and we need to have the id of the stored attempt. Should be overridden in each individual child
pagetype on a as required basis

param: object $attempt The attempt corresponding to the db record
param: object $result The result from the 'check_answer' method
return: array False if nothing to be modified, updated $attempt and $result if update required.

has_option()   X-Ref
True if the page uses a custom option

Should be override and set to true if the page uses a custom option.

return: bool

max_answers($default)   X-Ref
Returns the maximum number of answers for this page given the maximum number
of answers permitted by the lesson.

param: int $default
return: int

properties()   X-Ref
Returns the properties of this lesson page as an object

return: stdClass;

get_jumptooptions($pageid, lesson $lesson)   X-Ref
Returns an array of options to display when choosing the jumpto for a page/answer

param: int $pageid
param: lesson $lesson
return: array

get_contents()   X-Ref
Returns the contents field for the page properly formatted and with plugin
file url's converted

return: string

get_displayinmenublock()   X-Ref
Set to true if this page should display in the menu block

return: bool

option_description_string()   X-Ref
Get the string that describes the options of this page type

return: string

display_answers(html_table $table)   X-Ref
Updates a table with the answers for this page

param: html_table $table
return: html_table

get_grayout()   X-Ref
Determines if this page should be grayed out on the management/report screens

return: int 0 or 1

stats(array &$pagestats, $tries)   X-Ref
Adds stats for this page to the &pagestats object. This should be defined
for all page types that grade

param: array $pagestats
param: int $tries
return: bool

report_answers($answerpage, $answerdata, $useranswer, $pagestats, &$i, &$n)   X-Ref
Formats the answers of this page for a report

param: object $answerpage
param: object $answerdata
param: object $useranswer
param: array $pagestats
param: int $i Count of first level answers
param: int $n Count of second level answers
return: object The answer page for this

get_jumps()   X-Ref
Gets an array of the jumps used by the answers of this page

return: array

requires_manual_grading()   X-Ref
Informs whether this page type require manual grading or not

return: bool

override_next_page()   X-Ref
A callback method that allows a page to override the next page a user will
see during when this page is being completed.

return: false|int

valid_page_and_view(&$validpages, &$pageviews)   X-Ref
This method is used to determine if this page is a valid page

param: array $validpages
param: array $pageviews
return: int The next page id to check

get_files($includedirs = true, $updatedsince = 0)   X-Ref
Get files from the page area file.

param: bool $includedirs whether or not include directories
param: int $updatedsince return files updated since this time
return: array list of stored_file objects

update_form_data(stdClass $data)   X-Ref
Make updates to the form data if required.

param: stdClass $data The form data to update.
return: stdClass The updated fom data.

Class: lesson_page_answer  - X-Ref

Class used to represent an answer to a page

load($id)   X-Ref
Loads an page answer from the DB

param: int $id
return: lesson_page_answer

create($properties, lesson_page $page)   X-Ref
Given an object of properties and a page created answer(s) and saves them
in the database.

param: stdClass $properties
param: lesson_page $page
return: array

get_files($includedirs = true, $updatedsince = 0)   X-Ref
Get files from the answer area file.

param: bool $includedirs whether or not include directories
param: int $updatedsince return files updated since this time
return: array list of stored_file objects

Class: lesson_page_type_manager  - X-Ref

A management class for page types

This class is responsible for managing the different pages. A manager object can
be retrieved by calling the following line of code:
<code>
$manager  = lesson_page_type_manager::get($lesson);
</code>
The first time the page type manager is retrieved the it includes all of the
different page types located in mod/lesson/pagetypes.

get(lesson $lesson)   X-Ref
Retrieves the lesson page type manager object

If the object hasn't yet been created it is created here.

param: lesson $lesson
return: lesson_page_type_manager

load_lesson_types(lesson $lesson)   X-Ref
Finds and loads all lesson page types in mod/lesson/pagetypes

param: lesson $lesson

get_page_type_strings($type=null, $special=true)   X-Ref
Returns an array of strings to describe the loaded page types

param: int $type Can be used to return JUST the string for the requested type
return: array

get_page_type_idstring($id)   X-Ref
Returns the basic string used to identify a page type provided with an id

This string can be used to instantiate or identify the page type class.
If the page type id is unknown then 'unknown' is returned

param: int $id
return: string

load_page($pageid, lesson $lesson)   X-Ref
Loads a page for the provided lesson given it's id

This function loads a page from the lesson when given both the lesson it belongs
to as well as the page's id.
If the page doesn't exist an error is thrown

param: int $pageid The id of the page to load
param: lesson $lesson The lesson the page belongs to
return: lesson_page A class that extends lesson_page

check_page_order($page1, $page2)   X-Ref
This function detects errors in the ordering between 2 pages and updates the page records.

param: stdClass $page1 Either the first of 2 pages or null if the $page2 param is the first in the list.
param: stdClass $page1 Either the second of 2 pages or null if the $page1 param is the last in the list.

load_all_pages(lesson $lesson)   X-Ref
This function loads ALL pages that belong to the lesson.

param: lesson $lesson
return: array An array of lesson_page_type_*

get_page_form($type, $arguments)   X-Ref
Fetches an mform that can be used to create/edit an page

param: int $type The id for the page type
param: array $arguments Any arguments to pass to the mform
return: lesson_add_page_form_base

Class: requested  - X-Ref

get_add_page_type_links($previd)   X-Ref
Returns an array of links to use as add page links

param: int $previd The id of the previous page
return: array

Functions that are not part of a class:

lesson_display_teacher_warning($lesson)   X-Ref
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.

param: stdClass $lesson Id of the lesson that is to be checked.
return: boolean True or false.

lesson_unseen_question_jump($lesson, $user, $pageid)   X-Ref
Interprets the LESSON_UNSEENBRANCHPAGE jump.

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

param: lesson $lesson
param: int $userid Id of the user.
param: int $pageid Id of the page from which we are jumping.
return: int Id of the next page.

lesson_unseen_branch_jump($lesson, $userid)   X-Ref
Handles the unseen branch table jump.

param: lesson $lesson
param: int $userid User id.
return: int Will return the page id of a branch table or end of lesson

lesson_random_question_jump($lesson, $pageid)   X-Ref
Handles the random jump between a branch table and end of branch or end of lesson (LESSON_RANDOMPAGE).

param: lesson $lesson
param: int $pageid The id of the page that we are jumping from (?)
return: int The pageid of a random page that is within a branch table

lesson_grade($lesson, $ntries, $userid = 0)   X-Ref
Calculates a user's grade for a lesson.

param: object $lesson The lesson that the user is taking.
param: int $retries The attempt number.
param: int $userid Id of the user (optional, default current user).
return: object { nquestions => number of questions answered

lesson_displayleftif($lesson)   X-Ref
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

param: object $lesson Lesson object of the current lesson
return: boolean 0 if the user cannot see, or $lesson->displayleft to keep displayleft unchanged

lesson_add_fake_blocks($page, $cm, $lesson, $timer = null)   X-Ref

param: $cm
param: $lesson
param: $page
return: unknown_type

lesson_mediafile_block_contents($cmid, $lesson)   X-Ref
If there is a media file associated with this
lesson, return a block_contents that displays it.

param: int $cmid Course Module ID for this lesson
param: object $lesson Full lesson record object
return: block_contents

lesson_clock_block_contents($cmid, $lesson, $timer, $page)   X-Ref
If a timed lesson and not a teacher, then
return a block_contents containing the clock.

param: int $cmid Course Module ID for this lesson
param: object $lesson Full lesson record object
param: object $timer Full timer record object
return: block_contents

lesson_menu_block_contents($cmid, $lesson)   X-Ref
If left menu is turned on, then this will
print the menu in a block

param: int $cmid Course Module ID for this lesson
param: lesson $lesson Full lesson record object
return: void

lesson_add_header_buttons($cm, $context, $extraeditbuttons=false, $lessonpageid=null)   X-Ref
Adds header buttons to the page for the lesson

param: object $cm
param: object $context
param: bool $extraeditbuttons
param: int $lessonpageid

lesson_get_media_html($lesson, $context)   X-Ref
This is a function used to detect media types and generate html code.

param: object $lesson
param: object $context
return: string $code the html code of media

lesson_process_group_deleted_in_course($courseid, $groupid = null)   X-Ref
Logic to happen when a/some group(s) has/have been deleted in a course.

param: int $courseid The course ID.
param: int $groupid The group id if it is known
return: void

lesson_get_overview_report_table_and_data(lesson $lesson, $currentgroup)   X-Ref
Return the overview report table and data.

param: lesson $lesson       lesson instance
param: mixed $currentgroup  false if not group used, 0 for all groups, group id (int) to filter by that groups
return: mixed false if there is no information otherwise html_table and stdClass with the table and data

lesson_get_user_detailed_report_data(lesson $lesson, $userid, $attempt)   X-Ref
Return information about one user attempt (including answers)

param: lesson $lesson  lesson instance
param: int $userid     the user id
param: int $attempt    the attempt number
return: array the user answers (array) and user data stats (object)

lesson_get_user_deadline($courseid)   X-Ref
Return user's deadline for all lessons in a course, hereby taking into account group and user overrides.

param: int $courseid the course id.
return: object An object with of all lessonsids and close unixdates in this course,