Moodle  2.2.1
http://www.collinsharper.com
lesson_page Class Reference
Inheritance diagram for lesson_page:
Collaboration diagram for lesson_page:

Public Member Functions

 display ($renderer, $attempt)
 delete ()
 move ($nextpageid=null, $prevpageid=null)
 get_answers ()
 record_attempt ($context)
 __construct ($properties, lesson $lesson)
 earned_score ($answers, $attempt)
 callback_on_view ($canmanage)
 update ($properties, $context=null, $maxbytes=null)
 add_page_link ($previd)
 is_unseen ($param)
 is_unanswered ($nretakes)
 create_answers ($properties)
 check_answer ()
 has_option ()
 max_answers ($default)
 properties ()
 get_contents ()
 option_description_string ()
 display_answers (html_table $table)
 stats (array &$pagestats, $tries)
 report_answers ($answerpage, $answerdata, $useranswer, $pagestats, &$i, &$n)
 get_jumps ()
 requires_manual_grading ()
 override_next_page ()
 valid_page_and_view (&$validpages, &$pageviews)

Static Public Member Functions

static create ($properties, lesson $lesson, $context, $maxbytes)
static load ($id, lesson $lesson)
static get_jumptooptions ($pageid, lesson $lesson)

Data Fields

const TYPE_QUESTION = 0
const TYPE_STRUCTURE = 1

Protected Member Functions

 get_typeid ()
 get_typestring ()
 get_lesson ()
 get_type ()
 get_jump_name ($jumpto)
 get_displayinmenublock ()
 get_grayout ()

Protected Attributes

 $lesson = null
 $answers = null
 $type = 0

Detailed Description

Definition at line 1678 of file locallib.php.


Constructor & Destructor Documentation

__construct ( properties,
lesson lesson 
)

Constructor method

Parameters:
object$properties
lesson$lesson

Definition at line 2085 of file locallib.php.


Member Function Documentation

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
Returns:
bool

Reimplemented in lesson_page_type_branchtable, lesson_page_type_endofbranch, lesson_page_type_endofcluster, and lesson_page_type_cluster.

Definition at line 2180 of file locallib.php.

callback_on_view ( canmanage)

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
Returns:
mixed

Reimplemented in lesson_page_type_cluster, lesson_page_type_endofbranch, and lesson_page_type_endofcluster.

Definition at line 2108 of file locallib.php.

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.

Returns:
stdClass

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

Definition at line 2277 of file locallib.php.

Here is the caller graph for this function:

static create ( properties,
lesson lesson,
context,
maxbytes 
) [static, final]

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

Parameters:
object$properties
lesson$lesson
Returns:
lesson_page Specialised object that extends lesson_page

Definition at line 1735 of file locallib.php.

Here is the call graph for this function:

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
Returns:
array

Reimplemented in lesson_page_type_matching, and lesson_page_type_essay.

Definition at line 2224 of file locallib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

delete ( ) [final]

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

Returns:
bool

Definition at line 1824 of file locallib.php.

Here is the call graph for this function:

display ( renderer,
attempt 
) [abstract]

This method gets called to display the page to the user taking the lesson

Parameters:
object$renderer
object$attempt
Returns:
string

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

Here is the caller graph for this function:

Updates a table with the answers for this page

Parameters:
html_table$table
Returns:
html_table

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

Definition at line 2418 of file locallib.php.

earned_score ( answers,
attempt 
)

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

Parameters:
array$answers
object$attempt
Returns:
int

Definition at line 2097 of file locallib.php.

get_answers ( ) [final]

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

Returns:
array

Definition at line 1884 of file locallib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Returns:
string

Definition at line 2383 of file locallib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

get_displayinmenublock ( ) [protected]

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

Returns:
bool

Reimplemented in lesson_page_type_branchtable.

Definition at line 2401 of file locallib.php.

get_grayout ( ) [protected]

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

Returns:
int 0 or 1

Reimplemented in lesson_page_type_branchtable, lesson_page_type_endofbranch, lesson_page_type_endofcluster, and lesson_page_type_cluster.

Definition at line 2438 of file locallib.php.

get_jump_name ( jumpto) [final, protected]

