Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
Files | Namespaces | Classes | Functions | Variables
mod_quiz

Files

file  access.php
 Capability definitions for the quiz module.
 
file  accessmanager.php
 Classes to enforce the various access rules that can apply to a quiz.
 
file  accessmanager_form.php
 Defines the form that limits student's access to attempt a quiz.
 
file  accessrulebase.php
 Base class for rules that restrict the ability to attempt a quiz.
 
file  activity.php
 Search area for mod_quiz activities.
 
file  activity_base.php
 Activity base class.
 
file  add_action_column.php
 A column type for the add this question to the quiz action.
 
file  addrandomform.php
 Defines the Moodle forum used to add random questions to the quiz.
 
file  admin_review_setting.php
 Admin settings class for the quiz review options.
 
file  admin_setting_browsersecurity.php
 Admin settings class for the quiz browser security option.
 
file  admin_setting_grademethod.php
 Admin settings class for the quiz grading method.
 
file  admin_setting_overduehandling.php
 Admin settings class for the quiz overdue attempt handling method.
 
file  admin_setting_user_image.php
 Admin settings class for the choices for how to display the user's image.
 
file  attempt_abandoned.php
 The mod_quiz attempt abandoned event.
 
file  attempt_becameoverdue.php
 The mod_quiz attempt became overdue event.
 
file  attempt_deleted.php
 The mod_quiz attempt deleted event.
 
file  attempt_preview_started.php
 The mod_quiz attempt preview started event.
 
file  attempt_regraded.php
 The mod_quiz attempt regraded event.
 
file  attempt_reviewed.php
 The mod_quiz attempt reviewed event.
 
file  attempt_started.php
 The mod_quiz attempt started event.
 
 
file  attempt_summary_viewed.php
 The mod_quiz attempt summary viewed event.
 
file  attempt_viewed.php
 The mod_quiz attempt viewed event.
 
file  attemptlib.php
 Back-end code for handling data about quizzes and the current user's attempt.
 
file  attemptsreport.php
 The file defines a base class that can be used to build a report like the overview or responses report, that has one row per attempt.
 
file  attemptsreport_form.php
 Base class for the settings form for .
 
file  attemptsreport_options.php
 Base class for the options that control what is visible in an quiz_attempts_report.
 
file  attemptsreport_table.php
 Base class for the table used by a quiz_attempts_report.
 
file  backup_mod_quiz_access_subplugin.class.php
 Defines the base class for quiz access plugins backup code.
 
file  backup_quiz_activity_task.class.php
 Defines backup_quiz_activity_task class.
 
file  backup_quiz_stepslib.php
 @subpackage backup-moodle2
 
file  behat_mod_quiz.php
 Steps definitions related to mod_quiz.
 
file  behat_mod_quiz_generator.php
 Behat data generator for mod_quiz.
 
file  cognitive_depth.php
 Cognitive depth indicator - quiz.
 
file  course_module_instance_list_viewed.php
 The mod_quiz instance list viewed event.
 
file  course_module_viewed.php
 The mod_quiz course module viewed event.
 
file  cronlib.php
 Library code used by quiz cron.
 
file  custom_view.php
 Defines the custom question bank view used on the Edit quiz page.
 
file  default.php
 Base class for quiz report plugins.
 
file  edit_page_viewed.php
 The mod_quiz edit page viewed event.
 
file  edit_renderer.php
 Renderer outputting the quiz editing UI.
 
file  events.php
 Add event handlers for the quiz.
 
file  external.php
 Quiz external API.
 
file  group_observers.php
 Group observers.
 
file  group_override_created.php
 The mod_quiz group override created event.
 
file  group_override_deleted.php
 The mod_quiz group override deleted event.
 
file  group_override_updated.php
 The mod_quiz group override updated event.
 
file  helper.php
 Privacy Subsystem helper for mod_quiz.
 
file  legacy_quiz_accessrules_cron.php
 Legacy Cron Quiz Access Rules Task.
 
file  legacy_quiz_reports_cron.php
 Legacy Cron Quiz Reports Task.
 
file  legacy_quizaccess_polyfill.php
 This file contains the polyfil to allow a plugin to operate with Moodle 3.3 up.
 
file  lib.php
 Provides support for the conversion of moodle1 backup to the moodle2 format Based off of a template @ http://docs.moodle.org/dev/Backup_1.9_conversion_for_developers.
 
file  lib.php
 Library of functions for the quiz module.
 
file  lib.php
 Quiz module test data generator class.
 
file  locallib.php
 Library of functions used by the quiz module.
 
file  log.php
 Definition of log events for the quiz module.
 
file  messages.php
 Defines message providers (types of message sent) for the quiz module.
 
file  mod_form.php
 Defines the quiz module ettings form.
 
file  override_form.php
 Settings form for overrides in the quiz module.
 
file  provider.php
 Privacy Subsystem implementation for mod_quiz.
 
file  qubaids_for_users_attempts.php
 A qubaid_condition representing all the attempts by one user at a given quiz.
 
file  question_chooser.php
 The question_chooser renderable.
 
file  question_name_text_column.php
 A column type for the name followed by the start of the question text.
 
file  quiz.php
 Subplugin info class.
 
file  quizaccess.php
 Subplugin info class.
 
file  quizaccess_provider.php
 The quizaccess_provider interface provides the expected interface for all 'quizaccess' quizaccesss.
 
file  quizaccess_user_provider.php
 The quizaccess_user_provider interface provides the expected interface for all 'quizaccess' quizaccesss.
 
file  randomquestion_form.php
 Defines the editing form for random questions.
 
file  renderer.php
 Defines the renderer for the quiz module.
 
file  repaginate.php
 Defines the quiz repaginate class.
 
file  report_viewed.php
 The mod_quiz report viewed event.
 
file  reportlib.php
 Helper functions for the quiz reports.
 
file  restore_mod_quiz_access_subplugin.class.php
 Restore code for the quizaccess_honestycheck plugin.
 
file  restore_quiz_activity_task.class.php
 @subpackage backup-moodle2
 
file  restore_quiz_stepslib.php
 @subpackage backup-moodle2
 
file  services.php
 Quiz external functions and service definitions.
 
file  settings.php
 Administration settings definitions for the quiz module.
 
file  slot_random.php
 Defines the mod_quiz::local::structure::slot_random class.
 
file  social_breadth.php
 Social breadth indicator - quiz.
 
file  structure.php
 Defines the mod_quiz::structure class.
 
file  tasks.php
 Definition of Quiz scheduled tasks.
 
file  update_overdue_attempts.php
 Update Overdue Attempts Task.
 
file  upgrade.php
 Upgrade script for the quiz module.
 
file  user_override_created.php
 The mod_quiz user override created event.
 
file  user_override_deleted.php
 The mod_quiz user override deleted event.
 
file  user_override_updated.php
 The mod_quiz user override updated event.
 
file  version.php
 Quiz activity version information.
 

Namespaces

namespace  mod_quiz
  
 
namespace  mod_quiz\analytics\indicator
  
 
namespace  mod_quiz\event
  
 
namespace  mod_quiz\form
  
 
namespace  mod_quiz\local\structure
  
 
namespace  mod_quiz\output
  
 
namespace  mod_quiz\plugininfo
  
 
namespace  mod_quiz\privacy
  
 
namespace  mod_quiz\question
  
 
namespace  mod_quiz\question\bank
  
 
namespace  mod_quiz\search
  
 
namespace  mod_quiz\task
  
 

Classes

class  backup_mod_quiz_access_subplugin
 Base class for backing up all the quiz settings and attempt data for an access rule quiz sub-plugin. More...
 
