本文整理汇总了PHP中SoapClient::getSubmissionStatus方法的典型用法代码示例。如果您正苦于以下问题:PHP SoapClient::getSubmissionStatus方法的具体用法?PHP SoapClient::getSubmissionStatus怎么用?PHP SoapClient::getSubmissionStatus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoapClient
的用法示例。
在下文中一共展示了SoapClient::getSubmissionStatus方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SoapClient
function judge_ideone($sub)
{
global $CFG;
// creating soap client
$client = new SoapClient("http://ideone.com/api/1/service.wsdl");
$user = $CFG->assignment_oj_ideone_username;
$pass = $CFG->assignment_oj_ideone_password;
if ($source = $this->get_submission_file_content($sub->userid)) {
$cases = $this->get_tests();
$status_ideone = array(11 => 'ce', 12 => 're', 13 => 'tle', 15 => 'ok', 17 => 'mle', 19 => 'rf', 20 => 'ie');
$result->grade = -1;
try {
// Begin soap
// Submit all cases first to save time.
$links = array();
foreach ($cases as $case) {
$webid = $client->createSubmission($user, $pass, $source, $this->ideone_langs[$this->onlinejudge->language], $case->input, true, true);
if ($webid['error'] == 'OK') {
$links[] = $webid['link'];
} else {
$result->status = 'ie';
$result->info = $webid['error'];
return $result;
}
}
// Get ideone results
$delay = $CFG->assignment_oj_ideone_delay;
$i = 0;
$results = array();
foreach ($cases as $case) {
while (1) {
if ($delay > 0) {
sleep($delay);
$delay = ceil($delay / 2);
}
$status = $client->getSubmissionStatus($user, $pass, $links[$i]);
if ($status['status'] == 0) {
$delay = 0;
break;
}
}
$details = $client->getSubmissionDetails($user, $pass, $links[$i], false, true, true, true, true, false);
$result->status = $status_ideone[$details['result']];
// If got ce or compileonly, don't need to test other case
if ($result->status == 'ce' || $this->onlinejudge->compileonly) {
if ($result->status != 'ce' && $result->status != 'ie') {
$result->status = 'compileok';
}
$result->info = $details['cmpinfo'] . '<br />' . get_string('ideonelogo', 'assignment_onlinejudge');
$result->grade = $this->grade_marker('ce', $this->assignment->grade);
return $result;
}
// Check for wa, pe, tle, mle or accept
if ($result->status == 'ok') {
if ($details['time'] > $this->onlinejudge->cpulimit) {
$result->status = 'tle';
} else {
if ($details['memory'] * 1024 > $this->onlinejudge->memlimit) {
$result->status = 'mle';
} else {
$result->output = $details['output'];
$result->status = $this->diff($case->output, $result->output);
}
}
}
$results[] = $result;
unset($result);
$i++;
}
} catch (SoapFault $ex) {
$result->status = 'ie';
$result->info = 'faultcode=' . $ex->faultcode . '|faultstring=' . $ex->faultstring;
return $result;
}
$result = $this->merge_results($results, $cases);
$result->info .= '<br />' . get_string('ideonelogo', 'assignment_onlinejudge');
return $result;
} else {
return false;
}
}
示例2: judge
/**
* Judge the current task
*
* @return updated task
*/
function judge()
{
$task =& $this->task;
// create client.
$client = new SoapClient("http://ideone.com/api/1/service.wsdl");
$user = $task->var1;
$pass = $task->var2;
$language = $this->language;
$input = $task->input;
// Get source code
$fs = get_file_storage();
$files = $fs->get_area_files(get_context_instance(CONTEXT_SYSTEM)->id, 'local_onlinejudge', 'tasks', $task->id, 'sortorder, timemodified', false);
$source = '';
foreach ($files as $file) {
$source = $file->get_content();
break;
}
$status_ideone = array(0 => ONLINEJUDGE_STATUS_PENDING, 11 => ONLINEJUDGE_STATUS_COMPILATION_ERROR, 12 => ONLINEJUDGE_STATUS_RUNTIME_ERROR, 13 => ONLINEJUDGE_STATUS_TIME_LIMIT_EXCEED, 15 => ONLINEJUDGE_STATUS_COMPILATION_OK, 17 => ONLINEJUDGE_STATUS_MEMORY_LIMIT_EXCEED, 19 => ONLINEJUDGE_STATUS_RESTRICTED_FUNCTIONS, 20 => ONLINEJUDGE_STATUS_INTERNAL_ERROR);
// Begin soap
/**
* function createSubmission create a paste.
* @param user is the user name.
* @param pass is the user's password.
* @param source is the source code of the paste.
* @param language is language identifier. these identifiers can be
* retrieved by using the getLanguages methods.
* @param input is the data that will be given to the program on the stdin
* @param run is the determines whether the source code should be executed.
* @param private is the determines whether the paste should be private.
* Private pastes do not appear on the recent pastes page on ideone.com.
* Notice: you can only set submission's visibility to public or private through
* the API (you cannot set the user's visibility).
* @return array(
* error => string
* link => string
* )
*/
$webid = $client->createSubmission($user, $pass, $source, $language, $input, true, true);
$delay = get_config('local_onlinejudge', 'ideonedelay');
sleep($delay);
// ideone reject bulk access
if ($webid['error'] == 'OK') {
$link = $webid['link'];
} else {
throw new onlinejudge_exception('ideoneerror', $webid['error']);
}
// Get ideone results
while (1) {
$status = $client->getSubmissionStatus($user, $pass, $link);
sleep($delay);
// ideone reject bulk access. Always add delay between accesses
if ($status['status'] == 0) {
break;
}
}
$details = $client->getSubmissionDetails($user, $pass, $link, false, false, true, true, true);
$task->stdout = $details['output'];
$task->stderr = $details['stderr'];
$task->compileroutput = $details['cmpinfo'];
$task->memusage = $details['memory'] * 1024;
$task->cpuusage = $details['time'];
$task->infoteacher = get_string('ideoneresultlink', 'local_onlinejudge', $link);
$task->infostudent = get_string('ideonelogo', 'local_onlinejudge');
$task->status = $status_ideone[$details['result']];
if ($task->compileonly) {
if ($task->status != ONLINEJUDGE_STATUS_COMPILATION_ERROR && $task->status != ONLINEJUDGE_STATUS_INTERNAL_ERROR) {
$task->status = ONLINEJUDGE_STATUS_COMPILATION_OK;
}
} else {
if ($task->status == ONLINEJUDGE_STATUS_COMPILATION_OK) {
if ($task->cpuusage > $task->cpulimit) {
$task->status = ONLINEJUDGE_STATUS_TIME_LIMIT_EXCEED;
} else {
if ($task->memusage > $task->memlimit) {
$task->status = ONLINEJUDGE_STATUS_MEMORY_LIMIT_EXCEED;
} else {
$task->status = $this->diff();
}
}
}
}
return $task;
}
示例3: stripslashes
echo stripslashes($_POST["code"]);
?>
</textarea>
</fieldset>
<input type="submit" value="Execute" class="amit_button"/>
</form>
</body>
</html>
<?php
$code = stripslashes($_POST["code"]);
$lang = $_POST["PL"];
//explore($client->getLanguages($user="arsenalnerk",$pass="123456"));
if ($code) {
$result = $client->createSubmission($user = USER, $pass = PWD, $sourceCode = $code, $language = $lang, $input = "", $run = 1, $private = 0);
//explore($result);
$stat = $client->getSubmissionStatus($user = USER, $pass = PWD, $link = $result["link"]);
//explore($stat);
$output = $client->getSubmissionDetails($user = USER, $pass = PWD, $link = $result["link"], $withSource = 1, $withInput = 0, $withOutput = 1, $withStderr = 1, $withCmpinfo = 1);
echo $output["output"];
explore($output);
//echo $output["output"];
}
?>
</div>
</div>
</div>
<?php
} else {
// if profiles are not enabled in web.config
require_once ROOT_PATH . 'user/modules/accordion/error_messages.php';
示例4: die
//print_r( $_POST ); exit;
$result_sql = mysql_query("SELECT * FROM `questions_input` WHERE `qusID` = '{$questionID}'") or die("Invaild Question");
$result_array = mysql_fetch_array($result_sql);
$required_output = $result_array['output'];
if (!empty($required_output) && $valid_question) {
//isset( $_POST['process'] ) && $_POST['process'] == 1 ) {
$lang = isset($_POST['lang']) ? intval($_POST['lang']) : 11;
$input = trim($result_array['input']);
$mark = $result_array['mark'];
$code = trim($_POST['source']);
$client = new SoapClient("http://ideone.com/api/1/service.wsdl");
//create new submission
$result = $client->createSubmission($user, $pass, $code, $lang, $input, $run, $private);
//if submission is OK, get the status
if ($result['error'] == 'OK') {
$status = $client->getSubmissionStatus($user, $pass, $result['link']);
if ($status['error'] == 'OK') {
//check if the status is 0, otherwise getSubmissionStatus again
while ($status['status'] != 0) {
sleep(3);
//sleep 3 seconds
$status = $client->getSubmissionStatus($user, $pass, $result['link']);
}
//finally get the submission results
$details = $client->getSubmissionDetails($user, $pass, $result['link'], true, true, true, true, true);
if ($details['error'] == 'OK') {
//print_r( $details );
if ($details['status'] < 0) {
$status = 'waiting for compilation';
} else {
$status = $subStatus[$details['status']];
示例5: onCommandIdeone
/**
* Executes a source code sequence in a specified language and returns
* the result.
*
* @param string $language Programming language the source code is in
* @param string $code Source code to execute
*
* @return void
*/
public function onCommandIdeone($language, $code)
{
$source = $this->event->getSource();
$nick = $this->event->getNick();
// Get authentication credentials
$user = $this->getConfig('ideone.user', 'test');
$pass = $this->getConfig('ideone.pass', 'test');
// Normalize the command parameters
$language = strtolower($language);
// Massage PHP code to allow for convenient shorthand
if ($language == 'php') {
if (!preg_match('/^<\\?(?:php)?/', $code)) {
$code = '<?php ' . $code;
}
switch (substr($code, -1)) {
case '}':
case ';':
break;
default:
$code .= ';';
break;
}
}
// Identify the language to use
$client = new SoapClient('http://ideone.com/api/1/service.wsdl');
$response = $client->getLanguages($user, $pass);
if ($this->isError($response)) {
return;
}
$languageLength = strlen($language);
foreach ($response['languages'] as $languageId => $languageName) {
if (strncasecmp($language, $languageName, $languageLength) == 0) {
break;
}
}
// Send the paste data
$response = $client->createSubmission($user, $pass, $code, $languageId, null, true, false);
if ($this->isError($response)) {
return;
}
$link = $response['link'];
// Wait until the paste data is processed or the service fails
$attempts = $this->getConfig('ideone.attempts', 10);
foreach (range(1, $attempts) as $attempt) {
$response = $client->getSubmissionStatus($user, $pass, $link);
if ($this->isError($response)) {
return;
}
if ($response['status'] == 0) {
$result = $response['result'];
break;
} else {
$result = null;
sleep(1);
}
}
if ($result == null) {
$this->doNotice($nick, 'ideone error: Timed out');
return;
}
if ($result != 15) {
$this->doNotice($nick, 'ideone error: Status code ' . $result);
return;
}
// Get details for the created paste
$response = $client->getSubmissionDetails($user, $pass, $link, false, false, true, true, false);
if ($this->isError($response)) {
return;
}
// Replace the output if it exceeds a specified maximum length
$outputLimit = $this->getConfig('ideone.output_limit', 100);
var_dump($response);
if ($outputLimit && strlen($response['output']) > $outputLimit) {
$response['output'] = 'Output is too long to post';
}
// Format the message
$msg = $this->getConfig('ideone.format', '%nick%: [ %link% ] %output%');
$response['nick'] = $nick;
$response['link'] = 'http://ideone.com/' . $link;
foreach ($response as $key => $value) {
$msg = str_replace('%' . $key . '%', $value, $msg);
}
$this->doPrivmsg($source, $msg);
}