Moodle APIs 4.3
Moodle 4.3.6 (Build: 20240812)
lib.php File Reference

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'