class  backup_quiz_activity_structure_step
 Define all the backup steps that will be used by the backup_quiz_activity_task. More...
 
class  backup_quiz_activity_task
 Provides the steps to perform one complete backup of the Quiz instance. More...
 
class  behat_mod_quiz
 Steps definitions related to mod_quiz. More...
 
class  behat_mod_quiz_generator
 Behat data generator for mod_quiz. More...
 
class  mod_quiz\analytics\indicator\activity_base
 Activity base class. More...
 
class  mod_quiz\analytics\indicator\cognitive_depth
 Cognitive depth indicator - quiz. More...
 
class  mod_quiz\analytics\indicator\social_breadth
 Social breadth indicator - quiz. More...
 
class  mod_quiz\event\attempt_abandoned
 
class  mod_quiz\event\attempt_becameoverdue
 
class  mod_quiz\event\attempt_deleted
 
class  mod_quiz\event\attempt_preview_started
 
class  mod_quiz\event\attempt_regraded
 
class  mod_quiz\event\attempt_reviewed
 
class  mod_quiz\event\attempt_started
 
class  mod_quiz\event\attempt_submitted
 
class  mod_quiz\event\attempt_summary_viewed
 
class  mod_quiz\event\attempt_viewed
 
class  mod_quiz\event\course_module_instance_list_viewed
 The mod_quiz instance list viewed event class. More...
 
class  mod_quiz\event\course_module_viewed
 The mod_quiz course module viewed event class. More...
 
class  mod_quiz\event\edit_page_viewed
 
class  mod_quiz\event\group_override_created
 
class  mod_quiz\event\group_override_deleted
 
class  mod_quiz\event\group_override_updated
 
class  mod_quiz\event\report_viewed
 
class  mod_quiz\event\user_override_created
 
class  mod_quiz\event\user_override_deleted
 
class  mod_quiz\event\user_override_updated
 
class  mod_quiz\form\randomquestion_form
 Class randomquestion_form. More...
 
class  mod_quiz\group_observers
 Group observers class. More...
 
class  mod_quiz\local\structure\slot_random
 Class slot_random, represents a random question slot type. More...
 
class  mod_quiz\output\edit_renderer
 Renderer outputting the quiz editing UI. More...
 
class  mod_quiz\output\question_chooser
 The question_chooser renderable class. More...
 
class  mod_quiz\plugininfo\quiz
 
class  mod_quiz\plugininfo\quizaccess
 
class  mod_quiz\privacy\helper
 Privacy Subsystem implementation for mod_quiz. More...
 
class  mod_quiz\privacy\provider
 Privacy Subsystem implementation for mod_quiz. More...
 
interface  mod_quiz\privacy\quizaccess_provider
 The quizaccess_provider interface provides the expected interface for all 'quizaccess' quizaccesss. More...
 
interface  mod_quiz\privacy\quizaccess_user_provider
 
class  mod_quiz\question\bank\add_action_column
 A column type for the add this question to the quiz action. More...
 
class  mod_quiz\question\bank\custom_view
 Subclass to customise the view of the question bank for the quiz editing screen. More...
 
class  mod_quiz\question\bank\question_name_text_column
 A column type for the name followed by the start of the question text. More...
 
class  mod_quiz\question\qubaids_for_users_attempts
 A qubaid_condition representing all the attempts by one user at a given quiz. More...
 
class  mod_quiz\repaginate
 The repaginate class will rearrange questions in pages. More...
 
class  mod_quiz\search\activity
 Search area for mod_quiz activities. More...
 
class  mod_quiz\structure
 Quiz structure class. More...
 
class  mod_quiz\task\legacy_quiz_accessrules_cron
 Legacy Cron Quiz Access Rules Task. More...
 
class  mod_quiz\task\legacy_quiz_reports_cron
 Legacy Cron Quiz Reports Task. More...
 
class  mod_quiz\task\update_overdue_attempts
 Update Overdue Attempts Task. More...
 
class  mod_quiz_admin_review_setting
 Admin settings class for the quiz review options. More...
 
class  mod_quiz_admin_setting_browsersecurity
 Admin settings class for the quiz browser security option. More...
 
class  mod_quiz_admin_setting_grademethod
 Admin settings class for the quiz grading method. More...
 
class  mod_quiz_admin_setting_overduehandling
 Admin settings class for the quiz overdue attempt handling method. More...
 
class  mod_quiz_admin_setting_user_image
 Admin settings class for the choices for how to display the user's image. More...
 
class  mod_quiz_attempts_report_form
 Base class for the settings form for . More...
 
class  mod_quiz_attempts_report_options
 Base class for the options that control what is visible in an quiz_attempts_report. More...
 
class  mod_quiz_display_options
 An extension of question_display_options that includes the extra options used by the quiz. More...
 
class  mod_quiz_external
 
class  mod_quiz_generator
 
class  mod_quiz_links_to_other_attempts
 
class  mod_quiz_mod_form
 Settings form for the quiz module. More...
 
class  mod_quiz_overdue_attempt_updater
 This class holds all the code for automatically updating all attempts that have gone over their time limit. More...
 
class  mod_quiz_preflight_check_form
 A form that limits student's access to attempt a quiz. More...
 
class  mod_quiz_renderer
 The renderer for the quiz module. More...
 
class  mod_quiz_view_object
 
class  moodle1_mod_quiz_handler
 Quiz conversion handler. More...
 
class  moodle_quiz_exception
 Class for quiz exceptions. More...
 
class  qubaids_for_quiz
 A qubaid_condition for finding all the question usages belonging to a particular quiz. More...
 
class  qubaids_for_quiz_user
 A qubaid_condition for finding all the question usages belonging to a particular user and quiz combination. More...
 
class  quiz
 A class encapsulating a quiz and the questions it contains, and making the information available to scripts like view.php. More...
 
class  quiz_access_manager
 This class keeps track of the various access rules that apply to a particular quiz, with convinient methods for seeing whether access is allowed. More...
 
class  quiz_access_rule_base
 A base class that defines the interface for the various quiz access rules. More...
 
class  quiz_add_random_form
 The add random questions form. More...
 
class  quiz_attempt
 This class extends the quiz class to hold data about the state of a particular attempt, in addition to the data about the quiz. More...
 
class  quiz_attempt_nav_panel
 Specialisation of quiz_nav_panel_base for the attempt quiz page. More...
 
class  quiz_attempts_report
 Base class for quiz reports that are basically a table with one row for each attempt. More...
 
class  quiz_attempts_report_table
 Base class for the table used by a quiz_attempts_report. More...
 
class  quiz_default_report
 Base class for quiz report plugins. More...
 
class  quiz_nav_panel_base
 Represents the navigation panel, and builds a block_contents to allow it to be output. More...
 
class  quiz_nav_question_button
 Represents a single link in the navigation panel. More...
 
class  quiz_nav_section_heading
 Represents a heading in the navigation panel. More...
 
class  quiz_override_form
 Form for editing settings overrides. More...
 
class  quiz_review_nav_panel
 Specialisation of quiz_nav_panel_base for the review quiz page. More...
 
class  restore_mod_quiz_access_subplugin
 Base class for restoring up all the quiz settings and attempt data for an access rule quiz sub-plugin. More...
 
class  restore_quiz_activity_structure_step
 Structure step to restore one quiz activity. More...
 
