Skip to content

Commit

Permalink
got SUBMIT to work!
Browse files Browse the repository at this point in the history
  • Loading branch information
optimized-riyan committed Jun 24, 2024
1 parent e3f27f7 commit fb45f1e
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions app/Jobs/SubmitAndCheckAllTestcasesJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function handle(): void
$getUrl = "http://".env("JUDGE0_DOMAIN")."/submissions";
$stderr = "";
$errorneousTc = "";
$status = "";
$status = "right";
foreach ($tokens as $index => $token) {
do {
$res = Http::get($getUrl."/".$token."?fields=status_id");
Expand All @@ -70,23 +70,20 @@ public function handle(): void
$res = Http::get($getUrl."/".$token."?fields=stdout,stderr,time");
$body = $res->json();
if ($body["stderr"]) {
$status = "error";
$stderr = $body["stderr"];
$errorneousTc = $testcases[$index]["testcase"];
$status = "error";
break;
}
else if ($body["stdout"] != $testcases[$index]["testcase"]) {
else if (trim($body["stdout"]) != trim($testcases[$index]["expected_output"])) {
$status = "wrong";
$errorneousTc = $testcases[$index]["testcase"];
break;
}
}

$submission = Submission::find($this->submissionId);
if (!$status) {
$status = "right";
}
else if ($stderr) {
if ($status == "wrong" || $status == "error") {
$submission->error = $stderr;
$submission->errorneous_tc = $errorneousTc;
}
Expand All @@ -97,6 +94,6 @@ public function handle(): void
private function getAllTestcases(): Array
{
$problem = Problem::find($this->problemId);
return $problem->testcases()->get(['testcase'])->toArray();
return $problem->testcases()->get(["testcase", "expected_output"])->toArray();
}
}

0 comments on commit fb45f1e

Please sign in to comment.