Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Differences Between: [Versions 402 and 403]

(no description)

File Size: 748 lines (28 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: attempts_report_table  - X-Ref

Base class for the table used by a {@see attempts_report}.

__construct($uniqueid, $quiz, $context, $qmsubselect,attempts_report_options $options, \core\dml\sql_join $groupstudentsjoins, \core\dml\sql_join $studentsjoins,$questions, $reporturl)   X-Ref
Constructor.

param: string $uniqueid
param: stdClass $quiz
param: context_module $context
param: string $qmsubselect
param: attempts_report_options $options
param: \core\dml\sql_join $groupstudentsjoins Contains joins, wheres, params
param: \core\dml\sql_join $studentsjoins Contains joins, wheres, params
param: array $questions
param: moodle_url $reporturl

col_checkbox($attempt)   X-Ref
Generate the display of the checkbox column.

param: stdClass $attempt the table row being output.
return: string HTML content to go inside the td.

col_picture($attempt)   X-Ref
Generate the display of the user's picture column.

param: stdClass $attempt the table row being output.
return: string HTML content to go inside the td.

col_fullname($attempt)   X-Ref
Generate the display of the user's full name column.

param: stdClass $attempt the table row being output.
return: string HTML content to go inside the td.

col_state($attempt)   X-Ref
Generate the display of the attempt state column.

param: stdClass $attempt the table row being output.
return: string HTML content to go inside the td.

col_timestart($attempt)   X-Ref
Generate the display of the start time column.

param: stdClass $attempt the table row being output.
return: string HTML content to go inside the td.

col_timefinish($attempt)   X-Ref
Generate the display of the finish time column.

param: stdClass $attempt the table row being output.
return: string HTML content to go inside the td.

col_duration($attempt)   X-Ref
Generate the display of the time taken column.

param: stdClass $attempt the table row being output.
return: string HTML content to go inside the td.

col_feedbacktext($attempt)   X-Ref
Generate the display of the feedback column.

param: stdClass $attempt the table row being output.
return: string HTML content to go inside the td.

get_row_class($attempt)   X-Ref
No description

make_review_link($data, $attempt, $slot)   X-Ref
Make a link to review an individual question in a popup window.

param: string $data HTML fragment. The text to make into the link.
param: stdClass $attempt data for the row of the table being output.
param: int $slot the number used to identify this question within this usage.

slot_state($attempt, $slot)   X-Ref
Get the question attempt state for a particular question in a particular quiz attempt.

param: stdClass $attempt the row data.
param: int $slot indicates which question.
return: question_state the state of that question.

is_flagged($questionusageid, $slot)   X-Ref
Work out if a particular question in a particular attempt has been flagged.

param: int $questionusageid used to identify the attempt of interest.
param: int $slot identifies which question in the attempt to check.
return: bool true if the question is flagged in the attempt.

slot_fraction($attempt, $slot)   X-Ref
Get the mark (out of 1) for the question in a particular slot.

param: stdClass $attempt the row data
param: int $slot which slot to check.
return: float the score for this question on a scale of 0 - 1.

icon_for_fraction($fraction)   X-Ref
Return an appropriate icon (green tick, red cross, etc.) for a grade.

param: float $fraction grade on a scale 0..1.
return: string html fragment.

load_extra_data()   X-Ref
Load any extra data after main query.

At this point you can call {@see 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.

load_question_latest_steps(qubaid_condition $qubaids = null)   X-Ref
Load information about the latest state of selected questions in selected attempts.

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

param: qubaid_condition|null $qubaids used to restrict which usages are included
return: array of records. See the SQL in this function to see the fields available.

requires_extra_data()   X-Ref
Does this report require loading any more data after the main query.

return: bool should {@see query_db()} call {@see load_extra_data}?

requires_latest_steps_loaded()   X-Ref
Does this report require the detailed information for each question from the question_attempts_steps table?

return: bool should {@see load_extra_data} call {@see load_question_latest_steps}?

is_latest_step_column($column)   X-Ref
Is this a column that depends on joining to the latest state information?

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

param: string $column a column name
return: int|false false if no, else a slot.

get_required_latest_state_fields($slot, $alias)   X-Ref
Get any fields that might be needed when sorting on date for a particular slot.

Note: these values are only used for sorting. The values displayed are taken
from $this->lateststeps loaded in load_extra_data().

param: int $slot the slot for the column we want.
param: string $alias the table alias for latest state information relating to that slot.
return: string definitions of extra fields to add to the SELECT list of the query.

base_sql(\core\dml\sql_join $allowedstudentsjoins)   X-Ref
Contruct all the parts of the main database query.

param: \core\dml\sql_join $allowedstudentsjoins (joins, wheres, params) defines allowed users for the report.
return: array with 4 elements [$fields, $from, $where, $params] that can be used to

update_sql_after_count($fields, $from, $where, $params)   X-Ref
Lets subclasses modify the SQL after the count query has been created and before the full query is.

param: string $fields SELECT list.
param: string $from JOINs part of the SQL.
param: string $where WHERE clauses.
param: array $params Query params.
return: array with 4 elements ($fields, $from, $where, $params) as from base_sql.

setup_sql_queries($allowedjoins)   X-Ref
Set up the SQL queries (count rows, and get data).

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

add_latest_state_join($slot)   X-Ref
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.

param: int $slot the question to add information for.

get_qubaids_condition()   X-Ref
Get an appropriate qubaid_condition for loading more data about the attempts we are displaying.

return: qubaid_condition

query_db($pagesize, $useinitialsbar = true)   X-Ref
No description

get_sort_columns()   X-Ref
No description

wrap_html_start()   X-Ref
No description

wrap_html_finish()   X-Ref
No description

submit_buttons()   X-Ref
Output any submit buttons required by the $this->includecheckboxes form.


checkbox_col_header(string $columnname)   X-Ref
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.

param: string $columnname The name of the checkbox column.
return: string