Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
quiz_overview_report Class Reference

Quiz report subclass for the overview (grades) report. More...

Inheritance diagram for quiz_overview_report:
quiz_attempts_report quiz_default_report

Public Member Functions

 display ($quiz, $cm, $course)
 Override this function to displays the report. More...
 
 get_current_group ($cm, $course, $context)
 Get the current group for the user user looking at the report. More...
 
 print_header_and_tabs ($cm, $course, $quiz, $reportmode='overview')
 Initialise some parts of $PAGE and start output. More...
 

Static Public Member Functions

static get_bands_count_and_width ($quiz)
 Get the bands configuration for the quiz. More...
 
static get_bands_labels ($bands, $bandwidth, $quiz)
 Get the bands labels. More...
 

Public Attributes

string const ALL_WITH = 'all_with'
 constant used for the options, means all users with attempts.
 
int const DEFAULT_PAGE_SIZE = 30
 default page size for reports.
 
string const ENROLLED_ALL = 'enrolled_any'
 constant used for the options, means all enrolled users.
 
string const ENROLLED_WITH = 'enrolled_with'
 constant used for the options, means only enrolled users with attempts.
 
string const ENROLLED_WITHOUT = 'enrolled_without'
 constant used for the options, means only enrolled users without attempts.
 
const NO_GROUPS_ALLOWED = -2
 

Protected Member Functions

 add_grade_columns ($quiz, $usercanseegrades, &$columns, &$headers, $includefeedback=true)
 Add all the grade and feedback columns, if applicable, to the $columns and $headers arrays. More...
 
 add_state_column (&$columns, &$headers)
 Add the state column to the $columns and $headers arrays. More...
 
 add_time_columns (&$columns, &$headers)
 Add all the time-related columns to the $columns and $headers arrays. More...
 
 add_user_columns ($table, &$columns, &$headers)
 Add all the user-related columns to the $columns and $headers arrays. More...
 
 clear_regrade_table ($quiz, core\dml\sql_join $groupstudentsjoins)
 Remove all information about pending/complete regrades from the database. More...
 
 configure_user_columns ($table)
 Set the display options for the user-related columns in the table. More...
 
 count_question_attempts_needing_regrade ($quiz, core\dml\sql_join $groupstudentsjoins)
 Count the number of attempts in need of a regrade. More...
 
 delete_selected_attempts ($quiz, $cm, $attemptids, core\dml\sql_join $allowedjoins)
 Delete the quiz attempts. More...
 
 finish_regrade ($nexturl)
 Finish displaying the regrade progress page. More...
 
 get_base_url ()
 Get the base URL for this report. More...
 
 get_students_joins ($cm, $course=null)
 Get sql fragments (joins) which can be used to build queries that will select an appropriate set of students to show in the reports. More...
 
 has_regraded_questions ($from, $where, $params)
 Are there any pending regrades in the table we are going to show? More...
 
 init ($mode, $formclass, $quiz, $cm, $course)
 Initialise various aspects of this report. More...
 
 load_relevant_students ($cm, $course=null)
 Get information about which students to show in the report. More...
 
 print_standard_header_and_messages ($cm, $course, $quiz, $options, $currentgroup, $hasquestions, $hasstudents)
 Outputs the things you commonly want at the top of a quiz report. More...
 
 process_actions ($quiz, $cm, $currentgroup, core\dml\sql_join $groupstudentsjoins, core\dml\sql_join $allowedjoins, $redirecturl)
 Extends parent function processing any submitted actions. More...
 
 regrade_attempt ($attempt, $dryrun=false, $slots=null)
 Regrade a particular quiz attempt. More...
 
 regrade_attempts ($quiz, $dryrun=false, core\dml\sql_join $groupstudentsjoins=null, $attemptids=array())
 Regrade attempts for this quiz, exactly which attempts are regraded is controlled by the parameters. More...
 
 regrade_attempts_needing_it ($quiz, core\dml\sql_join $groupstudentsjoins)
 Regrade those questions in those attempts that are marked as needing regrading in the quiz_overview_regrades table. More...
 
 regrade_batch_of_attempts ($quiz, array $attempts, bool $dryrun, core\dml\sql_join $groupstudentsjoins)
 This is a helper used by } and * regrade_attempts_needing_it(). More...
 
 set_up_table_columns ($table, $columns, $headers, $reporturl, mod_quiz_attempts_report_options $options, $collapsible)
 Set up the table. More...
 
 start_regrade ($quiz, $cm)
 Check necessary capabilities, and start the display of the regrade progress page. More...
 
 unlock_session ()
 Unlock the session and allow the regrading process to run in the background.
 
 update_overall_grades ($quiz)
 Update the final grades for all attempts. More...
 

