当前位置: 首页>>代码示例>>PHP>>正文


PHP Problem::getServerPlugin方法代码示例

本文整理汇总了PHP中Problem::getServerPlugin方法的典型用法代码示例。如果您正苦于以下问题:PHP Problem::getServerPlugin方法的具体用法?PHP Problem::getServerPlugin怎么用?PHP Problem::getServerPlugin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Problem的用法示例。


在下文中一共展示了Problem::getServerPlugin方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: queriesToAdjustProblems

/**
 * creates queries to change problem set
 * @param $problems new problems
 * @param $contest_id contest id
 * @return array() list of temporary files. NULL if the existing file was used
 */
function queriesToAdjustProblems($problems, $contest_id)
{
    $prfx = DB_PREFIX;
    $changed_probs = array();
    //problems that will be changed by request
    $temp_probs = array();
    //find all contest problems
    $prob2settings = array();
    $res = Data::getRows(sprintf("SELECT * FROM {$prfx}problem WHERE contest_id=%s", Data::quote_smart($contest_id)));
    while ($row = Data::getNextRow($res)) {
        $prob2settings[$row['id']] = Data::_unserialize($row['contest_settings']);
    }
    $contest_pos = 1;
    foreach ($problems as $p) {
        $col_value = array();
        //new problem must have 1) data 2) settings
        //set contest id
        $col_value['contest_id'] = $contest_id;
        $col_value['contest_pos'] = $contest_pos++;
        if ($p->id != -1 && !isset($prob2settings[$p->id])) {
            throwBusinessLogicError(4);
        }
        //find problem file or make temporary if a new problem was sent
        if ($p->problem) {
            $problem_file = getTemporaryProblemFile();
            @file_put_contents($problem_file, $p->problem) or throwServerProblem(200, 'failed to write problem file: ' . $problem_file);
            $temp_probs[] = $problem_file;
        } else {
            if ($p->id < 0) {
                throwBusinessLogicError(1);
            }
            $problem_file = getProblemFile($p->id);
            $temp_probs[] = NULL;
        }
        $problem = new Problem($problem_file);
        //get server plugin
        //TODO improve security here
        $plugin_alias = $problem->getServerPlugin();
        require_once getServerPluginFile($plugin_alias);
        $plugin = new $plugin_alias($problem);
        //TODO consider calling updaters here instead of manual insertion of values
        //TODO recheck all values if new plugin specified
        $col_value['checker_columns'] = serialize($plugin->getColumnNames());
        $col_value['result_columns'] = serialize(array());
        //copy per contest settings
        if ($p->settings) {
            if ($p->id != -1) {
                $new_settings = $prob2settings[$p->id];
                copyValues($p->settings, $new_settings);
            } else {
                $new_settings = $p->settings;
            }
            $col_value['contest_settings'] = serialize($new_settings);
        } else {
            if ($p->id < 0) {
                throwBusinessLogicError(1);
            }
        }
        //query depends on whether we add or change a problem
        if ($p->id == -1) {
            Data::submitModificationQuery(Data::composeInsertQuery('problem', $col_value));
        } else {
            Data::submitModificationQuery(Data::composeUpdateQuery('problem', $col_value, "id='{$p->id}'"));
            $changed_probs[$p->id] = 1;
        }
    }
    //delete extra problems
    foreach (array_keys($prob2settings) as $id) {
        if (!isset($changed_probs[$id])) {
            Data::submitModificationQuery("DELETE FROM {$prfx}problem WHERE id='{$id}'");
        }
    }
    return $temp_probs;
}
开发者ID:stden,项目名称:cs-javaphp,代码行数:80,代码来源:AdjustContest.php

示例2: processSubmitSolutionRequest

