Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401]

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: 304 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, $timemodified = null)   X-Ref
Cache calculated stats stored in this object in 'question_statistics' table.

param: \qubaid_condition $qubaids
param: int|null $timemodified the modified time to store. Defaults to the current time.

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.