Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
|
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_next_page ($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. | |
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_ENDOFCLUSTER | |
$typeidstring = 'endofcluster' | |
|
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 |
lesson_page_type_endofcluster::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.
int | $previd |
bool |
Reimplemented from lesson_page.
lesson_page_type_endofcluster::callback_on_view | ( | $canmanage, | |
$redirect = true ) |
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 from lesson_page.
|
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.
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.
|
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_endofcluster::create_answers | ( | $properties | ) |
Creates answers within the database for this end of cluster 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_endofcluster::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 |
|
inherited |
Formats the answer.
Override for custom formatting.
string | $answer | |
context | $context | |
int | $answerformat |
string | Returns formatted string |
Reimplemented in lesson_page_type_essay, and lesson_page_type_numerical.
|
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 |
lesson_page_type_endofcluster::get_grayout | ( | ) |
Determines if this page should be grayed out on the management/report screens.
int | 0 or 1 |
Reimplemented from lesson_page.
|
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_endofcluster::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_endofcluster::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 |
|
inherited |
Checks to see if a page has been answered previously.
int | $nretakes |
bool |
Reimplemented in lesson_page_type_essay.
|
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 |
|
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
object | $attempt | The attempt corresponding to the db record |
object | $result | The result from the 'check_answer' method |
array | False if nothing to be modified, updated $attempt and $result if update required. |
Reimplemented in lesson_page_type_essay.
|
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.
lesson_page_type_endofcluster::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.
false|int |
Reimplemented from lesson_page.
|
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 |
|
inherited |
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 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.
|
inherited |
Informs whether this page type require manual grading or not.
bool |
Reimplemented in lesson_page_type_essay.
|
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 |
|
inherited |
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 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.
|
inherited |
Updates a lesson page and its answers within the database.
object | $properties |
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.
|
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.
lesson_page_type_endofcluster::valid_page_and_view | ( | & | $validpages, |
& | $pageviews ) |
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 from lesson_page.