Moodle  2.2.1
http://www.collinsharper.com
quiz_access_manager Class Reference

Public Member Functions

 __construct ($quizobj, $timenow, $canignoretimelimits)
 get_active_rule_names ()
 describe_rules ()
 prevent_new_attempt ($numprevattempts, $lastattempt)
 prevent_access ()
 is_preflight_check_required ($attemptid)
 get_preflight_check_form (moodle_url $url, $attemptid)
 notify_preflight_check_passed ($attemptid)
 current_attempt_finished ()
 is_finished ($numprevattempts, $lastattempt)
 setup_attempt_page ($page)
 show_attempt_timer_if_needed ($attempt, $timenow, $output)
 attempt_must_be_in_popup ()
 get_popup_options ()
 back_to_view_page ($output, $message= '')
 make_review_link ($attempt, $reviewoptions, $output)

Static Public Member Functions

static add_settings_form_fields (mod_quiz_mod_form $quizform, MoodleQuickForm $mform)
static get_browser_security_choices ()
static save_settings ($quiz)
static load_settings ($quizid)
static load_quiz_and_settings ($quizid)

Protected Member Functions

 make_rules ($quizobj, $timenow, $canignoretimelimits)
 accumulate_messages ($messages, $new)

Static Protected Member Functions

static get_rule_classes ()
static get_load_sql ($quizid, $rules, $basefields)

Protected Attributes

 $quizobj
 $timenow
 $rules = array()

Detailed Description

This class keeps track of the various access rules that apply to a particular quiz, with convinient methods for seeing whether access is allowed.

Definition at line 37 of file accessmanager.php.


Constructor & Destructor Documentation

__construct ( quizobj,
timenow,
canignoretimelimits 
)

Create an instance for a particular quiz.

Parameters:
object$quizobjAn instance of the class quiz from attemptlib.php. The quiz we will be controlling access to.
int$timenowThe time to use as 'now'.
bool$canignoretimelimitsWhether this user is exempt from time limits (has_capability('mod/quiz:ignoretimelimits', ...)).

Definition at line 53 of file accessmanager.php.

Here is the call graph for this function:


Member Function Documentation

accumulate_messages ( messages,
new 
) [protected]

Accumulates an array of messages.

Parameters:
array$messagesthe current list of messages.
string | array$newthe new messages or messages.
Returns:
array the updated array of messages.

Definition at line 252 of file accessmanager.php.

Here is the caller graph for this function:

static add_settings_form_fields ( mod_quiz_mod_form quizform,
MoodleQuickForm mform 
) [static]

Add any form fields that the access rules require to the settings form.

Note that the standard plugins do not use this mechanism, becuase all their settings are stored in the quiz table.

Parameters:
mod_quiz_mod_form$quizformthe quiz settings form that is being built.
MoodleQuickForm$mformthe wrapped MoodleQuickForm.

Definition at line 105 of file accessmanager.php.

Here is the caller graph for this function:

Returns:
bolean if this quiz should only be shown to students in a popup window.

Definition at line 423 of file accessmanager.php.

Here is the caller graph for this function:

back_to_view_page ( output,
message = '' 
)

Send the user back to the quiz view page. Normally this is just a redirect, but If we were in a secure window, we close this window, and reload the view window we came from.

This method does not return;

Parameters:
mod_quiz_renderer$outputthe quiz renderer.
string$messageoptional message to output while redirecting.

Definition at line 453 of file accessmanager.php.

Here is the call graph for this function:

Inform the rules that the current attempt is finished. This is use, for example by the password rule, to clear the flag in the session.

Definition at line 357 of file accessmanager.php.

Provide a description of the rules that apply to this quiz, such as is shown at the top of the quiz view page. Note that not all rules consider themselves important enough to output a description.

Returns:
array an array of description messages which may be empty. It would be sensible to output each one surrounded by <p> tags.

Definition at line 269 of file accessmanager.php.

Here is the call graph for this function:

Returns:
array the class names of all the active rules. Mainly useful for debugging.

Definition at line 238 of file accessmanager.php.

static get_browser_security_choices ( ) [static]

The the options for the Browser security settings menu.

Returns:
array key => lang string.

Definition at line 118 of file accessmanager.php.

Here is the caller graph for this function:

static get_load_sql ( quizid,
rules,
basefields 
) [static, protected]

Build the SQL for loading all the access settings in one go.

Parameters:
int$quizidthe quiz id.
string$basefieldsinitial part of the select list.
Returns:
array with two elements, the sql and the placeholder values. If $basefields is '' then you must allow for the possibility that there is no data to load, in which case this method returns $sql = ''.

Definition at line 150 of file accessmanager.php.

Here is the caller graph for this function:

Returns:
array any options that are required for showing the attempt page in a popup window.

Definition at line 436 of file accessmanager.php.

Here is the caller graph for this function:

get_preflight_check_form ( moodle_url url,
attemptid 
)

Build the form required to do the pre-flight checks.

Parameters:
moodle_url$urlthe form action URL.
int | null$attemptidthe id of the current attempt, if there is one, otherwise null.
Returns:
mod_quiz_preflight_check_form the form.

