diff --git a/roles/host.py b/roles/host.py index 73a9d98cdd0ddae5aa1e12e423481db3461010af..0471074fa6c764de8eea94955588bf678e37adeb 100644 --- a/roles/host.py +++ b/roles/host.py @@ -89,6 +89,16 @@ class Host(object): else: return {'status': 'error'} + def save_solution(self, problem_key): + + problem = self.get_problem(problem_key) + + if problem is not None: + problem.save_best_solution() + return {'status': 'saved'} + else: + return {'status': 'failed'} + def get_request_status(self, request_id): if request_id in self.request: return self.request[request_id].get_status() @@ -122,6 +132,9 @@ class Host(object): elif cmd == 'problem/solution': self.store_solution(params) return {'status': 'received'} + elif cmd == 'problem/save': + problem_key = params['problem'] + return self.save_solution(problem_key) elif cmd == 'request/status': request_id = float(params['request_id']) return self.get_request_status(request_id) diff --git a/static/css/adc2019.css b/static/css/adc2019.css index e0955e8fe57ebb8e8d294b766d69e0da90f69b7f..e070961ff193c0f21a59f23c4760696767f76ed0 100644 --- a/static/css/adc2019.css +++ b/static/css/adc2019.css @@ -60,16 +60,16 @@ body{ display: inline-block; } -#client-control-pane tr.solution-detail-row, -#client-control-pane tr.solution-detail-row td{ +#solution-list-container tr.solution-detail-row, +#solution-list-container tr.solution-detail-row td{ cursor: pointer; } -#client-control-pane tr.solution-detail-row:hover{ +#solution-list-container tr.solution-detail-row:hover{ background-color: rgba(200, 100, 100, .15); } -#client-control-pane tr.solution-detail-row.submit-answer{ +#solution-list-container tr.solution-detail-row.submit-solution{ background-color: rgba(100, 200, 100, .3); } diff --git a/static/js/adc2019.js b/static/js/adc2019.js index 72d16c66c5d354da644ca149c48c847f5708e4f6..347f992d5bb74989466b3290328148521e4a34b7 100644 --- a/static/js/adc2019.js +++ b/static/js/adc2019.js @@ -26,6 +26,10 @@ class StatusView { _this.container.find('.start-button').click(()=>{ _this.start_solver(); }); + + _this.container.find('.save-button').click(()=>{ + _this.save_solution(); + }); _this.container.find('.solution-detail-row td').click((e) => { var solution_id = $(e.target).parent("tr").data("solution-id"); @@ -83,6 +87,23 @@ class StatusView { alert(d); }); } + + // 保存 + save_solution(){ + var _this = this; + + $.ajax({ + type: "POST", + dataType: "json", + url: "/api/problem/save", + data: JSON.stringify({ + "problem": _this.problem_key + }), + contentType: 'application/json' + }).done((d) => { + _this.show_problem(); + }); + } get_request_status(request_id, timeout){ var _this = this; diff --git a/templates/part_problem_status.html b/templates/part_problem_status.html index e3565ac799b766854ccc5ea5b8522969d6b5e6fc..5a74f4f0e79fe01f290e06b5bea6dfbb33f84410 100644 --- a/templates/part_problem_status.html +++ b/templates/part_problem_status.html @@ -22,11 +22,11 @@
{% for k, v in problem.get_solutions().items() %} - {#% if (qdata.best_json == k) and (v.answer != "") %#} - - {#% else %#} + {% if k == problem.best_solution %} +