Moodle APIs 4.3
Moodle 4.3.6 (Build: 20240812)

Functions

 build_required_parameters_for_custom_view (array $params, array $extraparams)
 Build required parameters for question bank custom view.
 
 mod_quiz_calculate_question_stats (context $context)
 Implement the calculate_question_stats callback.
 
 mod_quiz_cm_info_dynamic (cm_info $cm)
 Sets dynamic information about a course module.
 
 mod_quiz_core_calendar_event_timestart_updated (\calendar_event $event, stdClass $quiz)
 This function will update the quiz module according to the event that has been modified.
 
 mod_quiz_core_calendar_get_event_action_string (string $eventtype)
 Callback to fetch the activity event type lang string.
 
 mod_quiz_core_calendar_get_valid_event_timestart_range (\calendar_event $event, stdClass $quiz)
 Returns the min and max values for the timestart property of a quiz activity event.
 
 mod_quiz_core_calendar_provide_event_action (calendar_event $event, core_calendar\action_factory $factory, int $userid=0)
 This function receives a calendar event and returns the action associated with it, or null if there is none.
 
 mod_quiz_get_completion_active_rule_descriptions ($cm)
 Callback which returns human-readable strings describing the active completion custom rules for the module instance.
 
 mod_quiz_get_fontawesome_icon_map ()
 Get icon mapping for font-awesome.
 
 mod_quiz_inplace_editable (string $itemtype, int $itemid, string $newvalue)
 In place editable callback for slot displaynumber.
 
 mod_quiz_output_fragment_add_random_question_form ($args)
 Generates the add random question in a fragment output.
 
 mod_quiz_output_fragment_question_data (array $args)
 Question data fragment to get the question html via ajax call.
 
 mod_quiz_output_fragment_quiz_question_bank ($args)
 Generates the question bank in a fragment output.
 
 mod_quiz_user_preferences ()
 Return a list of all the user preferences used by mod_quiz.
 
 quiz_add_instance ($quiz)
 Given an object containing all the necessary data, (defined by the form in mod_form.php) this function will create a new instance and return the id number of the new instance.
 
 quiz_after_add_or_update ($quiz)
 This function is called at the end of quiz_add_instance and quiz_update_instance, to do the common processing.
 
 quiz_allows_multiple_tries ($quiz)
 Does this quiz allow multiple tries?
 
 quiz_attempt_summary_link_to_reports ($quiz, $cm, $context, $returnzero=false, $currentgroup=0)
 Returns the same as quiz_num_attempt_summary() but wrapped in a link to the quiz reports.
 
 quiz_check_updates_since (cm_info $cm, $from, $filter=[])
 Check if the module has any update that affects the current user since a given time.
 
 quiz_delete_all_attempts ($quiz)
 Delete all the attempts belonging to a quiz.
 
 quiz_delete_all_overrides ($quiz, $log=true)
 Deletes all quiz overrides from the database and clears any corresponding calendar events.
 
 quiz_delete_instance ($id)
 Given an ID of an instance of this module, this function will permanently delete the instance and any data that depends on it.
 
 quiz_delete_override ($quiz, $overrideid, $log=true)
 Deletes a quiz override from the database and clears any corresponding calendar events.
 
 quiz_delete_references ($quizid)
 Delete all question references for a quiz.
 
 quiz_delete_user_attempts ($quiz, $user)
 Delete all the attempts belonging to a user in a particular quiz.
 
 quiz_extend_settings_navigation (settings_navigation $settings, navigation_node $quiznode)
 This function extends the settings navigation block for the site.
 
 quiz_format_grade ($quiz, $grade)
 Round a grade to the correct number of decimal places, and format it for display.
 
 quiz_format_question_grade ($quiz, $grade)
 Round a grade to the correct number of decimal places, and format it for display.
 
 quiz_get_best_grade ($quiz, $userid)
 Get the best current grade for a particular user in a quiz.
 
 quiz_get_coursemodule_info ($coursemodule)
 Add a get_coursemodule_info function in case any quiz type wants to add 'extra' information for the course (see resource).
 
 quiz_get_extra_capabilities ()
 
 quiz_get_grade_format ($quiz)
 Determine the correct number of decimal places required to format a grade.
 
 quiz_get_group_override_priorities ($quizid)
 Calculates the priorities of timeopen and timeclose values for group overrides for a quiz.
 
 quiz_get_navigation_options ()
 
 quiz_get_post_actions ()
 List the actions that correspond to a post of this module.
 
 quiz_get_recent_mod_activity (&$activities, &$index, $timestart, $courseid, $cmid, $userid=0, $groupid=0)
 Returns all quiz graded users since a given time for specified quiz.
 
 quiz_get_user_attempts ($quizids, $userid, $status='finished', $includepreviews=false)
 
 quiz_get_user_grades ($quiz, $userid=0)
 Return grade for given user or all users.
 
 quiz_get_view_actions ()
 List the actions that correspond to a view of this module.
 
 quiz_grade_item_delete ($quiz)
 Delete grade item for given quiz.
 
 quiz_grade_item_update ($quiz, $grades=null)
 Create or update the grade item for given quiz.
 
 quiz_has_grades ($quiz)
 Is this a graded quiz? If this method returns true, you can assume that $quiz->grade and $quiz->sumgrades are non-zero (for example, if you want to divide by them).
 
 quiz_num_attempt_summary ($quiz, $cm, $returnzero=false, $currentgroup=0)
 Return a textual summary of the number of attempts that have been made at a particular quiz, returns '' if no attempts have been made yet, unless $returnzero is passed as true.
 
 quiz_page_type_list ($pagetype, $parentcontext, $currentcontext)
 Return a list of page types.
 
 quiz_pluginfile ($course, $cm, $context, $filearea, $args, $forcedownload, array $options=[])
 Serves the quiz files.
 
 quiz_print_recent_mod_activity ($activity, $courseid, $detail, $modnames)
 
 quiz_process_options ($quiz)
 Pre-process the quiz options form data, making any necessary adjustments.
 
 quiz_question_pluginfile ($course, $context, $component, $filearea, $qubaid, $slot, $args, $forcedownload, array $options=[])
 Called via pluginfile.php -> question_pluginfile to serve files belonging to a question in a question_attempt when that attempt is a quiz attempt.
 
 quiz_questions_in_use ($questionids)
 Standard callback used by questions_in_use.
 
 quiz_refresh_events ($courseid=0, $instance=null, $cm=null)
 This standard function will check all instances of this module and make sure there are up-to-date events created for each of them.
 
 quiz_reset_course_form_defaults ($course)
 Course reset form defaults.
 
 quiz_reset_course_form_definition ($mform)
 Implementation of the function for printing the form elements that control whether the course reset functionality affects the quiz.
 
 quiz_reset_gradebook ($courseid, $type='')
 Removes all grades from gradebook.
 
 quiz_reset_userdata ($data)
 Actual implementation of the reset course functionality, delete all the quiz attempts for course $data->courseid, if $data->reset_quiz_attempts is set and true.
 
 quiz_review_option_form_to_db ($fromform, $field)
 Helper function for quiz_process_options().
 
 quiz_supports ($feature)
 
 quiz_update_effective_access ($quiz, $userid)
 Updates a quiz object with override information for a user.
 
 quiz_update_events ($quiz, $override=null)
 This function updates the events associated to the quiz.
 
 quiz_update_grades ($quiz, $userid=0, $nullifnone=true)
 Update grades in central gradebook.
 
 quiz_update_instance ($quiz, $mform)
 Given an object containing all the necessary data, (defined by the form in mod_form.php) this function will update an existing instance with new data.
 
 quiz_user_complete ($course, $user, $mod, $quiz)
 Print a detailed representation of what a user has done with a given particular instance of this module, for user activity reports.
 
 quiz_user_outline ($course, $user, $mod, $quiz)
 Return a small object with summary information about what a user has done with a given particular instance of this module Used for user activity reports.
 