Static Protected Member Functions

static get_chart ($labels, $data)
 Get a chart. More...
 

Protected Attributes

object $context
 the quiz context.
 
mod_quiz_attempts_report_form $form
 The settings form to use.
 
bool $hasgroupstudents
 whether there are actually students to show, given the options.
 
string $mode
 the mode this report is.
 
string $qmsubselect
 SQL fragment for selecting the attempt that gave the final grade, if applicable.
 
boolean $showgrades = null
 caches the results of should_show_grades().
 

Detailed Description

Quiz report subclass for the overview (grades) report.

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

Member Function Documentation

◆ add_grade_columns()

quiz_attempts_report::add_grade_columns (   $quiz,
  $usercanseegrades,
$columns,
$headers,
  $includefeedback = true 
)
protectedinherited

Add all the grade and feedback columns, if applicable, to the $columns and $headers arrays.

Parameters
object$quizthe quiz settings.
bool$usercanseegradeswhether the user is allowed to see grades for this quiz.
array$columnsthe list of columns. Added to.
array$headersthe columns headings. Added to.
bool$includefeedbackwhether to include the feedbacktext columns

◆ add_state_column()

quiz_attempts_report::add_state_column ( $columns,
$headers 
)
protectedinherited

Add the state column to the $columns and $headers arrays.

Parameters
array$columnsthe list of columns. Added to.
array$headersthe columns headings. Added to.

◆ add_time_columns()

quiz_attempts_report::add_time_columns ( $columns,
$headers 
)
protectedinherited

Add all the time-related columns to the $columns and $headers arrays.

Parameters
array$columnsthe list of columns. Added to.
array$headersthe columns headings. Added to.

◆ add_user_columns()

quiz_attempts_report::add_user_columns (   $table,
$columns,
$headers 
)
protectedinherited

Add all the user-related columns to the $columns and $headers arrays.

Parameters
table_sql$tablethe table being constructed.
array$columnsthe list of columns. Added to.
array$headersthe columns headings. Added to.

◆ clear_regrade_table()

quiz_overview_report::clear_regrade_table (   $quiz,
core\dml\sql_join  $groupstudentsjoins 
)
protected

Remove all information about pending/complete regrades from the database.

Parameters
object$quizthe quiz settings.
core\dml\sql_join$groupstudentsjoins(joins, wheres, params). If this is given, only data relating to these users is cleared.

◆ configure_user_columns()

quiz_attempts_report::configure_user_columns (   $table)
protectedinherited

Set the display options for the user-related columns in the table.

Parameters
table_sql$tablethe table being constructed.

◆ count_question_attempts_needing_regrade()

quiz_overview_report::count_question_attempts_needing_regrade (   $quiz,
core\dml\sql_join  $groupstudentsjoins 
)
protected

Count the number of attempts in need of a regrade.

Parameters
object$quizthe quiz settings.
core\dml\sql_join$groupstudentsjoins(joins, wheres, params) If this is given, only data relating to these users is cleared.
Return values
intthe number of attempts.

◆ delete_selected_attempts()

quiz_attempts_report::delete_selected_attempts (   $quiz,
  $cm,
  $attemptids,
core\dml\sql_join  $allowedjoins 
)
protectedinherited

Delete the quiz attempts.

Parameters
object$quizthe quiz settings. Attempts that don't belong to this quiz are not deleted.
object$cmthe course_module object.
array$attemptidsthe list of attempt ids to delete.
core\dml\sql_join$allowedjoins(joins, wheres, params) This list of userids that are visible in the report. Users can only delete attempts that they are allowed to see in the report. Empty means all users.

Reimplemented in testable_quiz_attempts_report.

◆ display()

quiz_overview_report::display (   $cm,
  $course,
  $quiz 
)

Override this function to displays the report.

Parameters
$cmthe course-module for this quiz.
$coursethe coures we are in.
$quizthis quiz.

