Moodle PHP Documentation 4.4
Moodle 4.4.1 (Build: 20240610) (db07c09afc5)
core_question\statistics\questions\calculator Class Reference

This class has methods to compute the question statistics from the raw data. More...

Public Member Functions

 __construct ($questions, $progress=null)
 Constructor.
 
 calculate ($qubaids)
 Calculate the stats.
 
 get_cached ($qubaids)
 Load cached statistics from the database.
 
 get_last_calculated_time ($qubaids)
 Find time of non-expired statistics in the database.
 
 get_sum_of_mark_variance ()
 Used when computing Coefficient of Internal Consistency by quiz statistics.
 

Protected Member Functions

 get_latest_steps ($qubaids)
 Get the latest step data from the db, from which we will calculate stats.
 
 get_random_guess_score ($questiondata)
 Given the question data find the average grade that random guesses would get.
 
 initial_question_walker ($stats)
 Then loop through all questions for the first time.
 
 initial_steps_walker ($step, $stats, $summarks, $positionstat=true, $dovariantalso=true)
 Calculating the stats is a four step process.
 
 secondary_question_walker ($stats)
 And finally loop through all the questions again.
 
 secondary_steps_walker ($step, $stats, $summarks)
 Loop through all last step data again.
 

Protected Attributes

progress_trace $progress
 
array[] $randomselectors = array()
 keyed by a string representing the pool of questions that this random question draws from.
 
all_calculated_for_qubaid_condition $stats
 all the stats calculated for slots and sub-questions and variants of those questions.
 
string $statscollectionclassname = '\core_question\statistics\questions\all_calculated_for_qubaid_condition'
 The class name of the class to instantiate to store statistics calculated.
 
float $sumofmarkvariance = 0
 

Detailed Description

This class has methods to compute the question statistics from the raw data.

Author
Jamie Pratt me@ja.nosp@m.miep.nosp@m..org
License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Constructor & Destructor Documentation

◆ __construct()

core_question\statistics\questions\calculator::__construct ( $questions,
$progress = null )

Constructor.

Parameters
object[]questions to analyze, keyed by slot, also analyses sub questions for random questions. we expect some extra fields - slot, maxmark and number on the full question data objects.
core\progress\base | null$progressthe element to send progress messages to, default is core\progress\none.

Member Function Documentation

◆ calculate()

core_question\statistics\questions\calculator::calculate ( $qubaids)

Calculate the stats.

Parameters
qubaid_condition$qubaidsWhich question usages to calculate the stats for?
Return values
all_calculated_for_qubaid_conditionThe calculated stats.

◆ get_cached()

core_question\statistics\questions\calculator::get_cached ( $qubaids)

Load cached statistics from the database.

Parameters
qubaid_condition$qubaidsWhich question usages to load the cached stats for?
Return values
all_calculated_for_qubaid_conditionThe cached stats.

◆ get_last_calculated_time()

core_question\statistics\questions\calculator::get_last_calculated_time ( $qubaids)

Find time of non-expired statistics in the database.

Parameters
qubaid_condition$qubaidsWhich question usages to look for?
Return values
int|boolTime of cached record that matches this qubaid_condition or false is non found.

◆ get_latest_steps()

core_question\statistics\questions\calculator::get_latest_steps ( $qubaids)
protected

Get the latest step data from the db, from which we will calculate stats.

Parameters
qubaid_condition$qubaidsWhich question usages to get the latest steps for?
Return values
arraywith two items
  • $lateststeps array of latest step data for the question usages
  • $summarks array of total marks for each usage, indexed by usage id

◆ get_random_guess_score()

core_question\statistics\questions\calculator::get_random_guess_score ( $questiondata)
protected

Given the question data find the average grade that random guesses would get.

Parameters
object$questiondatathe full question object.
Return values
floatthe random guess score for this question.

◆ get_sum_of_mark_variance()

core_question\statistics\questions\calculator::get_sum_of_mark_variance ( )

Used when computing Coefficient of Internal Consistency by quiz statistics.

Return values
float

◆ initial_question_walker()

core_question\statistics\questions\calculator::initial_question_walker ( $stats)
protected

Then loop through all questions for the first time.

Perform some computations on the per-question statistics calculations after we have been through all the step data.

Parameters
calculated$statsquestion stats to update.

◆ initial_steps_walker()

core_question\statistics\questions\calculator::initial_steps_walker ( $step,
$stats,
$summarks,
$positionstat = true,
$dovariantalso = true )
protected

Calculating the stats is a four step process.

We loop through all 'last step' data first.

Update $stats->totalmarks, $stats->markarray, $stats->totalothermarks and $stats->othermarksarray to include another state.

Parameters
object$stepthe state to add to the statistics.
calculated$statsthe question statistics we are accumulating.
array$summarksof the sum of marks for each question usage, indexed by question usage id
bool$positionstatwhether this is a statistic of position of question.
bool$dovariantalsodo we also want to do the same calculations for this variant?

◆ secondary_question_walker()

core_question\statistics\questions\calculator::secondary_question_walker ( $stats)
protected

And finally loop through all the questions again.

Perform more per-question statistics calculations.

Parameters
calculated$statsquestion stats to update.

◆ secondary_steps_walker()

core_question\statistics\questions\calculator::secondary_steps_walker ( $step,
$stats,
$summarks )
protected

Loop through all last step data again.

Now we know the averages, accumulate the date needed to compute the higher moments of the question scores.

Parameters
object$stepthe state to add to the statistics.
calculated$statsthe question statistics we are accumulating.
float[]$summarksof the sum of marks for each question usage, indexed by question usage id

Member Data Documentation

◆ $randomselectors

array [] core_question\statistics\questions\calculator::$randomselectors = array()
protected

keyed by a string representing the pool of questions that this random question draws from.

string as returned from core_question::statistics::questions::calculated::random_selector_string


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