Variables

const QUIZ_ATTEMPTFIRST '3'
 
const QUIZ_ATTEMPTLAST '4'
 
const QUIZ_EVENT_TYPE_CLOSE 'close'
 
const QUIZ_EVENT_TYPE_OPEN 'open'
 #-
 
const QUIZ_GRADEAVERAGE '2'
 
const QUIZ_GRADEHIGHEST '1'
 #-
 
const QUIZ_MAX_ATTEMPT_OPTION 10
 #+ Option controlling what options are offered on the quiz settings form.
 
const QUIZ_MAX_DECIMAL_OPTION 5
 
const QUIZ_MAX_EVENT_LENGTH 5*24*60*60
 #-
 
const QUIZ_MAX_Q_DECIMAL_OPTION 7
 
const QUIZ_MAX_QPP_OPTION 50
 
const QUIZ_NAVMETHOD_FREE 'free'
 #+ Options for navigation method within quizzes.
 
const QUIZ_NAVMETHOD_SEQ 'sequential'
 

Detailed Description

Function Documentation

◆ build_required_parameters_for_custom_view()

build_required_parameters_for_custom_view ( array $params,
array $extraparams )

Build required parameters for question bank custom view.

Parameters
array$paramsthe page parameters
array$extraparamsadditional parameters
Return values
array