Reimplemented from quiz_default_report.

◆ finish_regrade()

quiz_overview_report::finish_regrade (   $nexturl)
protected

Finish displaying the regrade progress page.

Parameters
moodle_url$nexturlwhere to send the user after the regrade. @uses exit. This method never returns.

◆ get_bands_count_and_width()

static quiz_overview_report::get_bands_count_and_width (   $quiz)
static

Get the bands configuration for the quiz.

This returns the configuration for having between 11 and 20 bars in a chart based on the maximum grade to be given on a quiz. The width of a band is the number of grade points it encapsulates.

Parameters
object$quizThe quiz object.
Return values
arrayContains the number of bands, and their width.

◆ get_bands_labels()

static quiz_overview_report::get_bands_labels (   $bands,
  $bandwidth,
  $quiz 
)
static

Get the bands labels.

Parameters
int$bandsThe number of bands.
int$bandwidthThe band width.
object$quizThe quiz object.
Return values
string[]The labels.

◆ get_base_url()

quiz_attempts_report::get_base_url ( )
protectedinherited

Get the base URL for this report.

Return values
moodle_urlthe URL.

◆ get_chart()

static quiz_overview_report::get_chart (   $labels,
  $data 
)
staticprotected

Get a chart.

Parameters
string[]$labelsChart labels.
int[]$dataThe data.
Return values
core

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

quiz_attempts_report::get_students_joins (   $cm,
  $course = null 
)
protectedinherited

Get sql fragments (joins) which can be used to build queries that will select an appropriate set of students to show in the reports.

Parameters
object$cmthe course module.
object$coursethe course settings.
Return values
arraywith four elements: 0 => integer the current group id (0 for none). 1 => core\dml\sql_join Contains joins, wheres, params for all the students in this course. 2 => core\dml\sql_join Contains joins, wheres, params for all the students in the current group. 3 => core\dml\sql_join Contains joins, wheres, params for all the students to show in the report. Will be the same as either element 1 or 2.

◆ has_regraded_questions()

quiz_overview_report::has_regraded_questions (   $from,
  $where,
  $params 
)
protected

Are there any pending regrades in the table we are going to show?

Parameters
string$fromtables used by the main query.
string$wherewhere clause used by the main query.
array$paramsrequired by the SQL.
Return values
boolwhether there are pending regrades.

◆ init()

quiz_attempts_report::init (   $mode,
  $formclass,
  $quiz,
  $cm,
  $course 
)
protectedinherited

Initialise various aspects of this report.

Parameters
string$mode
string$formclass
object$quiz
object$cm
object$course
Return values
arraywith four elements: 0 => integer the current group id (0 for none). 1 => core\dml\sql_join Contains joins, wheres, params for all the students in this course. 2 => core\dml\sql_join Contains joins, wheres, params for all the students in the current group. 3 => core\dml\sql_join Contains joins, wheres, params for all the students to show in the report. Will be the same as either element 1 or 2.

◆ load_relevant_students()

quiz_attempts_report::load_relevant_students (   $cm,
  $course = null 
)
protectedinherited

Get information about which students to show in the report.

Parameters
object$cmthe coures module.
object$coursethe course settings.
Return values
arraywith four elements: 0 => integer the current group id (0 for none). 1 => array ids of all the students in this course. 2 => array ids of all the students in the current group. 3 => array ids of all the students to show in the report. Will be the same as either element 1 or 2.
Deprecated:
since Moodle 3.2 Please use get_students_joins() instead.

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

◆ print_standard_header_and_messages()

quiz_attempts_report::print_standard_header_and_messages (   $cm,
  $course,
  $quiz,
  $options,
  $currentgroup,
  $hasquestions,
  $hasstudents 
)
protectedinherited

Outputs the things you commonly want at the top of a quiz report.

Calls through to print_header_and_tabs() and then outputs the standard group selector, number of attempts summary, and messages to cover common cases when the report can't be shown.

Parameters
stdClass$cmthe course_module information.
stdClass$coursethe course settings.
stdClass$quizthe quiz settings.
mod_quiz_attempts_report_options$optionsthe current report settings.
int$currentgroupthe current group.
bool$hasquestionswhether there are any questions in the quiz.
bool$hasstudentswhether there are any relevant students.

