Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
core_question\statistics\responses\analyser Class Reference

This class can compute, store and cache the analysis of the responses to a particular question. More...

Public Member Functions

 __construct ($questiondata, $whichtries=question_attempt::LAST_TRY)
 Create a new instance of this class for holding/computing the statistics for a particular question.
 
 calculate ($qubaids, $whichtries=question_attempt::LAST_TRY)
 Analyse all the response data for all the specified attempts at this question.
 
 get_last_analysed_time ($qubaids, $whichtries)
 Find time of non-expired analysis in the database.
 
 has_response_classes ()
 Does the computed analysis's sub parts have classes?
 
 has_subparts ()
 Does the computed analysis have sub parts?
 
 load_cached ($qubaids, $whichtries)
 Retrieve the computed response analysis from the question_response_analysis table.
 

Public Attributes

analysis_for_question analysis_for_question_all_tries $analysis
 
array $responseclasses = array()
 Two index array first index is unique string for each sub question part, the second string index is the 'class' that sub-question part can be classified into.
 
int const MAX_TRY_COUNTED = 5
 When analysing responses and breaking down the count of responses per try, how many columns should we break down tries into? This is set to 5 columns, any response in a try more than try 5 will be counted in the fifth column.
 
int const TIME_TO_CACHE = 900
 previously, the time after which statistics are automatically recomputed.
 

Protected Attributes

bool $breakdownbyvariant
 whether to break down response analysis by variant.
 
int $calculationtime
 used during calculations, so all results are stored with the same timestamp.
 
object $questiondata
 full question data from db.
 

Detailed Description

This class can compute, store and cache the analysis of the responses to a particular question.

Author
James 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\responses\analyser::__construct ( $questiondata,
$whichtries = question_attempt::LAST_TRY )

Create a new instance of this class for holding/computing the statistics for a particular question.

Parameters
object$questiondatathe full question data from the database defining this question.
string$whichtrieswhich tries to analyse.

Member Function Documentation

◆ calculate()

core_question\statistics\responses\analyser::calculate ( $qubaids,
$whichtries = question_attempt::LAST_TRY )

Analyse all the response data for all the specified attempts at this question.

Parameters
qubaid_condition$qubaidswhich attempts to consider.
string$whichtrieswhich tries to analyse. Will be one of question_attempt\FIRST_TRY, LAST_TRY or ALL_TRIES.
Return values
analysis_for_question

◆ get_last_analysed_time()

core_question\statistics\responses\analyser::get_last_analysed_time ( $qubaids,
$whichtries )

Find time of non-expired analysis in the database.

Parameters
qubaid_condition$qubaidscheck for the analysis of which question usages?
string$whichtriescheck for the analysis of which tries?
Return values
integer|booleanTime of cached record that matches this qubaid_condition or false if none found.

◆ has_response_classes()

core_question\statistics\responses\analyser::has_response_classes ( )

Does the computed analysis's sub parts have classes?

Return values
boolwhether this analysis has (a subpart with) more than one response class.

◆ has_subparts()

core_question\statistics\responses\analyser::has_subparts ( )

Does the computed analysis have sub parts?

Return values
boolwhether this analysis has more than one subpart.

◆ load_cached()

core_question\statistics\responses\analyser::load_cached ( $qubaids,
$whichtries )

Retrieve the computed response analysis from the question_response_analysis table.

Parameters
qubaid_condition$qubaidsload the analysis of which question usages?
string$whichtriesload the analysis of which tries?
Return values
analysis_for_question|booleananalysis or false if no cached analysis found.

Member Data Documentation

◆ $breakdownbyvariant

bool core_question\statistics\responses\analyser::$breakdownbyvariant
protected

whether to break down response analysis by variant.

This only applies to questions that have variants and is used to suppress the break down of analysis by variant when there are going to be very many variants.

◆ $responseclasses

array core_question\statistics\responses\analyser::$responseclasses = array()

Two index array first index is unique string for each sub question part, the second string index is the 'class' that sub-question part can be classified into.

This is the return value from question_type::get_possible_responses() see that method for fuller documentation.

◆ TIME_TO_CACHE

int const core_question\statistics\responses\analyser::TIME_TO_CACHE = 900

previously, the time after which statistics are automatically recomputed.

Deprecated
since Moodle 4.3. Use of pre-computed stats is no longer time-limited.
Todo
MDL-78090 Final deprecation in Moodle 4.7

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