Moodle PHP Documentation 5.1
Moodle 5.1dev (Build: 20250530) (c39b7370636)
mod_feedback_responses_table Class Reference

Class mod_feedback_responses_table. More...

Inheritance diagram for mod_feedback_responses_table:
mod_feedback_responses_anon_table

Public Member Functions

 __construct (mod_feedback_structure $feedbackstructure, $group=0)
 Constructor.
 
 build_table ()
 Take the data returned from the db_query and go through all the rows processing each col using either col_{columnname} method or other_cols method or if other_cols returns NULL then put the data straight into the table.
 
 col_completed_timemodified ($student)
 Prepares column completed_timemodified for display.
 
 col_courseid ($row)
 Prepares column courseid for display.
 
 col_deleteentry ($row)
 Prepares column deleteentry for display.
 
 col_groups ($row)
 Prepares column groups for display.
 
 col_userpic ($row)
 Prepares column userpic for display.
 
 define_columns ($columns)
 Defines columns.
 
 display ()
 Displays the table.
 
 download ()
 Download the data.
 
 download_buttons ()
 Returns html code for displaying "Download" button if applicable.
 
 export_external_structure ($page=0, $perpage=0)
 Exports the table as an external structure handling pagination.
 
 get_context ()
 Current context.
 
 get_reponse_navigation_links ($record)
 Returns links to previous/next responses in the list.
 
 get_total_responses_count ()
 Returns total number of reponses (without any filters applied)
 
 other_cols ($column, $row)
 Allows to set the display column value for all columns without "col_xxxxx" method.
 
 out ($pagesize, $useinitialsbar, $downloadhelpbutton='')
 Convenience method to call a number of methods for you to display the table.
 
 query_db ($pagesize, $useinitialsbar=true)
 Query the db.
 

Public Attributes

const PREVIEWCOLUMNSLIMIT = 10
 Maximum number of feedback questions to display in the "Show responses" table.
 
const ROWCHUNKSIZE = 100
 When additional queries are needed to retrieve more than TABLEJOINLIMIT questions answers, do it in chunks every x rows.
 
const TABLEJOINLIMIT = 59
 Maximum number of feedback questions answers to retrieve in one SQL query.
 

Protected Member Functions

 add_all_values_to_output ()
 Adds common values to the table that do not change the number or order of entries and are only needed when outputting or downloading data.
 
 add_data_for_external ($row)
 Add data for the external structure that will be returned.
 
 build_table_chunk (&$rows, &$columnsgroups)
 Retrieve additional columns.
 
 get_link_single_entry ($row)
 Returns a link for viewing a single response.
 
 get_responses_for_external ($row)
 Return user responses data ready for the external function.
 
 init ($group=0)
 Initialises table.
 

Protected Attributes

bool $buildforexternal = false
 whether we are building this table for a external function
 
array $dataforexternal = []
 the data structure containing the table data for the external function
 
string $downloadparamname = 'download'
 
mod_feedback_structure $feedbackstructure
 
int $grandtotal = null
 
int $hasmorecolumns = 0
 number of columns that were not retrieved in the main SQL query (no more than TABLEJOINLIMIT tables with values can be joined).
 
bool $pageable
 true if elements per page > 0, otherwise false.
 
bool $showall = false
 
string $showallparamname = 'showall'
 

Detailed Description

Class mod_feedback_responses_table.

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

Constructor & Destructor Documentation

◆ __construct()

mod_feedback_responses_table::__construct ( mod_feedback_structure $feedbackstructure,
$group = 0 )

Constructor.

Parameters
mod_feedback_structure$feedbackstructure
int$groupretrieve only users from this group (optional)

Member Function Documentation

◆ add_data_for_external()

mod_feedback_responses_table::add_data_for_external ( $row)
protected

Add data for the external structure that will be returned.

Parameters
stdClass$rowa database query record row
Since
Moodle 3.3

Reimplemented in mod_feedback_responses_anon_table.

◆ build_table()

mod_feedback_responses_table::build_table ( )

Take the data returned from the db_query and go through all the rows processing each col using either col_{columnname} method or other_cols method or if other_cols returns NULL then put the data straight into the table.

This overwrites the parent method because full SQL query may fail on Mysql because of the limit in the number of tables in the join. Therefore we only join 59 tables in the main query and add the rest here.

Return values
void

◆ build_table_chunk()

mod_feedback_responses_table::build_table_chunk ( & $rows,
& $columnsgroups )
protected