◆ process_actions()

quiz_overview_report::process_actions (   $quiz,
  $cm,
  $currentgroup,
core\dml\sql_join  $groupstudentsjoins,
core\dml\sql_join  $allowedjoins,
  $redirecturl 
)
protected

Extends parent function processing any submitted actions.

Parameters
object$quiz
object$cm
int$currentgroup
core\dml\sql_join$groupstudentsjoins(joins, wheres, params)
core\dml\sql_join$allowedjoins(joins, wheres, params)
moodle_url$redirecturl

Reimplemented from quiz_attempts_report.

◆ regrade_attempt()

quiz_overview_report::regrade_attempt (   $attempt,
  $dryrun = false,
  $slots = null 
)
protected

Regrade a particular quiz attempt.

Either for real ($dryrun = false), or as a pretend regrade to see which fractions would change. The outcome is stored in the quiz_overview_regrades table.

Note, $attempt is not upgraded in the database. The caller needs to do that. However, $attempt->sumgrades is updated, if this is not a dry run.

Parameters
object$attemptthe quiz attempt to regrade.
bool$dryrunif true, do a pretend regrade, otherwise do it for real.
array$slotsif null, regrade all questions, otherwise, just regrade the quetsions with those slots.

◆ regrade_attempts()

quiz_overview_report::regrade_attempts (   $quiz,
  $dryrun = false,
core\dml\sql_join  $groupstudentsjoins = null,
  $attemptids = array() 
)
protected

Regrade attempts for this quiz, exactly which attempts are regraded is controlled by the parameters.

Parameters
object$quizthe quiz settings.
bool$dryrunif true, do a pretend regrade, otherwise do it for real.
core\dml\sql_join | array$groupstudentsjoinsempty for all attempts, otherwise regrade attempts for these users.
array$attemptidsblank for all attempts, otherwise only regrade attempts whose id is in this list.

◆ regrade_attempts_needing_it()

quiz_overview_report::regrade_attempts_needing_it (   $quiz,
core\dml\sql_join  $groupstudentsjoins 
)
protected

Regrade those questions in those attempts that are marked as needing regrading in the quiz_overview_regrades table.

Parameters
object$quizthe quiz settings.
core\dml\sql_join$groupstudentsjoinsempty for all attempts, otherwise regrade attempts for these users.

◆ regrade_batch_of_attempts()

quiz_overview_report::regrade_batch_of_attempts (   $quiz,
array  $attempts,
bool  $dryrun,
core\dml\sql_join  $groupstudentsjoins 
)
protected

This is a helper used by } and * regrade_attempts_needing_it().

Given an array of attempts, it regrades them all, or does a dry run. Each object in the attempts array must be a row from the quiz_attempts table, with the get_all_user_name_fields from the user table joined in. In addition, if $attempt->regradeonlyslots is set, then only those slots are regraded, otherwise all slots are regraded.

Parameters
object$quizthe quiz settings.
array$attemptsof data from the quiz_attempts table, with extra data as above.
bool$dryrunif true, do a pretend regrade, otherwise do it for real.
core\dml\sql_join$groupstudentsjoinsempty for all attempts, otherwise regrade attempts

◆ set_up_table_columns()

quiz_attempts_report::set_up_table_columns (   $table,
  $columns,
  $headers,
  $reporturl,
mod_quiz_attempts_report_options  $options,
  $collapsible 
)
protectedinherited

Set up the table.

Parameters
table_sql$tablethe table being constructed.
array$columnsthe list of columns.
array$headersthe columns headings.
moodle_url$reporturlthe URL of this report.
mod_quiz_attempts_report_options$optionsthe display options.
bool$collapsiblewhether to allow columns in the report to be collapsed.

◆ start_regrade()

quiz_overview_report::start_regrade (   $quiz,
  $cm 
)
protected

Check necessary capabilities, and start the display of the regrade progress page.

Parameters
object$quizthe quiz settings.
object$cmthe cm object for the quiz.

◆ update_overall_grades()

quiz_overview_report::update_overall_grades (   $quiz)
protected

Update the final grades for all attempts.

This method is used following a regrade.

Parameters
object$quizthe quiz settings.
array$useridsonly update scores for these userids.
array$attemptidsattemptids only update scores for these attempt ids.

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