◆ mod_quiz_calculate_question_stats()

mod_quiz_calculate_question_stats ( context $context)

Implement the calculate_question_stats callback.

This enables quiz statistics to be shown in statistics columns in the database.

Parameters
context$contextreturn the statistics related to this context (which will be a quiz context).
Return values
all_calculated_for_qubaid_condition|nullThe statistics for this quiz, if available, else null.

◆ mod_quiz_cm_info_dynamic()

mod_quiz_cm_info_dynamic ( cm_info $cm)

Sets dynamic information about a course module.

This function is called from cm_info when displaying the module

Parameters
cm_info$cm

◆ mod_quiz_core_calendar_event_timestart_updated()

mod_quiz_core_calendar_event_timestart_updated ( \calendar_event $event,
stdClass $quiz )

This function will update the quiz module according to the event that has been modified.

It will set the timeopen or timeclose value of the quiz instance according to the type of event provided.

Exceptions
moodle_exception
Parameters
calendar_event$eventA quiz activity calendar event
stdClass$quizA quiz activity instance

◆ mod_quiz_core_calendar_get_event_action_string()

mod_quiz_core_calendar_get_event_action_string ( string $eventtype)

Callback to fetch the activity event type lang string.

Parameters
string$eventtypeThe event type.
Return values
lang_stringThe event type lang string.

◆ mod_quiz_core_calendar_get_valid_event_timestart_range()

mod_quiz_core_calendar_get_valid_event_timestart_range ( \calendar_event $event,
stdClass $quiz )

Returns the min and max values for the timestart property of a quiz activity event.

The min and max values will be the timeopen and timeclose properties of the quiz, respectively, if they are set.

If either value isn't set then null will be returned instead to indicate that there is no cutoff for that value.

If the vent has no valid timestart range then [false, false] will be returned. This is the case for overriden events.

A minimum and maximum cutoff return value will look like: [ [1505704373, 'The date must be after this date'], [1506741172, 'The date must be before this date'] ]

Exceptions
moodle_exception
Parameters
calendar_event$eventThe calendar event to get the time range for
stdClass$quizThe module instance to get the range from
Return values
array

◆ mod_quiz_core_calendar_provide_event_action()

mod_quiz_core_calendar_provide_event_action ( calendar_event $event,
core_calendar\action_factory $factory,
int $userid = 0 )

This function receives a calendar event and returns the action associated with it, or null if there is none.

This is used by block_myoverview in order to display the event appropriately. If null is returned then the event is not displayed on the block.

Parameters
calendar_event$event
core_calendar\action_factory$factory
int$useridUser id to use for all capability checks, etc. Set to 0 for current user (default).
Return values
core_calendar\local\event\entities\action_interface|null

◆ mod_quiz_get_completion_active_rule_descriptions()

mod_quiz_get_completion_active_rule_descriptions ( $cm)

Callback which returns human-readable strings describing the active completion custom rules for the module instance.

Parameters
cm_info | stdClass$cmobject with fields ->completion and ->customdata['customcompletionrules']
Return values
array\$descriptionsthe array of descriptions for the custom rules.

◆ mod_quiz_inplace_editable()

mod_quiz_inplace_editable ( string $itemtype,
int $itemid,
string $newvalue )

In place editable callback for slot displaynumber.

Parameters
string$itemtypeslotdisplarnumber
int$itemidthe id of the slot in the quiz_slots table
string$newvaluethe new value for displaynumber field for a given slot in the quiz_slots table
Return values
core\output\inplace_editable|void

