Skip to content

Commit

Permalink
Merge pull request #14 from SkyEye-FAST/SkyEye-FAST/issue7
Browse files Browse the repository at this point in the history
提示、跳过、计分功能
  • Loading branch information
SkyEye-FAST authored Jul 23, 2024
2 parents 941f96d + d03bcdc commit 62c583d
Show file tree
Hide file tree
Showing 33 changed files with 52,038 additions and 319 deletions.
22 changes: 11 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
.idea
.vercel
.env

__pycache__/
group_code.py
rating.py
hist.py

tongyong_guifan.txt

.idea
.vercel
.env

__pycache__/
group_code.py
rating.py
hist.py

tongyong_guifan.txt

I.Ming*.ttf
23 changes: 20 additions & 3 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import geoip2.errors

from app_base import P
from app_init import data, id_map, get_translation
from app_init import data, id_map, rating, get_translation

# 初始化 Flask 应用
flask_app = Flask(__name__)
Expand All @@ -40,7 +40,7 @@ def get_locale() -> str:
"""

locale = request.accept_languages.best_match(
["zh_CN", "zh_TW", "zh", "en"], default="en"
["zh_CN", "zh_TW", "zh", "en"], default="zh_CN"
)
if locale == "zh":
return "zh_CN"
Expand Down Expand Up @@ -336,7 +336,8 @@ def get_questions() -> str:
str: 题组编号。
"""

random_keys = sorted(sample(list(id_map.keys()), QUESTION_AMOUNT))
keys = list(id_map.keys())
random_keys = sorted(sample(keys, QUESTION_AMOUNT), key=lambda x: id_map[x])
return "".join(random_keys)


Expand Down Expand Up @@ -395,12 +396,16 @@ def quiz_sub(code: str) -> str:
key: {"source": data["en_us"][key], "translation": data[lang][key]}
for key in keys
}
if lang == "zh_cn":
for k, d in questions.items():
d["rating"] = rating[k]

p2 = _l("Enter translation here...")

