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]

Data structure to count responses for each of the sub parts of a question.

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

Defines 2 classes

analysis_for_subpart:: (3 methods):
  __construct()
  get_response_class_ids()
  get_response_class()

id:: (5 methods):
  has_multiple_response_classes()
  count_response()
  cache()
  has_actual_responses()
  get_maximum_tries()


Class: analysis_for_subpart  - X-Ref

Representing the analysis of each of the sub parts of each variant of the question.

- 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 $responseclasses = null)   X-Ref
Takes an array of possible_responses as returned from {@link \question_type::get_possible_responses()}.

param: \question_possible_response[] $responseclasses as returned from {@link \question_type::get_possible_responses()}.

get_response_class_ids()   X-Ref
Unique ids for response classes.

return: string[]

get_response_class($classid)   X-Ref
Get the instance of the class handling the analysis of $classid for this sub part.

param: string $classid id for response class.
return: analysis_for_class

Class: id  - X-Ref

has_multiple_response_classes()   X-Ref
Whether there is more than one response class for responses in this question sub part?

return: bool Are there?

count_response($subpart, $try = 0)   X-Ref
Count a part of a response.

param: \question_classified_response $subpart
param: int $try the try number or zero if not keeping track of try number

cache($qubaids, $whichtries, $questionid, $variantno, $subpartid, $calculationtime = null)   X-Ref
Cache analysis for sub part.

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               $variantno  which variant.
param: string            $subpartid  which sub part.
param: int|null          $calculationtime time when the analysis was done. (Defaults to time()).

has_actual_responses()   X-Ref
Has actual responses different to the model response for this class?

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

get_maximum_tries()   X-Ref
What is the highest try number for this sub part?

return: int max tries