release: prepare Hulumath v1.2.0
This commit is contained in:
@@ -180,3 +180,13 @@ def test_math_life_使用独立界面印记面板且清理交叉点():
|
||||
assert "function renderStoryMarks(run)" in app
|
||||
assert "choice.special" in app
|
||||
assert ".story-experience { position: fixed; inset: 0" in styles
|
||||
|
||||
|
||||
def test_home_公众号入口可复制并跳转微信():
|
||||
template = (settings.BASE_DIR / "templates" / "index.html").read_text(encoding="utf-8")
|
||||
app = (STATIC_ROOT / "js" / "app.js").read_text(encoding="utf-8")
|
||||
|
||||
assert 'id="wechat-copy"' in template
|
||||
assert 'href="weixin://"' in template
|
||||
assert "function copyWechatName()" in app
|
||||
assert 'navigator.clipboard.writeText(name)' in app
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import pytest
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_health_包含当前发布版本(client):
|
||||
response = client.get("/health/")
|
||||
|
||||
assert response.status_code == 200
|
||||
assert response.json() == {
|
||||
"status": "ok",
|
||||
"database": "ok",
|
||||
"version": settings.APP_VERSION,
|
||||
}
|
||||
|
||||
|
||||
def test_home_展示公众号入口与版本(client):
|
||||
response = client.get("/")
|
||||
content = response.content.decode()
|
||||
|
||||
assert response.status_code == 200
|
||||
assert "公众号" in content
|
||||
assert "葫芦数学" in content
|
||||
assert f"Hulumath v{settings.APP_VERSION}" in content
|
||||
assert 'href="weixin://"' in content
|
||||
@@ -1,14 +1,21 @@
|
||||
from django.conf import settings
|
||||
from django.db import connection
|
||||
from django.http import JsonResponse
|
||||
from django.shortcuts import render
|
||||
|
||||
|
||||
def home(request):
|
||||
return render(request, "index.html")
|
||||
return render(request, "index.html", {"app_version": settings.APP_VERSION})
|
||||
|
||||
|
||||
def health(request):
|
||||
with connection.cursor() as cursor:
|
||||
cursor.execute("SELECT 1")
|
||||
cursor.fetchone()
|
||||
return JsonResponse({"status": "ok", "database": "ok"})
|
||||
return JsonResponse(
|
||||
{
|
||||
"status": "ok",
|
||||
"database": "ok",
|
||||
"version": settings.APP_VERSION,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -6,6 +6,7 @@ from django.core.exceptions import ImproperlyConfigured
|
||||
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
PROJECT_ROOT = BASE_DIR.parent
|
||||
APP_VERSION = os.getenv("APP_VERSION", "1.2.0")
|
||||
|
||||
SECRET_KEY = os.getenv("DJANGO_SECRET_KEY", "dev-only-change-before-production")
|
||||
DEBUG = os.getenv("DJANGO_DEBUG", "true").lower() == "true"
|
||||
|
||||
@@ -117,6 +117,21 @@ def _generate_advanced():
|
||||
result = n * (n + 1) // 2
|
||||
questions.append((f"a-auto-sum-{idx:04d}", f"1 到 {n} 的整数和", str(result)))
|
||||
idx += 1
|
||||
# 一元一次方程,补足稳定的 200 题池
|
||||
for solution in range(2, 60):
|
||||
if idx >= 200:
|
||||
break
|
||||
coefficient = solution % 7 + 2
|
||||
offset = solution % 11 + 1
|
||||
total = coefficient * solution + offset
|
||||
questions.append(
|
||||
(
|
||||
f"a-auto-linear-{idx:04d}",
|
||||
f"{coefficient}x + {offset} = {total},求 x",
|
||||
str(solution),
|
||||
)
|
||||
)
|
||||
idx += 1
|
||||
return questions[:200]
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def fill_advanced_pool(apps, schema_editor):
|
||||
Contest = apps.get_model("contest", "Contest")
|
||||
ContestQuestion = apps.get_model("contest", "ContestQuestion")
|
||||
Question = apps.get_model("contest", "Question")
|
||||
QuestionVersion = apps.get_model("contest", "QuestionVersion")
|
||||
|
||||
versions = []
|
||||
for offset, solution in enumerate(range(2, 22), start=180):
|
||||
coefficient = solution % 7 + 2
|
||||
constant = solution % 11 + 1
|
||||
total = coefficient * solution + constant
|
||||
question, _ = Question.objects.update_or_create(
|
||||
slug=f"a-auto-linear-{offset:04d}",
|
||||
defaults={
|
||||
"track": "advanced",
|
||||
"tags": ["口算"],
|
||||
"is_active": True,
|
||||
},
|
||||
)
|
||||
version, _ = QuestionVersion.objects.update_or_create(
|
||||
question=question,
|
||||
version=1,
|
||||
defaults={
|
||||
"prompt": f"{coefficient}x + {constant} = {total},求 x",
|
||||
"answer": str(solution),
|
||||
"explanation": f"答案为 {solution}",
|
||||
},
|
||||
)
|
||||
versions.append(version)
|
||||
|
||||
for contest in Contest.objects.filter(track="advanced").iterator():
|
||||
existing_ids = set(
|
||||
ContestQuestion.objects.filter(contest=contest).values_list(
|
||||
"question_version_id",
|
||||
flat=True,
|
||||
)
|
||||
)
|
||||
next_order = (
|
||||
ContestQuestion.objects.filter(contest=contest)
|
||||
.order_by("-order")
|
||||
.values_list("order", flat=True)
|
||||
.first()
|
||||
or 0
|
||||
)
|
||||
additions = []
|
||||
for version in versions:
|
||||
if version.id in existing_ids:
|
||||
continue
|
||||
next_order += 1
|
||||
additions.append(
|
||||
ContestQuestion(
|
||||
contest_id=contest.id,
|
||||
question_version_id=version.id,
|
||||
order=next_order,
|
||||
points=100,
|
||||
)
|
||||
)
|
||||
ContestQuestion.objects.bulk_create(additions)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("contest", "0007_remove_realtimematch_matchmaking_lookup_idx_and_more"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(
|
||||
fill_advanced_pool,
|
||||
migrations.RunPython.noop,
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,8 @@
|
||||
from contest.management.commands.seed_contests import QUESTIONS
|
||||
from contest.models import Question
|
||||
|
||||
|
||||
def test_seed_question_pool_三个历史赛道题量充足():
|
||||
assert len(QUESTIONS[Question.Track.BEGINNER]) == 400
|
||||
assert len(QUESTIONS[Question.Track.STANDARD]) == 400
|
||||
assert len(QUESTIONS[Question.Track.ADVANCED]) == 200
|
||||
@@ -50,6 +50,7 @@ button { color: inherit; }
|
||||
.sidebar-foot { margin-top: auto; display: grid; gap: 15px; }
|
||||
.system-status { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
|
||||
.system-status i { width: 7px; height: 7px; margin-right: 7px; display: inline-block; border-radius: 50%; background: #5bb67c; box-shadow: 0 0 0 4px rgba(91,182,124,.13); }
|
||||
.app-version { color: var(--muted); font-size: 9px; letter-spacing: .1em; }
|
||||
.ghost-button, .text-button {
|
||||
background: transparent; border: 1px solid var(--line); border-radius: 10px; padding: 11px 14px; cursor: pointer;
|
||||
}
|
||||
@@ -79,6 +80,7 @@ button { color: inherit; }
|
||||
content: ""; position: absolute; width: 330px; height: 330px; right: -100px; bottom: -150px;
|
||||
border: 55px solid rgba(25,101,72,.09); border-radius: 50%;
|
||||
}
|
||||
.wechat-entry { display: flex; align-items: center; justify-content: space-between; gap: 28px; margin-top: 18px; padding: 28px 32px; border: 1px solid rgba(25,101,72,.16); border-radius: 20px; background: linear-gradient(120deg, rgba(25,101,72,.08), rgba(204,232,91,.18)); }.wechat-entry h2 { margin: 8px 0; font: 28px Georgia, serif; }.wechat-entry p { margin: 0; color: var(--muted); line-height: 1.7; }.wechat-entry-actions { display: flex; gap: 9px; flex-shrink: 0; }.wechat-entry-actions a { display: inline-flex; align-items: center; text-decoration: none; }
|
||||
.kicker { color: var(--green); font-size: 10px; font-weight: 700; letter-spacing: .24em; }
|
||||
.hero h1, .page-title h1 { margin: 20px 0 18px; font: 500 clamp(42px, 5vw, 76px)/1.03 Georgia, "Songti SC", serif; letter-spacing: -.04em; }
|
||||
.hero h1 em { color: var(--green); font-weight: inherit; }
|
||||
@@ -307,6 +309,7 @@ dialog::backdrop { background: rgba(17,25,20,.55); backdrop-filter: blur(5px); }
|
||||
.match-mode-switch { grid-template-columns: 1fr; }
|
||||
.board-online-panel { grid-template-columns: 1fr; }.board-online-panel > div, .board-online-panel form { display: grid; grid-template-columns: 1fr; }.board-online-panel p, .board-online-panel > strong { grid-column: 1; }
|
||||
.story-experience { padding: 14px 14px 40px; }.story-experience-header { align-items: flex-start; }.story-experience-header .ghost-button { width: auto; padding: 9px 11px; font-size: 10px; }.story-chapter-bar, .story-experience-layout { grid-template-columns: 1fr; }.story-scene-panel { min-height: 0; padding: 25px 20px; }.story-scene-panel .scene { min-height: 120px; }.story-mark-panel { position: static; }.story-domain-counts { grid-template-columns: repeat(2, 1fr); }
|
||||
.wechat-entry { align-items: flex-start; flex-direction: column; padding: 24px; }.wechat-entry-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }.wechat-entry-actions > * { justify-content: center; text-align: center; }
|
||||
.tool-card { min-height: 125px; }.workspace-heading, .map-heading { display: block; }.workspace-heading p { margin-top: 12px; }.tool-workspace { padding: 16px; }.calculator-controls { grid-template-columns: 1fr 1fr; }.calculator-display { min-height: 120px; padding: 18px; }.calculator-display output { font-size: 34px; }.calc-examples .primary-button { width: 100%; margin-left: 0; }.drawing-toolbar { align-items: stretch; }.drawing-toolbar .primary-button { width: 100%; margin-left: 0; }.canvas-stage canvas { width: 100%; min-width: 0; }
|
||||
.math-games-section { margin-top: 45px; }.game-card { min-height: 260px; padding: 21px; }.game-card-controls { align-items: stretch; }.game-card-controls .primary-button { flex: 1; }.twenty-four-numbers { gap: 7px; }.twenty-four-numbers button { border-radius: 13px; font-size: 28px; }.sudoku-board input { font-size: clamp(13px, 4.5vw, 20px); }.sudoku-actions { display: grid; grid-template-columns: 1fr 1fr; }.game-keypad { gap: 5px; }
|
||||
.challenge-panel { grid-template-columns: 1fr; padding: 20px; }.challenge-actions form { grid-template-columns: 1fr; }.challenge-actions .dark-button { width: 100%; }.challenge-code { width: 100%; padding: 14px 10px; font-size: 27px; }.realtime-status-line { display: grid; }.realtime-progress-panel { grid-template-columns: 1fr 1fr; }
|
||||
|
||||
@@ -148,6 +148,16 @@ function showToast(message) {
|
||||
window.setTimeout(() => toast.classList.remove("show"), 2600);
|
||||
}
|
||||
|
||||
async function copyWechatName() {
|
||||
const name = $("#wechat-copy").dataset.wechatName;
|
||||
try {
|
||||
await navigator.clipboard.writeText(name);
|
||||
showToast(`已复制公众号名称:${name}`);
|
||||
} catch {
|
||||
showToast(`请在微信内搜索:${name}`);
|
||||
}
|
||||
}
|
||||
|
||||
function navigate(view) {
|
||||
$$(".nav-item").forEach((button) => button.classList.toggle("active", button.dataset.view === view));
|
||||
$$(".view").forEach((section) => section.classList.toggle("active", section.id === `view-${view}`));
|
||||
@@ -1273,6 +1283,7 @@ function bindUI() {
|
||||
$$("[data-jump]").forEach((button) => button.addEventListener("click", () => navigate(button.dataset.jump)));
|
||||
$$("[data-open-auth]").forEach((button) => button.addEventListener("click", openAuth));
|
||||
$("#start-mathbti").addEventListener("click", startMathBTI);
|
||||
$("#wechat-copy").addEventListener("click", copyWechatName);
|
||||
$("#story-experience-close").addEventListener("click", closeStoryExperience);
|
||||
$("#save-formula").addEventListener("click", saveFormula);
|
||||
$("#latex-source").addEventListener("input", (event) => { renderLatexPreview(event.target.value); });
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
</nav>
|
||||
<div class="sidebar-foot">
|
||||
<div class="system-status"><i></i>系统在线</div>
|
||||
<small class="app-version">Hulumath v{{ app_version }}</small>
|
||||
<button id="auth-button" class="ghost-button">登录 / 注册</button>
|
||||
</div>
|
||||
</aside>
|
||||
@@ -66,6 +67,18 @@
|
||||
</article>
|
||||
</div>
|
||||
|
||||
<section class="wechat-entry">
|
||||
<div>
|
||||
<span class="kicker">WECHAT OFFICIAL ACCOUNT</span>
|
||||
<h2>在公众号继续收到数学人生更新</h2>
|
||||
<p>微信内搜索公众号「葫芦数学」,获取新剧情、比赛活动与版本公告。</p>
|
||||
</div>
|
||||
<div class="wechat-entry-actions">
|
||||
<button id="wechat-copy" class="ghost-button" data-wechat-name="葫芦数学">复制公众号名称</button>
|
||||
<a class="primary-button" href="weixin://">打开微信</a>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<div class="section-heading">
|
||||
<div><span class="kicker">FOUR SPIRITS</span><h2>四种数学精神</h2></div>
|
||||
|
||||
Reference in New Issue
Block a user