Moodle PHP Documentation 5.1
Moodle 5.1dev (Build: 20250711) (9addea9f0ac)
quiz_last_responses_table Class Reference
Inheritance diagram for quiz_last_responses_table:
mod_quiz\local\reports\attempts_report_table quiz_first_or_all_responses_table

Public Member Functions

 __construct ($quiz, $context, $qmsubselect, quiz_responses_options $options, core\dml\sql_join $groupstudentsjoins, core\dml\sql_join $studentsjoins, $questions, $reporturl)
 Constructor.
 
 base_sql (\core\dml\sql_join $allowedstudentsjoins)
 Contruct all the parts of the main database query.
 
 build_table ()
 
 checkbox_col_header (string $columnname)
 Generates the contents for the checkbox column header.
 
 col_checkbox ($attempt)
 Generate the display of the checkbox column.
 
 col_duration ($attempt)
 Generate the display of the duration column.
 
 col_feedbacktext ($attempt)
 Generate the display of the feedback column.
 
 col_fullname ($attempt)
 Generate the display of the user's full name column.
 
 col_picture ($attempt)
 Generate the display of the user's picture column.
 
 col_state ($attempt)
 Generate the display of the attempt state column.
 
 col_sumgrades ($attempt)
 
 col_timefinish ($attempt)
 Generate the display of the finish time column.
 
 col_timestart ($attempt)
 Generate the display of the start time column.
 
 data_col ($slot, $field, $attempt)
 
 get_row_class ($attempt)
 
 get_sort_columns ()
 
 make_review_link ($data, $attempt, $slot)
 Make a link to review an individual question in a popup window.
 
 other_cols ($colname, $attempt)
 
 query_db ($pagesize, $useinitialsbar=true)
 
 set_quiz_setting (quiz_settings $quizobj)
 A way for the report to pass in the quiz settings object.
 
 setup_sql_queries ($allowedjoins)
 Set up the SQL queries (count rows, and get data).
 
 wrap_html_finish ()
 
 wrap_html_start ()
 

Public Attributes

 $useridfield = 'userid'
 

Protected Member Functions

 add_grade_item_mark (int $gradeitemid)
 Add a field marks$gradeitemid to the query, with the total score for that grade item.
 
 add_latest_state_join ($slot)
 Add the information about the latest state of the question with slot $slot to the query.
 
 field_from_extra_data ($attempt, $slot, $field)
 Column text from the extra data loaded in load_extra_data(), before html formatting etc.
 
 get_qubaids_condition ()
 Get an appropriate qubaid_condition for loading more data about the attempts we are displaying.
 
 get_required_latest_state_fields ($slot, $alias)
 Get any fields that might be needed when sorting on date for a particular slot.
 
 icon_for_fraction ($fraction)
 Return an appropriate icon (green tick, red cross, etc.) for a grade.
 
 is_flagged ($questionusageid, $slot)
 Work out if a particular question in a particular attempt has been flagged.
 
 is_grade_item_column (string $columnname)
 Is this the column key for an extra grade item column?
 
 is_latest_step_column ($column)
 Is this a column that depends on joining to the latest state information?
 
 load_extra_data ()
 Load any extra data after main query.
 
 load_grade_item_marks ()
 Load the total mark for each grade item for each attempt.
 
 load_question_latest_steps (?qubaid_condition $qubaids=null)
 Load information about the latest state of selected questions in selected attempts.
 
 requires_extra_data ()
 Does this report require loading any more data after the main query.
 
 requires_latest_steps_loaded ()
 Does this report require the detailed information for each question from the question_attempts_steps table?
 
 slot_fraction ($attempt, $slot)
 Get the mark (out of 1) for the question in a particular slot.
 
 slot_state ($attempt, $slot)
 Get the question attempt state for a particular question in a particular quiz attempt.
 
 submit_buttons ()
 Output any submit buttons required by the $this->includecheckboxes form.
 
 update_sql_after_count ($fields, $from, $where, $params)
 Lets subclasses modify the SQL after the count query has been created and before the full query is.
 

Protected Attributes

