Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
lesson_page_type_endofbranch Class Reference
Inheritance diagram for lesson_page_type_endofbranch:
lesson_page lesson_base

Public Member Functions

 __get ($key)
 Magic get method.
 
 __isset ($key)
 Stupid PHP needs an isset magic method if you use the get magic method and still want empty calls to work....
 
 __set ($key, $value)
 Magic property method.
 
 add_page_link ($previd)
 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.
 
 callback_on_view ($canmanage, $redirect=true)
 This is a callback method that can be override and gets called when ever a page is viewed.
 
 check_answer ()
 This method MUST be overridden by all question page types, or page types that wish to score a page.
 
 create_answers ($properties)
 Creates answers within the database for this end of cluster page.
 
 delete ()
 Deletes a lesson_page from the database as well as any associated records.
 
 display ($renderer, $attempt)
 This method gets called to display the page to the user taking the lesson @abstract.
 
 display_answers (html_table $table)
 Updates a table with the answers for this page.
 
 earned_score ($answers, $attempt)
 Returns the score for the attempt This may be overridden by page types that require manual grading.
 
 format_answer ($answer, $context, $answerformat, $options=[])
 Formats the answer.
 
 get_answers ()
 Returns the answers that are associated with this page in the database.
 
 get_contents ()
 Returns the contents field for the page properly formatted and with plugin file url's converted.
 
 get_files ($includedirs=true, $updatedsince=0)
 Get files from the page area file.
 
 get_grayout ()
 Determines if this page should be grayed out on the management/report screens.
 
 get_idstring ()
 
 get_jumps ()
 Gets an array of the jumps used by the answers of this page.
 
 get_typeid ()
 This method should return the integer used to identify the page type within the database and throughout code.
 
 get_typestring ()
 This method should return the string that describes the pagetype @abstract.
 
 has_option ()
 True if the page uses a custom option.
 
 is_unanswered ($nretakes)
 Checks to see if a page has been answered previously.
 
 is_unseen ($param)
 Returns true if a page has been viewed before.
 
 max_answers ($default)
 Returns the maximum number of answers for this page given the maximum number of answers permitted by the lesson.
 
 move ($nextpageid=null, $prevpageid=null)
 Moves a page by updating its nextpageid and prevpageid values within the database.
 
 on_after_write_attempt ($attempt, $result)
 Do any post persistence processing logic of an attempt.
 
 option_description_string ()
 Get the string that describes the options of this page type.
 
 override_next_page ()
 A callback method that allows a page to override the next page a user will see during when this page is being completed.
 
 properties ()
 Returns the properties of this lesson page as an object.
 
moodle_database record_attempt ($context)
 Records an attempt at this page.
 
 redirect_to_first_answer ($canmanage, $redirect)
 
 report_answers ($answerpage, $answerdata, $useranswer, $pagestats, &$i, &$n)
 Formats the answers of this page for a report.
 
 requires_manual_grading ()
 Informs whether this page type require manual grading or not.
 
 save_answers_files ($context, $maxbytes, &$answer, $answereditor='', $responseeditor='')
 save editor answers files and update answer record
 
 stats (array &$pagestats, $tries)
 Adds stats for this page to the &pagestats object.
 
 update ($properties, $context=null, $maxbytes=null)
 Updates a lesson page and its answers within the database.
 
 update_form_data (stdClass $data)
 Make updates to the form data if required.
 
 valid_page_and_view (&$validpages, &$pageviews)
 This method is used to determine if this page is a valid page.
 

Static Public Member Functions

static create ($properties, lesson $lesson, $context, $maxbytes)
 Creates a new lesson_page within the database and returns the correct pagetype object to use to interact with the new lesson.
 
static get_jumptooptions ($pageid, lesson $lesson)
 Returns an array of options to display when choosing the jumpto for a page/answer.
 
static load ($id, lesson $lesson)
 This method loads a page object from the database and returns it as a specialised object that extends lesson_page.
 
static rewrite_answers_urls ($answer, $rewriteanswer=true)
 Rewrite urls in response and optionality answer of a question answer.
 