◆ mod_quiz_output_fragment_add_random_question_form()

mod_quiz_output_fragment_add_random_question_form ( $args)

Generates the add random question in a fragment output.

This allows the form to be rendered in javascript, for example inside a modal.

The required arguments as keys in the $args array are: cat {string} The category and category context ids comma separated. addonpage {int} The page id to add this question to. returnurl {string} URL to return to after form submission. cmid {int} The course module id the questions are being added to.

Parameters
array$argsThe fragment arguments.
Return values
stringThe rendered mform fragment.

◆ mod_quiz_output_fragment_question_data()

mod_quiz_output_fragment_question_data ( array $args)

Question data fragment to get the question html via ajax call.

Parameters
array$args
Return values
string

◆ mod_quiz_output_fragment_quiz_question_bank()

mod_quiz_output_fragment_quiz_question_bank ( $args)

Generates the question bank in a fragment output.

This allows the question bank to be displayed in a modal.

The only expected argument provided in the $args array is 'querystring'. The value should be the list of parameters URL encoded and used to build the question bank page.

The individual list of parameters expected can be found in question_build_edit_resources.

Parameters
array$argsThe fragment arguments.
Return values
stringThe rendered mform fragment.

◆ mod_quiz_user_preferences()

mod_quiz_user_preferences ( )

Return a list of all the user preferences used by mod_quiz.

@uses core_user\is_current_user

Return values
array[]

◆ quiz_add_instance()

quiz_add_instance ( $quiz)

Given an object containing all the necessary data, (defined by the form in mod_form.php) this function will create a new instance and return the id number of the new instance.

Parameters
stdClass$quizthe data that came from the form.
Return values
mixedthe id of the new instance on success, false or a string error message on failure.

◆ quiz_after_add_or_update()

quiz_after_add_or_update ( $quiz)

This function is called at the end of quiz_add_instance and quiz_update_instance, to do the common processing.

Parameters
stdClass$quizthe quiz object.

◆ quiz_allows_multiple_tries()

quiz_allows_multiple_tries ( $quiz)

Does this quiz allow multiple tries?

Return values
bool

◆ quiz_attempt_summary_link_to_reports()

quiz_attempt_summary_link_to_reports ( $quiz,
$cm,
$context,
$returnzero = false,
$currentgroup = 0 )

Returns the same as quiz_num_attempt_summary() but wrapped in a link to the quiz reports.

Parameters
stdClass$quizthe quiz object. Only $quiz->id is used at the moment.
stdClass$cmthe cm object. Only $cm->course, $cm->groupmode and $cm->groupingid fields are used at the moment.
stdClass$contextthe quiz context.
bool$returnzeroif false (default), when no attempts have been made '' is returned instead of 'Attempts: 0'.
int$currentgroupif there is a concept of current group where this method is being called (e.g. a report) pass it in here. Default 0 which means no current group.
Return values
stringHTML fragment for the link.

◆ quiz_check_updates_since()

quiz_check_updates_since ( cm_info $cm,
$from,
$filter = [] )

Check if the module has any update that affects the current user since a given time.

Parameters
cm_info$cmcourse module data
int$fromthe time to check updates from
array$filterif we need to check only specific updates
Return values
stdClassan object with the different type of areas indicating if they were updated or not
Since
Moodle 3.2

◆ quiz_delete_all_attempts()

quiz_delete_all_attempts ( $quiz)

Delete all the attempts belonging to a quiz.

Parameters
stdClass$quizThe quiz object.

◆ quiz_delete_all_overrides()

quiz_delete_all_overrides ( $quiz,
$log = true )

Deletes all quiz overrides from the database and clears any corresponding calendar events.

Parameters
stdClass$quizThe quiz object.
bool$logWhether to trigger logs.

◆ quiz_delete_instance()

quiz_delete_instance ( $id)

Given an ID of an instance of this module, this function will permanently delete the instance and any data that depends on it.

Parameters
int$idthe id of the quiz to delete.
Return values
boolsuccess or failure.

◆ quiz_delete_override()

quiz_delete_override ( $quiz,
$overrideid,
$log = true )

Deletes a quiz override from the database and clears any corresponding calendar events.

Parameters
stdClass$quizThe quiz object.
int$overrideidThe id of the override being deleted
bool$logWhether to trigger logs.
Return values
booltrue on success

