1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2024-12-25 06:22:22 +00:00

Display problem names

Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
Emmy D'Anello 2023-04-04 11:56:13 +02:00
parent 90bfc45858
commit 4357d51b9a
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
4 changed files with 23 additions and 12 deletions

View File

@ -382,7 +382,7 @@ class DrawConsumer(AsyncJsonWebsocketConsumer):
return await self.alert("This is not your turn.", 'danger') return await self.alert("This is not your turn.", 'danger')
while True: while True:
problem = randint(1, settings.PROBLEM_COUNT) problem = randint(1, len(settings.PROBLEMS))
if await TeamDraw.objects.filter(participation_id=td.participation_id, if await TeamDraw.objects.filter(participation_id=td.participation_id,
round__draw__tournament=self.tournament, round__draw__tournament=self.tournament,
round__number=1, round__number=1,
@ -431,7 +431,8 @@ class DrawConsumer(AsyncJsonWebsocketConsumer):
await td.asave() await td.asave()
trigram = await sync_to_async(lambda: td.participation.team.trigram)() trigram = await sync_to_async(lambda: td.participation.team.trigram)()
msg = f"L'équipe <strong>{trigram}</strong> a accepté le problème <strong>{td.accepted}</strong>. " msg = f"L'équipe <strong>{trigram}</strong> a accepté le problème <strong>{td.accepted} : " \
f"{settings.PROBLEMS[td.accepted - 1]}</strong>. "
if pool.size == 5 and await pool.teamdraw_set.filter(accepted=td.accepted).acount() < 2: if pool.size == 5 and await pool.teamdraw_set.filter(accepted=td.accepted).acount() < 2:
msg += "Une équipe peut encore l'accepter." msg += "Une équipe peut encore l'accepter."
else: else:
@ -574,10 +575,11 @@ class DrawConsumer(AsyncJsonWebsocketConsumer):
td.purposed = None td.purposed = None
await td.asave() await td.asave()
remaining = settings.PROBLEM_COUNT - 5 - len(td.rejected) remaining = len(settings.PROBLEMS) - 5 - len(td.rejected)
trigram = await sync_to_async(lambda: td.participation.team.trigram)() trigram = await sync_to_async(lambda: td.participation.team.trigram)()
msg = f"L'équipe <strong>{trigram}</strong> a refusé le problème <strong>{problem}</strong>. " msg = f"L'équipe <strong>{trigram}</strong> a refusé le problème <strong>{problem} : " \
f"{settings.PROBLEMS[problem - 1]}</strong>. "
if remaining >= 0: if remaining >= 0:
msg += f"Il lui reste {remaining} refus sans pénalité." msg += f"Il lui reste {remaining} refus sans pénalité."
else: else:

View File

@ -96,10 +96,10 @@ class Draw(models.Model):
tirer un nouveau problème immédiatement, ou bien revenir sur son choix.""" tirer un nouveau problème immédiatement, ou bien revenir sur son choix."""
else: else:
s += "Elle peut décider d'accepter ou de refuser ce problème. " s += "Elle peut décider d'accepter ou de refuser ce problème. "
if len(td.rejected) >= settings.PROBLEM_COUNT - 5: if len(td.rejected) >= len(settings.PROBLEMS) - 5:
s += "Refuser ce problème ajoutera une nouvelle pénalité de 0.5 sur le coefficient de l'oral de læ défenseur⋅se." s += "Refuser ce problème ajoutera une nouvelle pénalité de 0.5 sur le coefficient de l'oral de læ défenseur⋅se."
else: else:
s += f"Il reste {settings.PROBLEM_COUNT - 5 - len(td.rejected)} refus sans pénalité." s += f"Il reste {len(settings.PROBLEMS) - 5 - len(td.rejected)} refus sans pénalité."
case 'WAITING_FINAL': case 'WAITING_FINAL':
s += "Le tirage au sort pour le tour 2 aura lieu à la fin du premier tour. Bon courage !" s += "Le tirage au sort pour le tour 2 aura lieu à la fin du premier tour. Bon courage !"
case 'DRAW_ENDED': case 'DRAW_ENDED':
@ -318,7 +318,7 @@ class TeamDraw(models.Model):
accepted = models.PositiveSmallIntegerField( accepted = models.PositiveSmallIntegerField(
choices=[ choices=[
(i, format_lazy(_("Problem #{problem}"), problem=i)) for i in range(1, settings.PROBLEM_COUNT + 1) (i, format_lazy(_("Problem #{problem}"), problem=i)) for i in range(1, len(settings.PROBLEMS) + 1)
], ],
null=True, null=True,
default=None, default=None,
@ -341,7 +341,7 @@ class TeamDraw(models.Model):
purposed = models.PositiveSmallIntegerField( purposed = models.PositiveSmallIntegerField(
choices=[ choices=[
(i, format_lazy(_("Problem #{problem}"), problem=i)) for i in range(1, settings.PROBLEM_COUNT + 1) (i, format_lazy(_("Problem #{problem}"), problem=i)) for i in range(1, len(settings.PROBLEMS) + 1)
], ],
null=True, null=True,
default=None, default=None,
@ -359,7 +359,7 @@ class TeamDraw(models.Model):
@property @property
def penalty_int(self): def penalty_int(self):
return max(0, len(self.rejected) - (settings.PROBLEM_COUNT - 5)) return max(0, len(self.rejected) - (len(settings.PROBLEMS) - 5))
@property @property
def penalty(self): def penalty(self):

View File

@ -431,7 +431,7 @@ class Passage(models.Model):
solution_number = models.PositiveSmallIntegerField( solution_number = models.PositiveSmallIntegerField(
verbose_name=_("defended solution"), verbose_name=_("defended solution"),
choices=[ choices=[
(i, format_lazy(_("Problem #{problem}"), problem=i)) for i in range(1, settings.PROBLEM_COUNT + 1) (i, format_lazy(_("Problem #{problem}"), problem=i)) for i in range(1, len(settings.PROBLEMS) + 1)
], ],
) )
@ -585,7 +585,7 @@ class Solution(models.Model):
problem = models.PositiveSmallIntegerField( problem = models.PositiveSmallIntegerField(
verbose_name=_("problem"), verbose_name=_("problem"),
choices=[ choices=[
(i, format_lazy(_("Problem #{problem}"), problem=i)) for i in range(1, settings.PROBLEM_COUNT + 1) (i, format_lazy(_("Problem #{problem}"), problem=i)) for i in range(1, len(settings.PROBLEMS) + 1)
], ],
) )

View File

@ -234,7 +234,16 @@ PHONENUMBER_DEFAULT_REGION = 'FR'
GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY") GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")
# Custom parameters # Custom parameters
PROBLEM_COUNT = 8 PROBLEMS = [
"Philatélie",
"La montagne aux ruisseaux",
"Appoint monétaire",
"Musique déformée",
"Angles entiers",
"Tribus hiérarchiques",
"Miroirs et lasers",
"Graine de deck",
]
FORBIDDEN_TRIGRAMS = [ FORBIDDEN_TRIGRAMS = [
"BIT", "BIT",
"CNO", "CNO",