Retrieve additional columns.

Database engine may have a limit on number of joins.

Parameters
array$rowsArray of rows with already retrieved data, new values will be added to this array
array$columnsgroupsarray of arrays of columns. Each element has up to self::TABLEJOINLIMIT items. This is easy to calculate but because we can call this method many times we calculate it once and pass by reference for performance reasons

◆ col_completed_timemodified()

mod_feedback_responses_table::col_completed_timemodified ( $student)

Prepares column completed_timemodified for display.

Parameters
stdClass$student
Return values
string

◆ col_courseid()

mod_feedback_responses_table::col_courseid ( $row)

Prepares column courseid for display.

Parameters
array$row
Return values
string

◆ col_deleteentry()

mod_feedback_responses_table::col_deleteentry ( $row)

Prepares column deleteentry for display.

Parameters
stdClass$row
Return values
string

◆ col_groups()

mod_feedback_responses_table::col_groups ( $row)

Prepares column groups for display.

Parameters
array$row
Return values
string

◆ col_userpic()

mod_feedback_responses_table::col_userpic ( $row)

Prepares column userpic for display.

Parameters
stdClass$row
Return values
string

◆ define_columns()

mod_feedback_responses_table::define_columns ( $columns)

Defines columns.

Parameters
array$columnsan array of identifying names for columns. If columns are sorted then column names must correspond to a field in sql.

◆ export_external_structure()

mod_feedback_responses_table::export_external_structure ( $page = 0,
$perpage = 0 )

Exports the table as an external structure handling pagination.

Parameters
int$pagepage number (for pagination)
int$perpageelements per page
Since
Moodle 3.3
Return values
arrayreturns the table ready to be used by an external function

◆ get_context()

mod_feedback_responses_table::get_context ( )

Current context.

Return values
context_module

◆ get_link_single_entry()

mod_feedback_responses_table::get_link_single_entry ( $row)
protected

Returns a link for viewing a single response.

Parameters
stdClass$row
Return values
moodle_url

Reimplemented in mod_feedback_responses_anon_table.

◆ get_reponse_navigation_links()

mod_feedback_responses_table::get_reponse_navigation_links ( $record)

Returns links to previous/next responses in the list.

Parameters
stdClass$record
Return values
arrayarray of three elements [$prevresponseurl, $returnurl, $nextresponseurl]

◆ get_responses_for_external()

mod_feedback_responses_table::get_responses_for_external ( $row)
protected

Return user responses data ready for the external function.

Parameters
stdClass$rowthe table row containing the responses
Return values
arrayreturns the responses ready to be used by an external function
Since
Moodle 3.3

◆ get_total_responses_count()

mod_feedback_responses_table::get_total_responses_count ( )

Returns total number of reponses (without any filters applied)

Return values
int

◆ init()

mod_feedback_responses_table::init ( $group = 0)
protected

Initialises table.

Parameters
int$groupretrieve only users from this group (optional)

Reimplemented in mod_feedback_responses_anon_table.

◆ other_cols()

mod_feedback_responses_table::other_cols ( $column,
$row )

Allows to set the display column value for all columns without "col_xxxxx" method.

Parameters
string$columncolumn name
stdClass$rowcurrent record result of SQL query

◆ out()

mod_feedback_responses_table::out ( $pagesize,
$useinitialsbar,
$downloadhelpbutton = '' )

Convenience method to call a number of methods for you to display the table.

Parameters
int$pagesize
bool$useinitialsbar
string$downloadhelpbutton

◆ query_db()

mod_feedback_responses_table::query_db ( $pagesize,
$useinitialsbar = true )

Query the db.

Store results in the table object for use by build_table.

Parameters
int$pagesizesize of page for paginated displayed table.
bool$useinitialsbardo you want to use the initials bar. Bar will only be used if there is a fullname column defined for the table.

Member Data Documentation

◆ ROWCHUNKSIZE

const mod_feedback_responses_table::ROWCHUNKSIZE = 100

When additional queries are needed to retrieve more than TABLEJOINLIMIT questions answers, do it in chunks every x rows.

Value too small will mean too many DB queries, value too big may cause memory overflow.

◆ TABLEJOINLIMIT

const mod_feedback_responses_table::TABLEJOINLIMIT = 59

Maximum number of feedback questions answers to retrieve in one SQL query.

Mysql has a limit of 60, we leave 1 for joining with users table.


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