Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
core_question\statistics\questions\all_calculated_for_qubaid_condition Class Reference

A collection of all the question statistics calculated for an activity instance. More...

Public Member Functions

 any_error_messages ()
 Call after calculations to output any error messages.
 
 cache ($qubaids)
 Save stats to db, first cleaning up any old ones.
 
 for_slot ($slot, $variant=null)
 Get position stats instance for a slot and optional variant no.
 
 for_subq ($questionid, $variant=null)
 Reference for a item stats instance for a questionid and optional variant no.
 
 get_all_slots ()
 All slots nos that stats have been calculated for.
 
 get_all_subq_ids ()
 ids of all randomly selected question for all slots.
 
 get_cached ($qubaids)
 Load cached statistics from the database.
 
 get_last_calculated_time ($qubaids)
 Find time of non-expired statistics in the database.
 
 get_sub_questions ()
 Return all sub-questions used.
 
 has_slot ($slot, $variant=null)
 Do we have stats for a particular slot (and optionally variant)?
 
 has_subq ($questionid, $variant=null)
 Do we have stats for a particular quesitonid (and optionally variant)?
 
 initialise_for_slot ($slot, $question, $variant=null)
 Set up a calculated instance ready to store a slot question's stats.
 
 initialise_for_subq ($step, $variant=null)
 Set up a calculated_for_subquestion instance ready to store a randomly selected question's stats.
 
 structure_analysis_for_one_slot ($slot, $limitvariants=false)
 Return all stats for one slot, stats for the slot itself, and either :
 

Public Attributes

calculated[] $questionstats = array()
 Holds slot (position) stats and stats for variants of questions in slots.
 
object[] $subquestions = []
 
calculated_for_subquestion[] $subquestionstats = array()
 Holds sub-question stats and stats for variants of subqs.
 
int const TIME_TO_CACHE = 900
 No longer used.
 

Protected Member Functions

 all_subq_and_variant_stats_for_slot ($slot, $limited)
 Return all variant or 'sub-question' stats one slot, either :
 
 all_subq_variants_for_one_slot ($slot)
 Return all stats for variants of randomly selected questions for one slot $slot.
 
 all_subqs_for_one_slot ($slot)
 Return all stats for randomly selected questions for one slot $slot.
 
 all_variant_stats_for_one_slot ($slot)
 Return all stats for variants of question in slot $slot.
 
 make_new_calculated_question_summary_stat ($randomquestioncalculated, $subquestionstats)
 Create a summary calculated object for a calculated question.
 
 make_new_subq_stat_for ($displaynumber, $slot, $subqid, $variant=null)
 We need a new object for display.
 

Detailed Description

A collection of all the question statistics calculated for an activity instance.

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

Member Function Documentation

◆ all_subq_and_variant_stats_for_slot()

core_question\statistics\questions\all_calculated_for_qubaid_condition::all_subq_and_variant_stats_for_slot ( $slot,
$limited )
protected

Return all variant or 'sub-question' stats one slot, either :

  • variants of question
  • variants of randomly selected questions
  • randomly selected questions
Parameters
int$slotthe slot no
bool$limitedlimit number of variants and sub-questions displayed?
Return values
calculated|calculated_for_subquestion|calculated_question_summary[]stats to display

◆ all_subq_variants_for_one_slot()

core_question\statistics\questions\all_calculated_for_qubaid_condition::all_subq_variants_for_one_slot ( $slot)
protected

Return all stats for variants of randomly selected questions for one slot $slot.

Parameters
int$slotThe slot no.
Return values
calculated[]The instances storing the calculated stats.

◆ all_subqs_for_one_slot()

core_question\statistics\questions\all_calculated_for_qubaid_condition::all_subqs_for_one_slot ( $slot)
protected

Return all stats for randomly selected questions for one slot $slot.

Parameters
int$slotThe slot no.
Return values
calculated[]The instances storing the calculated stats.

◆ all_variant_stats_for_one_slot()

core_question\statistics\questions\all_calculated_for_qubaid_condition::all_variant_stats_for_one_slot ( $slot)
protected

Return all stats for variants of question in slot $slot.

Parameters
int$slotThe slot no.
Return values
calculated[]The instances storing the calculated stats.

◆ any_error_messages()

core_question\statistics\questions\all_calculated_for_qubaid_condition::any_error_messages ( )

Call after calculations to output any error messages.

Return values
string[]Array of strings describing error messages found during stats calculation.

◆ cache()

core_question\statistics\questions\all_calculated_for_qubaid_condition::cache ( $qubaids)

Save stats to db, first cleaning up any old ones.

Parameters
qubaid_condition$qubaidsWhich question usages are we caching the stats of?

◆ for_slot()

core_question\statistics\questions\all_calculated_for_qubaid_condition::for_slot ( $slot,
$variant = null )

Get position stats instance for a slot and optional variant no.

