Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

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

(no description)

File Size: 284 lines (12 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: calculator  - X-Ref

Class to calculate and also manage caching of quiz statistics.

These quiz statistics calculations are described here :

http://docs.moodle.org/dev/Quiz_statistics_calculations#Test_statistics

__construct(\core\progress\base $progress = null)   X-Ref


calculate($quizid, $whichattempts, \core\dml\sql_join $groupstudentsjoins, $p, $sumofmarkvariance)   X-Ref
Compute the quiz statistics.

param: int   $quizid            the quiz id.
param: int $whichattempts which attempts to use, represented internally as one of the constants as used in
param: \core\dml\sql_join $groupstudentsjoins Contains joins, wheres, params for students in this group.
param: int   $p                 number of positions (slots).
param: float $sumofmarkvariance sum of mark variance, calculated as part of question statistics
return: calculated $quizstats The statistics for overall attempt scores.

get_cached($qubaids)   X-Ref
Load cached statistics from the database.

param: $qubaids \qubaid_condition
return: calculated The statistics for overall attempt scores or false if not cached.

get_last_calculated_time($qubaids)   X-Ref
Find time of non-expired statistics in the database.

param: $qubaids \qubaid_condition
return: integer|boolean Time of cached record that matches this qubaid_condition or false is non found.

using_attempts_lang_string($whichattempts)   X-Ref
Given a particular quiz grading method return a lang string describing which attempts contribute to grade.

Note internally we use the grading method constants to represent which attempts we are calculating statistics for, each
grading method corresponds to different attempts for each user.

param: int $whichattempts which attempts to use, represented internally as one of the constants as used in
return: string the appropriate lang string to describe this option.

using_attempts_string_id($whichattempts)   X-Ref
Given a particular quiz grading method return a string id for use as a field name prefix in mdl_quiz_statistics or to
fetch the appropriate language string describing which attempts contribute to grade.

Note internally we use the grading method constants to represent which attempts we are calculating statistics for, each
grading method corresponds to different attempts for each user.

param: int $whichattempts which attempts to use, represented internally as one of the constants as used in
return: string the string id for this option.

attempt_counts_and_averages($quizid, \core\dml\sql_join $groupstudentsjoins)   X-Ref
Calculating count and mean of marks for first and ALL attempts by students.

See : http://docs.moodle.org/dev/Quiz_item_analysis_calculations_in_practise
#Calculating_MEAN_of_grades_for_all_attempts_by_students
param: int $quizid
param: \core\dml\sql_join $groupstudentsjoins Contains joins, wheres, params for students in this group.
return: \stdClass with properties with count and avg with prefixes firstattempts, highestattempts, etc.

median($s, $fromqa, $whereqa, $qaparams)   X-Ref
Median mark.

http://docs.moodle.org/dev/Quiz_statistics_calculations#Median_Score

param: $s integer count of attempts
param: $fromqa string
param: $whereqa string
param: $qaparams string
return: float

sum_of_powers_of_difference_to_mean($mean, $fromqa, $whereqa, $qaparams)   X-Ref
Fetch the sum of squared, cubed and to the power 4 differences between sumgrade and it's mean.

Explanation here : http://docs.moodle.org/dev/Quiz_item_analysis_calculations_in_practise
#Calculating_Standard_Deviation.2C_Skewness_and_Kurtosis_of_grades_for_all_attempts_by_students

param: $mean
param: $fromqa
param: $whereqa
param: $qaparams
return: object with properties power2, power3, power4