Moodle PHP Documentation 4.5
Moodle 4.5.5+ (Build: 20250711) (ce34e8ff087)
quiz_first_or_all_responses_table Class Reference

This is a table subclass for displaying the quiz responses report, showing first or all tries. More...

Inheritance diagram for quiz_first_or_all_responses_table:
quiz_last_responses_table mod_quiz\local\reports\attempts_report_table

Public Member Functions

 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 ($tablerow)
 Generate the display of the checkbox column.
 
 col_duration ($attempt)
 Generate the display of the duration column.
 
 col_email ($tablerow)
 Cell value function for email 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 ($tablerow)
 Generate the display of the attempt state column.
 
 col_sumgrades ($tablerow)
 Cell value function for sumgrades column.
 
 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_no_of_tries ($tablerow, $slot)
 How many tries were attempted at this question in this slot, during this usage?
 
 get_row_class ($tablerow)
 
 get_sort_columns ()
 
 get_summary_after_try ($tablerow, $slot)
 Get the summary of the response after the try.
 
 make_review_link ($data, $tablerow, $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 ($tablerow, $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_question_attempt ($questionusagesid, $slot)
 Return the question attempt object.
 
 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)
 Has this question usage been flagged?
 
 is_grade_item_column (string $columnname)
 Is this the column key for an extra grade item column?
 
 is_last_try ($tablerow, $slot, $tryno)
 Is this the last try in the question attempt?
 
 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 ($tablerow, $slot)
 The grade for this slot after this try.
 
 slot_state ($tablerow, $slot)
 Find the state for $slot given after this try.
 
 step_no_for_try ($questionusageid, $slot, $tryno)
 What is the step no this try was seen in?
 
 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.
 
question_usage_by_activity[] $questionusagesbyactivity
 The full question usage object for each try shown in report.
 
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.
 

Detailed Description

This is a table subclass for displaying the quiz responses report, showing first or all tries.

Author
Jamie Pratt me@ja.nosp@m.miep.nosp@m..org
License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

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 master core\output\checkbox_toggleall component that selects/deselects all quiz attempts.

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

◆ col_checkbox()

quiz_first_or_all_responses_table::col_checkbox ( $attempt)

Generate the display of the checkbox column.

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

Reimplemented from mod_quiz\local\reports\attempts_report_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_email()

quiz_first_or_all_responses_table::col_email ( $tablerow)

Cell value function for email column.

This extracts the contents for any cell in the email column from the row data.

Parameters
stdClass$tablerowRow data.
Return values
stringWhat to put in the cell for this column, for this row data.

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

quiz_first_or_all_responses_table::col_state ( $attempt)

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 from mod_quiz\local\reports\attempts_report_table.

◆ col_sumgrades()

quiz_first_or_all_responses_table::col_sumgrades ( $tablerow)

Cell value function for sumgrades column.

This extracts the contents for any cell in the sumgrades column from the row data.

Parameters
stdClass$tablerowRow data.
Return values
stringWhat to put in the cell for this column, for this row data.

Reimplemented from quiz_last_responses_table.

◆ 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_first_or_all_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 from quiz_last_responses_table.

◆ get_no_of_tries()

quiz_first_or_all_responses_table::get_no_of_tries ( $tablerow,
$slot )

How many tries were attempted at this question in this slot, during this usage?

Parameters
stdClass$tablerowattempt data from db.
int$slotSlot number
Return values
intthe number of tries in the question attempt for slot $slot.

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

quiz_first_or_all_responses_table::get_question_attempt ( $questionusagesid,
$slot )
protected

Return the question attempt object.

Parameters
int$questionusagesid
int$slot
Return values
question_attempt

◆ get_required_latest_state_fields()

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

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.

◆ get_row_class()

quiz_first_or_all_responses_table::get_row_class ( $tablerow)

◆ get_summary_after_try()

quiz_first_or_all_responses_table::get_summary_after_try ( $tablerow,
$slot )

Get the summary of the response after the try.

Parameters
stdClass$tablerowrow data
int$slotSlot number.
Return values
stringsummary for the question after this try.

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

quiz_first_or_all_responses_table::is_flagged ( $questionusageid,
$slot )
protected

Has this question usage been flagged?

Parameters
int$questionusageidQuestion usage id.
int$slotSlot number
Return values
boolHas it been flagged?

Reimplemented from mod_quiz\local\reports\attempts_report_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_last_try()

quiz_first_or_all_responses_table::is_last_try ( $tablerow,
$slot,
$tryno )
protected

Is this the last try in the question attempt?

Parameters
stdClass$tablerowattempt data from db.
int$slotSlot number
int$trynotry no
Return values
boolIs it the last try?

◆ is_latest_step_column()

quiz_last_responses_table::is_latest_step_column ( $column)
protectedinherited

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

quiz_first_or_all_responses_table::load_extra_data ( )
protected

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 from mod_quiz\local\reports\attempts_report_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()

quiz_first_or_all_responses_table::make_review_link ( $data,
$attempt,
$slot )

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 from mod_quiz\local\reports\attempts_report_table.

◆ other_cols()

quiz_last_responses_table::other_cols ( $colname,
$attempt )
inherited

◆ requires_extra_data()

quiz_last_responses_table::requires_extra_data ( )
protectedinherited

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

quiz_first_or_all_responses_table::slot_fraction ( $tablerow,
$slot )
protected

The grade for this slot after this try.

Parameters
stdClass$tablerowattempt data from db.
int$slotSlot number.
Return values
floatThe fraction.

Reimplemented from mod_quiz\local\reports\attempts_report_table.

◆ slot_state()

quiz_first_or_all_responses_table::slot_state ( $tablerow,
$slot )
protected

Find the state for $slot given after this try.

Parameters
stdClass$tablerowrow data
int$slotSlot number.
Return values
question_stateThe question state after the attempt.

Reimplemented from mod_quiz\local\reports\attempts_report_table.

◆ step_no_for_try()

quiz_first_or_all_responses_table::step_no_for_try ( $questionusageid,
$slot,
$tryno )
protected

What is the step no this try was seen in?

Parameters
int$questionusageidThe question usage id.
int$slotSlot number
int$trynoTry no
Return values
intthe step no or zero if not found

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