Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
adc2018-system
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
adc2018
adc2018-system
Commits
18700dc5
Commit
18700dc5
authored
Aug 16, 2018
by
Kento HASEGAWA
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add save method to save the best solution (#12)
parent
80d1043d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
63 additions
and
3 deletions
+63
-3
main.py
comm/server/main.py
+42
-2
pynq-manager.css
comm/server/static/css/pynq-manager.css
+4
-0
pynq-manager.js
comm/server/static/js/pynq-manager.js
+11
-0
part_question_status.html
comm/server/templates/part_question_status.html
+6
-1
No files found.
comm/server/main.py
View file @
18700dc5
...
@@ -67,11 +67,11 @@ def load_questions():
...
@@ -67,11 +67,11 @@ def load_questions():
# 既に回答されているものを読み込む
# 既に回答されているものを読み込む
answer_path
=
os
.
path
.
abspath
(
app_args
[
"out"
])
answer_path
=
os
.
path
.
abspath
(
app_args
[
"out"
])
answer_list
=
glob
.
glob
(
"{}/
T03
_A*.txt"
.
format
(
answer_path
))
answer_list
=
glob
.
glob
(
"{}/
submit/T01
_A*.txt"
.
format
(
answer_path
))
for
v
in
answer_list
:
for
v
in
answer_list
:
_ans_name
=
os
.
path
.
basename
(
v
)
_ans_name
=
os
.
path
.
basename
(
v
)
m
=
re
.
search
(
r"T0
3
_A([0-9A-Za-z]+)\.txt"
,
_ans_name
)
m
=
re
.
search
(
r"T0
1
_A([0-9A-Za-z]+)\.txt"
,
_ans_name
)
if
m
:
if
m
:
_name
=
"NL_Q{}.txt"
.
format
(
m
.
group
(
1
))
_name
=
"NL_Q{}.txt"
.
format
(
m
.
group
(
1
))
with
open
(
v
,
"r"
)
as
fp
:
with
open
(
v
,
"r"
)
as
fp
:
...
@@ -102,6 +102,9 @@ def update_answer_list(qname):
...
@@ -102,6 +102,9 @@ def update_answer_list(qname):
answer_log
=
json
.
load
(
fp
)
answer_log
=
json
.
load
(
fp
)
questions
[
qname
][
'answers'
][
json_name
]
=
answer_log
questions
[
qname
][
'answers'
][
json_name
]
=
answer_log
if
questions
[
qname
][
'answer'
]
==
answer_log
[
'answer'
]:
questions
[
qname
][
'best_json'
]
=
json_name
@
app
.
before_request
@
app
.
before_request
def
before_request
():
def
before_request
():
global
app_args
global
app_args
...
@@ -283,6 +286,43 @@ def get_status():
...
@@ -283,6 +286,43 @@ def get_status():
return
json
.
dumps
(
res
)
return
json
.
dumps
(
res
)
@
app
.
route
(
"/save"
,
methods
=
[
"POST"
])
def
save_best_solution
():
"""
それぞれの問題に対し,解き終わった答えの中で最も品質の高い解を
submitフォルダに出力する.
"""
global
questions
global
app_args
qname
=
request
.
form
[
"qname"
]
_best_score
=
-
1
_best_json
=
""
for
k
,
v
in
questions
[
qname
][
'answers'
]
.
items
():
if
v
[
'nlcheck'
]
>
_best_score
:
_best_socer
=
v
[
'nlcheck'
]
_best_json
=
k
if
_best_json
!=
""
:
out_path
=
"{}/{}"
.
format
(
app_args
[
'out'
],
"submit"
)
if
not
os
.
path
.
isdir
(
out_path
):
os
.
makedirs
(
out_path
)
qnumber
=
qname
.
replace
(
"NL_Q"
,
""
)
.
replace
(
".txt"
,
""
)
out_file_path
=
"{}/T01_A{}.txt"
.
format
(
out_path
,
qnumber
)
with
open
(
out_file_path
,
'w'
)
as
fp
:
fp
.
write
(
questions
[
qname
][
'answers'
][
_best_json
][
'answer'
])
questions
[
qname
][
'best_json'
]
=
_best_json
res
=
{
"status"
:
"OK"
}
else
:
res
=
{
"status"
:
"No answer is found"
}
return
json
.
dumps
(
res
)
@
app
.
route
(
"/board-data"
,
methods
=
[
"POST"
])
@
app
.
route
(
"/board-data"
,
methods
=
[
"POST"
])
def
get_board_data
():
def
get_board_data
():
...
...
comm/server/static/css/pynq-manager.css
View file @
18700dc5
...
@@ -71,3 +71,7 @@ body{
...
@@ -71,3 +71,7 @@ body{
background-color
:
rgba
(
200
,
100
,
100
,
.15
);
background-color
:
rgba
(
200
,
100
,
100
,
.15
);
}
}
#client-control-pane
tr
.answer-detail-row.submit-answer
{
background-color
:
rgba
(
100
,
200
,
100
,
.3
);
}
comm/server/static/js/pynq-manager.js
View file @
18700dc5
...
@@ -166,6 +166,17 @@ $(function(){
...
@@ -166,6 +166,17 @@ $(function(){
$
(
"#client-control-pane"
).
find
(
".stop-button"
).
eq
(
0
).
click
(
function
(){
$
(
"#client-control-pane"
).
find
(
".stop-button"
).
eq
(
0
).
click
(
function
(){
pm
.
sendStop
();
pm
.
sendStop
();
});
});
$
(
"#client-control-pane"
).
find
(
".save-button"
).
eq
(
0
).
click
(
function
(){
var
qname
=
$
(
this
).
data
(
"qname"
);
$
.
ajax
({
type
:
"POST"
,
dataType
:
"json"
,
url
:
"/save"
,
data
:
{
qname
:
qname
}
}).
done
((
data
)
=>
{
alert
(
data
[
'status'
]);
});
});
$
(
".answer-detail-row td"
).
click
(
function
(){
$
(
".answer-detail-row td"
).
click
(
function
(){
var
json_name
=
$
(
this
).
parent
(
"tr"
).
data
(
"json"
);
var
json_name
=
$
(
this
).
parent
(
"tr"
).
data
(
"json"
);
...
...
comm/server/templates/part_question_status.html
View file @
18700dc5
...
@@ -3,7 +3,8 @@
...
@@ -3,7 +3,8 @@
<h3>
【{{qname}}】
</h3>
<h3>
【{{qname}}】
</h3>
<p>
<p>
<button
class=
"btn btn-primary btn-lg start-button"
type=
"button"
data-qname=
"{{qname}}"
>
Start
</button>
<button
class=
"btn btn-primary btn-lg start-button"
type=
"button"
data-qname=
"{{qname}}"
>
Start
</button>
<button
class=
"btn btn-danger btn-lg stop-button"
type=
"button"
data-qname=
"all"
>
Stop
</button>
<button
class=
"btn btn-danger btn-lg stop-button"
type=
"button"
data-qname=
"all"
>
Stop
</button><br
/>
<button
class=
"btn btn-info btn-lg save-button"
type=
"button"
data-qname=
"{{qname}}"
>
Save
</button>
</p>
</p>
</div>
</div>
<div
class=
"col-8"
>
<div
class=
"col-8"
>
...
@@ -40,7 +41,11 @@
...
@@ -40,7 +41,11 @@
<th>
Score
</th>
<th>
Score
</th>
</tr>
</tr>
{% for k, v in qdata.answers.items() %}
{% for k, v in qdata.answers.items() %}
{% if qdata.best_json == k %}
<tr
class=
"answer-detail-row submit-answer"
data-json=
"{{k}}"
data-qname=
"{{qname}}"
>
{% else %}
<tr
class=
"answer-detail-row"
data-json=
"{{k}}"
data-qname=
"{{qname}}"
>
<tr
class=
"answer-detail-row"
data-json=
"{{k}}"
data-qname=
"{{qname}}"
>
{% endif %}
<td>
{{v.timestamp}}
</td>
<td>
{{v.timestamp}}
</td>
<td>
{{v.solver}}
</td>
<td>
{{v.solver}}
</td>
<td>
{{v.nlcheck}}
</td>
<td>
{{v.nlcheck}}
</td>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment