|
Moodle
2.2.1
http://www.collinsharper.com
|
Go to the source code of this file.
We show the countdown timer if there is less than this amount of time left before the the quiz close date. (1 hour)
Definition at line 49 of file locallib.php.
| quiz_attempt_state | ( | $ | quiz, |
| $ | attempt | ||
| ) |
Work out what state this quiz attempt is in.
| object | $quiz | the quiz settings |
| object | $attempt | the quiz_attempt database row. |
Definition at line 937 of file locallib.php.

| quiz_attempt_submitted_handler | ( | $ | event | ) |
Handle the quiz_attempt_submitted event.
This sends the confirmation and notification messages, if required.
| object | $event | the event object. |
Definition at line 1276 of file locallib.php.

| quiz_calculate_best_attempt | ( | $ | quiz, |
| $ | attempts | ||
| ) |
Return the attempt with the best grade for a quiz
Which attempt is the best depends on $quiz->grademethod. If the grade method is GRADEAVERAGE then this function simply returns the last attempt.
| object | $quiz | The quiz for which the best grade is to be calculated |
| array | $attempts | An array of all the attempts of the user at the quiz |
Definition at line 747 of file locallib.php.
| quiz_calculate_best_grade | ( | $ | quiz, |
| $ | attempts | ||
| ) |
Calculate the overall grade for a quiz given a number of attempts by a particular user.
| object | $quiz | the quiz settings object. |
| array | $attempts | an array of all the user's attempts at this quiz in order. |
Definition at line 554 of file locallib.php.

| quiz_clean_layout | ( | $ | layout, |
| $ | removeemptypages = false |
||
| ) |
Clean the question layout from various possible anomalies:
| $string | $layout the quiz layout to clean up, usually from $quiz->questions. | |
| bool | $removeemptypages | If true, remove empty pages from the quiz. False by default. |
Definition at line 1047 of file locallib.php.

| quiz_create_attempt | ( | $ | quiz, |
| $ | attemptnumber, | ||
| $ | lastattempt, | ||
| $ | timenow, | ||
| $ | ispreview = false |
||
| ) |
Functions related to attempts /////////////////////////////////////////.
Creates an object to represent a new attempt at a quiz
Creates an attempt object to represent an attempt at the quiz by the current user starting at the current time. The ->id field is not set. The object is NOT written to the database.
| object | $quiz | the quiz to create an attempt for. |
| int | $attemptnumber | the sequence number for the attempt. |
| object | $lastattempt | the previous attempt by this user, if any. Only needed if $attemptnumber > 1 and $quiz->attemptonlast is true. |
| int | $timenow | the time the attempt was started at. |
| bool | $ispreview | whether this new attempt is a preview. |
Definition at line 69 of file locallib.php.

| quiz_delete_attempt | ( | $ | attempt, |
| $ | quiz | ||
| ) |
Delete a quiz attempt.
| mixed | $attempt | an integer attempt id or an attempt object (row of the quiz_attempts table). |
| object | $quiz | the quiz object. |
Definition at line 132 of file locallib.php.


| quiz_delete_previews | ( | $ | quiz, |
| $ | userid = null |
||
| ) |
Delete all the preview attempts at a quiz, or possibly all the attempts belonging to one user.
| object | $quiz | the quiz object. |
| int | $userid | (optional) if given, only delete the previews belonging to this user. |
Definition at line 168 of file locallib.php.


| quiz_feedback_for_grade | ( | $ | grade, |
| $ | quiz, | ||
| $ | context | ||
| ) |
Get the feedback text that should be show to a student who got this grade on this quiz. The feedback is processed ready for diplay.
| float | $grade | a grade on this quiz. |
| object | $quiz | the quiz settings. |
| object | $context | the quiz context. |
Definition at line 349 of file locallib.php.


| quiz_get_all_question_grades | ( | $ | quiz | ) |
Functions to do with quiz grades //////////////////////////////////////////.
Creates an array of maximum grades for a quiz
The grades are extracted from the quiz_question_instances table.
| object | $quiz | The quiz settings. |
Definition at line 280 of file locallib.php.