Definition at line 335 of file accessmanager.php.

Here is the call graph for this function:

static get_rule_classes ( ) [static, protected]
Returns:
array of all the installed rule class names.

Definition at line 92 of file accessmanager.php.

Here is the call graph for this function:

Here is the caller graph for this function:

is_finished ( numprevattempts,
lastattempt 
)

Do any of the rules mean that this student will no be allowed any further attempts at this quiz. Used, for example, to change the label by the grade displayed on the view page from 'your current grade is' to 'your final grade is'.

Parameters:
int$numattemptsthe number of previous attempts this user has made.
object$lastattemptinformation about the user's last completed attempt.
Returns:
bool true if there is no way the user will ever be allowed to attempt this quiz again.

Definition at line 373 of file accessmanager.php.

is_preflight_check_required ( attemptid)
Parameters:
int | null$attemptidthe id of the current attempt, if there is one, otherwise null.
Returns:
bool whether a check is required before the user starts/continues their attempt.

Definition at line 319 of file accessmanager.php.

static load_quiz_and_settings ( quizid) [static]

Load the quiz settings and any settings required by the access rules. We try to do this with a single DB query.

Note that the standard plugins do not use this mechanism, becuase all their settings are stored in the quiz table.

Parameters:
int$quizidthe quiz id.
Returns:
object mdl_quiz row with extra fields.

Definition at line 218 of file accessmanager.php.

Here is the call graph for this function:

Here is the caller graph for this function:

static load_settings ( quizid) [static]

Load any settings required by the access rules. We try to do this with a single DB query.

Note that the standard plugins do not use this mechanism, becuase all their settings are stored in the quiz table.

Parameters:
int$quizidthe quiz id.
Returns:
array setting value name => value. The value names should all start with the name of the corresponding plugin to avoid collisions.

Definition at line 189 of file accessmanager.php.

Here is the call graph for this function:

Here is the caller graph for this function:

make_review_link ( attempt,
reviewoptions,
output 
)

Make some text into a link to review the quiz, if that is appropriate.

Parameters:
string$linktextsome text.
object$attemptthe attempt object
Returns:
string some HTML, the $linktext either unmodified or wrapped in a link to the review page.

Definition at line 470 of file accessmanager.php.

Here is the call graph for this function:

make_rules ( quizobj,
timenow,
canignoretimelimits 
) [protected]

Make all the rules relevant to a particular quiz.

Parameters:
quiz$quizobjinformation about the quiz in question.
int$timenowthe time that should be considered as 'now'.
bool$canignoretimelimitswhether the current user is exempt from time limits by the mod/quiz:ignoretimelimits capability.
Returns:
array of quiz_access_rule_bases.

Definition at line 67 of file accessmanager.php.

Here is the caller graph for this function:

The pre-flight check has passed. This is a chance to record that fact in some way.

Parameters:
int | null$attemptidthe id of the current attempt, if there is one, otherwise null.

Definition at line 347 of file accessmanager.php.

Whether the user should be blocked from starting a new attempt or continuing an attempt now. If there are any restrictions in force now, return an array of reasons why access should be blocked. If access is OK, return false.

Returns:
mixed An array of reason why access is not allowed, or an empty array (== false) if access should be allowed.

Definition at line 305 of file accessmanager.php.

Here is the call graph for this function:

prevent_new_attempt ( numprevattempts,
lastattempt 
)

Whether or not a user should be allowed to start a new attempt at this quiz now. If there are any restrictions in force now, return an array of reasons why access should be blocked. If access is OK, return false.

Parameters:
int$numattemptsthe number of previous attempts this user has made.
object | false$lastattemptinformation about the user's last completed attempt. if there is not a previous attempt, the false is passed.
Returns:
mixed An array of reason why access is not allowed, or an empty array (== false) if access should be allowed.

Definition at line 288 of file accessmanager.php.

Here is the call graph for this function:

static save_settings ( quiz) [static]

Save any submitted settings when the quiz settings form is submitted.

Note that the standard plugins do not use this mechanism, becuase all their settings are stored in the quiz table.

Parameters:
object$quizthe data from the quiz form, including $quiz->id which is the is of the quiz being saved.

Definition at line 135 of file accessmanager.php.

Here is the caller graph for this function:

setup_attempt_page ( page)

Sets up the attempt (review or summary) page with any properties required by the access rules.

Parameters:
moodle_page$pagethe page object to initialise.

Definition at line 388 of file accessmanager.php.

show_attempt_timer_if_needed ( attempt,
timenow,
output 
)

Will cause the attempt time to start counting down after the page has loaded, if that is necessary.

Parameters:
object$attemptthe data from the relevant quiz_attempts row.
int$timenowthe time to consider as 'now'.
mod_quiz_renderer$outputthe quiz renderer.

Definition at line 402 of file accessmanager.php.


Field Documentation

$quizobj [protected]

Definition at line 39 of file accessmanager.php.

$rules = array() [protected]

Definition at line 43 of file accessmanager.php.

$timenow [protected]

Definition at line 41 of file accessmanager.php.


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