Example #1
0
/**
 * Registering problem into contest
 * @param type $pid
 * @param type $cid
 * @param type $cpid 
 */
function set_problem_cid($pid, $cid, $cpid)
{
    $problem = new ProblemTbl($pid);
    $problem->Get() or error('Error setting problem cid');
    $problem->update['cid'] = $cid;
    $problem->Update();
    $contest_problem = new ContestProblem($cid);
    $contest_problem->detail = array("cpid" => $cpid, "cid" => $cid, "pid" => $pid);
    $contest_problem->Add();
}
Example #2
0
function CopyProblem(&$arg)
{
    global $app_config;
    // Write data to file
    $newcid = 3;
    $problem_prefix = sprintf("%s/c%02d/%d", $app_config['contest_testdata_path'], $arg['cid'], $arg['pid']);
    $new_prefix = sprintf("%s/c%02d/%d", $app_config['contest_testdata_path'], $newcid, $arg['pid']);
    _makedir($new_prefix, 0777);
    exec("copy " . $problem_prefix . "/* " . $new_prefix . "/");
    $problem = new ContestProblem($arg['cid']);
    $problem->Get($arg['pid']);
    die;
    unset($arg['add_problem']);
    unset($arg['input_data']);
    unset($arg['standard_output']);
    $problem->detail = $arg;
    $problem->Add();
    MsgAndRedirect("problem_create.php");
}
Example #3
0
require "navigation.php";
$cid = safeget("cid");
$contest = new ContestsTbl($cid);
$contest->Get() or error("No such contest");
if (!is_contest_accessible($cid)) {
    if ($contest->detail['authtype'] == 'password' && !isset($_SESSION["access{$cid}"])) {
        MsgAndRedirect("contest_password.php?cid={$cid}");
    } else {
        if (!is_contest_started($cid)) {
            error(_("This contest is not started yet."));
        } else {
            error(_("You can't access to the contest"));
        }
    }
}
$problem = new ContestProblem($cid);
if (!$problem->GetByFields(array())) {
    error("No problem found");
}
global $conn;
$rs = new RecordSet($conn);
$rs->Query("SELECT cpid, COUNT(*) AS num FROM contest_status left join status on contest_status.sid = status.sid " . "WHERE cid = {$cid} and status = 'Accepted' GROUP BY cpid ORDER BY cpid");
$ac_num = array();
while ($rs->MoveNext()) {
    $ac_num[$rs->Fields['cpid']] = intval($rs->Fields['num']);
}
$rs->Query("SELECT cpid, COUNT(*) AS num FROM contest_status " . "WHERE cid = {$cid} GROUP BY cpid ORDER BY cpid");
$sm_num = array();
while ($rs->MoveNext()) {
    $sm_num[$rs->Fields['cpid']] = intval($rs->Fields['num']);
}