Skip to content

Commit

Permalink
wip demonstrating return type changes
Browse files Browse the repository at this point in the history
  • Loading branch information
snake committed Oct 31, 2023
1 parent e6d4e76 commit 27b341c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions grade/report/grader/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1200,9 +1200,9 @@ public function get_right_rows(bool $displayaverages) : array {
* @param grade_item $gradeitem Grade item.
* @param array|null $aggr Average value and meancount information.
* @param bool|null $shownumberofgrades Whether to show number of grades.
* @return mixed Formatted average cell.
* @return html_table_cell Formatted average cell.
*/
protected function format_average_cell(grade_item $gradeitem, ?array $aggr = null, ?bool $shownumberofgrades = null): mixed {
protected function format_average_cell(grade_item $gradeitem, ?array $aggr = null, ?bool $shownumberofgrades = null): html_table_cell {
global $OUTPUT;

if ($gradeitem->needsupdate) {
Expand Down
9 changes: 5 additions & 4 deletions grade/report/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -950,9 +950,10 @@ public function item_types(): array {
* Returns a row of grade items averages
*
* @param array $ungradedcounts Ungraded grade items counts with report preferences.
* @return mixed Row with averages
* @return html_table_row Row with averages
*/
protected function format_averages(array $ungradedcounts): mixed {
protected function format_averages(array $ungradedcounts): html_table_row
{

$avgrow = new html_table_row();
$avgrow->attributes['class'] = 'avg';
Expand Down Expand Up @@ -1004,9 +1005,9 @@ protected function format_averages(array $ungradedcounts): mixed {
* @param grade_item $gradeitem Grade item.
* @param array|null $aggr Average value and meancount information.
* @param bool|null $shownumberofgrades Whether to show number of grades.
* @return html_table_row HTML
* @return html_table_cell table cell.
*/
protected function format_average_cell(grade_item $gradeitem, ?array $aggr = null, ?bool $shownumberofgrades = null): mixed {
protected function format_average_cell(grade_item $gradeitem, ?array $aggr = null, ?bool $shownumberofgrades = null): html_table_cell {
return true;
}

Expand Down
10 changes: 5 additions & 5 deletions grade/report/user/classes/report/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,9 @@ public function __construct(int $courseid, ?object $gpr, object $context, int $u
* @param grade_item $gradeitem Grade item.
* @param array|null $aggr Average value and meancount information.
* @param bool|null $shownumberofgrades Whether to show number of grades.
* @return mixed Formatted average cell.
* @return \html_table_cell Formatted average cell.
*/
protected function format_average_cell(grade_item $gradeitem, ?array $aggr = null, ?bool $shownumberofgrades = null): mixed {
protected function format_average_cell(grade_item $gradeitem, ?array $aggr = null, ?bool $shownumberofgrades = null): \html_table_cell {

if ($gradeitem->needsupdate) {
$avg = '<td class="cell c' . $this->columncount++.'">' .
Expand All @@ -368,7 +368,7 @@ protected function format_average_cell(grade_item $gradeitem, ?array $aggr = nul
$avg = $aggr['average'] . $numberofgrades;
}
}
return $avg;
return new \html_table_cell($avg);
}

/**
Expand Down Expand Up @@ -852,8 +852,8 @@ private function fill_table_recursive(array &$element) {
$cache = \cache::make_from_params(\cache_store::MODE_REQUEST, 'gradereport_user', 'averages');
$avg = $cache->get(get_class($this));

$data['average']['content'] = $avg[$eid];
$gradeitemdata['averageformatted'] = $avg[$eid];
$data['average']['content'] = $avg[$eid]->text;
$gradeitemdata['averageformatted'] = $avg[$eid]->text;
$data['average']['headers'] = "$headercat $headerrow average$userid";
}

Expand Down

0 comments on commit 27b341c

Please sign in to comment.