Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
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:
quiz_default_report

Public Member Functions

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

Public Attributes

const NO_GROUPS_ALLOWED = -2
 

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. More...
 
 analyse_responses_for_questions ($questions, $qubaids, $whichtries, $progress=null, $done=array())
 Analyse responses for an array of questions or sub questions. More...
 
 clear_cached_data ($qubaids)
 Clear the cached data for a particular report configuration. More...
 
 download_quiz_info_table ($quizinfo)
 Download the table of overall quiz statistics. More...
 
 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. More...
 
 get_progress_trace_instance ()
 Appropriate instance depending if we want html output for the user or not. More...
 
 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. More...
 
 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. More...
 
 output_individual_question_data ($quiz, $questionstat)
 Display the statistical and introductory information about a question. More...
 
 output_individual_question_response_analysis ($question, $variantno, $s, $reporturl, $qubaids, $whichtries=question_attempt::LAST_TRY)
 Display the response analysis for a question. More...
 
 output_quiz_info_table ($quizinfo)
 Return HTML for table of overall quiz statistics. More...
 
 output_quiz_structure_analysis_table ($questionstats)
 Output the table that lists all the questions in the quiz with their statistics. More...
 
 output_statistics_graph ($quizorid, $qubaids)
 Output the HTML needed to show the statistics graph. More...
 
 render_question_text ($question)
 Output question text in a box with urls appropriate for a preview of the question. More...
 

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
object[]$questionsas returned by self::load_and_initialise_questions_for_calculations
object[]$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 = array() 
)
protected

Analyse responses for an array of questions or sub questions.

Parameters
object[]$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.

◆ clear_cached_data()

quiz_statistics_report::clear_cached_data (   $qubaids)
protected

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 quiz_default_report.

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

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

Parameters
object$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
Return values
arraywith 2 elements: - $quizstats The statistics for overall attempt scores.

◆ get_current_group()

quiz_default_report::get_current_group (   $cm,
  $course,
  $context 
)
inherited

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

Parameters
object$cmthe course_module information.
object$couresthe 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
object$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.
array$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
object$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
object$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 (   $quizorid,
  $qubaids 
)
protected

Output the HTML needed to show the statistics graph.

Parameters
int | object$quizoridThe quiz, or its ID.
qubaid_condition$qubaidsthe question usages whose responses to analyse.
string$whichattemptsWhich attempts constant.

◆ print_header_and_tabs()

quiz_default_report::print_header_and_tabs (   $cm,
  $course,
  $quiz,
  $reportmode = 'overview' 
)
inherited

Initialise some parts of $PAGE and start output.

Parameters
object$cmthe course_module information.
object$couresthe course settings.
object$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
object$questionquestion data.
Return values
stringHTML of question text, ready for display.

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