/** * adjust_grades_in_rawdata * * this function adjusts the grade values * * @param xxx $table (passed by reference) * @return xxx */ function adjust_grades_in_rawdata(&$table) { if (empty($table->rawdata)) { return false; // no records } if (!$table->has_column('grade')) { return false; // no grade column } if (empty($table->column_suppress) || empty($table->column_suppress['grade'])) { return false; // grade column is not suppressed (i.e. it is always printed) } $userid = 0; $grade = 0; $prefix = ''; foreach ($table->rawdata as $id => $record) { if ($userid) { if ($userid == $record->userid) { // same user - do nothing } else { if ($grade == $record->grade) { // oops, same grade as previous user - we must adjust the grade value, // so that "print_row()" (lib/tablelib.php) does not suppress this grade if ($prefix) { $prefix = ''; } else { // add an empty span tag to make grade different from previous user's $prefix = html_writer::tag('span', ''); } } else { // different grade from previous user, so we can unset the prefix $prefix = ''; } } if ($prefix) { $table->rawdata[$id]->grade = $prefix . $table->rawdata[$id]->grade; } } $userid = $record->userid; $grade = $record->grade; } }