Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
quiz_statistics\calculator Class Reference

Public Member Functions

 __construct (\core\progress\base $progress=null)
 
 calculate ($quizid, $whichattempts, core\dml\sql_join $groupstudentsjoins, $p, $sumofmarkvariance)
 Compute the quiz statistics.
 
 get_cached ($qubaids)
 Load cached statistics from the database.
 
 get_last_calculated_time ($qubaids)
 Find time of non-expired statistics in the database.
 

Static Public Member Functions

static using_attempts_lang_string ($whichattempts)
 Given a particular quiz grading method return a lang string describing which attempts contribute to grade.
 
static using_attempts_string_id ($whichattempts)
 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.
 

Public Attributes

int const TIME_TO_CACHE = 900
 No longer used.
 

Protected Member Functions

 attempt_counts_and_averages ($quizid, core\dml\sql_join $groupstudentsjoins)
 Calculating count and mean of marks for first and ALL attempts by students.
 
 median ($s, $fromqa, $whereqa, $qaparams)
 Median mark.
 
 sum_of_powers_of_difference_to_mean ($mean, $fromqa, $whereqa, $qaparams)
 Fetch the sum of squared, cubed and to the power 4 differences between sumgrade and it's mean.
 

Protected Attributes

core progress base $progress
 

Member Function Documentation

◆ attempt_counts_and_averages()

quiz_statistics\calculator::attempt_counts_and_averages ( $quizid,
core\dml\sql_join $groupstudentsjoins )
protected

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

Parameters
int$quizid
core\dml\sql_join$groupstudentsjoinsContains joins, wheres, params for students in this group.
Return values
stdClasswith properties with count and avg with prefixes firstattempts, highestattempts, etc.

◆ calculate()

quiz_statistics\calculator::calculate ( $quizid,
$whichattempts,
core\dml\sql_join $groupstudentsjoins,
$p,
$sumofmarkvariance )

Compute the quiz statistics.

Parameters
int$quizidthe quiz id.
int$whichattemptswhich attempts to use, represented internally as one of the constants as used in $quiz->grademethod ie. QUIZ_GRADEAVERAGE, QUIZ_GRADEHIGHEST, QUIZ_ATTEMPTLAST or QUIZ_ATTEMPTFIRST we calculate stats based on which attempts would affect the grade for each student.
core\dml\sql_join$groupstudentsjoinsContains joins, wheres, params for students in this group.
int$pnumber of positions (slots).
float$sumofmarkvariancesum of mark variance, calculated as part of question statistics
Return values
calculated\$quizstatsThe statistics for overall attempt scores.

◆ get_cached()

quiz_statistics\calculator::get_cached ( $qubaids)

Load cached statistics from the database.

Parameters
qubaid_condition$qubaids
Return values
calculated|falseThe statistics for overall attempt scores or false if not cached.

◆ get_last_calculated_time()

quiz_statistics\calculator::get_last_calculated_time ( $qubaids)

Find time of non-expired statistics in the database.

Parameters
$qubaidsqubaid_condition
Return values
int|boolTime of cached record that matches this qubaid_condition or false is non found.

◆ median()

quiz_statistics\calculator::median ( $s,
$fromqa,
$whereqa,
$qaparams )
protected

Median mark.

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

Parameters
$sinteger count of attempts
$fromqastring
$whereqastring
$qaparamsstring
Return values
float

◆ sum_of_powers_of_difference_to_mean()

quiz_statistics\calculator::sum_of_powers_of_difference_to_mean ( $mean,
$fromqa,
$whereqa,
$qaparams )
protected

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

Parameters
$mean
$fromqa
$whereqa
$qaparams
Return values
stdClasswith properties power2, power3, power4

◆ using_attempts_lang_string()

static quiz_statistics\calculator::using_attempts_lang_string ( $whichattempts)
static

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.

Parameters
int$whichattemptswhich attempts to use, represented internally as one of the constants as used in $quiz->grademethod ie. QUIZ_GRADEAVERAGE, QUIZ_GRADEHIGHEST, QUIZ_ATTEMPTLAST or QUIZ_ATTEMPTFIRST we calculate stats based on which attempts would affect the grade for each student.
Return values
stringthe appropriate lang string to describe this option.

◆ using_attempts_string_id()

static quiz_statistics\calculator::using_attempts_string_id ( $whichattempts)
static

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.

Parameters
int$whichattemptswhich attempts to use, represented internally as one of the constants as used in $quiz->grademethod ie. QUIZ_GRADEAVERAGE, QUIZ_GRADEHIGHEST, QUIZ_ATTEMPTLAST or QUIZ_ATTEMPTFIRST we calculate stats based on which attempts would affect the grade for each student.
Return values
stringthe string id for this option.

Member Data Documentation

◆ TIME_TO_CACHE

int const quiz_statistics\calculator::TIME_TO_CACHE = 900

No longer used.

Previously the time after which statistics are automatically recomputed.


The documentation for this class was generated from the following file: