Skip to content

Commit

Permalink
Merge pull request #45 from belivipro9x99/indev
Browse files Browse the repository at this point in the history
🐛 killing all the leftover bugs
  • Loading branch information
Belikhun authored Feb 29, 2020
2 parents 5d73e16 + fa728e9 commit 9d335e3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
7 changes: 4 additions & 3 deletions api/contest/rank.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
$data = ((new logParser($log, LOGPARSER_MODE_MINIMAL)) -> parse())["header"];
$filename = $data["file"]["logFilename"];
$user = $data["user"];
$userData = getUserData($user);

if (problemDisabled($data["problem"]) && $config["viewRankHideDisabled"] && $_SESSION["id"] !== "admin")
continue;
Expand All @@ -77,7 +78,7 @@
}

$res[$user]["username"] = $user;
$res[$user]["name"] = getUserData($user)["name"] ?: null;
$res[$user]["name"] = ($userData && isset($userData["name"])) ? $userData["name"] : null;

if (!isset($res[$user]["lastSubmit"]) || $res[$user]["lastSubmit"] < $data["file"]["lastModify"])
$res[$user]["lastSubmit"] = $data["file"]["lastModify"];
Expand Down Expand Up @@ -118,15 +119,15 @@
$header = Array("#", "username", "name", "total");

foreach ($list as $id)
array_push($header, $nameList[$id] ?: $id);
array_push($header, $nameList[$id] || $id);

array_push($data, $header);

foreach ($res as $i => $item) {
$line = Array($i + 1, $item["username"], $item["name"], $item["total"]);

foreach ($list as $id)
array_push($line, $item["point"][$id]);
array_push($line, $item["point"][$id] || null);

array_push($data, $line);
}
Expand Down
3 changes: 2 additions & 1 deletion api/contest/viewlog.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
require_once $_SERVER["DOCUMENT_ROOT"] ."/lib/logParser.php";

$logParsed = (new logParser($logPath, LOGPARSER_MODE_FULL)) -> parse();
$logParsed["header"]["name"] = getUserData($logParsed["header"]["user"])["name"] ?: null;
$userData = getUserData($logParsed["header"]["user"]);
$logParsed["header"]["name"] = ($userData && isset($userData["name"])) ? $userData["name"] : null;

stop(0, "Thành công!", 200, $logParsed);
?>
1 change: 1 addition & 0 deletions assets/css/core.css
Original file line number Diff line number Diff line change
Expand Up @@ -2346,6 +2346,7 @@ body.guest #problemp.hide {
flex-direction: column;
align-items: flex-end;
flex-grow: 0;
flex-shrink: 0;
}

.viewLog-container .testList .item .right .point {
Expand Down
11 changes: 7 additions & 4 deletions lib/logParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,12 @@ private function __parseHeader($file) {
$data["file"]["extension"] = $problemFileInfo["extension"];
} else {
$problemFileInfo = parseLogName($this -> logPath);
$data["file"]["base"] = $problemFileInfo["problem"];
$data["file"]["name"] = $problemFileInfo["name"];
$data["file"]["extension"] = $problemFileInfo["extension"];

if ($problemFileInfo) {
$data["file"]["base"] = $problemFileInfo["problem"];
$data["file"]["name"] = $problemFileInfo["name"];
$data["file"]["extension"] = $problemFileInfo["extension"];
}
}

return $data;
Expand Down Expand Up @@ -257,5 +260,5 @@ function parseLogName(String $path) {
);
}

return false;
return null;
}

0 comments on commit 9d335e3

Please sign in to comment.