bool null $canreopen = null
 used by {
 
context_module $context
 the quiz context.
 
array $displayoptions
 the display options.
 
float[][] null array $gradeitemtotals = null
 total mark for each grade item.
 
core dml sql_join $groupstudentsjoins
 Contains joins, wheres, params to find students in the currently selected group, if applicable.
 
bool $includecheckboxes
 whether to include the column with checkboxes to select each attempt.
 
array $lateststeps = null
 information about the latest step of each question.
 
stdClass $options
 attempts_report_options the options affecting this report.
 
string $qmsubselect
 HTML fragment to select the first/best/last attempt, if appropriate.
 
array $questions
 the questions that comprise this quiz.
 
stdClass $quiz
 the quiz settings for the quiz we are reporting on.
 
quiz_settings quiz_settings $quizobj
 quiz settings object for this quiz.
 
moodle_url $reporturl
 the URL of this report.
 
string $strtimeformat
 strftime format.
 
core dml sql_join $studentsjoins
 Contains joins, wheres, params to find the students in the course.
 
string $togglegroup = 'quiz-attempts'
 The toggle group name for the checkboxes in the checkbox column.
 

Constructor & Destructor Documentation

◆ __construct()

quiz_last_responses_table::__construct ( $quiz,
$context,
$qmsubselect,
quiz_responses_options $options,
core\dml\sql_join $groupstudentsjoins,
core\dml\sql_join $studentsjoins,
$questions,
$reporturl )

Constructor.

Parameters
stdClass$quiz
context$context
string$qmsubselect
quiz_responses_options$options
core\dml\sql_join$groupstudentsjoins
core\dml\sql_join$studentsjoins
array$questions
moodle_url$reporturl

Member Function Documentation

◆ add_grade_item_mark()

mod_quiz\local\reports\attempts_report_table::add_grade_item_mark ( int $gradeitemid)
protectedinherited

Add a field marks$gradeitemid to the query, with the total score for that grade item.

Parameters
int$gradeitemidthe grade item to add information for.

◆ add_latest_state_join()

mod_quiz\local\reports\attempts_report_table::add_latest_state_join ( $slot)
protectedinherited

Add the information about the latest state of the question with slot $slot to the query.

The extra information is added as a join to a 'table' with alias qa$slot, with columns that are a union of the columns of the question_attempts and question_attempts_states tables.

Parameters
int$slotthe question to add information for.

◆ base_sql()

mod_quiz\local\reports\attempts_report_table::base_sql ( \core\dml\sql_join $allowedstudentsjoins)
inherited

Contruct all the parts of the main database query.

Parameters
core\dml\sql_join$allowedstudentsjoins(joins, wheres, params) defines allowed users for the report.
Return values
arraywith 4 elements [$fields, $from, $where, $params] that can be used to build the actual database query.

◆ checkbox_col_header()

mod_quiz\local\reports\attempts_report_table::checkbox_col_header ( string $columnname)
inherited

Generates the contents for the checkbox column header.

It returns the HTML for a toggler core\output\checkbox_toggleall component that selects/deselects all quiz attempts.

Parameters
string$columnnameThe name of the checkbox column.
Return values
string

◆ col_checkbox()

mod_quiz\local\reports\attempts_report_table::col_checkbox ( $attempt)
inherited

Generate the display of the checkbox column.

Parameters
stdClass$attemptthe table row being output.
Return values
stringHTML content to go inside the td.

Reimplemented in quiz_first_or_all_responses_table.

◆ col_duration()

mod_quiz\local\reports\attempts_report_table::col_duration ( $attempt)
inherited

Generate the display of the duration column.

Parameters
stdClass$attemptthe table row being output.
Return values
stringHTML content to go inside the td.

◆ col_feedbacktext()

mod_quiz\local\reports\attempts_report_table::col_feedbacktext ( $attempt)
inherited

Generate the display of the feedback column.

Parameters
stdClass$attemptthe table row being output.
Return values
stringHTML content to go inside the td.

◆ col_fullname()

mod_quiz\local\reports\attempts_report_table::col_fullname ( $attempt)
inherited

Generate the display of the user's full name column.

Parameters
stdClass$attemptthe table row being output.
Return values
stringHTML content to go inside the td.

◆ col_picture()

mod_quiz\local\reports\attempts_report_table::col_picture ( $attempt)
inherited

Generate the display of the user's picture column.

Parameters
stdClass$attemptthe table row being output.
Return values
stringHTML content to go inside the td.

◆ col_state()

mod_quiz\local\reports\attempts_report_table::col_state ( $attempt)
inherited

Generate the display of the attempt state column.

Parameters
stdClass$attemptthe table row being output.
Return values
stringHTML content to go inside the td.

Reimplemented in quiz_first_or_all_responses_table.

◆ col_sumgrades()

quiz_last_responses_table::col_sumgrades ( $attempt)

◆ col_timefinish()

mod_quiz\local\reports\attempts_report_table::col_timefinish ( $attempt)
inherited

Generate the display of the finish time column.

Parameters
stdClass$attemptthe table row being output.
Return values
stringHTML content to go inside the td.

◆ col_timestart()

mod_quiz\local\reports\attempts_report_table::col_timestart ( $attempt)
inherited

Generate the display of the start time column.

Parameters
stdClass$attemptthe table row being output.
Return values
stringHTML content to go inside the td.

◆ field_from_extra_data()

quiz_last_responses_table::field_from_extra_data ( $attempt,
$slot,
$field )
protected

Column text from the extra data loaded in load_extra_data(), before html formatting etc.

Parameters
stdClass$attempt
int$slot
string$field
Return values
string

Reimplemented in quiz_first_or_all_responses_table.

◆ get_qubaids_condition()

mod_quiz\local\reports\attempts_report_table::get_qubaids_condition ( )
protectedinherited

Get an appropriate qubaid_condition for loading more data about the attempts we are displaying.

Return values
qubaid_condition

◆ get_required_latest_state_fields()

quiz_last_responses_table::get_required_latest_state_fields ( $slot,
$alias )
protected

Get any fields that might be needed when sorting on date for a particular slot.

Parameters
int$slotthe slot for the column we want.
string$aliasthe table alias for latest state information relating to that slot.
Return values
stringsql fragment to alias fields.

Reimplemented from mod_quiz\local\reports\attempts_report_table.

◆ icon_for_fraction()

mod_quiz\local\reports\attempts_report_table::icon_for_fraction ( $fraction)
protectedinherited

Return an appropriate icon (green tick, red cross, etc.) for a grade.

Parameters
float$fractiongrade on a scale 0..1.
Return values
stringhtml fragment.

◆ is_flagged()

mod_quiz\local\reports\attempts_report_table::is_flagged ( $questionusageid,
$slot )
protectedinherited

Work out if a particular question in a particular attempt has been flagged.

Parameters
int$questionusageidused to identify the attempt of interest.
int$slotidentifies which question in the attempt to check.
Return values
booltrue if the question is flagged in the attempt.

Reimplemented in quiz_first_or_all_responses_table.

◆ is_grade_item_column()

mod_quiz\local\reports\attempts_report_table::is_grade_item_column ( string $columnname)
protectedinherited

Is this the column key for an extra grade item column?

Parameters
string$columnnamee.g. 'marks123' or 'duration'.
Return values
intgrade item id if this is a column for showing that grade item grade, else, 0.

◆ is_latest_step_column()

quiz_last_responses_table::is_latest_step_column ( $column)
protected

Is this a column that depends on joining to the latest state information?

If so, return the corresponding slot. If not, return false.

Parameters
string$columna column name
Return values
int|falsefalse if no, else a slot.

Reimplemented from mod_quiz\local\reports\attempts_report_table.

◆ load_extra_data()

mod_quiz\local\reports\attempts_report_table::load_extra_data ( )
protectedinherited

Load any extra data after main query.

At this point you can call {

See also
get_qubaids_condition} to get the condition that limits the query to just the question usages shown in this report page or alternatively for all attempts if downloading a full report.

Reimplemented in quiz_first_or_all_responses_table.

◆ load_question_latest_steps()

mod_quiz\local\reports\attempts_report_table::load_question_latest_steps ( ?qubaid_condition $qubaids = null)
protectedinherited

Load information about the latest state of selected questions in selected attempts.

The results are returned as a two-dimensional array $qubaid => $slot => $dataobject.

Parameters
qubaid_condition | null$qubaidsused to restrict which usages are included in the query. See {
See also
qubaid_condition}.
Return values
arrayof records. See the SQL in this function to see the fields available.

◆ make_review_link()

mod_quiz\local\reports\attempts_report_table::make_review_link ( $data,
$attempt,
$slot )
inherited

Make a link to review an individual question in a popup window.

Parameters
string$dataHTML fragment. The text to make into the link.
stdClass$attemptdata for the row of the table being output.
int$slotthe number used to identify this question within this usage.

Reimplemented in quiz_first_or_all_responses_table.

◆ other_cols()

quiz_last_responses_table::other_cols ( $colname,
$attempt )

◆ requires_extra_data()

quiz_last_responses_table::requires_extra_data ( )
protected

Does this report require loading any more data after the main query.

Return values
boolshould {
See also
query_db()} call {
load_extra_data}?

Reimplemented from mod_quiz\local\reports\attempts_report_table.

◆ requires_latest_steps_loaded()

mod_quiz\local\reports\attempts_report_table::requires_latest_steps_loaded ( )
protectedinherited

Does this report require the detailed information for each question from the question_attempts_steps table?

Return values
boolshould {
See also
load_extra_data} call {
load_question_latest_steps}?

Reimplemented in quiz_overview_table.

◆ set_quiz_setting()

mod_quiz\local\reports\attempts_report_table::set_quiz_setting ( quiz_settings $quizobj)
inherited

A way for the report to pass in the quiz settings object.

Currently done in {

See also
attempts_report::set_up_table_columns()}.
Parameters
quiz_settings$quizobj

◆ setup_sql_queries()

mod_quiz\local\reports\attempts_report_table::setup_sql_queries ( $allowedjoins)
inherited

Set up the SQL queries (count rows, and get data).

Parameters
core\dml\sql_join$allowedjoins(joins, wheres, params) defines allowed users for the report.

◆ slot_fraction()

mod_quiz\local\reports\attempts_report_table::slot_fraction ( $attempt,
$slot )
protectedinherited

Get the mark (out of 1) for the question in a particular slot.

Parameters
stdClass$attemptthe row data
int$slotwhich slot to check.
Return values
floatthe score for this question on a scale of 0 - 1.

Reimplemented in quiz_first_or_all_responses_table.

◆ slot_state()

mod_quiz\local\reports\attempts_report_table::slot_state ( $attempt,
$slot )
protectedinherited

Get the question attempt state for a particular question in a particular quiz attempt.

Parameters
stdClass$attemptthe row data.
int$slotindicates which question.
Return values
question_statethe state of that question.

Reimplemented in quiz_first_or_all_responses_table.

◆ submit_buttons()

mod_quiz\local\reports\attempts_report_table::submit_buttons ( )
protectedinherited

Output any submit buttons required by the $this->includecheckboxes form.

Reimplemented in quiz_overview_table.

◆ update_sql_after_count()

mod_quiz\local\reports\attempts_report_table::update_sql_after_count ( $fields,
$from,
$where,
$params )
protectedinherited

Lets subclasses modify the SQL after the count query has been created and before the full query is.

Parameters
string$fieldsSELECT list.
string$fromJOINs part of the SQL.
string$whereWHERE clauses.
array$paramsQuery params.
Return values
arraywith 4 elements ($fields, $from, $where, $params) as from base_sql.

Reimplemented in quiz_overview_table.

Member Data Documentation

◆ $canreopen

bool null mod_quiz\local\reports\attempts_report_table::$canreopen = null
protectedinherited

used by {

See also
col_state()} to cache the has_capability result.

◆ $gradeitemtotals

float [][] null array mod_quiz\local\reports\attempts_report_table::$gradeitemtotals = null
protectedinherited

total mark for each grade item.

Array question_usage.id => quiz_grade_item.id => mark. Loaded by {

See also
load_grade_item_marks()}, if applicable.

◆ $lateststeps

array mod_quiz\local\reports\attempts_report_table::$lateststeps = null
protectedinherited

information about the latest step of each question.

Loaded by {

See also
load_question_latest_steps()}, if applicable.

◆ $quizobj

quiz_settings quiz_settings mod_quiz\local\reports\attempts_report_table::$quizobj
protectedinherited

quiz settings object for this quiz.

Gets set in {

See also
attempts_report::et_up_table_columns()}.

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