Skip to content

Commit

Permalink
Fix errors with reports
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastsg committed Oct 7, 2024
1 parent 31d9913 commit 35845c3
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 14 deletions.
9 changes: 9 additions & 0 deletions report/attempts/attempts_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ public function other_cols($colname, $attempt): ?string {
};
}

/**
* TODO: Fix this workaround for preventing errors with name column preferences.
*
* @return string
*/
public function get_sql_where(): string {
return '';
}

/**
* Format a single column, used in other_cols
*
Expand Down
4 changes: 2 additions & 2 deletions report/attempts/report.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ public function display($capquiz, $cm, $course, $download): bool {
}

if ($hasquestions && !empty($questions) && ($hasstudents || $this->options->attempts == self::ALL_WITH)) {

$table->setup_sql_queries($studentsjoins);

// Define table columns.
Expand All @@ -127,7 +126,7 @@ public function display($capquiz, $cm, $course, $download): bool {
$this->add_user_columns($table, $columns, $headers);

if ($table->is_downloading()) {
$this->add_uesrid_column($columns, $headers);
$this->add_userid_column($columns, $headers);
$this->add_moodlequestionid_column($columns, $headers);
}

Expand Down Expand Up @@ -179,6 +178,7 @@ public function display($capquiz, $cm, $course, $download): bool {
$table->collapsible(true);

$table->out($this->options->pagesize, true);

}
return true;
}
Expand Down
10 changes: 5 additions & 5 deletions report/attemptsreport.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@

namespace mod_capquiz\report;

use capquizreport_attempts\capquizreport_attempts_options;
use context_module;
use core\context\module;
use core\dml\sql_join;
use mod_capquiz\capquiz;
use mod_quiz\local\reports\attempts_report_options;
use mod_quiz\local\reports\attempts_report_options_form;
use moodle_url;
use stdClass;
Expand Down Expand Up @@ -69,7 +69,7 @@ abstract class capquiz_attempts_report extends report {
/** @var attempts_report_options_form The settings form to use. */
protected $form;

/** @var attempts_report_options the options affecting this report. */
/** @var ?capquizreport_attempts_options the options affecting this report. */
protected $options = null;

/**
Expand Down Expand Up @@ -113,12 +113,12 @@ protected function get_base_url(): moodle_url {
* @param stdClass $cm the course_module information.
* @param stdClass $course the course settings.
* @param capquiz $capquiz the capquiz settings.
* @param attempts_report_options $options the current report settings.
* @param capquiz_attempts_report_options $options the current report settings.
* @param bool $hasquestions whether there are any questions in the capquiz.
* @param bool $hasstudents whether there are any relevant students.
*/
protected function print_standard_header_and_messages(stdClass $cm, stdClass $course, capquiz $capquiz,
attempts_report_options $options, bool $hasquestions,
capquiz_attempts_report_options $options, bool $hasquestions,
bool $hasstudents): void {
global $OUTPUT;

Expand Down Expand Up @@ -215,7 +215,7 @@ protected function add_moodlequestionid_column(array &$columns, array &$headers)
* @param array $columns the list of columns. Added to.
* @param array $headers the columns headings. Added to.
*/
protected function add_uesrid_column(array &$columns, array &$headers): void {
protected function add_userid_column(array &$columns, array &$headers): void {
$columns[] = 'userid';
$headers[] = get_string('userid', 'capquiz');
}
Expand Down
3 changes: 3 additions & 0 deletions report/attemptsreport_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ abstract class capquiz_attempts_report_table extends table_sql {
/** @var bool whether to include the column with checkboxes to select each attempt. */
protected $includecheckboxes;

/** @var string date format. */
protected $strtimeformat;

/**
* Constructor.
*
Expand Down
4 changes: 2 additions & 2 deletions report/questions/questions_options.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@
class capquizreport_questions_options extends capquiz_attempts_report_options {

/** @var bool whether to show the question text columns. */
public bool $showqtext = false;
public $showqtext = false;

/**
* @var string quiz_attempts_report::ALL_WITH or quiz_attempts_report::ENROLLED_WITH
* quiz_attempts_report::ENROLLED_WITHOUT or quiz_attempts_report::ENROLLED_ALL
*/
public string $attempts = capquiz_attempts_report::ALL_WITH;
public $attempts = capquiz_attempts_report::ALL_WITH;

/**
* Get the current value of the settings to pass to the settings form.
Expand Down
3 changes: 1 addition & 2 deletions report/questions/questions_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function build_table(): void {
* @param string $colname
* @param stdClass $attempt
*/
public function other_cols(string $colname, stdClass $attempt): ?string {
public function other_cols($colname, $attempt): ?string {
return match ($colname) {
'question' => $this->data_col($attempt->slot, 'questionsummary', $attempt),
default => null,
Expand Down Expand Up @@ -159,7 +159,6 @@ public function col_answerstate(stdClass $attempt): string {
}
}


/**
* Generate the display of the question rating column.
*
Expand Down
7 changes: 4 additions & 3 deletions report/questions/report.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
use context_course;
use mod_capquiz\capquiz;
use mod_capquiz\report\capquiz_attempts_report;
use mod_quiz\local\reports\attempts_report_options;
use mod_capquiz\report\capquiz_attempts_report_options;
use stdClass;

defined('MOODLE_INTERNAL') || die();
Expand Down Expand Up @@ -170,11 +170,12 @@ public function display($capquiz, $cm, $course, $download): bool {
* @param stdClass $cm the course_module information.
* @param stdClass $course the course settings.
* @param capquiz $capquiz the capquiz settings.
* @param attempts_report_options $options the current report settings.
* @param capquiz_attempts_report_options $options the current report settings.
* @param bool $hasquestions whether there are any questions in the capquiz.
* @param bool $hasstudents whether there are any relevant students.
*/
protected function print_standard_header_and_messages($cm, $course, capquiz $capquiz, attempts_report_options $options,
protected function print_standard_header_and_messages($cm, $course, capquiz $capquiz,
capquiz_attempts_report_options $options,
bool $hasquestions, bool $hasstudents): void {
global $OUTPUT;
$this->print_header_and_tabs($cm, $course, $capquiz, $this->mode);
Expand Down

0 comments on commit 35845c3

Please sign in to comment.