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]

Question statistics calculations class. Used in the quiz statistics report but also available for use elsewhere.

Author: Jamie Pratt <me@jamiep.org>
Copyright: 2013 Open University
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 303 lines (9 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: calculated  - X-Ref

This class is used to return the stats as calculated by {@link \core_question\statistics\questions\calculator}

__construct($question = null, $slot = null, $variant = null)   X-Ref
Set up a calculated instance ready to store a question's (or a variant of a slot's question's)
stats for one slot in the quiz.

param: null|object     $question
param: null|int     $slot
param: null|int $variant

random_selector_string()   X-Ref
Used to determine which random questions pull sub questions from the same pools. Where pool means category and possibly
all the sub categories of that category.

return: null|string represents the pool of questions from which this question draws if it is random, or null if not.

cache($qubaids)   X-Ref
Cache calculated stats stored in this object in 'question_statistics' table.

param: \qubaid_condition $qubaids

populate_from_record($record)   X-Ref
Load properties of this class from db record.

param: object $record Given a record from 'question_statistics' copy stats from record to properties.

sort_variants()   X-Ref
Sort the variants of this question by variant number.


get_sub_question_ids()   X-Ref
Get any sub question ids for this question.

return: int[] array of sub-question ids or empty array if there are none.

get_variants()   X-Ref
Array of variants that have appeared in the attempt data for this question. Or an empty array if there is only one variant.

return: int[] the variant nos.

break_down_by_variant()   X-Ref
Do we break down the stats for this question by variant or not?

return: bool Do we?

clear_variants()   X-Ref
Delete the data structure for storing variant stats.