Skip to content
Snippets Groups Projects
Commit bb2a29d2 authored by Jan Prachař's avatar Jan Prachař Committed by Jiří Setnička
Browse files

Desetinné body: Limity na vítěze a úspěšné řešitele jsou také desetinné

Issue #189
parent f24a7775
No related branches found
No related tags found
1 merge request!51Desetinné body
SET ROLE 'mo_osmo'; SET ROLE 'mo_osmo';
ALTER TABLE rounds ALTER TABLE rounds
ADD COLUMN points_step numeric(2,1) NOT NULL DEFAULT 1; -- s jakou přesností jsou přidělovány body (celé aneb 1, 0.5, 0.1) ADD COLUMN points_step numeric(2,1) NOT NULL DEFAULT 1, -- s jakou přesností jsou přidělovány body (celé aneb 1, 0.5, 0.1)
ALTER COLUMN score_winner_limit SET DATA TYPE numeric(5,1),
ALTER COLUMN score_successful_limit SET DATA TYPE numeric(5,1);
ALTER TABLE solutions ALTER TABLE solutions
ALTER COLUMN points SET DATA TYPE numeric(5,1); ALTER COLUMN points SET DATA TYPE numeric(5,1);
......
...@@ -218,8 +218,8 @@ class Round(Base): ...@@ -218,8 +218,8 @@ class Round(Base):
pr_tasks_start = Column(DateTime(True)) pr_tasks_start = Column(DateTime(True))
pr_submit_end = Column(DateTime(True)) pr_submit_end = Column(DateTime(True))
score_mode = Column(Enum(RoundScoreMode, name='score_mode'), nullable=False, server_default=text("'basic'::score_mode")) score_mode = Column(Enum(RoundScoreMode, name='score_mode'), nullable=False, server_default=text("'basic'::score_mode"))
score_winner_limit = Column(Integer) score_winner_limit = Column(Numeric)
score_successful_limit = Column(Integer) score_successful_limit = Column(Numeric)
points_step = Column(Numeric, nullable=False) points_step = Column(Numeric, nullable=False)
has_messages = Column(Boolean, nullable=False, server_default=text("false")) has_messages = Column(Boolean, nullable=False, server_default=text("false"))
......
...@@ -24,6 +24,7 @@ app.jinja_env.trim_blocks = True ...@@ -24,6 +24,7 @@ app.jinja_env.trim_blocks = True
app.jinja_env.filters.update(timeformat=util_format.timeformat) app.jinja_env.filters.update(timeformat=util_format.timeformat)
app.jinja_env.filters.update(inflected=util_format.inflect_number) app.jinja_env.filters.update(inflected=util_format.inflect_number)
app.jinja_env.filters.update(inflected_by=util_format.inflect_by_number)
app.jinja_env.filters.update(timedelta=util_format.timedelta) app.jinja_env.filters.update(timedelta=util_format.timedelta)
app.jinja_env.filters.update(time_and_timedelta=util_format.time_and_timedelta) app.jinja_env.filters.update(time_and_timedelta=util_format.time_and_timedelta)
app.jinja_env.filters.update(data_size=util_format.data_size) app.jinja_env.filters.update(data_size=util_format.data_size)
......
...@@ -12,7 +12,6 @@ from typing import Optional, Tuple ...@@ -12,7 +12,6 @@ from typing import Optional, Tuple
import werkzeug.exceptions import werkzeug.exceptions
import wtforms import wtforms
from wtforms import validators, ValidationError from wtforms import validators, ValidationError
from wtforms.fields.html5 import DecimalField, IntegerField
from wtforms.widgets.html5 import NumberInput from wtforms.widgets.html5 import NumberInput
import mo import mo
...@@ -21,6 +20,7 @@ import mo.imports ...@@ -21,6 +20,7 @@ import mo.imports
from mo.rights import Right, RoundRights from mo.rights import Right, RoundRights
import mo.util import mo.util
from mo.web import app from mo.web import app
from mo.web.util import MODecimalField
from mo.web.org_contest import ParticipantsActionForm, ParticipantsFilterForm, get_contestant_emails, get_contestants_query, make_contestant_table, \ from mo.web.org_contest import ParticipantsActionForm, ParticipantsFilterForm, get_contestant_emails, get_contestants_query, make_contestant_table, \
generic_import, generic_batch_download, generic_batch_upload, generic_batch_points generic_import, generic_batch_download, generic_batch_upload, generic_batch_points
...@@ -429,12 +429,12 @@ class RoundEditForm(FlaskForm): ...@@ -429,12 +429,12 @@ class RoundEditForm(FlaskForm):
ct_submit_end = MODateTimeField("Konec odevzdávání pro účastníky", validators=[validators.Optional()]) ct_submit_end = MODateTimeField("Konec odevzdávání pro účastníky", validators=[validators.Optional()])
pr_submit_end = MODateTimeField("Konec odevzdávání pro dozor", validators=[validators.Optional()]) pr_submit_end = MODateTimeField("Konec odevzdávání pro dozor", validators=[validators.Optional()])
score_mode = wtforms.SelectField("Výsledková listina", choices=db.RoundScoreMode.choices(), coerce=db.RoundScoreMode.coerce) score_mode = wtforms.SelectField("Výsledková listina", choices=db.RoundScoreMode.choices(), coerce=db.RoundScoreMode.coerce)
score_winner_limit = IntegerField( score_winner_limit = MODecimalField(
"Hranice bodů pro vítěze", validators=[validators.Optional()], "Hranice bodů pro vítěze", validators=[validators.Optional(), validators.NumberRange(min=0)],
description="Řešitelé s alespoň tolika body budou označeni za vítěze, prázdná hodnota = žádné neoznačovat", description="Řešitelé s alespoň tolika body budou označeni za vítěze, prázdná hodnota = žádné neoznačovat",
) )
score_successful_limit = IntegerField( score_successful_limit = MODecimalField(
"Hranice bodů pro úspěšné řešitele", validators=[validators.Optional()], "Hranice bodů pro úspěšné řešitele", validators=[validators.Optional(), validators.NumberRange(min=0)],
description="Řešitelé s alespoň tolika body budou označeni za úspěšné řešitele, prázdná hodnota = žádné neoznačovat", description="Řešitelé s alespoň tolika body budou označeni za úspěšné řešitele, prázdná hodnota = žádné neoznačovat",
) )
points_step = wtforms.SelectField( points_step = wtforms.SelectField(
......
...@@ -59,8 +59,8 @@ ...@@ -59,8 +59,8 @@
{% endif %} {% endif %}
</thead> </thead>
<tr><td>Výsledková listina<td>{{ round.master.score_mode.friendly_name() }} <tr><td>Výsledková listina<td>{{ round.master.score_mode.friendly_name() }}
<tr><td>Hranice bodů pro vítěze<td>{{ round.master.score_winner_limit|none_value(Markup('<i>nenastaveno</i>')) }} <tr><td>Hranice bodů pro vítěze<td>{{ round.master.score_winner_limit|decimal|none_value(Markup('<i>nenastaveno</i>')) }}
<tr><td>Hranice bodů pro úspěšné řešitele<td>{{ round.master.score_successful_limit|none_value(Markup('<i>nenastaveno</i>')) }} <tr><td>Hranice bodů pro úspěšné řešitele<td>{{ round.master.score_successful_limit|decimal|none_value(Markup('<i>nenastaveno</i>')) }}
<tr><td>Přesnost bodování<td>{{ round.points_step_name() }} <tr><td>Přesnost bodování<td>{{ round.points_step_name() }}
</table> </table>
<div style="clear: both;"></div> <div style="clear: both;"></div>
......
...@@ -55,10 +55,10 @@ Rozkliknutím bodů se lze dostat na detail daného řešení.</p> ...@@ -55,10 +55,10 @@ Rozkliknutím bodů se lze dostat na detail daného řešení.</p>
{% if master.score_winner_limit is not none or master.score_successful_limit is not none %} {% if master.score_winner_limit is not none or master.score_successful_limit is not none %}
<p> <p>
{% if master.score_winner_limit is not none %} {% if master.score_winner_limit is not none %}
<b>Vítězi</b> se stávají účastníci s alespoň <b>{{ master.score_winner_limit|inflected("bodem", "body", "body") }}</b>. <b>Vítězi</b> se stávají účastníci s alespoň <b>{{ master.score_winner_limit|decimal }} {{ master.score_winner_limit|inflected_by("bodem", "body", "body") }}</b>.
{% endif %} {% endif %}
{% if master.score_successful_limit is not none %} {% if master.score_successful_limit is not none %}
<b>Úspěšnými řešiteli</b> se stávají účastníci s alespoň <b>{{ master.score_successful_limit|inflected("bodem", "body", "body") }}</b>. <b>Úspěšnými řešiteli</b> se stávají účastníci s alespoň <b>{{ master.score_successful_limit|decimal }} {{ master.score_successful_limit|inflected_by("bodem", "body", "body") }}</b>.
{% endif %} {% endif %}
{% endif %} {% endif %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment