Moodle PHP Documentation 4.3
Moodle 4.3.5 (Build: 20240610) (7dcfaa79f78)
quiz_statistics_report Class Reference

The quiz statistics report provides summary information about each question in a quiz, compared to the whole quiz. More...

Inheritance diagram for quiz_statistics_report:
mod_quiz\local\reports\report_base

Public Member Functions

 calculate_questions_stats_for_question_bank (int $quizid, bool $calculateifrequired=true, bool $performanalysis=true,)
 Load question stats for a quiz.
 
 clear_cached_data ($qubaids)
 Clear the cached data for a particular report configuration.
 
 display ($quiz, $cm, $course)
 Display the report.
 
 get_all_stats_and_analysis ( $quiz, $whichattempts, $whichtries, core\dml\sql_join $groupstudentsjoins, $questions, $progress=null, bool $calculateifrequired=true, bool $performanalysis=true)
 Get the quiz and question statistics, either by loading the cached results, or by recomputing them.
 
 get_current_group ($cm, $course, $context)
 Get the current group for the user user looking at the report.
 
 load_and_initialise_questions_for_calculations ($quiz)
 Load the questions in this quiz and add some properties to the objects needed in the reports.
 
 print_header_and_tabs ($cm, $course, $quiz, $reportmode='overview')
 Initialise some parts of $PAGE and start output.
 

Public Attributes

int const NO_GROUPS_ALLOWED = -2
 special value used in place of groupid, to mean the use cannot access any groups.
 

Protected Member Functions

 analyse_responses_for_all_questions_and_subquestions ($questions, $subquestions, $qubaids, $whichtries, $progress=null)
 Analyse responses for all questions and sub questions in this quiz.
 
 analyse_responses_for_questions ($questions, $qubaids, $whichtries, $progress=null, $done=[])
 Analyse responses for an array of questions or sub questions.
 
 download_quiz_info_table ($quizinfo)
 Download the table of overall quiz statistics.
 
 everything_download_options (moodle_url $reporturl)
 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.
 
 get_progress_trace_instance ()
 Appropriate instance depending if we want html output for the user or not.
 
 output_all_question_response_analysis ($qubaids, $questions, $questionstats, $reporturl, $whichtries=question_attempt::LAST_TRY)
 Output all response analysis for all questions, sub-questions and variants.
 
 output_caching_info ($lastcachetime, $quizid, $groupstudentsjoins, $whichattempts, $reporturl)
 Return HTML for a message that says when the stats were last calculated and a 'recalculate now' button.
 
 output_individual_question_data ($quiz, $questionstat)
 Display the statistical and introductory information about a question.
 
 output_individual_question_response_analysis ($question, $variantno, $s, $reporturl, $qubaids, $whichtries=question_attempt::LAST_TRY)
 Display the response analysis for a question.
 
 output_quiz_info_table ($quizinfo)
 Return HTML for table of overall quiz statistics.
 
 output_quiz_structure_analysis_table ($questionstats)
 Output the table that lists all the questions in the quiz with their statistics.
 
 output_statistics_graph ($quiz, $qubaids)
 Output the HTML needed to show the statistics graph.
 
 render_question_text ($question)
 Output question text in a box with urls appropriate for a preview of the question.
 

Protected Attributes

context_module $context
 context of this quiz.
 
core progress base null $progress = null
 $progress Handles progress reporting or not.
 
quiz_statistics_table $table
 instance of table class used for main questions stats table.
 

Detailed Description

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.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ analyse_responses_for_all_questions_and_subquestions()

quiz_statistics_report::analyse_responses_for_all_questions_and_subquestions ( $questions,
$subquestions,
$qubaids,
$whichtries,
$progress = null )
protected

Analyse responses for all questions and sub questions in this quiz.

Parameters
stdClass[]$questionsas returned by self\load_and_initialise_questions_for_calculations
stdClass[]$subquestionsfull question objects.
qubaid_condition$qubaidsthe question usages whose responses to analyse.
string$whichtrieswhich tries to analyse question_attempt\FIRST_TRY, LAST_TRY or ALL_TRIES.
null | core\progress\base$progressUsed to indicate progress of task.

◆ analyse_responses_for_questions()

quiz_statistics_report::analyse_responses_for_questions ( $questions,
$qubaids,
$whichtries,
$progress = null,
$done = [] )
protected

Analyse responses for an array of questions or sub questions.

Parameters
stdClass[]$questionsas returned by self\load_and_initialise_questions_for_calculations.
qubaid_condition$qubaidsthe question usages whose responses to analyse.
string$whichtrieswhich tries to analyse question_attempt\FIRST_TRY, LAST_TRY or ALL_TRIES.
null | core\progress\base$progressUsed to indicate progress of task.
int[]$donearray keys are ids of questions that have been analysed before calling method.
Return values
arrayarray keys are ids of questions that were analysed after this method call.

◆ calculate_questions_stats_for_question_bank()

quiz_statistics_report::calculate_questions_stats_for_question_bank ( int $quizid,
bool $calculateifrequired = true,
bool $performanalysis = true )

Load question stats for a quiz.

Parameters
int$quizidquestion usage
bool$calculateifrequiredif true (the default) the stats will be calculated if not already stored. If false, null will be returned if the stats are not already available.
bool$performanalysisif true (the default) and there are calculated stats, analysis will be performed for each question.
Return values
?all_calculated_for_qubaid_conditionquestion stats

◆ clear_cached_data()

quiz_statistics_report::clear_cached_data ( $qubaids)

Clear the cached data for a particular report configuration.

This will trigger a re-computation the next time the report is displayed.

Parameters
$qubaidsqubaid_condition

◆ display()

quiz_statistics_report::display ( $quiz,
$cm,
$course )

Display the report.

Reimplemented from mod_quiz\local\reports\report_base.

◆ download_quiz_info_table()

quiz_statistics_report::download_quiz_info_table ( $quizinfo)
protected

Download the table of overall quiz statistics.

Parameters
array$quizinfoas returned by get_formatted_quiz_info_data().

◆ everything_download_options()

quiz_statistics_report::everything_download_options ( moodle_url $reporturl)
protected

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.

Parameters
moodle_url$reporturlthe base URL of the report.
Return values
stringHTML.

◆ get_all_stats_and_analysis()

quiz_statistics_report::get_all_stats_and_analysis ( $quiz,
$whichattempts,
$whichtries,
core\dml\sql_join $groupstudentsjoins,
$questions,
$progress = null,
bool $calculateifrequired = true,
bool $performanalysis = true )

Get the quiz and question statistics, either by loading the cached results, or by recomputing them.

Parameters
stdClass$quizthe quiz settings.
string$whichattemptswhich attempts to use, represented internally as one of the constants as used in $quiz->grademethod ie. QUIZ_GRADEAVERAGE, QUIZ_GRADEHIGHEST, QUIZ_ATTEMPTLAST or QUIZ_ATTEMPTFIRST we calculate stats based on which attempts would affect the grade for each student.
string$whichtrieswhich tries to analyse for response analysis. Will be one of question_attempt\FIRST_TRY, LAST_TRY or ALL_TRIES.
core\dml\sql_join$groupstudentsjoinsContains joins, wheres, params for students in this group.
array$questionsfull question data.
core\progress\base | null$progress
bool$calculateifrequiredif true (the default) the stats will be calculated if not already stored. If false, [null, null] will be returned if the stats are not already available.
bool$performanalysisif true (the default) and there are calculated stats, analysis will be performed for each question.
Return values
arraywith 2 elements: - $quizstats The statistics for overall attempt scores.

◆ get_current_group()

mod_quiz\local\reports\report_base::get_current_group ( $cm,
$course,
$context )
inherited

Get the current group for the user user looking at the report.

Parameters
stdClass$cmthe course_module information.
stdClass$coursethe course settings.
context$contextthe quiz context.
Return values
intthe current group id, if applicable. 0 for all users, NO_GROUPS_ALLOWED if the user cannot see any group.

◆ get_progress_trace_instance()

quiz_statistics_report::get_progress_trace_instance ( )
protected

Appropriate instance depending if we want html output for the user or not.

Return values
core\progress\basechild of core\progress\base to handle the display (or not) of task progress.

◆ load_and_initialise_questions_for_calculations()

quiz_statistics_report::load_and_initialise_questions_for_calculations ( $quiz)

Load the questions in this quiz and add some properties to the objects needed in the reports.

Parameters
stdClass$quizthe quiz.
Return values
arrayof questions for this quiz.

◆ output_all_question_response_analysis()

quiz_statistics_report::output_all_question_response_analysis ( $qubaids,
$questions,
$questionstats,
$reporturl,
$whichtries = question_attempt::LAST_TRY )
protected

Output all response analysis for all questions, sub-questions and variants.

For download in a number of formats.

Parameters
$qubaids
$questions
$questionstats
$reporturl
$whichtriesstring

◆ output_caching_info()

quiz_statistics_report::output_caching_info ( $lastcachetime,
$quizid,
$groupstudentsjoins,
$whichattempts,
$reporturl )
protected

Return HTML for a message that says when the stats were last calculated and a 'recalculate now' button.

Parameters
int$lastcachetimethe time the stats were last cached.
int$quizidthe quiz id.
core\dml\sql_join$groupstudentsjoins(joins, wheres, params) for students in the group or empty array if groups not used.
string$whichattemptswhich attempts to use, represented internally as one of the constants as used in $quiz->grademethod ie. QUIZ_GRADEAVERAGE, QUIZ_GRADEHIGHEST, QUIZ_ATTEMPTLAST or QUIZ_ATTEMPTFIRST we calculate stats based on which attempts would affect the grade for each student.
moodle_url$reporturlurl for this report
Return values
stringHTML.

◆ output_individual_question_data()

quiz_statistics_report::output_individual_question_data ( $quiz,
$questionstat )
protected

Display the statistical and introductory information about a question.

Only called when not downloading.

Parameters
stdClass$quizthe quiz settings.
core_question\statistics\questions\calculated$questionstatthe question to report on.

◆ output_individual_question_response_analysis()

quiz_statistics_report::output_individual_question_response_analysis ( $question,
$variantno,
$s,
$reporturl,
$qubaids,
$whichtries = question_attempt::LAST_TRY )
protected

Display the response analysis for a question.

Parameters
stdClass$questionthe question to report on.
int | null$variantnothe variant
int$s
moodle_url$reporturlthe URL to redisplay this report.
qubaid_condition$qubaids
string$whichtries

◆ output_quiz_info_table()

quiz_statistics_report::output_quiz_info_table ( $quizinfo)
protected

Return HTML for table of overall quiz statistics.

Parameters
array$quizinfoas returned by get_formatted_quiz_info_data().
Return values
stringthe HTML.

◆ output_quiz_structure_analysis_table()

quiz_statistics_report::output_quiz_structure_analysis_table ( $questionstats)
protected

Output the table that lists all the questions in the quiz with their statistics.

Parameters
core_question\statistics\questions\all_calculated_for_qubaid_condition$questionstatsthe stats for all questions in the quiz including subqs and variants.

◆ output_statistics_graph()

quiz_statistics_report::output_statistics_graph ( $quiz,
$qubaids )
protected

Output the HTML needed to show the statistics graph.

Parameters
stdClass$quizthe quiz.
qubaid_condition$qubaidsthe question usages whose responses to analyse.

◆ print_header_and_tabs()

mod_quiz\local\reports\report_base::print_header_and_tabs ( $cm,
$course,
$quiz,
$reportmode = 'overview' )
inherited

Initialise some parts of $PAGE and start output.

Parameters
stdClass$cmthe course_module information.
stdClass$coursethe course settings.
stdClass$quizthe quiz settings.
string$reportmodethe report name.

Reimplemented in quiz_grading_report.

◆ render_question_text()

quiz_statistics_report::render_question_text ( $question)
protected

Output question text in a box with urls appropriate for a preview of the question.

Parameters
stdClass$questionquestion data.
Return values
stringHTML of question text, ready for display.

The documentation for this class was generated from the following file: