Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
lesson_page_type_essay Class Reference
Inheritance diagram for lesson_page_type_essay:
lesson_page lesson_base

Public Member Functions

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

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. More...
 
static extract_useranswer ($useranswer)
 Unserialize attempt useranswer and add missing responseformat if needed for compatibility with old records. More...
 
static get_jumptooptions ($pageid, lesson $lesson)
 Returns an array of options to display when choosing the jumpto for a page/answer. More...
 
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. More...
 
static rewrite_answers_urls ($answer, $rewriteanswer=true)
 Rewrite urls in response and optionality answer of a question answer. More...
 

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. More...
 
 get_grayout ()
 Determines if this page should be grayed out on the management/report screens. More...
 
 get_jump_name ($jumpto)
 Returns the string for a jump name. More...
 
 get_lesson ()
 Returns the lesson this page is associated with @final. More...
 
 get_type ()
 Returns the type of page this is. More...
 

Protected Attributes

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

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::add_page_link (   $previd)
inherited

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 in lesson_page_type_branchtable, lesson_page_type_cluster, lesson_page_type_endofbranch, and lesson_page_type_endofcluster.

◆ callback_on_view()

lesson_page::callback_on_view (   $canmanage,
  $redirect = true 
)
inherited

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 in lesson_page_type_cluster, lesson_page_type_endofbranch, and lesson_page_type_endofcluster.

◆ check_answer()

lesson_page_type_essay::check_answer ( )

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 from lesson_page.

◆ 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_essay::create_answers (   $properties)

Creates answers within the database for this lesson_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_essay::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

◆ extract_useranswer()

static lesson_page_type_essay::extract_useranswer (   $useranswer)
static

Unserialize attempt useranswer and add missing responseformat if needed for compatibility with old records.

Parameters
string$useranswerserialized object
Return values
object

◆ format_answer()

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

Custom formats the answer to display.

Parameters
string$answer
context$context
int$answerformat
array$optionsOptional param for additional options.
Return values
stringReturns formatted string

Reimplemented from lesson_page.

◆ 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::get_grayout ( )
protectedinherited

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

Return values
int0 or 1

Reimplemented in lesson_page_type_branchtable, lesson_page_type_cluster, lesson_page_type_endofbranch, and lesson_page_type_endofcluster.

◆ 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_essay::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_essay::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_type_essay::is_unanswered (   $nretakes)

Checks to see if a page has been answered previously.

Parameters
int$nretakes
Return values
bool

Reimplemented from lesson_page.

◆ 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_type_essay::on_after_write_attempt (   $attempt,
  $result 
)

Overridden function.

Parameters
object$attempt
object$result
Return values
array

Reimplemented from lesson_page.

◆ 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_type_essay::report_answers (   $answerpage,
  $answerdata,
  $useranswer,
  $pagestats,
$i,
$n 
)

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 from lesson_page.

◆ requires_manual_grading()

lesson_page_type_essay::requires_manual_grading ( )

Informs whether this page type require manual grading or not.

Return values
bool

Reimplemented from lesson_page.

◆ 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_type_essay::stats ( array &  $pagestats,
  $tries 
)

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 from lesson_page.

◆ update()

lesson_page_type_essay::update (   $properties,
  $context = null,
  $maxbytes = null 
)

Updates a lesson page and its answers within the database.

Parameters
object$properties
Return values
bool

Reimplemented from lesson_page.

◆ 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::valid_page_and_view ( $validpages,
$pageviews 
)
inherited

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 in lesson_page_type_cluster, lesson_page_type_endofbranch, and lesson_page_type_endofcluster.


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