| quiz_get_combined_reviewoptions | ( | $ | quiz, |
| $ | attempts | ||
| ) |
Combines the review options from a number of different quiz attempts. Returns an array of two ojects, so the suggested way of calling this funciton is: list($someoptions, $alloptions) = quiz_get_combined_reviewoptions(...)
| object | $quiz | the quiz instance. |
| array | $attempts | an array of attempt objects. |
| $context | the roles and permissions context, normally the context for the quiz module instance. |
Definition at line 1012 of file locallib.php.

| quiz_get_flag_option | ( | $ | attempt, |
| $ | context | ||
| ) |
| object | $attempt | the attempt. |
| object | $context | the quiz context. |
Definition at line 919 of file locallib.php.


| quiz_get_grading_option_name | ( | $ | option | ) |
| int | $option | one of the values QUIZ_GRADEHIGHEST, QUIZ_GRADEAVERAGE, QUIZ_ATTEMPTFIRST or QUIZ_ATTEMPTLAST. |
Definition at line 794 of file locallib.php.


Definition at line 780 of file locallib.php.

| quiz_get_review_options | ( | $ | quiz, |
| $ | attempt, | ||
| $ | context | ||
| ) |
The the appropraite mod_quiz_display_options object for this attempt at this quiz right now.
| object | $quiz | the quiz instance. |
| object | $attempt | the attempt in question. |
| $context | the quiz context. |
Definition at line 959 of file locallib.php.


| quiz_get_slot_for_question | ( | $ | quiz, |
| $ | questionid | ||
| ) |
Get the slot for a question with a particular id.
| object | $quiz | the quiz settings. |
| int | $questionid | the of a question in the quiz. |
Definition at line 1093 of file locallib.php.


| quiz_get_user_attempt_unfinished | ( | $ | quizid, |
| $ | userid | ||
| ) |
Returns an unfinished attempt (if there is one) for the given user on the given quiz. This function does not return preview attempts.
| int | $quizid | the id of the quiz. |
| int | $userid | the id of the user. |
Definition at line 117 of file locallib.php.

| quiz_has_attempts | ( | $ | quizid | ) |
| int | $quizid | The quiz id. |
Definition at line 184 of file locallib.php.

| quiz_has_feedback | ( | $ | quiz | ) |
| object | $quiz | the quiz database row. |
Definition at line 381 of file locallib.php.


| quiz_number_of_pages | ( | $ | layout | ) |
Returns the number of pages in a quiz layout
| string | $layout | The string representing the quiz layout. Always ends in ,0 |
Definition at line 215 of file locallib.php.

| quiz_number_of_questions_in_quiz | ( | $ | layout | ) |
Returns the number of questions in the quiz layout
| string | $layout | the string representing the quiz layout. |
Definition at line 225 of file locallib.php.


| quiz_question_action_icons | ( | $ | quiz, |
| $ | cmid, | ||
| $ | question, | ||
| $ | returnurl | ||
| ) |
Other quiz functions ////////////////////////////////////////////////////.
| object | $quiz | the quiz. |
| int | $cmid | the course_module object for this quiz. |
| object | $question | the question. |
| string | $returnurl | url to return to after action is done. |
Definition at line 809 of file locallib.php.


| quiz_question_edit_button | ( | $ | cmid, |
| $ | question, | ||
| $ | returnurl, | ||
| $ | contentaftericon = '' |
||
| ) |
| int | $cmid | the course_module.id for this quiz. |
| object | $question | the question. |
| string | $returnurl | url to return to after action is done. |
| string | $contentbeforeicon | some HTML content to be added inside the link, before the icon. |
Definition at line 823 of file locallib.php.


| quiz_question_preview_button | ( | $ | quiz, |
| $ | question, | ||
| $ | label = false |
||
| ) |
| object | $quiz | the quiz settings |
| object | $question | the question |
| bool | $label | if true, show the preview question label after the icon |
Definition at line 890 of file locallib.php.


| quiz_question_preview_url | ( | $ | quiz, |
| $ | question | ||
| ) |
| object | $quiz | the quiz settings |
| object | $question | the question |
Definition at line 869 of file locallib.php.


| quiz_questions_in_quiz | ( | $ | layout | ) |
Functions to do with quiz layout and pages ////////////////////////////////.
Returns a comma separated list of question ids for the quiz
| string | $layout | The string representing the quiz layout. Each page is represented as a comma separated list of question ids and 0 indicating page breaks. So 5,2,0,3,0 means questions 5 and 2 on page 1 and question 3 on page 2 |
Definition at line 200 of file locallib.php.