return render_template(
"quiz_sub.html",
lang=lang.replace("_", "-"),
locale=session["locale"],
questions=questions,
placeholder=p2,
random_code=get_questions(),
Expand All @@ -419,6 +424,18 @@ def favicon() -> str:
return send_from_directory("static", "favicon.ico")


@flask_app.route("/apple-touch-icon.png")
def apple_touch_icon() -> str:
"""
apple-touch-icon.png 重定向路由。
Returns:
str: 静态文件 apple-touch-icon.png 的路径。
"""

return send_from_directory("static", "apple-touch-icon.png")


@flask_app.route("/table.tsv")
def table_tsv() -> str:
"""
Expand Down
1 change: 1 addition & 0 deletions app_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
LANG_DIR_FULL = LANG_DIR / "full"
LANG_DIR_VALID = LANG_DIR / "valid"
ID_MAP_PATH = P / "static" / "id.json"
RATING_PATH = P / "static" / "rating.json"

# 语言列表
language_list = [
Expand Down
6 changes: 5 additions & 1 deletion app_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import json
from typing import Dict

from app_base import LANG_DIR, LANG_DIR_VALID, ID_MAP_PATH, language_list
from app_base import LANG_DIR, LANG_DIR_VALID, ID_MAP_PATH, RATING_PATH, language_list

# 是否忽略补充字符串
IGNORE_SUPPLEMENTS: bool = True
Expand All @@ -19,6 +19,10 @@
with open(ID_MAP_PATH, "r", encoding="utf-8") as f:
id_map = json.load(f)

# 读取题目评级
with open(RATING_PATH, "r", encoding="utf-8") as f:
rating = json.load(f)

# 读取补充字符串
if not IGNORE_SUPPLEMENTS:
language_list.remove("en_us")
Expand Down
3,988 changes: 3,988 additions & 0 deletions data/archive/zh_cn_1132.json

Large diffs are not rendered by default.

4,326 changes: 4,326 additions & 0 deletions data/archive/zh_cn_1144.json

Large diffs are not rendered by default.

4,387 changes: 4,387 additions & 0 deletions data/archive/zh_cn_1152.json

Large diffs are not rendered by default.

4,812 changes: 4,812 additions & 0 deletions data/archive/zh_cn_1165.json

Large diffs are not rendered by default.

5,140 changes: 5,140 additions & 0 deletions data/archive/zh_cn_1171.json

Large diffs are not rendered by default.

5,163 changes: 5,163 additions & 0 deletions data/archive/zh_cn_1182.json

Large diffs are not rendered by default.

6,062 changes: 6,062 additions & 0 deletions data/archive/zh_cn_1194.json

Large diffs are not rendered by default.

6,770 changes: 6,770 additions & 0 deletions data/archive/zh_cn_1206.json

Large diffs are not rendered by default.

6,881 changes: 6,881 additions & 0 deletions data/archive/zh_cn_121.json

Large diffs are not rendered by default.

135 changes: 135 additions & 0 deletions data/changed.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
{
"1.2": {
"block.minecraft.chorus_flower": "紫颂花",
"item.minecraft.chorus_fruit": "紫颂果",
"item.minecraft.popped_chorus_fruit": "爆裂紫颂果",
"block.minecraft.lava": "熔岩",
"item.minecraft.lava_bucket": "熔岩桶",
"block.minecraft.cut_red_sandstone": "切制红砂岩",
"block.minecraft.cut_red_sandstone_slab": "切制红砂岩台阶",
"block.minecraft.cut_sandstone": "切制砂岩",
"block.minecraft.cut_sandstone_slab": "切制砂岩台阶",
"block.minecraft.red_sandstone": "红砂岩",
"block.minecraft.red_sandstone_slab": "红砂岩台阶",
"block.minecraft.red_sandstone_stairs": "红砂岩楼梯",
"block.minecraft.red_sandstone_wall": "红砂岩墙",
"block.minecraft.sandstone": "砂岩",
"block.minecraft.sandstone_slab": "砂岩台阶",
"block.minecraft.sandstone_stairs": "砂岩楼梯",
"block.minecraft.sandstone_wall": "砂岩墙",
"item.minecraft.glowstone_dust": "荧石粉",
"block.minecraft.glowstone": "荧石",
"block.minecraft.poppy": "虞美人"
},
"1.6": {
"item.minecraft.clock": "时钟",
"block.minecraft.dead_bush": "枯萎的灌木",
"block.minecraft.creeper_head": "苦力怕的头",
"block.minecraft.creeper_wall_head": "墙上的苦力怕的头",
"entity.minecraft.creeper": "苦力怕",
"item.minecraft.creeper_banner_pattern": "旗帜图案",
"item.minecraft.creeper_spawn_egg": "苦力怕刷怪蛋",
"block.minecraft.acacia_button": "金合欢木按钮",
"block.minecraft.acacia_door": "金合欢木门",
"block.minecraft.acacia_fence": "金合欢木栅栏",
"block.minecraft.acacia_fence_gate": "金合欢木栅栏门",
"block.minecraft.acacia_hanging_sign": "悬挂式金合欢木告示牌",
"block.minecraft.acacia_leaves": "金合欢树叶",
"block.minecraft.acacia_log": "金合欢原木",
"block.minecraft.acacia_planks": "金合欢木板",
"block.minecraft.acacia_pressure_plate": "金合欢木压力板",
"block.minecraft.acacia_sapling": "金合欢树苗",
"block.minecraft.acacia_sign": "金合欢木告示牌",
"block.minecraft.acacia_slab": "金合欢木台阶",
"block.minecraft.acacia_stairs": "金合欢木楼梯",
"block.minecraft.acacia_trapdoor": "金合欢木活板门",
"block.minecraft.acacia_wall_hanging_sign": "墙上的悬挂式金合欢木告示牌",
"block.minecraft.acacia_wall_sign": "墙上的金合欢木告示牌",
"block.minecraft.acacia_wood": "金合欢木",
"block.minecraft.spawner": "刷怪笼",
"block.minecraft.trial_spawner": "试炼刷怪笼",
"entity.minecraft.spawner_minecart": "刷怪笼矿车",
"block.minecraft.cracked_nether_bricks": "裂纹下界砖块",
"block.minecraft.nether_brick_fence": "下界砖栅栏",
"block.minecraft.nether_brick_slab": "下界砖台阶",
"block.minecraft.nether_brick_stairs": "下界砖楼梯",
"block.minecraft.nether_brick_wall": "下界砖墙",
"block.minecraft.nether_bricks": "下界砖块",
"block.minecraft.red_nether_brick_slab": "红色下界砖台阶",
"block.minecraft.red_nether_brick_stairs": "红色下界砖楼梯",
"block.minecraft.red_nether_brick_wall": "红色下界砖墙",
"block.minecraft.red_nether_bricks": "红色下界砖块",
"item.minecraft.nether_brick": "下界砖",
"block.minecraft.nether_wart": "下界疣",
"block.minecraft.nether_wart_block": "下界疣块",
"block.minecraft.netherrack": "下界岩",
"block.minecraft.purpur_pillar": "紫珀柱",
"block.minecraft.quartz_pillar": "石英柱",
"block.minecraft.slime_block": "黏液块",
"block.minecraft.sticky_piston": "黏性活塞",
"item.minecraft.clay_ball": "黏土球",
"item.minecraft.slime_ball": "黏液球"
},
"2.2": {
"block.minecraft.azure_bluet": "蓝花美耳草",
"block.minecraft.cracked_stone_bricks": "裂纹石砖",
"item.minecraft.milk_bucket": "奶桶",
"entity.minecraft.sheep": "绵羊",
"block.minecraft.chorus_plant": "紫颂植株",
"biome.minecraft.deep_frozen_ocean": "冰冻深海",
"block.minecraft.powered_rail": "动力铁轨",
"block.minecraft.smooth_stone_slab": "平滑石头台阶",
"block.minecraft.stone_pressure_plate": "石头压力板",
"block.minecraft.stone_slab": "石头台阶",
"block.minecraft.stone_stairs": "石头楼梯",
"block.minecraft.brick_slab": "红砖台阶",
"block.minecraft.brick_stairs": "红砖楼梯",
"block.minecraft.brick_wall": "红砖墙",
"block.minecraft.bricks": "红砖块",
"block.minecraft.creeper_wall_head": "墙上的苦力怕的头",
"biome.minecraft.end_barrens": "末地荒地",
"biome.minecraft.end_highlands": "末地高地",
"biome.minecraft.end_midlands": "末地内陆",
"entity.minecraft.end_crystal": "末地水晶",
"block.minecraft.light": "光源方块",
"block.minecraft.player_head": "玩家的头",
"block.minecraft.player_wall_head": "墙上的玩家的头",
"entity.minecraft.shulker_bullet": "潜影弹",
"block.minecraft.zombie_wall_head": "墙上的僵尸的头",
"item.minecraft.lingering_potion.effect.awkward": "滞留型粗制的药水",
"item.minecraft.splash_potion.effect.awkward": "喷溅型粗制的药水",
"block.minecraft.chiseled_deepslate": "雕纹深板岩",
"block.minecraft.chiseled_nether_bricks": "雕纹下界砖块",
"block.minecraft.chiseled_polished_blackstone": "雕纹磨制黑石",
"block.minecraft.chiseled_quartz_block": "雕纹石英块",
"block.minecraft.chiseled_red_sandstone": "雕纹红砂岩",
"block.minecraft.chiseled_sandstone": "雕纹砂岩",
"block.minecraft.chiseled_stone_bricks": "雕纹石砖",
"block.minecraft.potted_wither_rose": "凋灵玫瑰盆栽",
"block.minecraft.wither_rose": "凋灵玫瑰",
"item.minecraft.bucket": "铁桶",
"block.minecraft.carved_pumpkin": "雕刻南瓜",
"biome.minecraft.eroded_badlands": "风蚀恶地",
"enchantment.minecraft.feather_falling": "摔落缓冲",
"effect.minecraft.fire_resistance": "抗火",
"block.minecraft.hay_block": "干草捆",
"biome.minecraft.ice_spikes": "冰刺之地",
"block.minecraft.infested_chiseled_stone_bricks": "虫蚀雕纹石砖",
"block.minecraft.infested_cobblestone": "虫蚀圆石",
"block.minecraft.infested_cracked_stone_bricks": "虫蚀裂纹石砖",
"block.minecraft.infested_deepslate": "虫蚀深板岩",
"block.minecraft.infested_mossy_stone_bricks": "虫蚀苔石砖",
"block.minecraft.infested_stone": "虫蚀石头",
"block.minecraft.infested_stone_bricks": "虫蚀石砖",
"block.minecraft.moss_carpet": "覆地苔藓",
"block.minecraft.mycelium": "菌丝体",
"biome.minecraft.snowy_beach": "积雪沙滩",
"biome.minecraft.snowy_plains": "雪原",
"biome.minecraft.snowy_slopes": "积雪山坡",
"biome.minecraft.snowy_taiga": "积雪针叶林",
"effect.minecraft.speed": "迅捷",
"item.minecraft.suspicious_stew": "谜之炖菜",
"biome.minecraft.wooded_badlands": "疏林恶地",
"block.minecraft.clay": "黏土"
}
}
Loading

0 comments on commit 62c583d

Please sign in to comment.