/** * Output a team row from the scoreboard based on the cached data in * table 'scoreboard'. */ function putTeamRow($cdata, $teamids) { global $DB; if (empty($cdata)) { return; } $fdata = calcFreezeData($cdata); $displayrank = IS_JURY || !$fdata['showfrozen']; $cid = $cdata['cid']; if (!$fdata['cstarted']) { if (!IS_JURY) { global $teamdata; echo "<h2 id=\"teamwelcome\">welcome team <span id=\"teamwelcometeam\">" . htmlspecialchars($teamdata['name']) . "</span>!</h2>\n\n"; echo "<h3 id=\"contestnotstarted\">contest is " . printContestStart($cdata) . "</h3>\n\n"; } return; } // For computing team row, use smart trick when only a single team is requested such // that we don't need to compute the whole scoreboard. // This does not fully populate the summary, so the first correct problem per problem // is not computed and hence not shown in the individual team row. if (count($teamids) == 1) { $teams = getTeams(array("teams" => $teamids), true, $cdata); $probs = getProblems($cdata); $SCORES = initScores($teams); $SUMMARY = initSummary($probs); // Calculate rank, num points and total time from rank cache foreach ($teams as $teamid => $team) { $totals = $DB->q("MAYBETUPLE SELECT points, totaltime\n\t\t\t FROM rankcache_jury\n\t\t\t WHERE cid = %i\n\t\t\t AND teamid = %i", $cid, $teamid); if ($totals != null) { $SCORES[$teamid]['num_points'] = $totals['points']; $SCORES[$teamid]['total_time'] = $totals['totaltime']; } if ($displayrank) { $SCORES[$teamid]['rank'] = calcTeamRank($cdata, $teamid, $totals, true); } } // Get values for this team about problems from scoreboard cache $MATRIX = array(); $scoredata = $DB->q("SELECT * FROM scorecache_jury WHERE cid = %i AND teamid = %i", $cid, current($teamids)); // loop all info the scoreboard cache and put it in our own datastructure while ($srow = $scoredata->next()) { // skip this row if the problem is not known by us if (!array_key_exists($srow['probid'], $probs)) { continue; } $penalty = calcPenaltyTime($srow['is_correct'], $srow['submissions']); // fill our matrix with the scores from the database $MATRIX[$srow['teamid']][$srow['probid']] = array('is_correct' => (bool) $srow['is_correct'], 'num_submissions' => $srow['submissions'], 'num_pending' => $srow['pending'], 'time' => $srow['totaltime'], 'penalty' => $penalty); } // Fill in empty places in the matrix foreach (array_keys($teams) as $team) { foreach (array_keys($probs) as $prob) { // provide default scores when nothing submitted for this team,problem yet if (!isset($MATRIX[$team][$prob])) { $MATRIX[$team][$prob] = array('is_correct' => FALSE, 'num_submissions' => 0, 'num_pending' => 0, 'time' => 0, 'penalty' => 0); } } } // Combine into data as genScoreBoard returns it $sdata = array('matrix' => $MATRIX, 'scores' => $SCORES, 'summary' => $SUMMARY, 'teams' => $teams, 'problems' => $probs, 'categories' => null); } else { // Otherwise, calculate scoreboard as jury to display non-visible teams $sdata = genScoreBoard($cdata, TRUE); } // Render the row based on this info $myteamid = null; $static = FALSE; if (!IS_JURY) { echo "<div id=\"teamscoresummary\">\n"; } renderScoreBoardTable($sdata, $myteamid, $static, $teamids, $displayrank, TRUE, FALSE); if (!IS_JURY) { echo "</div>\n\n"; } return; }
if (difftime($cdata['endtime'], now()) >= 0) { error("Contest did not end yet. Refusing to upload standings before contest end."); } curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/xml')); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); $data = '<?xml version="1.0" encoding="UTF-8"?><icpc computeCitations="1" name="Upload_via_DOMjudge_' . date("c") . '">'; $teams = $DB->q('SELECT teamid, externalid FROM team WHERE externalid IS NOT NULL AND enabled=1'); while ($row = $teams->next()) { $totals = $DB->q('MAYBETUPLE SELECT points, totaltime FROM rankcache_jury WHERE cid = %i AND teamid = %i', $cid, $row['teamid']); if ($totals === null) { $totals['points'] = $totals['totaltime'] = 0; } $rank = calcTeamRank($cdata, $row['teamid'], $totals, TRUE); $lastProblem = $DB->q('MAYBEVALUE SELECT MAX(totaltime) FROM scorecache_jury WHERE teamid=%i AND cid=%i', $row['teamid'], $cid); if ($lastProblem === NULL) { $lastProblem = 0; } $data .= '<Standing LastProblemTime="' . $lastProblem . '" ProblemsSolved="' . $totals['points'] . '" Rank="' . $rank . '" TeamID="' . $row['externalid'] . '" TotalTime="' . $totals['totaltime'] . '"/>'; } $data .= '</icpc>'; curl_setopt($ch, CURLOPT_POSTFIELDS, $data); } $response = curl_exec($ch); if ($response === FALSE) { error("Error while retrieving data from icpc.baylor.edu: " . curl_error($ch)); } $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);