Search moodle.org's
Developer Documentation

See Release Notes

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

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

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

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: 253 lines (10 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: analysis_for_question  - X-Ref

Analysis for possible responses for parts of a question. It is up to a question type designer to decide on how many parts their
question has. See {@link \question_type::get_possible_responses()} and sub classes where the sub parts and response classes are
defined.

A sub part might represent a sub question embedded in the question for example in a matching question there are
several sub parts. A numeric question with a unit might be divided into two sub parts for the purposes of response analysis
or the question type designer might decide to treat the answer, both the numeric and unit part,
as a whole for the purposes of response analysis.

- There is a separate data structure for each question or sub question's analysis
{@link \core_question\statistics\responses\analysis_for_question}
or {@link \core_question\statistics\responses\analysis_for_question_all_tries}.
- There are separate analysis for each variant in this top level instance.
- Then there are class instances representing the analysis of each of the sub parts of each variant of the question.
{@link \core_question\statistics\responses\analysis_for_subpart}.
- Then within the sub part analysis there are response class analysis
{@link \core_question\statistics\responses\analysis_for_class}.
- Then within each class analysis there are analysis for each actual response
{@link \core_question\statistics\responses\analysis_for_actual_response}.

__construct(array $possiblereponses = null)   X-Ref
Constructor method.

param: array[] Two index array, first index is unique string for each sub question part,

initialise_stats_for_variant($variantno)   X-Ref
Initialise data structure for response analysis of one variant.

param: int $variantno

get_variant_nos()   X-Ref
Variant nos found in this question's attempt data.

return: int[]

get_subpart_ids($variantno)   X-Ref
Unique ids for sub parts.

param: int $variantno
return: string[]

get_analysis_for_subpart($variantno, $subpartid)   X-Ref
Get the response counts etc. for variant $variantno, question sub part $subpartid.

Or if there is no recorded analysis yet then initialise the data structure for that part of the analysis and return the
initialised analysis objects.

param: int    $variantno
param: string $subpartid id for sub part.
return: analysis_for_subpart

has_multiple_response_classes()   X-Ref
Used to work out what kind of table is needed to display stats.

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

has_subparts()   X-Ref
Used to work out what kind of table is needed to display stats.

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

has_multiple_tries_data()   X-Ref

return: bool Does this response analysis include counts for responses for multiple tries of the question?

get_maximum_tries()   X-Ref
What is the highest number of tries at this question?

return: int always 1 as this class is for analysing only one try.

count_response_parts($variantno, $responseparts)   X-Ref
Takes an array of {@link \question_classified_response} and adds counts of the responses to the sub parts and classes.

param: int                             $variantno
param: \question_classified_response[] $responseparts keys are sub-part id.

cache($qubaids, $whichtries, $questionid, $calculationtime = null)   X-Ref
Save the analysis to the DB, first cleaning up any old ones.

param: \qubaid_condition $qubaids    which question usages have been analysed.
param: string            $whichtries which tries have been analysed?
param: int               $questionid which question.
param: int|null          $calculationtime time when the analysis was done. (Defaults to time()).

has_actual_responses()   X-Ref

return: bool whether this analysis has a response class with more than one