Пример #1
0
    if (array_key_exists('category', $args)) {
        $filter['categoryid'] = array($args['category']);
    }
    if (array_key_exists('country', $args)) {
        $filter['country'] = array($args['country']);
    }
    if (array_key_exists('affiliation', $args)) {
        $filter['affilid'] = array($args['affiliation']);
    }
    $scoreboard = genScoreBoard($cdatas[$args['cid']], !$args['public'], $filter);
    $prob2label = $DB->q('KEYVALUETABLE SELECT probid, shortname
	                      FROM contestproblem WHERE cid = %i', $args['cid']);
    $res = array();
    foreach ($scoreboard['scores'] as $teamid => $data) {
        $row = array('rank' => $data['rank'], 'team' => $teamid);
        $row['score'] = array('num_solved' => safe_int($data['num_points']), 'total_time' => safe_int($data['total_time']));
        $row['problems'] = array();
        foreach ($scoreboard['matrix'][$teamid] as $probid => $pdata) {
            $row['problems'][] = array('problem' => safe_int($probid), 'label' => $prob2label[$probid], 'num_judged' => safe_int($pdata['num_submissions']), 'num_pending' => safe_int($pdata['num_pending']), 'time' => safe_int($pdata['time']), 'solved' => safe_bool($pdata['is_correct']));
        }
        $res[] = $row;
    }
    return $res;
}
$doc = 'Get the scoreboard. Returns scoreboard for jury members if authenticated as a jury member (and public is not 1).';
$args = array('cid' => 'ID of the contest to get the scoreboard for.', 'category' => 'ID of a single category to search for.', 'affiliation' => 'ID of an affiliation to search for.', 'country' => 'ISO 3166-1 alpha-3 country code to search for.');
$exArgs = array(array('cid' => 2, 'category' => 1, 'affiliation' => 'UU'), array('cid' => 2, 'country' => 'NLD'));
$api->provideFunction('GET', 'scoreboard', $doc, $args, $exArgs, null, true);
// Now provide the api, which will handle the request
$api->provideApi();