作业:

'; $header_row .= ''.UOJLocale::get('username').''; $header_row .= ''.UOJLocale::get('contests::total score').''; foreach ($problem_ids as $problem_id) { $header_row .= '' . '#'.$problem_id.'' . ''; } $header_row .= ''; $print_row = function($row) use ($problem_ids) { $username = $row['username']; $scores = []; $sum = 0; $total_score = count($problem_ids) * 100; $query = DB::query("SELECT MAX(id), problem_id, MAX(score) FROM submissions WHERE (problem_id, score) IN (SELECT problem_id, MAX(score) FROM submissions WHERE submitter = '{$username}' AND problem_id IN (".implode(',', $problem_ids).") GROUP BY problem_id) AND submitter = '{$username}' GROUP BY problem_id"); while ($row = DB::fetch($query)) { $scores[$row['problem_id']] = [ 'submission_id' => $row['MAX(id)'], 'score' => $row['MAX(score)'], ]; $sum += $row['MAX(score)']; } if ($sum == $total_score) { echo ''; } else { echo ''; } echo '' . getUserLink($username) . ''; echo ''; echo '', $sum, ''; echo ''; foreach ($problem_ids as $problem_id) { if (!isset($scores[$problem_id])) { echo ''; } else { if ($scores[$problem_id]['score'] == 100) { echo ''; } else { echo ''; } echo ''.$scores[$problem_id]['score'].''; } echo ''; } echo ''; }; $from = "user_info a inner join groups_users b on (b.group_id = {$group['id']} and a.username = b.username)"; $col_names = array('a.username as username'); $cond = "1"; $tail = "order by a.username asc"; $config = [ 'page_len' => 50, 'div_classes' => ['card', 'my-3', 'table-responsive', 'text-center'], 'table_classes' => ['table', 'uoj-table', 'mb-0'], ]; echoLongTable($col_names, $from, $cond, $tail, $header_row, $print_row, $config); ?>