diff --git a/lib/gradelib.php b/lib/gradelib.php index 7c078e0fb8f..ec2a676197e 100644 --- a/lib/gradelib.php +++ b/lib/gradelib.php @@ -209,7 +209,7 @@ function grade_update($source, $courseid, $itemtype, $itemmodule, $iteminstance, $count = count($grades); if ($count > 0 and $count < 200) { - list($uids, $params) = $DB->get_in_or_equal(array_keys($grades), SQL_PARAMS_NAMED, $start='uid0'); + list($uids, $params) = $DB->get_in_or_equal(array_keys($grades), SQL_PARAMS_NAMED, $start='uid0'); $params['gid'] = $grade_item->id; $sql = "SELECT * FROM {grade_grades} WHERE itemid = :gid AND userid $uids"; @@ -226,11 +226,8 @@ function grade_update($source, $courseid, $itemtype, $itemmodule, $iteminstance, $grade_grade = null; $grade = null; - while ($rs and $rs->valid()) { - $rs->next(); - if (!$gd = $rs->current()) { - break; - } + foreach ($rs as $gd) { + $userid = $gd->userid; if (!isset($grades[$userid])) { // this grade not requested, continue @@ -243,6 +240,7 @@ function grade_update($source, $courseid, $itemtype, $itemmodule, $iteminstance, break; } + if (is_null($grade_grade)) { if (count($grades) == 0) { // no more grades to process diff --git a/lib/tablelib.php b/lib/tablelib.php index 3504216cc01..166de5e0c19 100644 --- a/lib/tablelib.php +++ b/lib/tablelib.php @@ -37,7 +37,7 @@ class flexible_table { var $totalrows = 0; var $sort_default_column = NULL; var $sort_default_order = SORT_ASC; - + /** * Array of positions in which to display download controls. */ @@ -49,26 +49,26 @@ class flexible_table { * passes in cleaned data from $ */ var $download = ''; - + /** * @var boolean whether data is downloadable from table. Determines whether * to display download buttons. Set by method downloadable(). */ var $downloadable = false; - + /** * @var string which download plugin to use. Default '' means none - print * html table with paging. */ var $defaultdownloadformat = 'csv'; - + /** * @var boolean Has start output been called yet? */ var $started_output = false; - + var $exportclass = null; - + /** * Constructor * @param int $uniqueid @@ -115,7 +115,7 @@ class flexible_table { /** * Probably don't need to call this directly. Calling is_downloading with a * param automatically sets table as downloadable. - * + * * @param boolean $downloadable optional param to set whether data from * table is downloadable. If ommitted this function can be used to get * current state of table. @@ -127,7 +127,7 @@ class flexible_table { } return $this->downloadable; } - + /** * Where to show download buttons. * @param array $showat array of postions in which to show download buttons. @@ -136,10 +136,10 @@ class flexible_table { function show_download_buttons_at($showat){ $this->showdownloadbuttonsat = $showat; } - - + + /** - * Sets the is_sortable variable to the given boolean, sort_default_column to + * Sets the is_sortable variable to the given boolean, sort_default_column to * the given string, and the sort_default_order to the given integer. * @param bool $bool * @param string $defaultcolumn @@ -239,9 +239,9 @@ class flexible_table { } /** - * What this method does is set the column so that if the same data appears in + * What this method does is set the column so that if the same data appears in * consecutive rows, then it is not repeated. - * + * * For example, in the quiz overview report, the fullname column is set to be suppressed, so * that when one student has made multiple attempts, their name is only printed in the row * for their first attempt. @@ -329,7 +329,7 @@ class flexible_table { function define_headers($headers) { $this->headers = $headers; } - + @@ -559,19 +559,19 @@ class flexible_table { } /** - * Add a row of data to the table. This function takes an array with - * column names as keys. + * Add a row of data to the table. This function takes an array with + * column names as keys. * It ignores any elements with keys that are not defined as columns. It * puts in empty strings into the row when there is no element in the passed * array corresponding to a column in the table. It puts the row elements in * the proper order. * @param $rowwithkeys array - * + * */ function add_data_keyed($rowwithkeys){ $this->add_data($this->get_row_from_keyed($rowwithkeys)); } - + /** * Add a seperator line to table. */ @@ -581,14 +581,14 @@ class flexible_table { } $this->add_data(NULL); } - + /** * This method actually directly echoes the row passed to it now or adds it * to the download. If this is the first row and start_output has not * already been called this method also calls start_output to open the table * or send headers for the downloaded. * Can be used as before. print_html now calls finish_html to close table. - * + * * @param array $row a numerically keyed row of data to add to the table. * @return boolean success. */ @@ -616,7 +616,7 @@ class flexible_table { /** * You should call this to finish outputting the table data after adding * data to the table with add_data or add_data_keyed. - * + * */ function finish_output(){ if ($this->exportclass!==null){ @@ -625,7 +625,7 @@ class flexible_table { $this->finish_html(); } } - + /** * Hook that can be overridden in child classes to wrap a table in a form * for example. Called only when there is data to display and not @@ -641,7 +641,7 @@ class flexible_table { */ function wrap_html_finish(){ } - + /** * This method is deprecated although the old api is still supported. * @deprecated 1.9.2 - Jun 2, 2008 @@ -676,18 +676,18 @@ class flexible_table { return $this->sess->i_last; } - + /** * This function is not part of the public api. */ function print_initials_bar(){ if($this->use_initials && isset($this->columns['fullname'])) { - + $strall = get_string('all'); $alpha = explode(',', get_string('alphabet')); - + // Bar of first initials - + echo '
'; - + // Bar of last initials - + echo ''; - + } } @@ -766,7 +766,7 @@ class flexible_table { } return $exportclasses; } - + /** * This function is not part of the public api. */ @@ -789,7 +789,7 @@ class flexible_table { * This function is not part of the public api. * You don't normally need to call this. It is called automatically when * needed when you start adding data to the table. - * + * */ function start_output(){ $this->started_output = true; @@ -859,7 +859,7 @@ class flexible_table { print_paging_bar($this->totalrows, $this->currpage, $this->pagesize, $this->baseurl, $this->request[TABLE_VAR_PAGE]); } } - } + } /** * This function is not part of the public api. */ @@ -925,7 +925,7 @@ class flexible_table { break; case 'userpic': - // do nothing, do not display sortable links + // do nothing, do not display sortable links break; default: @@ -940,7 +940,7 @@ class flexible_table { $localsortorder = get_string('desc'); } } else { - $localsortorder = get_string('asc'); + $localsortorder = get_string('asc'); } $this->headers[$index] = ''.$this->headers[$index].get_accesshide(get_string('sortby').' '.$this->headers[$index].' '.$localsortorder).''; } @@ -967,12 +967,12 @@ class flexible_table { } echo ''; } - + /** * This function is not part of the public api. */ function start_html(){ - + // Do we need to print initial bars? $this->print_initials_bar(); @@ -980,16 +980,16 @@ class flexible_table { if($this->use_pages) { print_paging_bar($this->totalrows, $this->currpage, $this->pagesize, $this->baseurl, $this->request[TABLE_VAR_PAGE]); } - + if(in_array(TABLE_P_TOP, $this->showdownloadbuttonsat)) { echo $this->download_buttons(); } - + $this->wrap_html_start(); // Start of main data table echo '