| quiz_repaginate | ( | $ | layout, |
| $ | perpage, | ||
| $ | shuffle = false |
||
| ) |
Re-paginates the quiz layout
| string | $layout | The string representing the quiz layout. If there is if there is any doubt about the quality of the input data, call quiz_clean_layout before you call this function. |
| int | $perpage | The number of questions per page |
| bool | $shuffle | Should the questions be reordered randomly? |
Definition at line 244 of file locallib.php.


| quiz_rescale_grade | ( | $ | rawgrade, |
| $ | quiz, | ||
| $ | format = true |
||
| ) |
Convert the raw grade stored in $attempt into a grade out of the maximum grade for this quiz.
| float | $rawgrade | the unadjusted grade, fof example $attempt->sumgrades |
| object | $quiz | the quiz object. Only the fields grade, sumgrades and decimalpoints are used. |
| bool | string | $format | whether to format the results for display or 'question' to format a question grade (different number of decimal places. |
Definition at line 324 of file locallib.php.


| quiz_save_best_grade | ( | $ | quiz, |
| $ | userid = null, |
||
| $ | attempts = array() |
||
| ) |
Save the overall grade for a user at a quiz in the quiz_grades table
| object | $quiz | The quiz for which the best grade is to be calculated and then saved. |
| int | $userid | The userid to calculate the grade for. Defaults to the current user. |
| array | $attempts | The attempts of this user. Useful if you are looping through many users. Attempts can be fetched in one master query to avoid repeated querying. |
Definition at line 510 of file locallib.php.


| quiz_send_confirmation | ( | $ | recipient, |
| $ | a | ||
| ) |
FUNCTIONS FOR SENDING NOTIFICATION MESSAGES ///////////////////////////////.
Sends a confirmation message to the student confirming that the attempt was processed.
| object | $a | lots of useful information that can be used in the message subject and body. |
Definition at line 1113 of file locallib.php.


| quiz_send_notification | ( | $ | recipient, |
| $ | submitter, | ||
| $ | a | ||
| ) |
Sends notification messages to the interested parties that assign the role capability
| object | $recipient | user object of the intended recipient |
| object | $a | associative array of replaceable fields for the templates |
Definition at line 1149 of file locallib.php.


| quiz_send_notification_messages | ( | $ | course, |
| $ | quiz, | ||
| $ | attempt, | ||
| $ | context, | ||
| $ | cm | ||
| ) |
Send all the requried messages when a quiz attempt is submitted.
| object | $course | the course |
| object | $quiz | the quiz |
| object | $attempt | this attempt just finished |
| object | $context | the quiz context |
| object | $cm | the coursemodule for this quiz |
Definition at line 1188 of file locallib.php.


| quiz_set_grade | ( | $ | newgrade, |
| $ | quiz | ||
| ) |
The quiz grade is the maximum that student's results are marked out of. When it changes, the corresponding data in quiz_grades and quiz_feedback needs to be rescaled. After calling this function, you probably need to call quiz_update_all_attempt_sumgrades, quiz_update_all_final_grades and quiz_update_grades.
| float | $newgrade | the new maximum grade for the quiz. |
| object | $quiz | the quiz we are updating. Passed by reference so its grade field can be updated too. |
Definition at line 455 of file locallib.php.


| quiz_update_all_attempt_sumgrades | ( | $ | quiz | ) |
Update the sumgrades field of the attempts at a quiz.
| object | $quiz | a quiz. |
Definition at line 428 of file locallib.php.

| quiz_update_all_final_grades | ( | $ | quiz | ) |
Update the final grade at this quiz for all students.
This function is equivalent to calling quiz_save_best_grade for all users, but much more efficient.
| object | $quiz | the quiz settings. |
Definition at line 600 of file locallib.php.

| quiz_update_sumgrades | ( | $ | quiz | ) |
Update the sumgrades field of the quiz. This needs to be called whenever the grading structure of the quiz is changed. For example if a question is added or removed, or a question weight is changed.
You should call quiz_delete_previews() before you call this function.
| object | $quiz | a quiz. |
Definition at line 402 of file locallib.php.

