';
$accordion_parent = "{$this->name}_details_accordion";
if ($this->subtask_num != null) {
$accordion_parent .= "_collapse_subtask_{$this->subtask_num}_accordion";
}
$accordion_collapse = "{$accordion_parent}_collapse_test_{$test_num}";
if ($this->subtask_num != null) {
$accordion_collapse .= "_in_subtask_{$this->subtask_num}";
}
if (!$this->styler->shouldFadeDetails($test_info)) {
echo '';
} elseif ($node->nodeName == 'custom-test') {
$test_info = $node->getAttribute('info');
$test_time = $this->_get_attr($node, 'time', -1);
$test_memory = $this->_get_attr($node, 'memory', -1);
echo '
';
$accordion_parent = "{$this->name}_details_accordion";
$accordion_collapse = "{$accordion_parent}_collapse_custom_test";
if (!$this->styler->shouldFadeDetails($test_info)) {
echo '';
}
} elseif ($node->nodeName == 'in') {
echo '
input:
';
echo '
', "\n";
$this->_print_c($node);
echo "\n
";
} elseif ($node->nodeName == 'out') {
echo '
output:
';
echo '
', "\n";
$this->_print_c($node);
echo "\n
";
} elseif ($node->nodeName == 'ans') {
echo '
answer:
';
echo '
', "\n";
$this->_print_c($node);
echo "\n
";
} elseif ($node->nodeName == 'res') {
echo '
result:
';
echo '
', "\n";
if ($node->hasChildNodes()) {
$this->_print_c($node);
} else {
echo "\n";
}
echo "
";
} elseif ($node->nodeName == "info-block") {
echo '
';
if ($node->hasAttribute("title")) {
if ($node->hasAttribute("size")) {
echo '
';
if ($node->getAttribute("size") <= 1) {
echo '(', $node->getAttribute("size"), ' byte)';
} else {
echo '(', $node->getAttribute("size"), ' bytes)';
}
echo '
';
}
echo '
', $node->getAttribute("title"), ":
";
}
echo '
', "\n";
$this->_print_c($node);
echo "\n
";
echo '
';
} else {
echo '<', $node->nodeName;
foreach ($node->attributes as $attr) {
echo ' ', $attr->name, '="', htmlspecialchars($attr->value), '"';
}
echo '>';
$this->_print_c($node);
echo '', $node->nodeName, '>';
}
}
public function __construct($details, $styler, $name) {
$this->name = $name;
$this->styler = $styler;
$this->details = $details;
$this->dom = new DOMDocument();
if (!$this->dom->loadXML($this->details)) {
throw new Exception("XML syntax error");
}
$this->details = '';
}
public function printHTML() {
$this->subtask_num = null;
$this->_print($this->dom->documentElement);
}
}
function echoJudgementDetails($raw_details, $styler, $name) {
try {
$printer = new JudgmentDetailsPrinter($raw_details, $styler, $name);
$printer->printHTML();
} catch (Exception $e) {
echo 'Failed to show details';
}
}
class SubmissionDetailsStyler {
public $show_score = true;
public $show_small_tip = true;
public $collapse_in = false;
public $fade_all_details = false;
public function getTestInfoClass($info) {
if ($info == 'Accepted' || $info == 'Extra Test Passed') {
return 'card-uoj-accepted';
} elseif ($info == 'Time Limit Exceeded') {
return 'card-uoj-tle';
} elseif ($info == 'Acceptable Answer') {
return 'card-uoj-acceptable-answer';
} else {
return 'card-uoj-wrong';
}
}
public function getTestInfoIcon($test_info) {
if ($test_info == 'Accepted' || $test_info == 'Extra Test Passed') {
return '
';
} elseif ($test_info == 'Time Limit Exceeded') {
return '
';
} elseif ($test_info == 'Acceptable Answer') {
return '
';
} elseif ($test_info == 'Wrong Answer') {
return '
';
} else {
return '
';
}
}
public function shouldFadeDetails($info) {
return $this->fade_all_details || $info == 'Extra Test Passed' || $info == 'Skipped';
}
}
class CustomTestSubmissionDetailsStyler {
public $show_score = true;
public $show_small_tip = false;
public $collapse_in = true;
public $fade_all_details = false;
public $ioi_contest_is_running = false;
public function getTestInfoClass($info) {
if ($info == 'Success') {
return 'card-uoj-accepted';
} elseif ($info == 'Time Limit Exceeded') {
return 'card-uoj-tle';
} elseif ($info == 'Acceptable Answer') {
return 'card-uoj-acceptable-answer';
} else {
return 'card-uoj-wrong';
}
}
public function getTestInfoIcon($test_info) {
if ($test_info == 'Success') {
return '
';
} elseif ($test_info == 'Time Limit Exceeded') {
return '
';
} elseif ($test_info == 'Acceptable Answer') {
return '
';
} elseif ($test_info == 'Wrong Answer') {
return '
';
} else {
return '
';
}
}
public function shouldFadeDetails($info) {
return $this->fade_all_details;
}
}
class HackDetailsStyler {
public $show_score = false;
public $show_small_tip = false;
public $collapse_in = true;
public $fade_all_details = false;
public function getTestInfoClass($info) {
if ($info == 'Accepted' || $info == 'Extra Test Passed') {
return 'card-uoj-accepted';
} elseif ($info == 'Time Limit Exceeded') {
return 'card-uoj-tle';
} elseif ($info == 'Acceptable Answer') {
return 'card-uoj-acceptable-answer';
} else {
return 'card-uoj-wrong';
}
}
public function getTestInfoIcon($test_info) {
if ($test_info == 'Accepted' || $test_info == 'Extra Test Passed') {
return '
';
} elseif ($test_info == 'Time Limit Exceeded') {
return '
';
} elseif ($test_info == 'Acceptable Answer') {
return '
';
} elseif ($test_info == 'Wrong Answer') {
return '
';
} else {
return '
';
}
}
public function shouldFadeDetails($info) {
return $this->fade_all_details;
}
}
function echoSubmissionDetails($submission_details, $name) {
echoJudgementDetails($submission_details, new SubmissionDetailsStyler(), $name);
}
function echoCustomTestSubmissionDetails($submission_details, $name) {
echoJudgementDetails($submission_details, new CustomTestSubmissionDetailsStyler(), $name);
}
function echoHackDetails($hack_details, $name) {
echoJudgementDetails($hack_details, new HackDetailsStyler(), $name);
}
function echoHack($hack, $config, $viewer) {
$uhack = new UOJHack($hack);
$uhack->setProblem();
$uhack->setSubmission();
$uhack->echoStatusTableRow($config, $viewer);
}
function echoHackListOnlyOne($hack, $config, $user) {
echo '
';
echo '
';
echo '';
echo '';
if (!isset($config['id_hidden'])) {
echo 'ID | ';
}
if (!isset($config['submission_id_hidden'])) {
echo '' . UOJLocale::get('problems::submission id') . ' | ';
}
if (!isset($config['problem_hidden'])) {
echo '' . UOJLocale::get('problems::problem') . ' | ';
}
if (!isset($config['hacker_hidden'])) {
echo '' . UOJLocale::get('problems::hacker') . ' | ';
}
if (!isset($config['owner_hidden'])) {
echo '' . UOJLocale::get('problems::owner') . ' | ';
}
if (!isset($config['result_hidden'])) {
echo '' . UOJLocale::get('problems::result') . ' | ';
}
if (!isset($config['submit_time_hidden'])) {
echo '' . UOJLocale::get('problems::submit time') . ' | ';
}
if (!isset($config['judge_time_hidden'])) {
echo '' . UOJLocale::get('problems::judge time') . ' | ';
}
echo '
';
echo '';
echo '';
echoHack($hack, $config, $user);
echo '';
echo '
';
echo '
';
}
function echoHacksList($cond, $tail, $config, $user) {
$header_row = '
';
$col_names = [];
$col_names[] = 'id';
$col_names[] = 'success';
$col_names[] = 'status';
$col_names[] = 'judge_time';
if (!isset($config['id_hidden'])) {
$header_row .= 'ID | ';
}
if (!isset($config['submission_id_hidden'])) {
$header_row .= '' . UOJLocale::get('problems::submission id') . ' | ';
$col_names[] = 'submission_id';
}
if (!isset($config['problem_hidden'])) {
$header_row .= '' . UOJLocale::get('problems::problem') . ' | ';
$col_names[] = 'problem_id';
}
if (!isset($config['hacker_hidden'])) {
$header_row .= '' . UOJLocale::get('problems::hacker') . ' | ';
$col_names[] = 'hacker';
}
if (!isset($config['owner_hidden'])) {
$header_row .= '' . UOJLocale::get('problems::owner') . ' | ';
$col_names[] = 'owner';
}
if (!isset($config['result_hidden'])) {
$header_row .= '' . UOJLocale::get('problems::result') . ' | ';
}
if (!isset($config['submit_time_hidden'])) {
$header_row .= '' . UOJLocale::get('problems::submit time') . ' | ';
$col_names[] = 'submit_time';
}
if (!isset($config['judge_time_hidden'])) {
$header_row .= '' . UOJLocale::get('problems::judge time') . ' | ';
}
$header_row .= '
';
if (!isSuperUser($user)) {
if ($user != null) {
$permission_cond = DB::lor([
'is_hidden' => false,
DB::land([
'is_hidden' => true,
DB::lor([
[
'problem_id', 'in', DB::rawbracket([
'select problem_id from problems_permissions',
'where', ['username' => $user['username']]
])
],
[
'problem_id', 'in', DB::rawbracket([
'select problem_id from problems',
'where', ['uploader' => $user['username']]
])
]
])
])
]);
} else {
$permission_cond = ['is_hidden' => false];
}
if ($cond !== '1') {
$cond = [
DB::conds($cond),
DB::conds($permission_cond)
];
} else {
$cond = $permission_cond;
}
}
$table_config = isset($config['table_config']) ? $config['table_config'] : null;
echoLongTable(
$col_names,
'hacks',
$cond,
$tail,
$header_row,
function ($hacks) use ($config, $user) {
echoHack($hacks, $config, $user);
},
$table_config
);
}
function echoBlog($blog, $config = array()) {
global $REQUIRE_LIB;
$default_config = array(
'blog' => $blog,
'show_title_only' => false,
'is_preview' => false
);
foreach ($default_config as $key => $val) {
if (!isset($config[$key])) {
$config[$key] = $val;
}
}
$config['REQUIRE_LIB'] = $REQUIRE_LIB;
uojIncludeView('blog-preview', $config);
}
function echoBlogTag($tag) {
echo '
', '', HTML::escape($tag), ' ';
}
function echoUOJPageHeader($page_title, $extra_config = array()) {
global $REQUIRE_LIB;
$config = UOJContext::pageConfig();
$config['REQUIRE_LIB'] = $REQUIRE_LIB;
$config['PageTitle'] = $page_title;
$config = array_merge($config, $extra_config);
uojIncludeView('page-header', $config);
}
function echoUOJPageFooter($config = array()) {
global $REQUIRE_LIB;
$config['REQUIRE_LIB'] = $REQUIRE_LIB;
uojIncludeView('page-footer', $config);
}
// ===== uoj.ac =====
function echoJudgmentDetails($raw_details, $styler, $name) {
try {
$printer = new JudgmentDetailsPrinter($raw_details, $styler, $name);
$printer->printHTML();
} catch (Exception $e) {
echo 'Failed to show details';
}
}