◆ quiz_delete_references()

quiz_delete_references ( $quizid)

Delete all question references for a quiz.

Parameters
int$quizidThe id of quiz.

◆ quiz_delete_user_attempts()

quiz_delete_user_attempts ( $quiz,
$user )

Delete all the attempts belonging to a user in a particular quiz.

Parameters
mod_quiz\quiz_settings$quizThe quiz object.
stdClass$userThe user object.

◆ quiz_extend_settings_navigation()

quiz_extend_settings_navigation ( settings_navigation $settings,
navigation_node $quiznode )

This function extends the settings navigation block for the site.

It is safe to rely on PAGE here as we will only ever be within the module context when this is called

Parameters
settings_navigation$settings
navigation_node$quiznode
Return values
void

◆ quiz_format_grade()

quiz_format_grade ( $quiz,
$grade )

Round a grade to the correct number of decimal places, and format it for display.

Parameters
stdClass$quizThe quiz table row, only $quiz->decimalpoints is used.
float$gradeThe grade to round.
Return values
string

◆ quiz_format_question_grade()

quiz_format_question_grade ( $quiz,
$grade )

Round a grade to the correct number of decimal places, and format it for display.

Parameters
stdClass$quizThe quiz table row, only $quiz->decimalpoints is used.
float$gradeThe grade to round.
Return values
string

◆ quiz_get_best_grade()

quiz_get_best_grade ( $quiz,
$userid )

Get the best current grade for a particular user in a quiz.

Parameters
stdClass$quizthe quiz settings.
int$useridthe id of the user.
Return values
floatthe user's current grade for this quiz, or null if this user does not have a grade on this quiz.

◆ quiz_get_coursemodule_info()

quiz_get_coursemodule_info ( $coursemodule)

Add a get_coursemodule_info function in case any quiz type wants to add 'extra' information for the course (see resource).

Given a course_module object, this function returns any "extra" information that may be needed when printing this activity in a course listing. See get_array_of_activities() in course/lib.php.

Parameters
stdClass$coursemoduleThe coursemodule object (record).
Return values
cached_cm_info|falseAn object on information that the courses will know about (most noticeably, an icon).

◆ quiz_get_extra_capabilities()

quiz_get_extra_capabilities ( )
Return values
arrayall other caps used in module

◆ quiz_get_grade_format()

quiz_get_grade_format ( $quiz)

Determine the correct number of decimal places required to format a grade.

Parameters
stdClass$quizThe quiz table row, only $quiz->decimalpoints and ->questiondecimalpoints are used.
Return values
integer

◆ quiz_get_group_override_priorities()

quiz_get_group_override_priorities ( $quizid)

Calculates the priorities of timeopen and timeclose values for group overrides for a quiz.

Parameters
int$quizidThe quiz ID.
Return values
array|nullArray of group override priorities for open and close times. Null if there are no group overrides.

◆ quiz_get_navigation_options()

quiz_get_navigation_options ( )
Return values
theoptions for quiz navigation.

◆ quiz_get_post_actions()

quiz_get_post_actions ( )

List the actions that correspond to a post of this module.

This is used by the participation report.

Note: This is not used by new logging system. Event with crud = ('c' || 'u' || 'd') and edulevel = LEVEL_PARTICIPATING will be considered as post action.

Return values
array

◆ quiz_get_user_attempts()

quiz_get_user_attempts ( $quizids,
$userid,
$status = 'finished',
$includepreviews = false )
Parameters
int | array$quizidsA quiz ID, or an array of quiz IDs.
int$useridthe userid.
string$status'all', 'finished' or 'unfinished' to control
bool$includepreviews
Return values
arrayof all the user's attempts at this quiz. Returns an empty array if there are none.

◆ quiz_get_user_grades()

quiz_get_user_grades ( $quiz,
$userid = 0 )

Return grade for given user or all users.

Parameters
int$quizidid of quiz
int$useridoptional user id, 0 means all users
Return values
arrayarray of grades, false if none. These are raw grades. They should be processed with quiz_format_grade for display.

◆ quiz_get_view_actions()

quiz_get_view_actions ( )

List the actions that correspond to a view of this module.

This is used by the participation report.