Public Attributes

const MULTIANSWER_DELIMITER = '@^#|'
 Constant used as a delimiter when parsing multianswer questions.
 
const TYPE_QUESTION = 0
 Constants used to identify the type of the page.
 
const TYPE_STRUCTURE = 1
 

Protected Member Functions

 get_displayinmenublock ()
 Set to true if this page should display in the menu block.
 
 get_jump_name ($jumpto)
 Returns the string for a jump name.
 
 get_lesson ()
 Returns the lesson this page is associated with @final.
 
 get_type ()
 Returns the type of page this is.
 

Protected Attributes

null array $answers = null
 Contains the answers to this lesson_page once loaded.
 
 $jumpto = null
 
lesson $lesson = null
 A reference to the lesson this page belongs to.
 
stdClass $properties
 An object containing properties.
 
 $string = null
 
 $type = lesson_page::TYPE_STRUCTURE
 
 $typeid = LESSON_PAGE_ENDOFBRANCH
 
 $typeidstring = 'endofbranch'
 

Member Function Documentation

◆ __get()

lesson_base::__get ( $key)
inherited

Magic get method.

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

Parameters
str$key
Return values
mixed

◆ __isset()

lesson_base::__isset ( $key)
inherited

Stupid PHP needs an isset magic method if you use the get magic method and still want empty calls to work....

blah ~!

Parameters
string$key
Return values
bool

◆ __set()

lesson_base::__set ( $key,
$value )
inherited

Magic property method.

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

Parameters
string$key
mixed$value

◆ add_page_link()

lesson_page_type_endofbranch::add_page_link ( $previd)

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.

Parameters
int$previd
Return values
bool

Reimplemented from lesson_page.

◆ callback_on_view()

lesson_page_type_endofbranch::callback_on_view ( $canmanage,
$redirect = true )

This is a callback method that can be override and gets called when ever a page is viewed.

Parameters
bool$canmanageTrue if the user has the manage cap
bool$redirectOptional, default to true. Set to false to avoid redirection and return the page to redirect.
Return values
mixed

Reimplemented from lesson_page.

◆ check_answer()

lesson_page::check_answer ( )
inherited

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 $result = parent\check_answer(); before modifying it as required.

Return values
stdClass

Reimplemented in lesson_page_type_branchtable, lesson_page_type_essay, lesson_page_type_matching, lesson_page_type_multichoice, lesson_page_type_numerical, lesson_page_type_shortanswer, and lesson_page_type_truefalse.

◆ create()

static lesson_page::create ( $properties,
lesson $lesson,
$context,
$maxbytes )
staticfinalinherited

Creates a new lesson_page within the database and returns the correct pagetype object to use to interact with the new lesson.

@final

Parameters
object$properties
lesson$lesson
Return values
lesson_pageSpecialised object that extends lesson_page

◆ create_answers()

lesson_page_type_endofbranch::create_answers ( $properties)

Creates answers within the database for this end of cluster page.

Usually only ever called when creating a new page instance.

Parameters
object$properties
Return values
array

Reimplemented from lesson_page.

◆ delete()

lesson_page::delete ( )
finalinherited

Deletes a lesson_page from the database as well as any associated records.

@final

Return values
bool

◆ display()

lesson_page_type_endofbranch::display ( $renderer,
$attempt )

This method gets called to display the page to the user taking the lesson @abstract.

Parameters
object$renderer
object$attempt
Return values
string

Reimplemented from lesson_page.

◆ display_answers()

lesson_page::display_answers ( html_table $table)
inherited

◆ earned_score()

lesson_page::earned_score ( $answers,
$attempt )
inherited

Returns the score for the attempt This may be overridden by page types that require manual grading.

Parameters
array$answers
object$attempt
Return values
int

◆ format_answer()

lesson_page::format_answer ( $answer,
$context,
$answerformat,
$options = [] )
inherited

Formats the answer.

Override for custom formatting.

Parameters
string$answer
context$context
int$answerformat
Return values
stringReturns formatted string

