|
Moodle
2.2.1
http://www.collinsharper.com
|
Public Member Functions | |
| __construct ($quiz, $cm, $course, $getcontext=true) | |
| preload_questions () | |
| load_questions ($questionids=null) | |
| get_courseid () | |
| get_course () | |
| get_quizid () | |
| get_quiz () | |
| get_quiz_name () | |
| get_num_attempts_allowed () | |
| get_cmid () | |
| get_cm () | |
| get_context () | |
| is_preview_user () | |
| has_questions () | |
| get_question ($id) | |
| get_questions ($questionids=null) | |
| get_access_manager ($timenow) | |
| has_capability ($capability, $userid=null, $doanything=true) | |
| require_capability ($capability, $userid=null, $doanything=true) | |
| view_url () | |
| edit_url () | |
| attempt_url ($attemptid, $page=0) | |
| start_attempt_url ($page=0) | |
| review_url ($attemptid) | |
| confirm_start_attempt_message ($unfinished) | |
| cannot_review_message ($when, $short=false) | |
| navigation ($title) | |
Static Public Member Functions | |
| static | create ($quizid, $userid) |
Protected Member Functions | |
| ensure_question_loaded ($id) | |
Protected Attributes | |
| $course | |
| $cm | |
| $quiz | |
| $context | |
| $questionids | |
| $questions = null | |
| $accessmanager = null | |
| $ispreviewuser = null | |
A class encapsulating a quiz and the questions it contains, and making the information available to scripts like view.php.
Initially, it only loads a minimal amout of information about each question - loading extra information only when necessary or when asked. The class tracks which questions are loaded.
Definition at line 63 of file attemptlib.php.
| __construct | ( | $ | quiz, |
| $ | cm, | ||
| $ | course, | ||
| $ | getcontext = true |
||
| ) |
Constructor, assuming we already have the necessary data loaded.
| object | $quiz | the row from the quiz table. |
| object | $cm | the course_module object for this quiz. |
| object | $course | the row from the course table for the course we belong to. |
| bool | $getcontext | intended for testing - stops the constructor getting the context. |
Definition at line 85 of file attemptlib.php.

| attempt_url | ( | $ | attemptid, |
| $ | page = 0 |
||
| ) |
| int | $attemptid | the id of an attempt. |
| int | $page | optional page number to go to in the attempt. |
Definition at line 294 of file attemptlib.php.
| cannot_review_message | ( | $ | when, |
| $ | short = false |
||
| ) |
If $reviewoptions->attempt is false, meaning that students can't review this attempt at the moment, return an appropriate string explaining why.
| int | $when | One of the mod_quiz_display_options::DURING, IMMEDIATELY_AFTER, LATER_WHILE_OPEN or AFTER_CLOSE constants. |
| bool | $short | if true, return a shorter string. |
Definition at line 354 of file attemptlib.php.


| confirm_start_attempt_message | ( | $ | unfinished | ) |
| bool | $unfinished | whether there is currently an unfinished attempt active. |
Definition at line 329 of file attemptlib.php.
| static create | ( | $ | quizid, |
| $ | userid | ||
| ) | [static] |
Static function to create a new quiz object for a specific user.
| int | $quizid | the the quiz id. |
| int | $userid | the the userid. |
Definition at line 108 of file attemptlib.php.

| edit_url | ( | ) |
Definition at line 284 of file attemptlib.php.

| ensure_question_loaded | ( | $ | id | ) | [protected] |
Check that the definition of a particular question is loaded, and if not throw an exception.
| $id | a questionid. |
Definition at line 392 of file attemptlib.php.

| get_access_manager | ( | $ | timenow | ) |
| int | $timenow | the current time as a unix timestamp. |
Definition at line 250 of file attemptlib.php.

| get_cm | ( | ) |
Definition at line 192 of file attemptlib.php.

| get_cmid | ( | ) |
Definition at line 187 of file attemptlib.php.
| get_context | ( | ) |
Definition at line 197 of file attemptlib.php.
| get_course | ( | ) |
Definition at line 162 of file attemptlib.php.
| get_courseid | ( | ) |
Definition at line 157 of file attemptlib.php.
Definition at line 182 of file attemptlib.php.

| get_question | ( | $ | id | ) |
| int | $id | the question id. |
Definition at line 223 of file attemptlib.php.
| get_questions | ( | $ | questionids = null | ) |
| array | $questionids | question ids of the questions to load. null for all. |
Definition at line 230 of file attemptlib.php.

| get_quiz | ( | ) |
Definition at line 172 of file attemptlib.php.

| get_quiz_name | ( | ) |
Definition at line 177 of file attemptlib.php.
| get_quizid | ( | ) |
Definition at line 167 of file attemptlib.php.
| has_capability | ( | $ | capability, |
| $ | userid = null, |
||
| $ | doanything = true |
||
| ) |
Wrapper round the has_capability funciton that automatically passes in the quiz context.
Definition at line 261 of file attemptlib.php.

| has_questions | ( | ) |
Definition at line 215 of file attemptlib.php.

| is_preview_user | ( | ) |
Definition at line 205 of file attemptlib.php.

| load_questions | ( | $ | questionids = null | ) |
Fully load some or all of the questions for this quiz. You must call preload_questions() first.
| array | $questionids | question ids of the questions to load. null for all. |
Definition at line 142 of file attemptlib.php.

| navigation | ( | $ | title | ) |
| string | $title | the name of this particular quiz page. |
Definition at line 381 of file attemptlib.php.
Load just basic information about all the questions in this quiz.
Definition at line 126 of file attemptlib.php.

| require_capability | ( | $ | capability, |
| $ | userid = null, |
||
| $ | doanything = true |
||
| ) |
Wrapper round the require_capability funciton that automatically passes in the quiz context.
Definition at line 268 of file attemptlib.php.
| review_url | ( | $ | attemptid | ) |
| int | $attemptid | the id of an attempt. |
Definition at line 318 of file attemptlib.php.
| start_attempt_url | ( | $ | page = 0 | ) |
Definition at line 306 of file attemptlib.php.

| view_url | ( | ) |
Definition at line 276 of file attemptlib.php.

$accessmanager = null [protected] |
Definition at line 73 of file attemptlib.php.
$cm [protected] |
Definition at line 66 of file attemptlib.php.
$context [protected] |
Definition at line 68 of file attemptlib.php.
$course [protected] |
Definition at line 65 of file attemptlib.php.
$ispreviewuser = null [protected] |
Definition at line 74 of file attemptlib.php.
$questionids [protected] |
Definition at line 69 of file attemptlib.php.
$questions = null [protected] |
Definition at line 72 of file attemptlib.php.
$quiz [protected] |
Definition at line 67 of file attemptlib.php.