feat: print includes answer only after unlocking solutions

- If solutions already unlocked (full mode), print button shows '打印题目+答案'
- If not unlocked, print button shows '打印题目' (problem only)
- No longer forces unlock when printing

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
这个提交包含在:
cryptocommuniums-afk
2026-02-16 21:19:57 +08:00
父节点 093b8c5bc3
当前提交 2b6def2560
修改 7 个文件,包含 1638 行新增123 行删除

查看文件

@@ -0,0 +1,43 @@
#!/usr/bin/env python3
from __future__ import annotations
import argparse
from pathlib import Path
def main():
ap = argparse.ArgumentParser()
ap.add_argument('--file', required=True)
ap.add_argument('--items', required=True)
args = ap.parse_args()
p = Path(args.file)
items = Path(args.items).read_text(encoding='utf-8')
s = p.read_text(encoding='utf-8')
marker = 'const CourseItem items[] = {'
i = s.find(marker)
if i < 0:
raise SystemExit(f'cannot find marker: {marker}')
j = s.find('};', i)
if j < 0:
raise SystemExit('cannot find end marker "};" after items start')
before = s[:i]
after = s[j+2:]
out = before + items + after
if out == s:
print('no change')
return
backup = p.with_suffix(p.suffix + '.bak_cppbasic20')
backup.write_text(s, encoding='utf-8')
p.write_text(out, encoding='utf-8')
print('patched', str(p))
print('backup', str(backup))
if __name__ == '__main__':
main()