class  restore_quiz_activity_task
 quiz restore task that provides all the settings and steps to perform one complete restore of the activity 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_add_quiz_question ($questionid, $quiz, $page=0, $maxmark=null)
 Add a question to a quiz. More...
 
 quiz_add_random_questions ($quiz, $addonpage, $categoryid, $number, $includesubcategories, $tagids=[])
 Add a random question to the quiz at a given point. 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_save_started ($quizobj, $quba, $attempt)
 The save started question usage and quiz attempt in db and log the started attempt. More...
 
 quiz_attempt_state ($quiz, $attempt)
 Work out what state this quiz attempt is in - in the sense used by quiz_get_review_options, not in the sense of $attempt->state. More...
 
 quiz_attempt_state_name ($state)
 Get the human-readable name for a quiz attempt state. More...
 
 quiz_attempt_submitted_handler ($event)
 Handle the quiz_attempt_submitted event. 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_calculate_best_attempt ($quiz, $attempts)
 Return the attempt with the best grade for a quiz. More...
 
 quiz_calculate_best_grade ($quiz, $attempts)
 Calculate the overall grade for a quiz given a number of attempts by a particular user. 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_create_attempt (quiz $quizobj, $attemptnumber, $lastattempt, $timenow, $ispreview=false, $userid=null)
 Creates an object to represent a new attempt at a quiz. More...
 
 quiz_create_attempt_handling_errors ($attemptid, $cmid=null)
 Get quiz attempt and handling error. 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_attempt ($attempt, $quiz)
 Delete a quiz attempt. 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_previews ($quiz, $userid=null)
 Delete all the preview attempts at a quiz, or possibly all the attempts belonging to one user. 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_feedback_for_grade ($grade, $quiz, $context)
 Get the feedback text that should be show to a student who got this grade on this quiz. More...
 
 quiz_feedback_record_for_grade ($grade, $quiz)
 Get the feedback object for this grade on this quiz. 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_attempt_usertime_sql ($redundantwhereclauses='')
 Returns SQL to compute timeclose and timelimit for every attempt, taking into account user and group overrides. More...
 
 quiz_get_best_grade ($quiz, $userid)
 Get the best current grade for a particular user in a quiz. More...
 
 quiz_get_combined_reviewoptions ($quiz, $attempts)
 Combines the review options from a number of different quiz attempts. 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_flag_option ($attempt, $context)
 
 quiz_get_grade_format ($quiz)
 Determine the correct number of decimal places required to format a grade. More...
 
 quiz_get_grading_option_name ($option)
 
 quiz_get_grading_options ()
 
 quiz_get_group_override_priorities ($quizid)
 Calculates the priorities of timeopen and timeclose values for group overrides for a quiz. More...
 
 quiz_get_js_module ()
 Get the information about the standard quiz JavaScript module. More...
 
 quiz_get_navigation_options ()
 
 quiz_get_overdue_handling_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_review_options ($quiz, $attempt, $context)
 The the appropraite mod_quiz_display_options object for this attempt at this quiz right now. More...
 
 quiz_get_user_attempt_unfinished ($quizid, $userid)
 Returns an unfinished attempt (if there is one) for the given user on the given quiz. More...
 
 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_user_image_options ()
 Get the choices for what size user picture to show. More...
 
 quiz_get_user_timeclose ($courseid)
 Return an user's timeclose for all quizzes in a course, hereby taking into account group and user overrides. 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_groups_group_deleted_handler ($event)
 Handle groups_group_deleted event. More...
 
 quiz_groups_member_added_handler ($event)
 Handle groups_member_added event. More...
 
 quiz_groups_member_removed_handler ($event)
 Handle groups_member_removed event. More...
 
 quiz_groups_members_removed_handler ($event)
 Handle groups_members_removed event. More...
 
 quiz_has_attempts ($quizid)
 
 quiz_has_feedback ($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). More...
 
 quiz_has_question_use ($quiz, $slot)
 Verify that the question exists, and the user has permission to use it. More...
 
 quiz_has_questions ($quizid)
 Are there any questions in this quiz? More...
 
 quiz_is_overriden_calendar_event (\calendar_event $event)
 Check if the given calendar_event is either a user or group override event for quiz. More...
 
 quiz_no_questions_message ($quiz, $cm, $context)
 Generate a message saying that this quiz has no questions, with a button to go to the edit page, if the user has the right capability. 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_prepare_and_start_new_attempt (quiz $quizobj, $attemptnumber, $lastattempt, $offlineattempt=false, $forcedrandomquestions=[], $forcedvariants=[], $userid=null)
 Prepare and start a new attempt deleting the previous preview attempts. More...
 
 quiz_print_overview ()
 
 quiz_print_recent_mod_activity ($activity, $courseid, $detail, $modnames)
 
 quiz_process_group_deleted_in_course ($courseid)
 Logic to happen when a/some group(s) has/have been deleted in a course. More...
 
 quiz_process_options ($quiz)
 Pre-process the quiz options form data, making any necessary adjustments. More...
 
 quiz_question_action_icons ($quiz, $cmid, $question, $returnurl, $variant=null)
 
 quiz_question_edit_button ($cmid, $question, $returnurl, $contentaftericon='')
 
 quiz_question_pluginfile ($course, $context, $component, $filearea, $qubaid, $slot, $args, $forcedownload, array $options=array())
 
 quiz_question_preview_button ($quiz, $question, $label=false, $variant=null)
 
 quiz_question_preview_url ($quiz, $question, $variant=null)
 
 quiz_question_tostring ($question, $showicon=false, $showquestiontext=true, $showidnumber=false, $showtags=false)
 Creates a textual representation of a question for display. More...
 
 quiz_questions_in_use ($questionids)
 
 quiz_questions_per_page_options ()
 Get the choices to offer for the 'Questions per page' option. More...
 
 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_repaginate_questions ($quizid, $slotsperpage)
 Repaginate the questions in a quiz. More...
 
 quiz_report_can_filter_only_graded ($quiz)
 
 quiz_report_default_report ($context)
 Get the default report for the current user. More...
 
 quiz_report_download_filename ($report, $courseshortname, $quizname)
 Create a filename for use when downloading data from a quiz report. More...
 
 quiz_report_feedback_for_grade ($grade, $quizid, $context)
 Get the feedback text for a grade on this quiz. More...
 
 quiz_report_get_significant_questions ($quiz)
 Get the slots of real questions (not descriptions) in this quiz, in order. More...
 
 quiz_report_grade_bands ($bandwidth, $bands, $quizid, core\dml\sql_join $usersjoins=null)
 Get the number of students whose score was in a particular band for this quiz. More...
 
 quiz_report_grade_method_sql ($grademethod, $quizattemptsalias='quiza')
 Given a quiz grading method return sql to test if this is an attempt that will be contribute towards the grade of the user. More...
 
 quiz_report_highlighting_grading_method ($quiz, $qmsubselect, $qmfilter)
 
 quiz_report_index_by_keys ($datum, $keys, $keysunique=true)
 Takes an array of objects and constructs a multidimensional array keyed by the keys it finds on the object. More...
 
 quiz_report_list ($context)
 Returns an array of reports to which the current user has access to. More...
 
 quiz_report_qm_filter_select ($quiz, $quizattemptsalias='quiza')
 This is a wrapper for quiz_report_grade_method_sql that takes the whole quiz object instead of just the grading method as a param. More...
 
 quiz_report_scale_summarks_as_percentage ($rawmark, $quiz, $round=true)
 Format a number as a percentage out of $quiz->sumgrades. More...
 
 quiz_report_should_show_grades ($quiz, context $context)
 Should the grades be displayed in this report. More...
 
 quiz_report_unindex ($datum)
 
 quiz_require_question_use ($questionid)
 Verify that the question exists, and the user has permission to use it. More...
 
 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. 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_retrieve_slot_tag_ids ($slotid)
 Retrieves tag ids for the given quiz slot. More...
 
 quiz_retrieve_slot_tags ($slotid)
 Retrieves tag information for the given quiz slot. More...
 
 quiz_retrieve_tags_for_slot_ids ($slotids)
 Retrieves tag information for the given list of quiz slot ids. More...
 
 quiz_review_option_form_to_db ($fromform, $field)
 Helper function for quiz_process_options(). More...
 
 quiz_save_best_grade ($quiz, $userid=null, $attempts=array())
 Save the overall grade for a user at a quiz in the quiz_grades table. More...
 
 quiz_send_confirmation ($recipient, $a)
 Sends a confirmation message to the student confirming that the attempt was processed. More...
 
 quiz_send_notification ($recipient, $submitter, $a)
 Sends notification messages to the interested parties that assign the role capability. More...
 
 quiz_send_notification_messages ($course, $quiz, $attempt, $context, $cm)
 Send all the requried messages when a quiz attempt is submitted. More...
 
 quiz_send_overdue_message ($attemptobj)
 Send the notification message when a quiz attempt becomes overdue. More...
 
 quiz_set_grade ($newgrade, $quiz)
 The quiz grade is the maximum that student's results are marked out of. More...
 
 quiz_start_attempt_built_on_last ($quba, $attempt, $lastattempt)
 Start a subsequent new attempt, in each attempt builds on last mode. More...
 
 quiz_start_new_attempt ($quizobj, $quba, $attempt, $attemptnumber, $timenow, $questionids=array(), $forcedvariantsbyslot=array())
 Start a normal, new, quiz attempt. More...
 
 quiz_supports ($feature)
 
 quiz_update_all_attempt_sumgrades ($quiz)
 Update the sumgrades field of the attempts at a quiz. More...
 
 quiz_update_all_final_grades ($quiz)
 Update the final grade at this quiz for all students. More...
 
 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_update_open_attempts (array $conditions)
 Efficiently update check state time on all open attempts. More...
 
 quiz_update_section_firstslots ($quizid, $direction, $afterslot, $beforeslot=null)
 Move all the section headings in a certain slot range by a certain offset. More...
 
 quiz_update_sumgrades ($quiz)
 Update the sumgrades field of the quiz. 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...
 
 quiz_validate_new_attempt (quiz $quizobj, quiz_access_manager $accessmanager, $forcenew, $page, $redirect)
 Validate permissions for creating a new attempt and start a new preview attempt if required. More...
 
 quiz_view ($quiz, $course, $cm, $context)
 Mark the activity completed (if required) and trigger the course_module_viewed event. More...
 
 xmldb_quiz_upgrade ($oldversion)
 Quiz module upgrade function. More...
 