Returns the string for a jump name

Parameters:
int$jumptoJump code or page ID
Returns:
string

Definition at line 2048 of file locallib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

get_jumps ( )

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

Returns:
array

Reimplemented in lesson_page_type_matching, lesson_page_type_multichoice, and lesson_page_type_branchtable.

Definition at line 2481 of file locallib.php.

Here is the call graph for this function:

static get_jumptooptions ( pageid,
lesson lesson 
) [static]

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

Parameters:
int$pageid
lesson$lesson
Returns:
array

Definition at line 2343 of file locallib.php.

Here is the call graph for this function:

get_lesson ( ) [final, protected]

Returns the lesson this page is associated with

Returns:
lesson

Definition at line 1907 of file locallib.php.

get_type ( ) [final, protected]

Returns the type of page this is. Not to be confused with page type

Returns:
int

Definition at line 1916 of file locallib.php.

get_typeid ( ) [abstract, protected]

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

Returns:
int

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

True if the page uses a custom option

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

Returns:
bool

Definition at line 2299 of file locallib.php.

is_unanswered ( nretakes)

Checks to see if a page has been answered previously

Parameters:
int$nretakes
Returns:
bool

Reimplemented in lesson_page_type_essay.

Definition at line 2210 of file locallib.php.

Here is the call graph for this function:

is_unseen ( param)

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
Returns:
bool

Reimplemented in lesson_page_type_branchtable.

Definition at line 2191 of file locallib.php.

Here is the call graph for this function:

static load ( id,
lesson lesson 
) [static, final]

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

Parameters:
int$id
lesson$lesson
Returns:
lesson_page Specialised lesson_page object

Definition at line 1798 of file locallib.php.

Here is the call graph for this function:

max_answers ( default)

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

Parameters:
int$default
Returns:
int

Definition at line 2310 of file locallib.php.

move ( nextpageid = null,
prevpageid = null 
) [final]

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

Parameters:
int$nextpageid
int$prevpageid

Definition at line 1863 of file locallib.php.

Here is the call graph for this function:

Get the string that describes the options of this page type

Returns:
string

Reimplemented in lesson_page_type_multichoice, lesson_page_type_matching, and lesson_page_type_shortanswer.

Definition at line 2409 of file locallib.php.

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

Returns:
false|int

Reimplemented in lesson_page_type_endofcluster, and lesson_page_type_cluster.

Definition at line 2507 of file locallib.php.

Returns the properties of this lesson page as an object

Returns:
stdClass;

Reimplemented from lesson_base.

Definition at line 2318 of file locallib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

record_attempt ( context) [final]

Records an attempt at this page

moodle_database $DB

Parameters:
stdClass$context
Returns:
stdClass Returns the result of the attempt

This should be overridden by each page type to actually check the response against what ever custom criteria they have defined

Definition at line 1928 of file locallib.php.

Here is the call graph for this function:

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
Returns:
object The answer page for this

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

Definition at line 2464 of file locallib.php.

Informs whether this page type require manual grading or not

Returns:
bool

Reimplemented in lesson_page_type_essay.

Definition at line 2498 of file locallib.php.

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
Returns:
bool

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

Definition at line 2449 of file locallib.php.

update ( properties,
context = null,
maxbytes = null 
)

Updates a lesson page and its answers within the database

Parameters:
object$properties
Returns:
bool

Definition at line 2118 of file locallib.php.

Here is the call graph for this function:

valid_page_and_view ( &$  validpages,
&$  pageviews 
)

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

Parameters:
array$validpages
array$pageviews
Returns:
int The next page id to check

Reimplemented in lesson_page_type_endofbranch, lesson_page_type_endofcluster, and lesson_page_type_cluster.

Definition at line 2518 of file locallib.php.


Field Documentation

$answers = null [protected]

Definition at line 1689 of file locallib.php.

$lesson = null [protected]

Definition at line 1684 of file locallib.php.

const TYPE_QUESTION = 0

Constants used to identify the type of the page

Definition at line 1699 of file locallib.php.

const TYPE_STRUCTURE = 1

Definition at line 1700 of file locallib.php.


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Enumerations