Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Functions | Variables
lib.php File Reference

Library of functions for the quiz module. More...

Functions

 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. More...
 
 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. More...
 
 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. More...
 
 mod_quiz_get_completion_active_rule_descriptions ($cm)
 Callback which returns human-readable strings describing the active completion custom rules for the module instance. More...
 
 mod_quiz_get_fontawesome_icon_map ()
 Get icon mapping for font-awesome.
 
 mod_quiz_output_fragment_add_random_question_form ($args)
 Generates the add random question in a fragment output. More...
 
 mod_quiz_output_fragment_quiz_question_bank ($args)
 Generates the question bank in a fragment output. More...
 
 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. More...
 
 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. More...
 
 quiz_allows_multiple_tries ($quiz)
 Does this quiz allow multiple tries? More...
 
 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. More...
 
 quiz_check_updates_since (cm_info $cm, $from, $filter=array())
 Check if the module has any update that affects the current user since a given time. More...
 
 quiz_delete_all_attempts ($quiz)
 Delete all the attempts belonging to a quiz. More...
 
 quiz_delete_all_overrides ($quiz, $log=true)
 Deletes all quiz overrides from the database and clears any corresponding calendar events. More...
 
 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. More...
 
 quiz_delete_override ($quiz, $overrideid, $log=true)
 Deletes a quiz override from the database and clears any corresponding calendar events. More...
 
 quiz_delete_user_attempts ($quiz, $user)
 Delete all the attempts belonging to a user in a particular quiz. More...
 
 quiz_extend_settings_navigation ($settings, $quiznode)
 This function extends the settings navigation block for the site. More...
 
 quiz_format_grade ($quiz, $grade)
 Round a grade to to the correct number of decimal places, and format it for display. More...
 
 quiz_format_question_grade ($quiz, $grade)
 Round a grade to the correct number of decimal places, and format it for display. More...
 
 quiz_get_best_grade ($quiz, $userid)
 Get the best current grade for a particular user in a quiz. More...
 
 quiz_get_completion_state ($course, $cm, $userid, $type)
 Obtains the automatic completion state for this quiz on any conditions in quiz settings, such as if all attempts are used or a certain grade is achieved. More...
 
 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). More...
 
 quiz_get_extra_capabilities ()
 
 quiz_get_grade_format ($quiz)
 Determine the correct number of decimal places required to format a grade. More...
 
 quiz_get_group_override_priorities ($quizid)
 Calculates the priorities of timeopen and timeclose values for group overrides for a quiz. More...
 
 quiz_get_navigation_options ()
 
 quiz_get_post_actions ()
 List the actions that correspond to a post of this module. More...
 
 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. More...
 
 quiz_get_view_actions ()
 List the actions that correspond to a view of this module. More...
 
 quiz_grade_item_delete ($quiz)
 
 quiz_grade_item_update ($quiz, $grades=null)
 
 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). More...
 
 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. More...
 
 quiz_page_type_list ($pagetype, $parentcontext, $currentcontext)
 Return a list of page types. More...
 
 quiz_pluginfile ($course, $cm, $context, $filearea, $args, $forcedownload, array $options=array())
 
 quiz_print_overview ()
 
 quiz_print_recent_mod_activity ($activity, $courseid, $detail, $modnames)
 
 quiz_process_options ($quiz)
 Pre-process the quiz options form data, making any necessary adjustments. More...
 
 quiz_question_pluginfile ($course, $context, $component, $filearea, $qubaid, $slot, $args, $forcedownload, array $options=array())
 
 quiz_questions_in_use ($questionids)
 
 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. More...
 
 quiz_reset_course_form_defaults ($course)
 Course reset form defaults. More...
 
 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. More...
 
 quiz_reset_gradebook ($courseid, $type='')
 Removes all grades from gradebook. More...
 
 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. More...
 
 quiz_review_option_form_to_db ($fromform, $field)
 Helper function for quiz_process_options(). More...
 
 quiz_supports ($feature)
 
 quiz_update_effective_access ($quiz, $userid)
 Updates a quiz object with override information for a user. More...
 
 quiz_update_events ($quiz, $override=null)
 This function updates the events associated to the quiz. More...
 
 quiz_update_grades ($quiz, $userid=0, $nullifnone=true)
 
 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. More...
 
 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. More...
 
 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. More...
 

Variables

const QUIZ_ATTEMPTFIRST '3'
 
const QUIZ_ATTEMPTLAST '4'
 
const QUIZ_EVENT_TYPE_CLOSE 'close'
 
const QUIZ_EVENT_TYPE_OPEN 'open'
 #- More...
 
const QUIZ_GRADEAVERAGE '2'
 
const QUIZ_GRADEHIGHEST '1'
 #- More...
 
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
 #- More...
 
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

Library of functions for the quiz module.

This contains functions that are called also from outside the quiz module Functions that are only called by the quiz module itself are in locallib.php

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later