Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ikonky zobraziujúce stav riešenia. #1331

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions css/src/base.less
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,26 @@ table.floatThead-table {
margin: 10px;
}

.task-status-ok {
color: @brand-primary;
}

.task-status-submitted {
color: @brand-info;
}

.task-status-wrong {
color: @brand-warning;
}

.task-status-empty {
color: @gray;
}

.task-status-disabled {
color: @gray-light;
}


/* Submit protocols */
@import "trojsten/protocol.less";
62 changes: 49 additions & 13 deletions trojsten/contests/templates/trojsten/contests/parts/task_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,20 @@
Kategória
</th>
{% endif %}
<th width="15%">
Max. body
</th>
{% if user.is_authenticated %}
{% if show_description_col %}
<th width="10%">
Popis
</th>
{% endif %}
{% if show_source_col %}
<th width="10%">
Program
</th>
{% endif %}
{% else %}
<th width="15%">
Tvoje body
Body
</th>
{% endif %}
</tr>
Expand All @@ -76,6 +84,7 @@
{% endfor %}
</td>
{% endif %}
{% if not user.is_authenticated %}
<td>
{% if task.description_points > 0 %}
<span class="points-item">popis:&nbsp;{{ task.description_points }}</span>
Expand All @@ -85,17 +94,44 @@
<span class="points-item">program:&nbsp;{{ task.source_points }}</span>
{% endif %}
</td>
{% if user.is_authenticated %}
{% lookup_as points.tasks task.id as task_points %}
<td>
{% if task.description_points > 0 %}
<span class="points-item">popis:&nbsp;{% if task_points.description_pending %}??{% else %}{{ task_points.description_points }}{% endif %}</span>
{% if task.source_points > 0 %}<br/>{% endif %}
{% else %}
{% lookup_as points.tasks task.id as task_points %}
{% if show_description_col %}
<td>
{% if task.description_points > 0 %}
{% if task_points.description_pending %}
<i class="glyphicon glyphicon-time task-status-submitted" data-toggle="tooltip" data-placement="top" data-original-title="popis: čaká na opravenie"></i>
{% elif task_points.submitted_description %}
<i class="glyphicon glyphicon-ok-circle task-status-ok" data-toggle="tooltip" data-placement="top" data-original-title="popis: opravený"></i>
{% else %}
<i class="glyphicon glyphicon-ban-circle task-status-empty" data-toggle="tooltip" data-placement="top" data-original-title="popis: neodovzdaný"></i>
{% endif %}

<b>{% if task_points.description_pending %}??{% else %}{{ task_points.description_points }}{% endif %}</b>&nbsp;/&nbsp;{{ task.description_points }}
{% else %}
<i class="glyphicon glyphicon-minus task-status-disabled" data-toggle="tooltip" data-placement="top" data-original-title="popis: neodovzáva sa"></i>
{% endif %}
</td>
{% endif %}
{% if task.source_points > 0 %}
<span class="points-item">program:&nbsp;{{ task_points.source_points }}</span>
{% if show_source_col %}
<td>
{% if task.source_points > 0 %}
{% if task_points.submitted_source %}
{% if task_points.source_points == task.source_points %}
<i class="glyphicon glyphicon-ok-circle task-status-ok" data-toggle="tooltip" data-placement="top" data-original-title="program: odovzdaný ({{ task_points.source_points }}b)"></i>
{% else %}
<i class="glyphicon glyphicon-remove-circle task-status-wrong" data-toggle="tooltip" data-placement="top" data-original-title="program: odovzdaný ({{ task_points.source_points }}b)"></i>
{% endif %}
{% else %}
<i class="glyphicon glyphicon-ban-circle task-status-empty" data-toggle="tooltip" data-placement="top" data-original-title="program: neodovzdaný"></i>
{% endif %}

<b>{{ task_points.source_points }}</b>&nbsp;/&nbsp;{{ task.source_points }}
{% else %}
<i class="glyphicon glyphicon-minus task-status-disabled" data-toggle="tooltip" data-placement="top" data-original-title="program: neodovzáva sa"></i>
{% endif %}
</td>
{% endif %}
</td>
{% endif %}
</tr>
{% empty %}
Expand Down
12 changes: 12 additions & 0 deletions trojsten/contests/templatetags/statements_parts.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ def show_task_list(context, round):
submits = Submit.objects.latest_for_user(tasks, context["user"])
results = get_points_from_submits(tasks, submits)
data["points"] = results

show_source_col = False
show_description_col = False
for task in tasks:
if task.description_points > 0:
show_description_col = True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Toto sa da nahradit idiomatickejsim:
show_description_col = any(map(lambda t: t.description_points >0, tasks))

if task.source_points > 0:
show_source_col = True

data["show_description_col"] = show_description_col
data["show_source_col"] = show_source_col

context.update(data)
return context

Expand Down
4 changes: 2 additions & 2 deletions trojsten/contests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def test_my_points_hidden(self):

self.client.force_login(self.nonstaff_user)
response = self.client.get(self.url)
self.assertContains(response, "popis:&nbsp;??")
self.assertContains(response, "popis:&nbsp;<b>??</b>")

def test_my_points_visible(self):
task = Task.objects.create(
Expand All @@ -306,7 +306,7 @@ def test_my_points_visible(self):

self.client.force_login(self.nonstaff_user)
response = self.client.get(self.url)
self.assertContains(response, "popis:&nbsp;5")
self.assertContains(response, "popis:&nbsp;<b>5</b>")


@override_settings(
Expand Down
5 changes: 5 additions & 0 deletions trojsten/results/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ def __init__(self):
self.source_points = 0
self.description_points = 0
self.submitted = False
self.submitted_source = False
self.submitted_description = False
self.description_pending = False

@property
Expand All @@ -24,14 +26,17 @@ def sum(self):

def add_source_points(self, points):
self.submitted = True
self.submitted_source = True
self.source_points += points

def set_description_points(self, points):
self.submitted = True
self.submitted_description = True
self.description_points = points

def set_description_pending(self):
self.submitted = True
self.submitted_description = True
self.description_pending = True
self.description_points = 0

Expand Down
2 changes: 1 addition & 1 deletion trojsten/static/css/fks/fks.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion trojsten/static/css/kms/kms.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion trojsten/static/css/ksp/ksp.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion trojsten/static/css/trojsten/trojsten.min.css

Large diffs are not rendered by default.