Parameters
int$slotThe slot no.
int | null$variantif provided then we want the object which stores a variant of a position's stats.
Return values
calculated|calculated_for_subquestionAn instance of the class storing the calculated position stats.
Exceptions
coding_exceptionif there is an attempt to respond to a non-existant set of stats.

◆ for_subq()

core_question\statistics\questions\all_calculated_for_qubaid_condition::for_subq ( $questionid,
$variant = null )

Reference for a item stats instance for a questionid and optional variant no.

Parameters
int$questionidThe id of the sub question.
int | null$variantif not null then we want the object to store a variant of a sub-question's stats.
Return values
calculated|calculated_for_subquestionstats instance for a questionid and optional variant no. Will be a calculated_for_subquestion if no variant specified.
Exceptions
coding_exceptionif there is an attempt to respond to a non-existant set of stats.

◆ get_all_slots()

core_question\statistics\questions\all_calculated_for_qubaid_condition::get_all_slots ( )

All slots nos that stats have been calculated for.

Return values
int[]An array of all slot nos.

◆ get_all_subq_ids()

core_question\statistics\questions\all_calculated_for_qubaid_condition::get_all_subq_ids ( )

ids of all randomly selected question for all slots.

Return values
int[]An array of all sub-question ids.

◆ get_cached()

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

Load cached statistics from the database.

Parameters
qubaid_condition$qubaidsWhich question usages to load stats for?

◆ get_last_calculated_time()

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

Find time of non-expired statistics in the database.

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

◆ get_sub_questions()

core_question\statistics\questions\all_calculated_for_qubaid_condition::get_sub_questions ( )

Return all sub-questions used.

Return values
object[]array of questions.

◆ has_slot()

core_question\statistics\questions\all_calculated_for_qubaid_condition::has_slot ( $slot,
$variant = null )

Do we have stats for a particular slot (and optionally variant)?

Parameters
int$slotThe slot no.
int | null$variantif provided then we want the object which stores a variant of a position's stats.
Return values
boolwhether those stats exist (yet).

◆ has_subq()

core_question\statistics\questions\all_calculated_for_qubaid_condition::has_subq ( $questionid,
$variant = null )

Do we have stats for a particular quesitonid (and optionally variant)?

Parameters
int$questionidThe id of the sub question.
int | null$variantif not null then we want the object to store a variant of a sub-question's stats.
Return values
boolwhether those stats exist (yet).

◆ initialise_for_slot()

core_question\statistics\questions\all_calculated_for_qubaid_condition::initialise_for_slot ( $slot,
$question,
$variant = null )

Set up a calculated instance ready to store a slot question's stats.

Parameters
int$slot
object$question
int | null$variantIs this to keep track of a variant's stats? If so what is the variant, if not null.

◆ initialise_for_subq()

core_question\statistics\questions\all_calculated_for_qubaid_condition::initialise_for_subq ( $step,
$variant = null )

Set up a calculated_for_subquestion instance ready to store a randomly selected question's stats.

Parameters
object$step
int | null$variantIs this to keep track of a variant's stats? If so what is the variant, if not null.

◆ make_new_calculated_question_summary_stat()

core_question\statistics\questions\all_calculated_for_qubaid_condition::make_new_calculated_question_summary_stat ( $randomquestioncalculated,
$subquestionstats )
protected

Create a summary calculated object for a calculated question.

This is used as a placeholder to indicate that a calculated question has sub questions or variations to show rather than listing each subquestion or variation directly.

Parameters
calculated$randomquestioncalculatedThe calculated instance for the random question slot.
calculated[]$subquestionstatsThe instances of the calculated stats of the questions that are being summarised.
Return values
calculated_question_summary

◆ make_new_subq_stat_for()

core_question\statistics\questions\all_calculated_for_qubaid_condition::make_new_subq_stat_for ( $displaynumber,
$slot,
$subqid,
$variant = null )
protected

We need a new object for display.

Sub-question stats can appear more than once in different slots. So we create a clone of the object and then we can set properties on the object that are per slot.

Parameters
int$displaynumberThe display number for this sub question.
int$slotThe slot number.
int$subqidThe sub question id.
null | int$variantThe variant no.
Return values
calculated_for_subquestionThe object for display.

◆ structure_analysis_for_one_slot()

core_question\statistics\questions\all_calculated_for_qubaid_condition::structure_analysis_for_one_slot ( $slot,
$limitvariants = false )

Return all stats for one slot, stats for the slot itself, and either :

  • variants of question
  • variants of randomly selected questions
  • randomly selected questions
Parameters
int$slotthe slot no
bool | int$limitvariantslimit number of variants and sub-questions displayed?
Return values
calculated|calculated_for_subquestion[]stats to display

Member Data Documentation

◆ TIME_TO_CACHE

int const core_question\statistics\questions\all_calculated_for_qubaid_condition::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: