Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

Differences Between: [Versions 311 and 403] [Versions 400 and 403] [Versions 401 and 403] [Versions 402 and 403]

List of deprecated mod_quiz functions.

Copyright: 2021 Shamim Rezaie <shamim@moodle.com>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 383 lines (15 kb)
Included or required: 1 time
Referenced: 1 time
Includes or requires: 0 files

Defines 3 classes

instead:: (2 methods):
  quiz_retrieve_tags_for_slot_ids()
  quiz_has_question_use()

mod_quiz_overdue_attempt_updater:: (2 methods):
  update_overdue_attempts()
  get_list_of_overdue_attempts()

moodle_quiz_exception:: (8 methods):
  __construct()
  quiz_update_sumgrades()
  quiz_update_all_attempt_sumgrades()
  quiz_update_all_final_grades()
  quiz_set_grade()
  quiz_save_best_grade()
  quiz_calculate_best_grade()
  quiz_calculate_best_attempt()

Defines 8 functions


Class: instead  - X-Ref

quiz_retrieve_tags_for_slot_ids($slotids)   X-Ref
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 => [],
]

param: int[] $slotids The list of id for the quiz slots.
return: array[] List of quiz_slot_tags records indexed by slot id.

quiz_has_question_use($quiz, $slot)   X-Ref
No description

Class: moodle_quiz_exception  - X-Ref

Class for quiz exceptions. Just saves a couple of arguments on the
constructor for a moodle_exception.

__construct($quizobj, $errorcode, $a = null, $link = '', $debuginfo = null)   X-Ref
Constructor.

param: quiz_settings $quizobj the quiz the error relates to.
param: string $errorcode The name of the string from error.php to print.
param: mixed $a Extra words and phrases that might be required in the error string.
param: string $link The url where the user will be prompted to continue.
param: string|null $debuginfo optional debugging information.

quiz_update_sumgrades($quiz)   X-Ref
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 {@see quiz_delete_previews()} before you call this function.

param: stdClass $quiz a quiz.

quiz_update_all_attempt_sumgrades($quiz)   X-Ref
Update the sumgrades field of the attempts at a quiz.

param: stdClass $quiz a quiz.

quiz_update_all_final_grades($quiz)   X-Ref
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.

param: stdClass $quiz the quiz settings.

quiz_set_grade($newgrade, $quiz)   X-Ref
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, grade_calculator::recompute_all_final_grades();
quiz_update_grades. (At least, that is what this comment has said for years, but
it seems to call recompute_all_final_grades itself.)

param: float $newgrade the new maximum grade for the quiz.
param: stdClass $quiz the quiz we are updating. Passed by reference so its
return: bool indicating success or failure.

quiz_save_best_grade($quiz, $userid = null, $attempts = [])   X-Ref
Save the overall grade for a user at a quiz in the quiz_grades table

param: stdClass $quiz The quiz for which the best grade is to be calculated and then saved.
param: int $userid The userid to calculate the grade for. Defaults to the current user.
param: array $attempts The attempts of this user. Useful if you are
return: bool Indicates success or failure.

quiz_calculate_best_grade($quiz, $attempts)   X-Ref
Calculate the overall grade for a quiz given a number of attempts by a particular user.

param: stdClass $quiz    the quiz settings object.
param: array $attempts an array of all the user's attempts at this quiz in order.
return: float          the overall grade

quiz_calculate_best_attempt($quiz, $attempts)   X-Ref
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.
param: stdClass $quiz    The quiz for which the best grade is to be calculated
param: array $attempts An array of all the attempts of the user at the quiz
return: stdClass         The attempt with the best grade

Functions that are not part of a class: