diff --git a/.gitignore b/.gitignore index 1821ce6dfe97570a0c32175860e15d49ced91c4d..bf7dd284920b0f6c33aa475c5c86481c712a4488 100644 --- a/.gitignore +++ b/.gitignore @@ -2,10 +2,10 @@ # Project-specific files /conf.json -/questions/* -!/questions/.gitkeep -/answers/* -!/answers/.gitkeep +/problems/* +!/problems/.gitkeep +/solutions/* +!/solutions/.gitkeep # Byte-compiled / optimized / DLL files diff --git a/main.py b/main.py index bcf3aa461e97b0b9257e45f8ddf41417e1063abc..e222197a2d2b81fa0ec6fdf82f339afca1b74b7b 100644 --- a/main.py +++ b/main.py @@ -16,16 +16,16 @@ def webui_index(): # return adc2019system.role.role return render_template('index.html') -@webui.route('/template/questions') -def webui_template_questions(): +@webui.route('/part/problems') +def webui_part_problems(): if (adc2019system.role is not None) and (adc2019system.role.type == 'host'): - questions = adc2019system.role.get_questions() - return render_template('part_questions.html', questions=questions) + problems = adc2019system.role.get_problems() + return render_template('part_problems.html', problems=problems) else: return abort(404) -@webui.route('/template/system-summary') -def webui_template_workers(): +@webui.route('/part/system-summary') +def webui_parte_workers(): if (adc2019system.role is not None) and (adc2019system.role.type == 'host'): workers = adc2019system.role.get_workers() return render_template('part_system_summary.html', workers=workers) @@ -41,18 +41,18 @@ def webui_part_request_status(request_id=None): else: return abort(404) -@webui.route('/template/question/') -def webui_template_question_status(name=None): +@webui.route('/part/problem/') +def webui_partem_status(name=None): if name is None: return abort(404) if (adc2019system.role is not None) and (adc2019system.role.type == 'host'): - question = adc2019system.role.get_question(name) - if question is None: + problem = adc2019system.role.get_problem(name) + if problem is None: return abort(404) else: - return render_template('part_question_status.html', question=question) + return render_template('part_problem_status.html', problem=problem) else: return abort(404) diff --git a/answers/.gitkeep b/problems/.gitkeep similarity index 100% rename from answers/.gitkeep rename to problems/.gitkeep diff --git a/roles/host.py b/roles/host.py index 6bd3f5a75893a44c6b7e5bdd29086b0884dbb0a9..6f4b9a107029e86f9ca52c1c2fee58ef76feff89 100644 --- a/roles/host.py +++ b/roles/host.py @@ -5,7 +5,7 @@ import threading import time import requests -from utils import Question +from utils import Problem class Host(object): @@ -13,29 +13,29 @@ class Host(object): self.type = 'host' self.config = config - self.questions = dict() + self.problems = dict() self.worker_manager = None self.request = dict() self.processing_request = None - self._load_questions(config['question_path']) + self._load_problems(config['problem_path']) self._setup_workers() def __repr__(self): return "Host" - def _load_questions(self, path): + def _load_problems(self, path): - questions_path = glob.glob(path) + problems_path = glob.glob(path) - questions_path = sorted(questions_path) + problems_path = sorted(problems_path) - for v in questions_path: + for v in problems_path: - question = Question(v) - _key = question.name + problem = Problem(v) + _key = problem.name - self.questions[_key] = question + self.problems[_key] = problem def _setup_workers(self): @@ -46,13 +46,13 @@ class Host(object): def get_workers(self): return self.worker_manager.get_workers() - def distribute_question(self, question_key): + def distribute_problem(self, problem_key): - question = self.get_question(question_key) - if question is None: + problem = self.get_problem(problem_key) + if problem is None: return {'status': 'key error'} else: - request = Request(self.worker_manager, question.get_dict()) + request = Request(self.worker_manager, problem.get_dict()) request_id = request.get_id() self.request[request_id] = request @@ -63,12 +63,12 @@ class Host(object): 'timeout': request.timeout } - def get_questions(self): - return self.questions + def get_problems(self): + return self.problems - def get_question(self, _key): - if _key in self.questions: - return self.questions[_key] + def get_problem(self, _key): + if _key in self.problems: + return self.problems[_key] else: return None @@ -80,10 +80,10 @@ class Host(object): else: print(f'W: Unknown request_id: {request_id}') - question_key = solution['question'] + problem_key = solution['problem'] - if question_key in self.questions: - self.questions[question_key].put_solution(solution) + if problem_key in self.problems: + self.problems[problem_key].put_solution(solution) return {'status': 'registered'} else: return {'status': 'error'} @@ -98,11 +98,11 @@ class Host(object): if cmd == 'role': # サーバの役割確認 return {'role': self.type} - elif cmd == 'question/solve': - # params['question']に指定された問題をworkerに配信 - question_key = params['question'] - return self.distribute_question(question_key) - elif cmd == 'question/solution': + elif cmd == 'problem/solve': + # params['problem']に指定された問題をworkerに配信 + problem_key = params['problem'] + return self.distribute_problem(problem_key) + elif cmd == 'problem/solution': self.store_solution(params) return {'status': 'received'} elif cmd == 'request/status': @@ -223,9 +223,9 @@ class Request(object): if self.broadcast_time is None: progress = 0, else: - progress_question = response_count / worker_count * 100 + progress_problem = response_count / worker_count * 100 progress_time = (time.time() - self.broadcast_time) / self.timeout * 100 - progress = min(100, max(progress_question, progress_time)) + progress = min(100, max(progress_problem, progress_time)) worker_list = self.worker_manager.get_workers().keys() worker_status = dict() diff --git a/roles/solver.py b/roles/solver.py index a0088e1aa07ac68ab7a8b58f092a0ac0835f30af..f79096b5fda83f8f053b5a2e522f8abdfd437d3d 100644 --- a/roles/solver.py +++ b/roles/solver.py @@ -64,11 +64,11 @@ class Solver(object): def submit_solution(self, params, solution): data = { 'request_id': params['request_id'], - 'question': params['name'], + 'problem': params['name'], 'worker': self.address } data.update(solution) - self.post('question/solution', data) + self.post('problem/solution', data) def start_solver(self, params): diff --git a/questions/.gitkeep b/solutions/.gitkeep similarity index 100% rename from questions/.gitkeep rename to solutions/.gitkeep diff --git a/static/css/adc2019.css b/static/css/adc2019.css index 1fd5b4f507741ba545e5d44edd4a25cc8ba2b161..d59c0197ceaed9bdc95d5b0cfd42a0e9138093d3 100644 --- a/static/css/adc2019.css +++ b/static/css/adc2019.css @@ -15,30 +15,30 @@ body{ background-color: rgba(0, 0, 50, .5); } -#question-list-container{ +#problem-list-container{ height: calc(100vh - 50px); overflow-y: scroll; overflow-x: hidden; } -#question-list-container th.large-cell, -#question-list-container td.large-cell{ +#problem-list-container th.large-cell, +#problem-list-container td.large-cell{ width: 24%; } -#question-list-container th.small-cell, -#question-list-container td.small-cell{ +#problem-list-container th.small-cell, +#problem-list-container td.small-cell{ width: 14%; } -#question-list-container tr.question-row, -#question-list-container tr.question-row td{ +#problem-list-container tr.problem-row, +#problem-list-container tr.problem-row td{ cursor: pointer; } -#question-list-container tr.question-row.q-selected{ +#problem-list-container tr.problem-row.q-selected{ background-color: rgba(200, 100, 100, .3); } -#question-list-container tr.question-row:hover{ +#problem-list-container tr.problem-row:hover{ background-color: rgba(200, 100, 100, .15); } @@ -56,7 +56,7 @@ body{ width: 20%; } -#question-control-pane h3{ +#problem-control-pane h3{ display: inline-block; } diff --git a/static/js/adc2019.js b/static/js/adc2019.js index 799b5989323e2471a1a6e83b476d3251e107238f..da2c6dd8f4ad870824c61557ea577e0698cad607 100644 --- a/static/js/adc2019.js +++ b/static/js/adc2019.js @@ -4,21 +4,21 @@ class StatusView { constructor(selector) { this.container = $(selector); - this.question_key = null; + this.problem_key = null; this.request_refresh_timer = null; } // 問題詳細画面を表示 - show_question(question_key = null){ + show_problem(problem_key = null){ var _this = this; - if(question_key != null){ - this.question_key = question_key; + if(problem_key != null){ + this.problem_key = problem_key; } $.ajax({ type: 'GET', dataType: 'html', - url: '/template/question/' + _this.question_key + url: '/part/problem/' + _this.problem_key }).done((d) => { _this.container.empty(); _this.container.html(d); @@ -36,9 +36,9 @@ class StatusView { $.ajax({ type: "POST", dataType: "json", - url: "/api/question/solve", + url: "/api/problem/solve", data: JSON.stringify({ - "question": _this.question_key + "problem": _this.problem_key }), contentType: 'application/json' }).done((d) => { @@ -48,7 +48,7 @@ class StatusView { _this.container.find('#solver-processing-modal').modal('show'); _this.container.find('#solver-processing-modal').on('hidden.bs.modal', function(e){ - _this.show_question(); + _this.show_problem(); }) _this.get_request_status(request_id, timeout); @@ -57,20 +57,6 @@ class StatusView { get_request_status(request_id, timeout){ var _this = this; - // $.ajax({ - // type: 'POST', - // dataType: 'json', - // url: '/api/request/status', - // data: JSON.stringify({ - // 'request_id': request_id - // }), - // contentType: 'application/json' - // }).done((d) => { - // if(d['status'] != 'done'){ - // _this.request_refresh_timer = setTimeout(_this.get_request_status(request_id, timeout), 1000); - // } - // console.log(d); - // }); $.ajax({ type: 'GET', dataType: 'html', @@ -83,7 +69,7 @@ class StatusView { console.log(status); if(status == 'done'){ _this.request_refresh_timer = null; - // _this.show_question(); + // _this.show_problem(); }else{ _this.request_refresh_timer = setTimeout(_this.get_request_status(request_id, timeout), 1000); } @@ -97,7 +83,7 @@ class StatusView { $.ajax({ type: "GET", dataType: "html", - url: "/template/system-summary" + url: "/part/system-summary" }).done((d) => { _this.container.empty(); _this.container.html(d); @@ -143,28 +129,28 @@ $(function(){ const status_view = new StatusView('#status-container'); - var refresh_questions = function(){ + var refresh_problems = function(){ $.ajax({ type: "GET", dataType: "html", - url: "/template/questions" + url: "/part/problems" }).done((d) => { - $("#question-list-container").empty(); - $("#question-list-container").html(d); + $("#problem-list-container").empty(); + $("#problem-list-container").html(d); - $(".question-row td").click(function(){ - var $tr = $(this).parent("tr.question-row"); - $(".question-row").removeClass("q-selected"); + $(".problem-row td").click(function(){ + var $tr = $(this).parent("tr.problem-row"); + $(".problem-row").removeClass("q-selected"); $tr.addClass("q-selected"); var qname = $tr.data("qname"); - // show_question_status(qname); + // show_problem_status(qname); location.hash = "#" + qname; return false; }); var hash = location.hash.replace("#", ""); if(hash != ""){ - $(".question-row[data-qname='" + hash + "']").addClass("q-selected"); + $(".problem-row[data-qname='" + hash + "']").addClass("q-selected"); } }); } @@ -174,11 +160,11 @@ $(function(){ if(hash == ""){ status_view.show_system(); }else{ - status_view.show_question(hash); + status_view.show_problem(hash); } }).trigger('hashchange'); - refresh_questions(); + refresh_problems(); }); diff --git a/templates/index.html b/templates/index.html index 6f28c74060ba607cf22330a1212c69f00f9f33f4..7b451b07fd12e9347f9bf6317ead073815570a72 100644 --- a/templates/index.html +++ b/templates/index.html @@ -23,7 +23,7 @@

問題一覧

  システム状況 -
+

Loading...

diff --git a/templates/part_question_status.html b/templates/part_problem_status.html similarity index 85% rename from templates/part_question_status.html rename to templates/part_problem_status.html index ed2824349f95a1409b6512c29b5520f7d66f266b..dd6cc4eee62f224300d7abba10fb70b05750e80d 100644 --- a/templates/part_question_status.html +++ b/templates/part_problem_status.html @@ -1,12 +1,12 @@
-

【{{question.name}}】

+

【{{problem.name}}】

{#% # if localmode %#}

- + - - + +

{#% else %#} @@ -21,11 +21,11 @@ Client Score - {% for k, v in question.get_solutions().items() %} + {% for k, v in problem.get_solutions().items() %} {#% if (qdata.best_json == k) and (v.answer != "") %#} {#% else %#} - + {#% endif %#} {{v.timestamp_str}} {{v.worker}} @@ -45,7 +45,7 @@