Reimplemented in lesson_page_type_essay, and lesson_page_type_numerical.

◆ get_answers()

lesson_page::get_answers ( )
finalinherited

Returns the answers that are associated with this page in the database.

@final

Return values
array

◆ get_contents()

lesson_page::get_contents ( )
inherited

Returns the contents field for the page properly formatted and with plugin file url's converted.

Return values
string

◆ get_displayinmenublock()

lesson_page::get_displayinmenublock ( )
protectedinherited

Set to true if this page should display in the menu block.

Return values
bool

Reimplemented in lesson_page_type_branchtable.

◆ get_files()

lesson_page::get_files ( $includedirs = true,
$updatedsince = 0 )
inherited

Get files from the page area file.

Parameters
bool$includedirswhether or not include directories
int$updatedsincereturn files updated since this time
Return values
arraylist of stored_file objects
Since
Moodle 3.2

◆ get_grayout()

lesson_page_type_endofbranch::get_grayout ( )

Determines if this page should be grayed out on the management/report screens.

Return values
int0 or 1

Reimplemented from lesson_page.

◆ get_jump_name()

lesson_page::get_jump_name ( $jumpto)
finalprotectedinherited

Returns the string for a jump name.

@final

Parameters
int$jumptoJump code or page ID
Return values
string

◆ get_jumps()

lesson_page::get_jumps ( )
inherited

Gets an array of the jumps used by the answers of this page.

Return values
array

Reimplemented in lesson_page_type_branchtable, lesson_page_type_matching, and lesson_page_type_multichoice.

◆ get_jumptooptions()

static lesson_page::get_jumptooptions ( $pageid,
lesson $lesson )
staticinherited

Returns an array of options to display when choosing the jumpto for a page/answer.

Parameters
int$pageid
lesson$lesson
Return values
array

Reimplemented in lesson_page_type_branchtable.

◆ get_lesson()

lesson_page::get_lesson ( )
finalprotectedinherited

Returns the lesson this page is associated with @final.

Return values
lesson

◆ get_type()

lesson_page::get_type ( )
finalprotectedinherited

Returns the type of page this is.

Not to be confused with page type @final

Return values
int

◆ get_typeid()

lesson_page_type_endofbranch::get_typeid ( )

This method should return the integer used to identify the page type within the database and throughout code.

This maps back to the defines used in 1.x @abstract

Return values
int

Reimplemented from lesson_page.

◆ get_typestring()

lesson_page_type_endofbranch::get_typestring ( )

This method should return the string that describes the pagetype @abstract.

Return values
string

Reimplemented from lesson_page.

◆ has_option()

lesson_page::has_option ( )
inherited

True if the page uses a custom option.

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

Return values
bool

◆ is_unanswered()

lesson_page::is_unanswered ( $nretakes)
inherited

Checks to see if a page has been answered previously.

Parameters
int$nretakes
Return values
bool

Reimplemented in lesson_page_type_essay.

◆ is_unseen()

lesson_page::is_unseen ( $param)
inherited

Returns true if a page has been viewed before.

Parameters
array | int$paramEither an array of pages that have been seen or the number of retakes a user has had
Return values
bool

Reimplemented in lesson_page_type_branchtable.

◆ load()

static lesson_page::load ( $id,
lesson $lesson )
staticfinalinherited

This method loads a page object from the database and returns it as a specialised object that extends lesson_page.

@final

Parameters
int$id
lesson$lesson
Return values
lesson_pageSpecialised lesson_page object

◆ max_answers()

lesson_page::max_answers ( $default)
inherited

Returns the maximum number of answers for this page given the maximum number of answers permitted by the lesson.

Parameters
int$default
Return values
int

◆ move()

lesson_page::move ( $nextpageid = null,
$prevpageid = null )
finalinherited

Moves a page by updating its nextpageid and prevpageid values within the database.

@final

Parameters
int$nextpageid
int$prevpageid

◆ on_after_write_attempt()

lesson_page::on_after_write_attempt ( $attempt,
$result )
inherited

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

