Skip to content

Commit

Permalink
Fix stat export (force translation). ref #1929
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn committed Feb 18, 2023
1 parent 925fbfa commit 42a5b4d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
9 changes: 6 additions & 3 deletions core/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,17 @@
QUESTION_TYPE_VF_CHOICE_LIST = ["a", "b"]
QUESTION_TYPE_QCM_CHOICE_LIST = ["a", "b", "c", "d"]

QUESTION_DIFFICULTY_JUNIOR = 0
QUESTION_DIFFICULTY_EASY = 1
QUESTION_DIFFICULTY_MEDIUM = 2
QUESTION_DIFFICULTY_HARD = 3
QUESTION_DIFFICULTY_EXPERT = 4
QUESTION_DIFFICULTY_OPTIONS = [
(0, _("Junior"), "🧸"),
(QUESTION_DIFFICULTY_JUNIOR, _("Junior"), "🧸"),
(QUESTION_DIFFICULTY_EASY, _("Easy"), "🏆"),
(2, _("Medium"), "🏆🏆"),
(QUESTION_DIFFICULTY_MEDIUM, _("Medium"), "🏆🏆"),
(QUESTION_DIFFICULTY_HARD, _("Hard"), "🏆🏆🏆"),
(4, _("Expert"), "🏆🏆🏆🏆"),
(QUESTION_DIFFICULTY_EXPERT, _("Expert"), "🏆🏆🏆🏆"),
]
QUESTION_DIFFICULTY_CHOICES = [(c[0], c[1]) for c in QUESTION_DIFFICULTY_OPTIONS]
QUESTION_DIFFICULTY_CHOICE_LIST = [c[0] for c in QUESTION_DIFFICULTY_OPTIONS]
Expand Down
4 changes: 3 additions & 1 deletion core/management/commands/export_stats_to_github.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import yaml
from django.conf import settings
from django.core.management import BaseCommand
from django.utils import timezone
from django.utils import timezone, translation

from core.models import Configuration
from core.utils import github, utilities
Expand All @@ -18,6 +18,8 @@ class Command(BaseCommand):
"""

def handle(self, *args, **options):
translation.activate("en")

# init
start_time = time.time()

Expand Down
2 changes: 1 addition & 1 deletion stats/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def difficulty_aggregate():
for value, name, emoji in constants.QUESTION_DIFFICULTY_OPTIONS:
difficulty_levels.append(
{
"name": name,
"name": str(name), # force gettext_lazy evaluation
"value": value,
"emoji": emoji,
"question_count": next(
Expand Down

0 comments on commit 42a5b4d

Please sign in to comment.