Note: This is not used by new logging system. Event with crud = 'r' and edulevel = LEVEL_PARTICIPATING will be considered as view action.

Return values
array

◆ quiz_grade_item_delete()

quiz_grade_item_delete ( $quiz)

Delete grade item for given quiz.

Parameters
stdClass$quizobject
Return values
int

◆ quiz_grade_item_update()

quiz_grade_item_update ( $quiz,
$grades = null )

Create or update the grade item for given quiz.

Parameters
stdClass$quizobject with extra cmidnumber
mixed$gradesoptional array/object of grade(s); 'reset' means reset grades in gradebook
Return values
int0 if ok, error code otherwise

◆ quiz_has_grades()

quiz_has_grades ( $quiz)

Is this a graded quiz? If this method returns true, you can assume that $quiz->grade and $quiz->sumgrades are non-zero (for example, if you want to divide by them).

Parameters
stdClass$quiza row from the quiz table.
Return values
boolwhether this is a graded quiz.

◆ quiz_num_attempt_summary()

quiz_num_attempt_summary ( $quiz,
$cm,
$returnzero = false,
$currentgroup = 0 )

Return a textual summary of the number of attempts that have been made at a particular quiz, returns '' if no attempts have been made yet, unless $returnzero is passed as true.

Parameters
stdClass$quizthe quiz object. Only $quiz->id is used at the moment.
stdClass$cmthe cm object. Only $cm->course, $cm->groupmode and $cm->groupingid fields are used at the moment.
bool$returnzeroif false (default), when no attempts have been made '' is returned instead of 'Attempts: 0'.
int$currentgroupif there is a concept of current group where this method is being called (e.g. a report) pass it in here. Default 0 which means no current group.
Return values
stringa string like "Attempts: 123", "Attemtps 123 (45 from your groups)" or "Attemtps 123 (45 from this group)".

◆ quiz_page_type_list()

quiz_page_type_list ( $pagetype,
$parentcontext,
$currentcontext )

Return a list of page types.

Parameters
string$pagetypecurrent page type
stdClass$parentcontextBlock's parent context
stdClass$currentcontextCurrent context of block

◆ quiz_pluginfile()

quiz_pluginfile ( $course,
$cm,
$context,
$filearea,
$args,
$forcedownload,
array $options = [] )

Serves the quiz files.

Parameters
stdClass$coursecourse object
stdClass$cmcourse module object
stdClass$contextcontext object
string$fileareafile area
array$argsextra arguments
bool$forcedownloadwhether or not force download
array$optionsadditional options affecting the file serving
Return values
boolfalse if file not found, does not return if found - justsend the file

◆ quiz_process_options()

quiz_process_options ( $quiz)

Pre-process the quiz options form data, making any necessary adjustments.

Called by add/update instance in this file.

Parameters
stdClass$quizThe variables set on the form.

◆ quiz_question_pluginfile()

quiz_question_pluginfile ( $course,
$context,
$component,
$filearea,
$qubaid,
$slot,
$args,
$forcedownload,
array $options = [] )

Called via pluginfile.php -> question_pluginfile to serve files belonging to a question in a question_attempt when that attempt is a quiz attempt.

Parameters
stdClass$coursecourse settings object
stdClass$contextcontext object
string$componentthe name of the component we are serving files for.
string$fileareathe name of the file area.
int$qubaidthe attempt usage id.
int$slotthe id of a question in this quiz attempt.
array$argsthe remaining bits of the file path.
bool$forcedownloadwhether the user must be forced to download the file.
array$optionsadditional options affecting the file serving
Return values
boolfalse if file not found, does not return if found - justsend the file

◆ quiz_questions_in_use()

quiz_questions_in_use ( $questionids)

Standard callback used by questions_in_use.

Parameters
array$questionidsof question ids.
Return values
boolwhether any of these questions are used by any instance of this module.

◆ quiz_refresh_events()

quiz_refresh_events ( $courseid = 0,
$instance = null,
$cm = null )

This standard function will check all instances of this module and make sure there are up-to-date events created for each of them.

If courseid = 0, then every quiz event in the site is checked, else only quiz events belonging to the course specified are checked. This function is used, in its new format, by restore_refresh_events()

Parameters
int$courseid
int | stdClass$instanceQuiz module instance or ID.
int | stdClass$cmCourse module object or ID (not used in this module).
Return values
bool

