Skip to content

Commit

Permalink
Merge pull request #35 from IU-MAP/client/volunteer_judge
Browse files Browse the repository at this point in the history
v1.1.0
  • Loading branch information
KerimKochekov authored May 23, 2021
2 parents fc051e2 + 8d5659b commit 75cccb8
Show file tree
Hide file tree
Showing 14 changed files with 111 additions and 11 deletions.
20 changes: 16 additions & 4 deletions client/checker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,35 @@ if ! [ -f "data/$2.zip" ]; then
fi

if ! [ -d "judge/$2" ]; then
echo "Directory not exist"
echo "Test directory missing"
mkdir judge/$2
unzip data/$2.zip -d judge/$2
fi

cat data/$1 > judge/$2/solution.cpp && g++ -std=c++11 judge/$2/solution.cpp -o judge/$2/solution.out && for ((i=1;;i++))
if ! [ -d "judge/$2/testdata" ]; then
echo "Testdata directory missing"
unzip data/$2.zip -d judge/$2
fi
cat data/$1 > judge/$2/solution.cpp
g++ -std=c++11 judge/$2/solution.cpp -o judge/$2/solution.out
max_runtime = 0
for ((i=1;;i++))
do
INPUT=judge/$2/testdata/input/$i.in
OUTPUT=judge/$2/testdata/output/$i.out
if [ -f "$INPUT" ] && [ -f "$OUTPUT" ]; then
start=`date +%s.%N`
./judge/$2/solution.out < $INPUT > judge/$2/out
end=`date +%s.%N`
runtime=$( echo "$end - $start" | bc -l )
if [[ "$runtime" > "$max_runtime" ]]; then
max_runtime="$runtime"
fi
if ! diff -w judge/$2/out $OUTPUT
then
exit 1
fi
else
echo $max_runtime
exit 0
fi
done

1 change: 1 addition & 0 deletions client/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const runSolution = async (solutionId) => {
await axios.put(`${host}/api/solutions/${data._id}`, {
problem: data.problem._id,
status: "ok",
time: Math.round(parseFloat(stdout)*1000),
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "client",
"version": "1.0.0",
"version": "1.1.0",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions server/controllers/solutionController.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ exports.api_solution_update = [
problem: req.body.problem,
message: req.body.message,
status: req.body.status,
time: req.body.time,
_id: req.params.id,
});

Expand Down
5 changes: 5 additions & 0 deletions server/models/solution.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ var SolutionSchema = new Schema({
enum: ["submitted", "ok", "failed", "running"],
default: "submitted",
},
time: {
type: Number,
required: true,
default: -1,
},
});

// Virtual for this Solution object's URL.
Expand Down
Binary file added server/public/stylesheets/donate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added server/public/stylesheets/failed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added server/public/stylesheets/ok.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added server/public/stylesheets/running.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
75 changes: 74 additions & 1 deletion server/public/stylesheets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,82 @@
}

.ok {
color: green;
color: #000;
background-color: #90ee90;
padding: 2px 10px 4px 10px;
border-radius: 4px;
content: 'Correct'
}

.ok {
visibility: hidden;
}

.ok:after {
visibility: visible;
color: #000;
background-color: #90ee90;
padding: 2px 10px 4px 10px;
margin-left: -20px;
border-radius: 4px;
content: 'Correct';
}

.failed {
color: brown;
}

h1 {
margin-top: 20px;
margin-bottom: 25px;
border-bottom: 2px solid #000;
}

.col-sm-2 {
padding-top: 75px;
padding-bottom: 1000px;
background-color: #EFEFEF;
}

.col-sm-2 a:link,
.col-sm-2 a:visited,
.col-sm-2 a:active {
font-size: 120%;
}

.col-sm-10 {
padding-left: 30px;
}

a:link,
a:visited,
a:active {
color: darkorange;
}

a:hover {
text-decoration: none;
color: orange;
}

p {
font-size: 120%;
}

hr {
background-color: #000;
}

.btn {
background-color: darkorange;
border: none;
font-size: 120%;
margin-top: 20px;
float: right;
padding-left: 25px;
padding-right: 25px;
}

.btn:hover {
background-color: orange;
}
Binary file added server/public/stylesheets/submitted.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion server/views/solution_form.pug
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ block content
label(for="file") Code (C++ only):
div.custom-file
input#file.custom-file-input(type='file', name='file' required='true' accept='.cpp')
label.custom-file-label(for='file') Choose file
label.custom-file-label(for='file') Choose file
div.form-group
label(for="judge") Judge on me:
input(type="checkbox" checked)
button.btn.btn-primary(type='submit') Submit
else
p No problem available. Please wait, or
Expand Down
11 changes: 8 additions & 3 deletions server/views/solution_list.pug
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@ extends layout

block content
h1= title

ul
each solution in solution_list
each solution in solution_list.reverse()
li
a(href=solution.url) #{solution._id}
a(href=solution.url) #{solution._id}
img(src="/stylesheets/"+solution.status+".png")
if solution.status == "ok"
b() [#{solution.time} ms]
else if solution.status != "failed"
b()
img(type="button" src="/stylesheets/donate.png")

else
li There are no solutions.

0 comments on commit 75cccb8

Please sign in to comment.