Variables

 $capabilities
 
 $functions
 
 $logs
 
 $messageproviders
 
 $observers
 
 $plugin = 2020060900
 
 $quizsettings = new admin_settingpage('modsettingquiz', $pagetitle, 'moodle/site:config')
 
 $reports = core_component::get_plugin_list_with_file('quiz', 'settings.php', false)
 
 $reportsbyname = array()
 
 $rules = core_component::get_plugin_list_with_file('quizaccess', 'settings.php', false)
 
 $rulesbyname = array()
 
foreach( $reportsbyname as $strreportname=> $report) foreach($rulesbyname as $strrulename=> $rule) $settings = null
 
 $tasks
 
$plugin component = 'mod_quiz'
 
if(empty($reportsbyname) &&empty($rulesbyname)) else
 
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_MIN_TIME_TO_CONTINUE '2'
 If there are fewer than this many seconds left when the student submits a page of the quiz, then do not take them to the next page of the quiz. More...
 
const QUIZ_NAVMETHOD_FREE 'free'
 #+ Options for navigation method within quizzes.
 
const QUIZ_NAVMETHOD_SEQ 'sequential'
 
const QUIZ_SHOW_TIME_BEFORE_DEADLINE '3600'
 We show the countdown timer if there is less than this amount of time left before the the quiz close date. More...
 
const QUIZ_SHOWIMAGE_LARGE 2
 We show Large image when user selects Large image from dropdown menu in quiz settings.
 
const QUIZ_SHOWIMAGE_NONE 0
 We show no image when user selects No image from dropdown menu in quiz settings.
 
const QUIZ_SHOWIMAGE_SMALL 1
 We show small image when user selects small image from dropdown menu in quiz settings.
 
$plugin version = 2020061500
 

Detailed Description

Function Documentation

◆ 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_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_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_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.

◆ 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
object$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_add_quiz_question()

quiz_add_quiz_question (   $questionid,
  $quiz,
  $page = 0,
  $maxmark = null 
)

Add a question to a quiz.

Adds a question to a quiz by updating $quiz as well as the quiz and quiz_slots tables. It also adds a page break if required.

