Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

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

Quiz statistics report class.

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

Defines 1 class


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)   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
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