From dc99b426e9dac715f2b83e4cce1af3e00e0c0ded Mon Sep 17 00:00:00 2001 From: Damyon Wiese Date: Tue, 13 Nov 2012 08:51:00 +0800 Subject: [PATCH] MDL-36509: Assignment grading table rownum offset is wrong by one. --- mod/assign/gradingtable.php | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/mod/assign/gradingtable.php b/mod/assign/gradingtable.php index 29be4ee84b8..6afdcf72739 100644 --- a/mod/assign/gradingtable.php +++ b/mod/assign/gradingtable.php @@ -208,6 +208,22 @@ class assign_grading_table extends table_sql implements renderable { } + /** + * Before adding each row to the table make sure rownum is incremented + * + * @param array $row row of data from db used to make one row of the table. + * @return array one row for the table + */ + function format_row($row) { + if ($this->rownum < 0) { + $this->rownum = $this->currpage * $this->pagesize; + } else { + $this->rownum += 1; + } + + return parent::format_row($row); + } + /** * Add the userid to the row class so it can be updated via ajax * @@ -277,7 +293,7 @@ class assign_grading_table extends table_sql implements renderable { /** - * Format a user picture for display (and update rownum as a sideeffect) + * Format a user picture for display * * @param stdClass $row * @return string @@ -435,11 +451,6 @@ class assign_grading_table extends table_sql implements renderable { */ function col_userid(stdClass $row) { $edit = ''; - if ($this->rownum < 0) { - $this->rownum = $this->currpage * $this->pagesize; - } else { - $this->rownum += 1; - } $actions = array(); -- 2.39.2