Parameters
int$questionidThe id of the question to be added
object$quizThe extended quiz object as used by edit.php This is updated by this function
int$pageWhich page in quiz to add the question on. If 0 (default), add at the end
float$maxmarkThe maximum mark to set for this question. (Optional, defaults to question.defaultmark.
Return values
boolfalse if the question was already in the quiz

◆ quiz_add_random_questions()

quiz_add_random_questions (   $quiz,
  $addonpage,
  $categoryid,
  $number,
  $includesubcategories,
  $tagids = [] 
)

Add a random question to the quiz at a given point.

Parameters
stdClass$quizthe quiz settings.
int$addonpagethe page on which to add the question.
int$categoryidthe question category to add the question from.
int$numberthe number of random questions to add.
bool$includesubcategorieswhether to include questoins from subcategories.
int[]$tagidsArray of tagids. The question that will be picked randomly should be tagged with all these tags.

◆ 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
object$quizthe quiz object.

◆ quiz_allows_multiple_tries()

quiz_allows_multiple_tries (   $quiz)

Does this quiz allow multiple tries?

Return values
bool

◆ quiz_attempt_save_started()

quiz_attempt_save_started (   $quizobj,
  $quba,
  $attempt 
)

The save started question usage and quiz attempt in db and log the started attempt.

Parameters
quiz$quizobj
question_usage_by_activity$quba
object$attempt
Return values
objectattempt object with uniqueid and id set.

◆ quiz_attempt_state()

quiz_attempt_state (   $quiz,
  $attempt 
)

Work out what state this quiz attempt is in - in the sense used by quiz_get_review_options, not in the sense of $attempt->state.

Parameters
object$quizthe quiz settings
object$attemptthe quiz_attempt database row.
Return values
intone of the mod_quiz_display_options::DURING, IMMEDIATELY_AFTER, LATER_WHILE_OPEN or AFTER_CLOSE constants.

◆ quiz_attempt_state_name()

quiz_attempt_state_name (   $state)

Get the human-readable name for a quiz attempt state.

Parameters
string$stateone of the state constants like quiz_attempt::IN_PROGRESS.
Return values
stringThe lang string to describe that state.

◆ quiz_attempt_submitted_handler()

quiz_attempt_submitted_handler (   $event)

Handle the quiz_attempt_submitted event.

This sends the confirmation and notification messages, if required.

Parameters
object$eventthe event object.

◆ 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
object$quizthe quiz object. Only $quiz->id is used at the moment.
object$cmthe cm object. Only $cm->course, $cm->groupmode and $cm->groupingid fields are used at the moment.
object$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_calculate_best_attempt()

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.

Return values
objectThe attempt with the best grade
Parameters
object$quizThe quiz for which the best grade is to be calculated
array$attemptsAn array of all the attempts of the user at the quiz

◆ quiz_calculate_best_grade()

quiz_calculate_best_grade (   $quiz,
  $attempts 
)

Calculate the overall grade for a quiz given a number of attempts by a particular user.

Parameters
object$quizthe quiz settings object.
array$attemptsan array of all the user's attempts at this quiz in order.
Return values
floatthe overall grade

◆ quiz_check_updates_since()

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.

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_create_attempt()

quiz_create_attempt ( quiz  $quizobj,
  $attemptnumber,
  $lastattempt,
  $timenow,
  $ispreview = false,
  $userid = null 
)

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.

Parameters
object$quizobjthe quiz object to create an attempt for.
int$attemptnumberthe sequence number for the attempt.
object$lastattemptthe previous attempt by this user, if any. Only needed if $attemptnumber > 1 and $quiz->attemptonlast is true.
int$timenowthe time the attempt was started at.
bool$ispreviewwhether this new attempt is a preview.
int$useridthe id of the user attempting this quiz.
Return values
objectthe newly created attempt object.

◆ quiz_create_attempt_handling_errors()

quiz_create_attempt_handling_errors (   $attemptid,
  $cmid = null 
)

Get quiz attempt and handling error.

Parameters
int$attemptidthe id of the current attempt.
int | null$cmidthe course_module id for this quiz.
Return values
quiz_attempt::$attemptobjall the data about the quiz attempt.
Exceptions
moodle_exception

◆ quiz_delete_all_attempts()

quiz_delete_all_attempts (   $quiz)

Delete all the attempts belonging to a quiz.

Parameters
object$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
object$quizThe quiz object.
bool$logWhether to trigger logs.

◆ quiz_delete_attempt()

quiz_delete_attempt (   $attempt,
  $quiz 
)

Delete a quiz attempt.

Parameters
mixed$attemptan integer attempt id or an attempt object (row of the quiz_attempts table).
object$quizthe quiz object.

◆ 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
object$quizThe quiz object.
int$overrideidThe id of the override being deleted
bool$logWhether to trigger logs.
Return values
booltrue on success

◆ quiz_delete_previews()

quiz_delete_previews (   $quiz,
  $userid = null 
)

Delete all the preview attempts at a quiz, or possibly all the attempts belonging to one user.

Parameters
object$quizthe quiz object.
int$userid(optional) if given, only delete the previews belonging to this user.

◆ quiz_delete_user_attempts()

quiz_delete_user_attempts (   $quiz,
  $user 
)

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

Parameters
object$quizThe quiz object.
object$userThe user object.

◆ quiz_extend_settings_navigation()

quiz_extend_settings_navigation (   $settings,
  $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_feedback_for_grade()

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.

Parameters
float$gradea grade on this quiz.
object$quizthe quiz settings.
object$contextthe quiz context.
Return values
stringthe comment that corresponds to this grade (empty string if there is not one.

◆ quiz_feedback_record_for_grade()

quiz_feedback_record_for_grade (   $grade,
  $quiz 
)

Get the feedback object for this grade on this quiz.

Parameters
float$gradea grade on this quiz.
object$quizthe quiz settings.
Return values
false|stdClassthe record object or false if there is not feedback for the given grade
Since
Moodle 3.1

◆ quiz_format_grade()

quiz_format_grade (   $quiz,
  $grade 
)

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

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

◆ 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
object$quizThe quiz table row, only $quiz->decimalpoints is used.
float$gradeThe grade to round.
Return values
float

◆ quiz_get_attempt_usertime_sql()

quiz_get_attempt_usertime_sql (   $redundantwhereclauses = '')

Returns SQL to compute timeclose and timelimit for every attempt, taking into account user and group overrides.

The query used herein is very similar to the one in function quiz_get_user_timeclose, so, in case you would change either one of them, make sure to apply your changes to both.

Parameters
string$redundantwhereclausesextra where clauses to add to the subquery for performance. These can use the table alias iquiza for the quiz attempts table.
Return values
stringSQL select with columns attempt.id, usertimeclose, usertimelimit.

◆ quiz_get_best_grade()

quiz_get_best_grade (   $quiz,
  $userid 
)

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

Parameters
object$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_combined_reviewoptions()

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(...)

Parameters
object$quizthe quiz instance.
array$attemptsan array of attempt objects.
Return values
arrayof two options objects, one showing which options are true for at least one of the attempts, the other showing which options are true for all attempts.

◆ quiz_get_completion_state()

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.

Parameters
object$courseCourse
object$cmCourse-module
int$useridUser ID
bool$typeType of comparison (or/and; can be used as return value if no conditions)
Return values
boolTrue if completed, false if not. (If no conditions, then return value depends on comparison type)

◆ 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_infoAn 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_flag_option()

quiz_get_flag_option (   $attempt,
  $context 
)
Parameters
object$attemptthe attempt.
object$contextthe quiz context.
Return values
intwhether flags should be shown/editable to the current user for this attempt.

◆ quiz_get_grade_format()

quiz_get_grade_format (   $quiz)

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

Parameters
object$quizThe quiz table row, only $quiz->decimalpoints is used.
Return values
integer

◆ quiz_get_grading_option_name()

quiz_get_grading_option_name (   $option)
Parameters
int$optionone of the values QUIZ_GRADEHIGHEST, QUIZ_GRADEAVERAGE, QUIZ_ATTEMPTFIRST or QUIZ_ATTEMPTLAST.
Return values
thelang string for that option.

◆ quiz_get_grading_options()

quiz_get_grading_options ( )
Return values
arrayint => lang string the options for calculating the quiz grade from the individual attempt grades.

◆ 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_js_module()

quiz_get_js_module ( )

Get the information about the standard quiz JavaScript module.

Return values
arraya standard jsmodule structure.

◆ quiz_get_navigation_options()

quiz_get_navigation_options ( )
Return values
theoptions for quiz navigation.

◆ quiz_get_overdue_handling_options()

quiz_get_overdue_handling_options ( )
Return values
arraystring => lang string the options for handling overdue quiz attempts.

◆ 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_review_options()

quiz_get_review_options (   $quiz,
  $attempt,
  $context 
)

The the appropraite mod_quiz_display_options object for this attempt at this quiz right now.

Parameters
stdClass$quizthe quiz instance.
stdClass$attemptthe attempt in question.
context$contextthe quiz context.
Return values
mod_quiz_display_options

◆ quiz_get_user_attempt_unfinished()

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.

Parameters
int$quizidthe id of the quiz.
int$useridthe id of the user.
Return values
mixedthe unfinished attempt if there is one, false if not.

◆ 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
anarray of 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_user_image_options()

quiz_get_user_image_options ( )

Get the choices for what size user picture to show.

Return values
arraystring => lang string the options for whether to display the user's picture.

◆ quiz_get_user_timeclose()

quiz_get_user_timeclose (   $courseid)

Return an user's timeclose for all quizzes in a course, hereby taking into account group and user overrides.

Parameters
int$courseidthe course id.
Return values
objectAn object with of all quizids and close unixdates in this course, taking into account the most lenient overrides, if existing and 0 if no close date is set.

◆ 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_groups_group_deleted_handler()

quiz_groups_group_deleted_handler (   $event)

Handle groups_group_deleted event.

Parameters
object$eventthe event object.
Deprecated:
since 2.6, see mod_quiz::group_observers::group_deleted().

◆ quiz_groups_member_added_handler()

quiz_groups_member_added_handler (   $event)

Handle groups_member_added event.

Parameters
object$eventthe event object.
Deprecated:
since 2.6, see mod_quiz::group_observers::group_member_added().

◆ quiz_groups_member_removed_handler()

quiz_groups_member_removed_handler (   $event)

Handle groups_member_removed event.

Parameters
object$eventthe event object.
Deprecated:
since 2.6, see mod_quiz::group_observers::group_member_removed().

◆ quiz_groups_members_removed_handler()

quiz_groups_members_removed_handler (   $event)

Handle groups_members_removed event.

Parameters
object$eventthe event object.
Deprecated:
since 2.6, see mod_quiz::group_observers::group_member_removed().

◆ quiz_has_attempts()

quiz_has_attempts (   $quizid)
Parameters
int$quizidThe quiz id.
Return values
boolwhether this quiz has any (non-preview) attempts.

◆ quiz_has_feedback()

quiz_has_feedback (   $quiz)
Parameters
object$quizthe quiz database row.
Return values
boolWhether this quiz has any non-blank feedback text.

◆ 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
object$quiza row from the quiz table.
Return values
boolwhether this is a graded quiz.

◆ quiz_has_question_use()

quiz_has_question_use (   $quiz,
  $slot 
)

Verify that the question exists, and the user has permission to use it.

Parameters
object$quizthe quiz settings.
int$slotwhich question in the quiz to test.
Return values
boolwhether the user can use this question.

◆ quiz_has_questions()

quiz_has_questions (   $quizid)

Are there any questions in this quiz?

Parameters
int$quizidthe quiz id.

◆ quiz_is_overriden_calendar_event()

quiz_is_overriden_calendar_event ( \calendar_event  $event)

Check if the given calendar_event is either a user or group override event for quiz.

Parameters
calendar_event$eventThe calendar event to check
Return values
bool

◆ quiz_no_questions_message()

quiz_no_questions_message (   $quiz,
  $cm,
  $context 
)

Generate a message saying that this quiz has no questions, with a button to go to the edit page, if the user has the right capability.

Parameters
object$quizthe quiz settings.
object$cmthe course_module object.
object$contextthe quiz context.
Return values
stringHTML to output.

◆ 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
object$quizthe quiz object. Only $quiz->id is used at the moment.
object$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_prepare_and_start_new_attempt()

quiz_prepare_and_start_new_attempt ( quiz  $quizobj,
  $attemptnumber,
  $lastattempt,
  $offlineattempt = false,
  $forcedrandomquestions = [],
  $forcedvariants = [],
  $userid = null 
)

Prepare and start a new attempt deleting the previous preview attempts.

Parameters
quiz$quizobjquiz object
int$attemptnumberthe attempt number
object$lastattemptlast attempt object
bool$offlineattemptwhether is an offline attempt or not
array$forcedrandomquestionsslot number => question id. Used for random questions, to force the choice of a particular actual question. Intended for testing purposes only.
array$forcedvariantsslot number => variant. Used for questions with variants, to force the choice of a particular variant. Intended for testing purposes only.
int$useridSpecific user id to create an attempt for that user, null for current logged in user
Return values
objectthe new attempt
Since
Moodle 3.1

◆ quiz_print_overview()

quiz_print_overview ( )
Deprecated:
since Moodle 3.3, when the block_course_overview block was removed.

◆ quiz_process_group_deleted_in_course()

quiz_process_group_deleted_in_course (   $courseid)

Logic to happen when a/some group(s) has/have been deleted in a course.

Parameters
int$courseidThe course ID.
Return values
void

◆ 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
object$quizThe variables set on the form.

◆ quiz_question_action_icons()

quiz_question_action_icons (   $quiz,
  $cmid,
  $question,
  $returnurl,
  $variant = null 
)
Parameters
object$quizthe quiz.
int$cmidthe course_module object for this quiz.
object$questionthe question.
string$returnurlurl to return to after action is done.
int$variantwhich question variant to preview (optional).
Return values
stringhtml for a number of icons linked to action pages for a question - preview and edit / view icons depending on user capabilities.

◆ quiz_question_edit_button()

quiz_question_edit_button (   $cmid,
  $question,
  $returnurl,
  $contentaftericon = '' 
)
Parameters
int$cmidthe course_module.id for this quiz.
object$questionthe question.
string$returnurlurl to return to after action is done.
string$contentbeforeiconsome HTML content to be added inside the link, before the icon.
Return values
theHTML for an edit icon, view icon, or nothing for a question (depending on permissions).

◆ quiz_question_preview_button()

quiz_question_preview_button (   $quiz,
  $question,
  $label = false,
  $variant = null 
)
Parameters
object$quizthe quiz settings
object$questionthe question
bool$labelif true, show the preview question label after the icon
int$variantwhich question variant to preview (optional).
Return values
theHTML for a preview question icon.

◆ quiz_question_preview_url()

quiz_question_preview_url (   $quiz,
  $question,
  $variant = null 
)
Parameters
object$quizthe quiz settings
object$questionthe question
int$variantwhich question variant to preview (optional).
Return values
moodle_urlto preview this question with the options from this quiz.

◆ quiz_question_tostring()

quiz_question_tostring (   $question,
  $showicon = false,
  $showquestiontext = true,
  $showidnumber = false,
  $showtags = false 
)

Creates a textual representation of a question for display.

Parameters
object$questionA question object from the database questions table
bool$showiconIf true, show the question's icon with the question. False by default.
bool$showquestiontextIf true (default), show question text after question name. If false, show only question name.
bool$showidnumberIf true, show the question's idnumber, if any. False by default.
core_tag_tag[] | bool$showtagsif array passed, show those tags. Else, if true, get and show tags, else, don't show tags (which is the default).
Return values
stringHTML fragment.

◆ quiz_questions_in_use()

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

◆ quiz_questions_per_page_options()

quiz_questions_per_page_options ( )

Get the choices to offer for the 'Questions per page' option.

Return values
arrayint => string.

◆ 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_repaginate_questions()

quiz_repaginate_questions (   $quizid,
  $slotsperpage 
)

Repaginate the questions in a quiz.

Parameters
int$quizidthe id of the quiz to repaginate.
int$slotsperpagenumber of items to put on each page. 0 means unlimited.

◆ quiz_report_can_filter_only_graded()

quiz_report_can_filter_only_graded (   $quiz)
Parameters
object$quizthe quiz settings.
Return values
boolwhether, for this quiz, it is possible to filter attempts to show only those that gave the final grade.

◆ quiz_report_default_report()

quiz_report_default_report (   $context)

Get the default report for the current user.

Parameters
object$contextthe quiz context.

◆ quiz_report_download_filename()

quiz_report_download_filename (   $report,
  $courseshortname,
  $quizname 
)

Create a filename for use when downloading data from a quiz report.

It is expected that this will be passed to flexible_table::is_downloading, which cleans the filename of bad characters and adds the file extension.

Parameters
string$reportthe type of report.
string$courseshortnamethe course shortname.
string$quiznamethe quiz name.
Return values
stringthe filename.

◆ quiz_report_feedback_for_grade()

quiz_report_feedback_for_grade (   $grade,
  $quizid,
  $context 
)

Get the feedback text for a grade on this quiz.

The feedback is processed ready for display.

Parameters
float$gradea grade on this quiz.
int$quizidthe id of the quiz object.
Return values
stringthe comment that corresponds to this grade (empty string if there is not one.

◆ quiz_report_get_significant_questions()

quiz_report_get_significant_questions (   $quiz)

Get the slots of real questions (not descriptions) in this quiz, in order.

Parameters
object$quizthe quiz.
Return values
arrayof slot => $question object with fields ->slot, ->id, ->maxmark, ->number, ->length.

◆ quiz_report_grade_bands()

quiz_report_grade_bands (   $bandwidth,
  $bands,
  $quizid,
core\dml\sql_join  $usersjoins = null 
)

Get the number of students whose score was in a particular band for this quiz.

Parameters
number$bandwidththe width of each band.
int$bandsthe number of bands
int$quizidthe quiz id.
core::dml::sql_join$usersjoins(joins, wheres, params) to get enrolled users
Return values
arrayband number => number of users with scores in that band.

◆ quiz_report_grade_method_sql()

quiz_report_grade_method_sql (   $grademethod,
  $quizattemptsalias = 'quiza' 
)

Given a quiz grading method return sql to test if this is an attempt that will be contribute towards the grade of the user.

Or return an empty string if the grading method is QUIZ_GRADEAVERAGE and thus all attempts contribute to final grade.

Parameters
string$grademethodquiz grading method.
string$quizattemptsaliassql alias for 'quiz_attempts' table
Return values
stringsql to test if this is an attempt that will contribute towards the graded of the user

◆ quiz_report_index_by_keys()

quiz_report_index_by_keys (   $datum,
  $keys,
  $keysunique = true 
)

Takes an array of objects and constructs a multidimensional array keyed by the keys it finds on the object.

Parameters
array$datuman array of objects with properties on the object including the keys passed as the next param.
array$keysArray of strings with the names of the properties on the objects in datum that you want to index the multidimensional array by.
bool$keysuniqueIf there is not only one object for each combination of keys you are using you should set $keysunique to true. Otherwise all the object will be added to a zero based array. So the array returned will have count($keys) + 1 indexs.
Return values
arraymultidimensional array properly indexed.

◆ quiz_report_list()

quiz_report_list (   $context)

Returns an array of reports to which the current user has access to.

Return values
arrayreports are ordered as they should be for display in tabs.

◆ quiz_report_qm_filter_select()

quiz_report_qm_filter_select (   $quiz,
  $quizattemptsalias = 'quiza' 
)

This is a wrapper for quiz_report_grade_method_sql that takes the whole quiz object instead of just the grading method as a param.

See definition for quiz_report_grade_method_sql below.

Parameters
object$quiz
string$quizattemptsaliassql alias for 'quiz_attempts' table
Return values
stringsql to test if this is an attempt that will contribute towards the grade of the user

◆ quiz_report_scale_summarks_as_percentage()

quiz_report_scale_summarks_as_percentage (   $rawmark,
  $quiz,
  $round = true 
)

Format a number as a percentage out of $quiz->sumgrades.

Parameters
number$rawgradethe mark to format.
object$quizthe quiz settings
bool$roundwhether to round the results ot $quiz->decimalpoints.

◆ quiz_report_should_show_grades()

quiz_report_should_show_grades (   $quiz,
context  $context 
)

Should the grades be displayed in this report.

That depends on the quiz display options, and whether the quiz is graded.

Parameters
object$quizthe quiz settings.
context$contextthe quiz context.
Return values
bool

◆ quiz_require_question_use()

quiz_require_question_use (   $questionid)

Verify that the question exists, and the user has permission to use it.

Does not return. Throws an exception if the question cannot be used.

Parameters
int$questionidThe id of the question.

◆ quiz_rescale_grade()

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.

Parameters
float$rawgradethe unadjusted grade, fof example $attempt->sumgrades
object$quizthe quiz object. Only the fields grade, sumgrades and decimalpoints are used.
bool | string$formatwhether to format the results for display or 'question' to format a question grade (different number of decimal places.
Return values
float|stringthe rescaled grade, or null/the lang string 'notyetgraded' if the $grade is null.

◆ 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
$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
object$datathe data submitted from the reset course.
Return values
arraystatus array

◆ quiz_retrieve_slot_tag_ids()

quiz_retrieve_slot_tag_ids (   $slotid)

Retrieves tag ids for the given quiz slot.

A quiz slot have some tags if and only if it is representing a random question by tags.

Parameters
int$slotidThe id of the quiz slot.
Return values
int[]

◆ quiz_retrieve_slot_tags()

quiz_retrieve_slot_tags (   $slotid)

Retrieves tag information for the given quiz slot.

A quiz slot have some tags if and only if it is representing a random question by tags.

Parameters
int$slotidThe id of the quiz slot.
Return values
stdClass[]List of quiz_slot_tags records.

◆ quiz_retrieve_tags_for_slot_ids()

quiz_retrieve_tags_for_slot_ids (   $slotids)

Retrieves tag information for the given list of quiz slot ids.

Currently the only slots that have tags are random question slots.

Example: If we have 3 slots with id 1, 2, and 3. The first slot has two tags, the second has one tag, and the third has zero tags. The return structure will look like: [ 1 => [ quiz_slot_tags.id => { ...tag data... }, quiz_slot_tags.id => { ...tag data... }, ], 2 => [ quiz_slot_tags.id => { ...tag data... }, ], 3 => [], ]

Parameters
int[]$slotidsThe list of id for the quiz slots.
Return values
array[]List of quiz_slot_tags records indexed by slot id.

◆ quiz_review_option_form_to_db()

quiz_review_option_form_to_db (   $fromform,
  $field 
)

Helper function for quiz_process_options().

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

◆ quiz_save_best_grade()

quiz_save_best_grade (   $quiz,
  $userid = null,
  $attempts = array() 
)

Save the overall grade for a user at a quiz in the quiz_grades table.

Parameters
object$quizThe quiz for which the best grade is to be calculated and then saved.
int$useridThe userid to calculate the grade for. Defaults to the current user.
array$attemptsThe attempts of this user. Useful if you are looping through many users. Attempts can be fetched in one master query to avoid repeated querying.
Return values
boolIndicates success or failure.

◆ quiz_send_confirmation()

quiz_send_confirmation (   $recipient,
  $a 
)

Sends a confirmation message to the student confirming that the attempt was processed.

Parameters
object$alots of useful information that can be used in the message subject and body.
Return values
int|falseas for message_send().

◆ quiz_send_notification()

quiz_send_notification (   $recipient,
  $submitter,
  $a 
)

Sends notification messages to the interested parties that assign the role capability.

Parameters
object$recipientuser object of the intended recipient
object$aassociative array of replaceable fields for the templates
Return values
int|falseas for message_send().

◆ quiz_send_notification_messages()

quiz_send_notification_messages (   $course,
  $quiz,
  $attempt,
  $context,
  $cm 
)

Send all the requried messages when a quiz attempt is submitted.

Parameters
object$coursethe course
object$quizthe quiz
object$attemptthis attempt just finished
object$contextthe quiz context
object$cmthe coursemodule for this quiz
Return values
booltrue if all necessary messages were sent successfully, else false.

◆ quiz_send_overdue_message()

quiz_send_overdue_message (   $attemptobj)

Send the notification message when a quiz attempt becomes overdue.

Parameters
quiz_attempt$attemptobjall the data about the quiz attempt.

◆ quiz_set_grade()

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.

Parameters
float$newgradethe new maximum grade for the quiz.
object$quizthe quiz we are updating. Passed by reference so its grade field can be updated too.
Return values
boolindicating success or failure.

◆ quiz_start_attempt_built_on_last()

quiz_start_attempt_built_on_last (   $quba,
  $attempt,
  $lastattempt 
)

Start a subsequent new attempt, in each attempt builds on last mode.

Parameters
question_usage_by_activity$qubathis question usage
object$attemptthis attempt
object$lastattemptlast attempt
Return values
objectmodified attempt object

◆ quiz_start_new_attempt()

quiz_start_new_attempt (   $quizobj,
  $quba,
  $attempt,
  $attemptnumber,
  $timenow,
  $questionids = array(),
  $forcedvariantsbyslot = array() 
)

Start a normal, new, quiz attempt.

Parameters
quiz$quizobjthe quiz object to start an attempt for.
question_usage_by_activity$quba
object$attempt
integer$attemptnumberstarting from 1
integer$timenowthe attempt start time
array$questionidsslot number => question id. Used for random questions, to force the choice of a particular actual question. Intended for testing purposes only.
array$forcedvariantsbyslotslot number => variant. Used for questions with variants, to force the choice of a particular variant. Intended for testing purposes only.
Exceptions
moodle_exception
Return values
objectmodified attempt object

◆ quiz_supports()

quiz_supports (   $feature)
Parameters
string$featureFEATURE_xx constant for requested feature
Return values
boolTrue if quiz supports feature

◆ quiz_update_all_attempt_sumgrades()

quiz_update_all_attempt_sumgrades (   $quiz)

Update the sumgrades field of the attempts at a quiz.

Parameters
object$quiza quiz.

◆ quiz_update_all_final_grades()

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.

Parameters
object$quizthe quiz settings.

◆ 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
object$quizThe quiz object.
int$useridThe userid.
Return values
object::$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.

@uses QUIZ_MAX_EVENT_LENGTH

Parameters
object$quizthe quiz object.
objectoptional $override limit to a specific override

◆ 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
object$quizthe data that came from the form.
Return values
mixedtrue on success, false or a string error message on failure.

◆ quiz_update_open_attempts()

quiz_update_open_attempts ( array  $conditions)

Efficiently update check state time on all open attempts.

Parameters
array$conditionsoptional restrictions on which attempts to update Allowed conditions: courseid => (array|int) attempts in given course(s) userid => (array|int) attempts for given user(s) quizid => (array|int) attempts in given quiz(s) groupid => (array|int) quizzes with some override for given group(s)

◆ quiz_update_section_firstslots()

quiz_update_section_firstslots (   $quizid,
  $direction,
  $afterslot,
  $beforeslot = null 
)

Move all the section headings in a certain slot range by a certain offset.

Parameters
int$quizidthe id of a quiz
int$directionamount to adjust section heading positions. Normally +1 or -1.
int$afterslotadjust headings that start after this slot.
int | null$beforeslotoptionally, only adjust headings before this slot.

◆ quiz_update_sumgrades()

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.

Parameters
object$quiza quiz.

◆ 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
object$course
object$user
object$mod
object$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
object$course
object$user
object$mod
object$quiz
Return values
object|null

◆ quiz_validate_new_attempt()

quiz_validate_new_attempt ( quiz  $quizobj,
quiz_access_manager  $accessmanager,
  $forcenew,
  $page,
  $redirect 
)

Validate permissions for creating a new attempt and start a new preview attempt if required.

Parameters
quiz$quizobjquiz object
quiz_access_manager$accessmanagerquiz access manager
bool$forcenewwhether was required to start a new preview attempt
int$pagepage to jump to in the attempt
bool$redirectwhether to redirect or throw exceptions (for web or ws usage)
Return values
arrayan array containing the attempt information, access error messages and the page to jump to in the attempt
Exceptions
moodle_quiz_exception
Since
Moodle 3.1

◆ quiz_view()

quiz_view (   $quiz,
  $course,
  $cm,
  $context 
)

Mark the activity completed (if required) and trigger the course_module_viewed event.

Parameters
stdClass$quizquiz object
stdClass$coursecourse object
stdClass$cmcourse module object
stdClass$contextcontext object
Since
Moodle 3.1

◆ xmldb_quiz_upgrade()

xmldb_quiz_upgrade (   $oldversion)

Quiz module upgrade function.

Parameters
string$oldversionthe version we are upgrading from.

Variable Documentation

◆ $logs

$logs
Initial value:
= array(
array('module'=>'quiz', 'action'=>'add', 'mtable'=>'quiz', 'field'=>'name'),
array('module'=>'quiz', 'action'=>'update', 'mtable'=>'quiz', 'field'=>'name'),
array('module'=>'quiz', 'action'=>'view', 'mtable'=>'quiz', 'field'=>'name'),
array('module'=>'quiz', 'action'=>'report', 'mtable'=>'quiz', 'field'=>'name'),
array('module'=>'quiz', 'action'=>'attempt', 'mtable'=>'quiz', 'field'=>'name'),
array('module'=>'quiz', 'action'=>'submit', 'mtable'=>'quiz', 'field'=>'name'),
array('module'=>'quiz', 'action'=>'review', 'mtable'=>'quiz', 'field'=>'name'),
array('module'=>'quiz', 'action'=>'editquestions', 'mtable'=>'quiz', 'field'=>'name'),
array('module'=>'quiz', 'action'=>'preview', 'mtable'=>'quiz', 'field'=>'name'),
array('module'=>'quiz', 'action'=>'start attempt', 'mtable'=>'quiz', 'field'=>'name'),
array('module'=>'quiz', 'action'=>'close attempt', 'mtable'=>'quiz', 'field'=>'name'),
array('module'=>'quiz', 'action'=>'continue attempt', 'mtable'=>'quiz', 'field'=>'name'),
array('module'=>'quiz', 'action'=>'edit override', 'mtable'=>'quiz', 'field'=>'name'),
array('module'=>'quiz', 'action'=>'delete override', 'mtable'=>'quiz', 'field'=>'name'),
array('module'=>'quiz', 'action'=>'view summary', 'mtable'=>'quiz', 'field'=>'name'),
)

◆ $messageproviders

$messageproviders
Initial value:
= array(
'submission' => array(
'capability' => 'mod/quiz:emailnotifysubmission'
),
'confirmation' => array(
'capability' => 'mod/quiz:emailconfirmsubmission',
'defaults' => array(
'airnotifier' => MESSAGE_PERMITTED + MESSAGE_DEFAULT_LOGGEDIN + MESSAGE_DEFAULT_LOGGEDOFF,
),
),
'attempt_overdue' => array(
'capability' => 'mod/quiz:emailwarnoverdue',
'defaults' => array(
'airnotifier' => MESSAGE_PERMITTED + MESSAGE_DEFAULT_LOGGEDIN + MESSAGE_DEFAULT_LOGGEDOFF,
),
),
)
const MESSAGE_DEFAULT_LOGGEDIN
Define contants for messaging default settings population.
Definition: lib.php:44

◆ $tasks

$tasks
Initial value:
= [
[
'classname' => 'mod_quiz\task\update_overdue_attempts',
'blocking' => 0,
'minute' => '*',
'hour' => '*',
'day' => '*',
'dayofweek' => '*',
'month' => '*'
],
[
'classname' => 'mod_quiz\task\legacy_quiz_reports_cron',
'blocking' => 0,
'minute' => '*',
'hour' => '*',
'day' => '*',
'dayofweek' => '*',
'month' => '*'
],
[
'classname' => 'mod_quiz\task\legacy_quiz_accessrules_cron',
'blocking' => 0,
'minute' => '*',
'hour' => '*',
'day' => '*',
'dayofweek' => '*',
'month' => '*'
]
]

◆ else

if($ADMIN->fulltree) if (empty( $reportsbyname) &&empty( $rulesbyname)) else
Initial value:
{
$pagetitle = get_string('generalsettings', 'admin')

◆ 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

◆ QUIZ_MIN_TIME_TO_CONTINUE

const QUIZ_MIN_TIME_TO_CONTINUE '2'

If there are fewer than this many seconds left when the student submits a page of the quiz, then do not take them to the next page of the quiz.

Instead close the quiz immediately.

◆ QUIZ_SHOW_TIME_BEFORE_DEADLINE

const QUIZ_SHOW_TIME_BEFORE_DEADLINE '3600'

We show the countdown timer if there is less than this amount of time left before the the quiz close date.

(1 hour)