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

Functions

 quiz_add_quiz_question ($questionid, $quiz, $page=0, $maxmark=null)
 Add a question to a quiz.
 
 quiz_add_random_questions (stdClass $quiz, int $addonpage, int $categoryid, int $number)
 Add a random question to the quiz at a given point.
 
 quiz_attempt_save_started ($quizobj, $quba, $attempt)
 The save started question usage and quiz attempt in db and log the started attempt.
 
 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.
 
 quiz_attempt_state_name ($state)
 Get the human-readable name for a quiz attempt state.
 
 quiz_attempt_submitted_handler ($event)
 Handle the quiz_attempt_submitted event.
 
 quiz_create_attempt (quiz_settings $quizobj, $attemptnumber, $lastattempt, $timenow, $ispreview=false, $userid=null)
 Creates an object to represent a new attempt at a quiz.
 
 quiz_create_attempt_handling_errors ($attemptid, $cmid=null)
 Get quiz attempt and handling error.
 
 quiz_delete_attempt ($attempt, $quiz)
 Delete a quiz attempt.
 
 quiz_delete_previews ($quiz, $userid=null)
 Delete all the preview attempts at a quiz, or possibly all the attempts belonging to one user.
 
 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.
 
 quiz_feedback_record_for_grade ($grade, $quiz)
 Get the feedback object for this grade on this quiz.
 
 quiz_get_attempt_usertime_sql ($redundantwhereclauses='')
 Returns SQL to compute timeclose and timelimit for every attempt, taking into account user and group overrides.
 
 quiz_get_combined_reviewoptions ($quiz, $attempts)
 Combines the review options from a number of different quiz attempts.
 
 quiz_get_flag_option ($attempt, $context)
 
 quiz_get_grading_option_name ($option)
 
 quiz_get_grading_options ()
 
 quiz_get_js_module ()
 Get the information about the standard quiz JavaScript module.
 
 quiz_get_overdue_handling_options ()
 
 quiz_get_review_options ($quiz, $attempt, $context)
 The appropriate display_options object for this attempt at this quiz right now.
 
 quiz_get_user_attempt_unfinished ($quizid, $userid)
 Returns an unfinished attempt (if there is one) for the given user on the given quiz.
 
 quiz_get_user_image_options ()
 Get the choices for what size user picture to show.
 
 quiz_get_user_timeclose ($courseid)
 Return an user's timeclose for all quizzes in a course, hereby taking into account group and user overrides.
 
 quiz_has_attempts ($quizid)
 
 quiz_has_feedback ($quiz)
 
 quiz_is_overriden_calendar_event (\calendar_event $event)
 Check if the given calendar_event is either a user or group override event for quiz.
 
 quiz_override_summary (stdClass $quiz, cm_info|stdClass $cm, int $currentgroup=0)
 Return summary of the number of settings override that exist.
 
 quiz_prepare_and_start_new_attempt (quiz_settings $quizobj, $attemptnumber, $lastattempt, $offlineattempt=false, $forcedrandomquestions=[], $forcedvariants=[], $userid=null)
 Prepare and start a new attempt deleting the previous preview attempts.
 
 quiz_process_group_deleted_in_course ($courseid)
 Logic to happen when a/some group(s) has/have been deleted in a course.
 
 quiz_question_action_icons ($quiz, $cmid, $question, $returnurl, $variant=null)
 
 quiz_question_edit_button ($cmid, $question, $returnurl, $contentaftericon='')
 
 quiz_question_preview_button ($quiz, $question, $label=false, $variant=null, $random=null)
 
 quiz_question_preview_url ($quiz, $question, $variant=null, $restartversion=null)
 
 quiz_question_tostring ($question, $showicon=false, $showquestiontext=true, $showidnumber=false, $showtags=false)
 Creates a textual representation of a question for display.
 
 quiz_questions_per_page_options ()
 Get the choices to offer for the 'Questions per page' option.
 
 quiz_repaginate_questions ($quizid, $slotsperpage)
 Repaginate the questions in a quiz.
 
 quiz_require_question_use ($questionid)
 Verify that the question exists, and the user has permission to use it.
 
 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.
 
 quiz_send_confirmation ($recipient, $a, $studentisonline)
 Sends a confirmation message to the student confirming that the attempt was processed.
 
 quiz_send_notification ($recipient, $submitter, $a)
 Sends notification messages to the interested parties that assign the role capability.
 
 quiz_send_notification_messages ($course, $quiz, $attempt, $context, $cm, $studentisonline)
 Send all the requried messages when a quiz attempt is submitted.
 
 quiz_send_notify_manual_graded_message (quiz_attempt $attemptobj, object $userto)
 Send the notification message when a quiz attempt has been manual graded.
 
 quiz_send_overdue_message ($attemptobj)
 Send the notification message when a quiz attempt becomes overdue.
 
 quiz_start_attempt_built_on_last ($quba, $attempt, $lastattempt)
 Start a subsequent new attempt, in each attempt builds on last mode.
 
 quiz_start_new_attempt ($quizobj, $quba, $attempt, $attemptnumber, $timenow, $questionids=[], $forcedvariantsbyslot=[])
 Start a normal, new, quiz attempt.
 
 quiz_update_open_attempts (array $conditions)
 Efficiently update check state time on all open attempts.
 
 quiz_update_section_firstslots ($quizid, $direction, $afterslot, $beforeslot=null)
 Move all the section headings in a certain slot range by a certain offset.
 
 quiz_validate_new_attempt (quiz_settings $quizobj, access_manager $accessmanager, $forcenew, $page, $redirect)
 Validate permissions for creating a new attempt and start a new preview attempt if required.
 
 quiz_view ($quiz, $course, $cm, $context)
 Mark the activity completed (if required) and trigger the course_module_viewed event.
 

Variables

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