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.

Class: quiz_statistics_report  - X-Ref

The quiz statistics report provides summary information about each question in
a quiz, compared to the whole quiz. It also provides a drill-down to more
detailed information about each question.

display($quiz, $cm, $course)   X-Ref
Display the report.


output_individual_question_data($quiz, $questionstat)   X-Ref
Display the statistical and introductory information about a question.
Only called when not downloading.

param: object                                         $quiz         the quiz settings.
param: \core_question\statistics\questions\calculated $questionstat the question to report on.

render_question_text($question)   X-Ref
Output question text in a box with urls appropriate for a preview of the question.

param: object $question question data.
return: string HTML of question text, ready for display.

output_individual_question_response_analysis($question, $variantno, $s, $reporturl, $qubaids,$whichtries = question_attempt::LAST_TRY)   X-Ref
Display the response analysis for a question.

param: object           $question  the question to report on.
param: int|null         $variantno the variant
param: int              $s
param: moodle_url       $reporturl the URL to redisplay this report.
param: qubaid_condition $qubaids
param: string           $whichtries

output_quiz_structure_analysis_table($questionstats)   X-Ref
Output the table that lists all the questions in the quiz with their statistics.

param: \core_question\statistics\questions\all_calculated_for_qubaid_condition $questionstats the stats for all questions in

output_quiz_info_table($quizinfo)   X-Ref
Return HTML for table of overall quiz statistics.

param: array $quizinfo as returned by {@link get_formatted_quiz_info_data()}.
return: string the HTML.

download_quiz_info_table($quizinfo)   X-Ref
Download the table of overall quiz statistics.

param: array $quizinfo as returned by {@link get_formatted_quiz_info_data()}.

output_statistics_graph($quizorid, $qubaids)   X-Ref
Output the HTML needed to show the statistics graph.

param: int|object $quizorid The quiz, or its ID.
param: qubaid_condition $qubaids the question usages whose responses to analyse.
param: string $whichattempts Which attempts constant.

get_all_stats_and_analysis($quiz, $whichattempts, $whichtries, \core\dml\sql_join $groupstudentsjoins,$questions, $progress = null, bool $calculateifrequired = true, bool $performanalysis = true)   X-Ref
Get the quiz and question statistics, either by loading the cached results,
or by recomputing them.

param: object $quiz               the quiz settings.
param: string $whichattempts      which attempts to use, represented internally as one of the constants as used in
param: string $whichtries         which tries to analyse for response analysis. Will be one of
param: \core\dml\sql_join $groupstudentsjoins Contains joins, wheres, params for students in this group.
param: array  $questions          full question data.
param: \core\progress\base|null   $progress
param: bool $calculateifrequired  if true (the default) the stats will be calculated if not already stored.
param: bool $performanalysis      if true (the default) and there are calculated stats, analysis will be performed
return: array with 2 elements:    - $quizstats The statistics for overall attempt scores.

get_progress_trace_instance()   X-Ref
Appropriate instance depending if we want html output for the user or not.

return: \core\progress\base child of \core\progress\base to handle the display (or not) of task progress.

analyse_responses_for_all_questions_and_subquestions($questions, $subquestions, $qubaids,$whichtries, $progress = null)   X-Ref
Analyse responses for all questions and sub questions in this quiz.

param: object[] $questions as returned by self::load_and_initialise_questions_for_calculations
param: object[] $subquestions full question objects.
param: qubaid_condition $qubaids the question usages whose responses to analyse.
param: string $whichtries which tries to analyse \question_attempt::FIRST_TRY, LAST_TRY or ALL_TRIES.
param: null|\core\progress\base $progress Used to indicate progress of task.

analyse_responses_for_questions($questions, $qubaids, $whichtries, $progress = null, $done = array()   X-Ref
Analyse responses for an array of questions or sub questions.

param: object[] $questions  as returned by self::load_and_initialise_questions_for_calculations.
param: qubaid_condition $qubaids the question usages whose responses to analyse.
param: string $whichtries which tries to analyse \question_attempt::FIRST_TRY, LAST_TRY or ALL_TRIES.
param: null|\core\progress\base $progress Used to indicate progress of task.
param: int[] $done array keys are ids of questions that have been analysed before calling method.
return: array array keys are ids of questions that were analysed after this method call.

everything_download_options(moodle_url $reporturl)   X-Ref
Return a little form for the user to request to download the full report, including quiz stats and response analysis for
all questions and sub-questions.

param: moodle_url $reporturl the base URL of the report.
return: string HTML.

output_caching_info($lastcachetime, $quizid, $groupstudentsjoins, $whichattempts, $reporturl)   X-Ref
Return HTML for a message that says when the stats were last calculated and a 'recalculate now' button.

param: int    $lastcachetime  the time the stats were last cached.
param: int    $quizid         the quiz id.
param: array  $groupstudentsjoins (joins, wheres, params) for students in the group or empty array if groups not used.
param: string $whichattempts which attempts to use, represented internally as one of the constants as used in
param: moodle_url $reporturl url for this report
return: string HTML.

clear_cached_data($qubaids)   X-Ref
Clear the cached data for a particular report configuration. This will trigger a re-computation the next time the report
is displayed.

param: $qubaids qubaid_condition

load_and_initialise_questions_for_calculations($quiz)   X-Ref
Load the questions in this quiz and add some properties to the objects needed in the reports.

param: object $quiz the quiz.
return: array of questions for this quiz.

output_all_question_response_analysis($qubaids,$questions,$questionstats,$reporturl,$whichtries = question_attempt::LAST_TRY)   X-Ref
Output all response analysis for all questions, sub-questions and variants. For download in a number of formats.

param: $qubaids
param: $questions
param: $questionstats
param: $reporturl
param: $whichtries string

calculate_questions_stats_for_question_bank(int $quizid,bool $calculateifrequired = true,bool $performanalysis = true)   X-Ref
Load question stats for a quiz

param: int $quizid question usage
param: bool $calculateifrequired if true (the default) the stats will be calculated if not already stored.
param: bool $performanalysis if true (the default) and there are calculated stats, analysis will be performed
return: ?all_calculated_for_qubaid_condition question stats