From 491bda31fd7ff08a51bed7be46633c5a6ba4ad01 Mon Sep 17 00:00:00 2001 From: Kento HASEGAWA Date: Tue, 13 Aug 2019 13:26:14 +0900 Subject: [PATCH] Add filling rates and highlights to the problem list --- static/css/adc2019.css | 11 +++++++++++ templates/part_problem_status.html | 2 -- templates/part_problems.html | 12 ++++++++++-- utils/data.py | 17 ++++++++++++++++- 4 files changed, 37 insertions(+), 5 deletions(-) diff --git a/static/css/adc2019.css b/static/css/adc2019.css index 078db36..db78001 100644 --- a/static/css/adc2019.css +++ b/static/css/adc2019.css @@ -37,11 +37,22 @@ body{ #problem-list-container tr.problem-row.q-selected{ background-color: rgba(200, 100, 100, .3); + border: 2px solid #888; } #problem-list-container tr.problem-row:hover{ background-color: rgba(200, 100, 100, .15); } +#problem-list-container tr.problem-row.solution-tried{ + background-color: rgba(200, 200, 100, 0.3); +} +#problem-list-container tr.problem-row.solution-solved{ + background-color: rgba(100, 200, 200, 0.3); +} +#problem-list-container tr.problem-row.solution-saved{ + background-color: rgba(100, 200, 100, 0.3); +} + #client-control-pane{ height: calc(100vh - 20px); overflow-y: scroll; diff --git a/templates/part_problem_status.html b/templates/part_problem_status.html index 8aa0c24..89ebf3e 100644 --- a/templates/part_problem_status.html +++ b/templates/part_problem_status.html @@ -25,9 +25,7 @@ {% set tr_class = '' %} {% set tr_class = tr_class + ' submit-solution' if k == problem.best_solution else '' %} {% set tr_class = tr_class + ' valid-solution' if v.is_valid_solution() else '' %} - {#% else %#} - {#% endif %#} {{v.timestamp_str}} {{v.worker}} diff --git a/templates/part_problems.html b/templates/part_problems.html index 3de937c..c44b4c1 100644 --- a/templates/part_problems.html +++ b/templates/part_problems.html @@ -12,10 +12,18 @@ {% for k, v in problems.items() %} - + {% set tr_class = '' %} + {% if v.status == 'Saved' %} + {% set tr_class = 'solution-saved' %} + {% elif v.status.startswith('Solved') %} + {% set tr_class = 'solution-solved' %} + {% elif v.status.startswith('Tried') %} + {% set tr_class = 'solution-tried' %} + {% endif %} + {{v.name}} - {{v.size_str}}
+ {{v.size_str}} [{{'{:,.1f}%'.format(v.filling_rate * 100)}}]
{{v.block_num}} / {{v.line_numbers | length - 1}} / {{v.block_groups | length}} diff --git a/utils/data.py b/utils/data.py index 1ffec02..177f517 100644 --- a/utils/data.py +++ b/utils/data.py @@ -15,8 +15,8 @@ class Problem(object): self.size = (0, 0) self.block_num = 0 self.blocks = dict() + self.tile_num = 0 self.problem = '' - # self.status = 'Ready' self.solutions = dict() self.solution_path = solution_path self.best_solution = None @@ -29,6 +29,17 @@ class Problem(object): @property def size_str(self): return f'{self.size[0]}X{self.size[1]}' + + @property + def board_area(self): + return self.size[0] * self.size[1] + + @property + def filling_rate(self): + if self.board_area == 0: + return 0 + else: + return self.tile_num / self.board_area @property def problem_text(self): @@ -91,6 +102,8 @@ class Problem(object): block_num = 0 blocks = dict() + tile_num = 0 + def intplus(v): if v.isdecimal(): return int(v) @@ -133,6 +146,7 @@ class Problem(object): if not _line_num in line_number_list: line_number_list.append(_line_num) # _line_num = line_number_list.index(_line_num) + tile_num += 1 # Make connection list if not bi in block_to_line: @@ -152,6 +166,7 @@ class Problem(object): self.size = board_size self.block_num = block_num self.blocks = blocks + self.tile_num = tile_num self.name = name self.problem = q_text self.line_numbers = line_number_list -- 2.22.0