Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 39 and 403] [Versions 400 and 403] [Versions 401 and 403] [Versions 402 and 403]

This file contains the code to analyse all the responses to a particular question.

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

Defines 1 class

analyser:: (6 methods):
  __construct()
  has_subparts()
  has_response_classes()
  calculate()
  load_cached()
  get_last_analysed_time()


Class: analyser  - X-Ref

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

__construct($questiondata, $whichtries = \question_attempt::LAST_TRY)   X-Ref
Create a new instance of this class for holding/computing the statistics
for a particular question.

param: object $questiondata the full question data from the database defining this question.
param: string $whichtries   which tries to analyse.

has_subparts()   X-Ref
Does the computed analysis have sub parts?

return: bool whether this analysis has more than one subpart.

has_response_classes()   X-Ref
Does the computed analysis's sub parts have classes?

return: bool whether this analysis has (a subpart with) more than one response class.

calculate($qubaids, $whichtries = \question_attempt::LAST_TRY)   X-Ref
Analyse all the response data for all the specified attempts at this question.

param: \qubaid_condition $qubaids which attempts to consider.
param: string $whichtries         which tries to analyse. Will be one of
return: analysis_for_question

load_cached($qubaids, $whichtries)   X-Ref
Retrieve the computed response analysis from the question_response_analysis table.

param: \qubaid_condition $qubaids    load the analysis of which question usages?
param: string            $whichtries load the analysis of which tries?
return: analysis_for_question|boolean analysis or false if no cached analysis found.

get_last_analysed_time($qubaids, $whichtries)   X-Ref
Find time of non-expired analysis in the database.

param: \qubaid_condition $qubaids    check for the analysis of which question usages?
param: string            $whichtries check for the analysis of which tries?
return: integer|boolean Time of cached record that matches this qubaid_condition or false if none found.