function processSubmitSolutionRequest($request)
{
    $prfx = DB_PREFIX;
    //get user_id or die, if session is invalid
    $userRow = RequestUtils::testSession($request->sessionID);
    $user_id = $userRow['id'];
    //authorize user for this operation
    // get contest ID
    $user_type = $userRow['user_type'];
    //get problem row
    $problem_row = Data::getRow(sprintf("SELECT * FROM {$prfx}problem WHERE id=%s", Data::quote_smart($request->problemID)));
    if (!$problem_row) {
        throwBusinessLogicError(4);
    }
    //get contest id of a problem
    $problem_contest_id = $problem_row['contest_id'];
    //test if we have rights to submit solution for the contest
    $contest_id = RequestUtils::getRequestedContest($problem_contest_id, $userRow['contest_id'], $user_type);
    if ($contest_id < 0) {
        throwBusinessLogicError(0);
    }
    //get all settings
    $contest_settings = Data::_unserialize($userRow['settings']);
    //test submission time
    $cur_time = getCurrentContestTime($contest_settings, DateMySQLToPHP($userRow['contest_start']), DateMySQLToPHP($userRow['contest_finish']));
    if ($cur_time['interval'] === 'before') {
        throwBusinessLogicError(19);
    }
    if ($cur_time['interval'] === 'after') {
        throwBusinessLogicError(20);
    }
    $problem_settings = Data::_unserialize($problem_row['contest_settings']);
    //test that not all submission attempts were used
    $hist = Data::getRow(sprintf("SELECT COUNT(*) AS cnt FROM {$prfx}submission_history WHERE (problem_id=%s) AND (user_id=%s)", Data::quote_smart($request->problemID), Data::quote_smart($user_id)));
    if ($hist >= getSetting($contest_settings->problemsDefaultSettings->sendCount, $problem_settings->sendCount)) {
        throwBusinessLogicError(21);
    }
    //save submission result in history
    $cur_php_time = getdate();
    $col_value = array();
    $col_value['problem_id'] = $request->problemID;
    $col_value['user_id'] = $user_id;
    $col_value['submission'] = serialize($request->problemResult);
    $col_value['result'] = null;
    //serialize($check_result);
    $col_value['submission_time'] = DatePHPToMySQL($cur_php_time[0]);
    //TODO implement asynchronous plugin
    //get problem and create plugin
    $problem = new Problem(getProblemFile($request->problemID));
    $plugin_alias = $problem->getServerPlugin();
    require_once getServerPluginFile();
    require_once getServerPluginFile($plugin_alias);
    $plugin = new $plugin_alias($problem);
    //check solution
    $last_result = $plugin->checkSolution(Data::getInsertedID(), $request->problemResult);
    $col_value['result'] = serialize($last_result);
    Data::submitModificationQuery(Data::composeInsertQuery('submission_history', $col_value));
    //get result for result table and store in user
    $all_results = Data::_unserialize($userRow['results']);
    $user_result = ResultUtils::getUserResults($user_id, $request->problemID, getSetting($contest_settings->problemsDefaultSettings->tableResultChoice, $problem_settings->tableResultChoice), getSetting($contest_settings->problemsDefaultSettings->resultTransition, $problem_settings->resultTransition), $plugin, $last_result);
    //update user result for results table
    $all_results[$request->problemID] = $user_result;
    Data::submitModificationQuery(Data::composeUpdateQuery('user', array('results' => serialize($all_results)), 'id=' . Data::quote_smart($user_id)));
    //return submission result
    $res = new AcceptedResponse();
    return $res;
}
开发者ID:stden,项目名称:cs-javaphp,代码行数:67,代码来源:SubmitSolution.php

示例3: Problem

$a->f1->v = 'q';

$b = $a;
*/
var_dump($a);
echo "<br>";
var_dump($b);
die;
var_dump(null);
//var_dump($a);
die;
require_once 'utils/Problems.php';
$p = new Problem('/home/ilya/tmp/probs/prob.zip');
var_dump($p->getClientPlugin());
var_dump($p->getServerPlugin());
//var_dump($p->getProblemBytes());
var_dump($p->getResource('ANSWER'));
var_dump($p->isTeacher('EXE'));
var_dump($p->isTeacher('ANSWER'));
var_dump($p->getResource('STATEMENT'));
die;
echo $_SERVER['DOCUMENT_ROOT'];
die;
$s = 'asdf';
$i = $s . asdf();
var_dump($i);
die;
class B
{
}
开发者ID:stden,项目名称:cs-javaphp,代码行数:30,代码来源:learn_php.php


注:本文中的Problem::getServerPlugin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。