◆ quiz_reset_course_form_defaults()

quiz_reset_course_form_defaults ( $course)

Course reset form defaults.

Return values
arraythe defaults.

◆ quiz_reset_course_form_definition()

quiz_reset_course_form_definition ( $mform)

Implementation of the function for printing the form elements that control whether the course reset functionality affects the quiz.

Parameters
MoodleQuickForm$mformthe course reset form that is being built.

◆ quiz_reset_gradebook()

quiz_reset_gradebook ( $courseid,
$type = '' )

Removes all grades from gradebook.

Parameters
int$courseid
stringoptional type

◆ quiz_reset_userdata()

quiz_reset_userdata ( $data)

Actual implementation of the reset course functionality, delete all the quiz attempts for course $data->courseid, if $data->reset_quiz_attempts is set and true.

Also, move the quiz open and close dates, if the course start date is changing.

Parameters
stdClass$datathe data submitted from the reset course.
Return values
arraystatus array

◆ quiz_review_option_form_to_db()

quiz_review_option_form_to_db ( $fromform,
$field )

Helper function for quiz_process_options().

Parameters
stdClass$fromformthe sumbitted form date.
string$fieldone of the review option field names.

◆ quiz_supports()

quiz_supports ( $feature)
Parameters
string$featureFEATURE_xx constant for requested feature
Return values
mixedTrue if module supports feature, false if not, null if doesn't know or string for the module purpose.

◆ quiz_update_effective_access()

quiz_update_effective_access ( $quiz,
$userid )

Updates a quiz object with override information for a user.

Algorithm: For each quiz setting, if there is a matching user-specific override, then use that otherwise, if there are group-specific overrides, return the most lenient combination of them. If neither applies, leave the quiz setting unchanged.

Special case: if there is more than one password that applies to the user, then quiz->extrapasswords will contain an array of strings giving the remaining passwords.

Parameters
stdClass$quizThe quiz object.
int$useridThe userid.
Return values
stdClass\$quizThe updated quiz object.

◆ quiz_update_events()

quiz_update_events ( $quiz,
$override = null )

This function updates the events associated to the quiz.

If $override is non-zero, then it updates only the events associated with the specified override.

Parameters
stdClass$quizthe quiz object.
stdClass | null$overridelimit to a specific override

◆ quiz_update_grades()

quiz_update_grades ( $quiz,
$userid = 0,
$nullifnone = true )

Update grades in central gradebook.

Parameters
stdClass$quizthe quiz settings.
int$useridspecific user only, 0 means all users.
bool$nullifnoneIf a single user is specified and $nullifnone is true a grade item with a null rawgrade will be inserted

◆ quiz_update_instance()

quiz_update_instance ( $quiz,
$mform )

Given an object containing all the necessary data, (defined by the form in mod_form.php) this function will update an existing instance with new data.

Parameters
stdClass$quizthe data that came from the form.
stdClass$mformno longer used.
Return values
mixedtrue on success, false or a string error message on failure.

◆ quiz_user_complete()

quiz_user_complete ( $course,
$user,
$mod,
$quiz )

Print a detailed representation of what a user has done with a given particular instance of this module, for user activity reports.

Parameters
stdClass$course
stdClass$user
stdClass$mod
stdClass$quiz
Return values
bool

◆ quiz_user_outline()

quiz_user_outline ( $course,
$user,
$mod,
$quiz )

Return a small object with summary information about what a user has done with a given particular instance of this module Used for user activity reports.

$return->time = the time they did it $return->info = a short text description

Parameters
stdClass$course
stdClass$user
stdClass$mod
stdClass$quiz
Return values
stdClass|null

Variable Documentation

◆ QUIZ_EVENT_TYPE_OPEN

const QUIZ_EVENT_TYPE_OPEN 'open'

#-

Event types.

◆ QUIZ_GRADEHIGHEST

const QUIZ_GRADEHIGHEST '1'

#-

#+ Options determining how the grades from individual attempts are combined to give the overall grade for a user

◆ QUIZ_MAX_EVENT_LENGTH

const QUIZ_MAX_EVENT_LENGTH 5*24*60*60

#-

If start and end date for the quiz are more than this many seconds apart they will be represented by two separate events in the calendar