Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
|
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 lesson_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=[]) | |
Custom formats the answer to display. | |
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_earnedscore ($answers, $attempt) | |
get_files ($includedirs=true, $updatedsince=0) | |
Get files from the page area file. | |
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) | |
Overridden function. | |
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. | |
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 | extract_useranswer ($useranswer) |
Unserialize attempt useranswer and add missing responseformat if needed for compatibility with old records. | |
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. | |
Protected Member Functions | |
get_displayinmenublock () | |
Set to true if this page should display in the menu block. | |
get_grayout () | |
Determines if this page should be grayed out on the management/report screens. | |
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. | |
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' | |
|
inherited |
Magic get method.
Attempts to call a get_$key method to return the property and ralls over to return the raw property
str | $key |
mixed |
|
inherited |
Stupid PHP needs an isset magic method if you use the get magic method and still want empty calls to work....
blah ~!
string | $key |
bool |
|
inherited |
Magic property method.
Attempts to call a set_$key method if one exists otherwise falls back to simply set the property
string | $key | |
mixed | $value |
|
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.
int | $previd |
bool |
Reimplemented in lesson_page_type_branchtable, lesson_page_type_cluster, lesson_page_type_endofbranch, and lesson_page_type_endofcluster.
|
inherited |
This is a callback method that can be override and gets called when ever a page is viewed.
bool | $canmanage | True if the user has the manage cap |
bool | $redirect | Optional, default to true. Set to false to avoid redirection and return the page to redirect. |
mixed |
Reimplemented in lesson_page_type_cluster, lesson_page_type_endofbranch, and lesson_page_type_endofcluster.
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.
stdClass |
Reimplemented from lesson_page.
|
staticfinalinherited |
Creates a new lesson_page within the database and returns the correct pagetype object to use to interact with the new lesson.
@final
object | $properties | |
lesson | $lesson |
lesson_page | Specialised object that extends lesson_page |
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
object | $properties |
array |
Reimplemented from lesson_page.
|
finalinherited |
Deletes a lesson_page from the database as well as any associated records.
@final
bool |
lesson_page_type_essay::display | ( | $renderer, | |
$attempt ) |
This method gets called to display the page to the user taking the lesson @abstract.
object | $renderer | |
object | $attempt |
string |
Reimplemented from lesson_page.
|
inherited |
Updates a table with the answers for this page.
html_table | $table |
html_table |
Reimplemented in lesson_page_type_branchtable, lesson_page_type_matching, lesson_page_type_multichoice, lesson_page_type_numerical, lesson_page_type_shortanswer, and lesson_page_type_truefalse.
|
inherited |
Returns the score for the attempt This may be overridden by page types that require manual grading.
array | $answers | |
object | $attempt |
int |
|
static |
Unserialize attempt useranswer and add missing responseformat if needed for compatibility with old records.
string | $useranswer | serialized object |
object |
lesson_page_type_essay::format_answer | ( | $answer, | |
$context, | |||
$answerformat, | |||
$options = [] ) |
Custom formats the answer to display.
string | $answer | |
context | $context | |
int | $answerformat | |
array | $options | Optional param for additional options. |
string | Returns formatted string |
Reimplemented from lesson_page.
|
finalinherited |
Returns the answers that are associated with this page in the database.
@final
array |
|
inherited |
Returns the contents field for the page properly formatted and with plugin file url's converted.
string |
|
protectedinherited |
Set to true if this page should display in the menu block.
bool |
Reimplemented in lesson_page_type_branchtable.
|
inherited |
Get files from the page area file.
bool | $includedirs | whether or not include directories |
int | $updatedsince | return files updated since this time |
array | list of stored_file objects |
|
protectedinherited |
Determines if this page should be grayed out on the management/report screens.
int | 0 or 1 |
Reimplemented in lesson_page_type_branchtable, lesson_page_type_cluster, lesson_page_type_endofbranch, and lesson_page_type_endofcluster.
|
finalprotectedinherited |
Returns the string for a jump name.
@final
int | $jumpto | Jump code or page ID |
string |
|
inherited |
Gets an array of the jumps used by the answers of this page.
array |
Reimplemented in lesson_page_type_branchtable, lesson_page_type_matching, and lesson_page_type_multichoice.
|
staticinherited |
Returns an array of options to display when choosing the jumpto for a page/answer.
int | $pageid | |
lesson | $lesson |
array |
Reimplemented in lesson_page_type_branchtable.
|
finalprotectedinherited |
Returns the lesson this page is associated with @final.
lesson |
|
finalprotectedinherited |
Returns the type of page this is.
Not to be confused with page type @final
int |
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
int |
Reimplemented from lesson_page.
lesson_page_type_essay::get_typestring | ( | ) |
This method should return the string that describes the pagetype @abstract.
string |
Reimplemented from lesson_page.
|
inherited |
True if the page uses a custom option.
Should be override and set to true if the page uses a custom option.
bool |
lesson_page_type_essay::is_unanswered | ( | $nretakes | ) |
Checks to see if a page has been answered previously.
int | $nretakes |
bool |
Reimplemented from lesson_page.
|
inherited |
Returns true if a page has been viewed before.
array | int | $param | Either an array of pages that have been seen or the number of retakes a user has had |
bool |
Reimplemented in lesson_page_type_branchtable.
|
staticfinalinherited |
This method loads a page object from the database and returns it as a specialised object that extends lesson_page.
@final
int | $id | |
lesson | $lesson |
lesson_page | Specialised lesson_page object |
|
inherited |
Returns the maximum number of answers for this page given the maximum number of answers permitted by the lesson.
int | $default |
int |
|
finalinherited |
Moves a page by updating its nextpageid and prevpageid values within the database.
@final
int | $nextpageid | |
int | $prevpageid |
lesson_page_type_essay::on_after_write_attempt | ( | $attempt, | |
$result ) |
Overridden function.
object | $attempt | |
object | $result |
array |
Reimplemented from lesson_page.
|
inherited |
Get the string that describes the options of this page type.
string |
Reimplemented in lesson_page_type_matching, lesson_page_type_multichoice, and lesson_page_type_shortanswer.
|
inherited |
A callback method that allows a page to override the next page a user will see during when this page is being completed.
false|int |
Reimplemented in lesson_page_type_cluster, and lesson_page_type_endofcluster.
|
inherited |
Returns the properties of this lesson page as an object.
stdClass; |
Reimplemented from lesson_base.
|
finalinherited |
Records an attempt at this page.
@final $DB
stdClass | $context |
stdClass | Returns the result of the attempt |
lesson_page_type_essay::report_answers | ( | $answerpage, | |
$answerdata, | |||
$useranswer, | |||
$pagestats, | |||
& | $i, | ||
& | $n ) |
Formats the answers of this page for a report.
object | $answerpage | |
object | $answerdata | |
object | $useranswer | |
array | $pagestats | |
int | $i | Count of first level answers |
int | $n | Count of second level answers |
object | The answer page for this |
Reimplemented from lesson_page.
lesson_page_type_essay::requires_manual_grading | ( | ) |
Informs whether this page type require manual grading or not.
bool |
Reimplemented from lesson_page.
|
staticinherited |
Rewrite urls in response and optionality answer of a question answer.
object | $answer | |
bool | $rewriteanswer | must rewrite answer |
object | answer with rewritten urls |
|
inherited |
save editor answers files and update answer record
object | $context | |
int | $maxbytes | |
object | $answer | |
object | $answereditor | |
object | $responseeditor |
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
array | $pagestats | |
int | $tries |
bool |
Reimplemented from lesson_page.
lesson_page_type_essay::update | ( | $properties, | |
$context = null, | |||
$maxbytes = null ) |
Updates a lesson page and its answers within the database.
object | $properties |
bool |
Reimplemented from lesson_page.
|
inherited |
Make updates to the form data if required.
stdClass | $data | The form data to update. |
stdClass | The updated fom data. |
Reimplemented in lesson_page_type_numerical, and lesson_page_type_shortanswer.
|
inherited |
This method is used to determine if this page is a valid page.
array | $validpages | |
array | $pageviews |
int | The next page id to check |
Reimplemented in lesson_page_type_cluster, lesson_page_type_endofbranch, and lesson_page_type_endofcluster.