Parameters
object$attemptThe attempt corresponding to the db record
object$resultThe result from the 'check_answer' method
Return values
arrayFalse if nothing to be modified, updated $attempt and $result if update required.

Reimplemented in lesson_page_type_essay.

◆ option_description_string()

lesson_page::option_description_string ( )
inherited

Get the string that describes the options of this page type.

Return values
string

Reimplemented in lesson_page_type_matching, lesson_page_type_multichoice, and lesson_page_type_shortanswer.

◆ override_next_page()

lesson_page::override_next_page ( )
inherited

A callback method that allows a page to override the next page a user will see during when this page is being completed.

Return values
false|int

Reimplemented in lesson_page_type_cluster, and lesson_page_type_endofcluster.

◆ properties()

lesson_page::properties ( )
inherited

Returns the properties of this lesson page as an object.

Return values
stdClass;

Reimplemented from lesson_base.

◆ record_attempt()

moodle_database lesson_page::record_attempt ( $context)
finalinherited

Records an attempt at this page.

@final $DB

Parameters
stdClass$context
Return values
stdClassReturns the result of the attempt

◆ report_answers()

lesson_page::report_answers ( $answerpage,
$answerdata,
$useranswer,
$pagestats,
& $i,
& $n )
inherited

Formats the answers of this page for a report.

Parameters
object$answerpage
object$answerdata
object$useranswer
array$pagestats
int$iCount of first level answers
int$nCount of second level answers
Return values
objectThe answer page for this

Reimplemented in lesson_page_type_branchtable, lesson_page_type_essay, lesson_page_type_matching, lesson_page_type_multichoice, lesson_page_type_numerical, lesson_page_type_shortanswer, and lesson_page_type_truefalse.

◆ requires_manual_grading()

lesson_page::requires_manual_grading ( )
inherited

Informs whether this page type require manual grading or not.

Return values
bool

Reimplemented in lesson_page_type_essay.

◆ rewrite_answers_urls()

static lesson_page::rewrite_answers_urls ( $answer,
$rewriteanswer = true )
staticinherited

Rewrite urls in response and optionality answer of a question answer.

Parameters
object$answer
bool$rewriteanswermust rewrite answer
Return values
objectanswer with rewritten urls

◆ save_answers_files()

lesson_page::save_answers_files ( $context,
$maxbytes,
& $answer,
$answereditor = '',
$responseeditor = '' )
inherited

save editor answers files and update answer record

Parameters
object$context
int$maxbytes
object$answer
object$answereditor
object$responseeditor

◆ stats()

lesson_page::stats ( array & $pagestats,
$tries )
inherited

Adds stats for this page to the &pagestats object.

This should be defined for all page types that grade

Parameters
array$pagestats
int$tries
Return values
bool

Reimplemented in lesson_page_type_essay, lesson_page_type_matching, lesson_page_type_multichoice, lesson_page_type_numerical, lesson_page_type_shortanswer, and lesson_page_type_truefalse.

◆ update()

lesson_page::update ( $properties,
$context = null,
$maxbytes = null )
inherited

Updates a lesson page and its answers within the database.

Parameters
object$properties
Return values
bool

Reimplemented in lesson_page_type_branchtable, lesson_page_type_essay, lesson_page_type_matching, lesson_page_type_numerical, lesson_page_type_shortanswer, and lesson_page_type_truefalse.

◆ update_form_data()

lesson_page::update_form_data ( stdClass $data)
inherited

Make updates to the form data if required.

Since
Moodle 3.7
Parameters
stdClass$dataThe form data to update.
Return values
stdClassThe updated fom data.

Reimplemented in lesson_page_type_numerical, and lesson_page_type_shortanswer.

◆ valid_page_and_view()

lesson_page_type_endofbranch::valid_page_and_view ( & $validpages,
& $pageviews )

This method is used to determine if this page is a valid page.

Parameters
array$validpages
array$pageviews
Return values
intThe next page id to check

Reimplemented from lesson_page.


The documentation for this class was generated from the following file: