Skip to content

ZeKaiNie/universal-examprep-skill / skills/universal-exam-cram-coach

universal-exam-cram-coach

Flagged

临考复习教练 / Exam cram coach. 学生给一个课程资料文件夹(课件 PDF/PPTX/DOCX/笔记/作业/答案/真题/往年卷),它按章节讲解并标出处、把讲义和题目里的图裁出来展示、只用资料里的题考试判分、记错题和笔记、按天排复习计划、做小抄,并标明每句话是否来自资料。触发词:期末、期中、考试、备考、复习、突击、刷题、真题、作业讲解、错题本、划重点、小抄、复习计划、考研、考证、课件讲解、讲义。Use when a student wants to prepare for a final, midterm or any exam from their own course files: teach chapter by chapter with page citations and the figures cropped from the materials, quiz only from the homework and past papers, keep progress, mistakes and notes across chats, plan the remaining days, build a cheat sheet, and label what comes from the materials. Triggers: exam prep, cram, revise, study for the test, lecture slides, homework solutions, past papers, practice questions, quiz me, mistake log, cheat sheet, study plan, study guide, flashcards.

FileKindSize
LICENSEother1.0 KB
SKILL.mdskill md10.3 KB
coach.pyscript286 B
coach/__init__.pyscript154 B
coach/chapters.pyscript8.1 KB
coach/cli.pyscript58.3 KB
coach/extract.pyscript11.3 KB
coach/figures.pyscript13.1 KB
coach/guard.pyscript6.6 KB
coach/index.pyscript2.4 KB
coach/questions.pyscript15.3 KB
coach/state.pyscript6.4 KB
coach/text.pyscript4.0 KB

coach/state.py

View on GitHub
# -*- coding: utf-8 -*-
"""study_state.json: the one file that remembers progress. progress.md and notebook.md are views."""
import datetime as _dt
import json
import os

STATE_FILE = "study_state.json"
PROGRESS_FILE = "progress.md"
NOTEBOOK_FILE = "notebook.md"


def now():
    return _dt.datetime.now().strftime("%Y-%m-%d %H:%M")


def exam_date_in(days, today=None):
    """ISO date `days` from today (the exam day), or None."""
    if days is None:
        return None
    return ((today or _dt.date.today()) + _dt.timedelta(days=max(0, days))).isoformat()


def days_left(state, today=None):
    """Whole days until the exam date (0 on the day itself), or None when no date is set."""
    d = state.get("exam_date")
    if not d:
        return None
    try:
        exam = _dt.date.fromisoformat(d)
    except ValueError:
        return None
    return max(0, (exam - (today or _dt.date.today())).days)


def new_state(course, language, exam_date, materials, chapters, slice_chars, profile="standard"):
    return {
        "version": 5,
        "course": course,
        "language": language,
        "exam_date": exam_date,
        "profile": profile,
        "materials": materials,
        "created": now(),
        "updated": now(),
        "slice_chars": slice_chars,
        "current": chapters[0]["n"] if chapters else None,
        "chapters": [
            {"n": c["n"], "title": c["title"], "status": "todo", "part": 0, "parts": c["parts"],
             "sources": c["sources"], "questions": c["questions"]}
            for c in chapters
        ],
        "history": [],   # {"qid","result","ts","chapter"}
        "mistakes": [],  # {"qid","chapter","note","status": open|fixed,"count"}
        "notes": [],     # {"chapter","type": summary|confusion|note,"text","ts"}
    }


def path(ws):
    return os.path.join(ws, STATE_FILE)


def load(ws):
    p = path(ws)
    if not os.path.exists(p):
        return None
    with open(p, encoding="utf-8") as fh:
        state = json.load(fh)
    if "exam_days" in state:  # before 5.3 the count was stored and never went down
        days = state.pop("exam_days")
        if days is not None and not state.get("exam_date"):
            try:
                start = _dt.date.fromisoformat(state.get("created", "")[:10])
            except ValueError:
                start = _dt.date.today()
            state["exam_date"] = exam_date_in(days, start)
    state.setdefault("exam_date", None)
    state.setdefault("profile", "standard")
    return state


def _atomic_write(p, text):
    tmp = p + ".tmp"
    with open(tmp, "w", encoding="utf-8") as fh:
        fh.write(text)
    os.replace(tmp, p)


def save(ws, state):
    state["updated"] = now()
    _atomic_write(path(ws), json.dumps(state, ensure_ascii=False, indent=1))
    _atomic_write(os.path.join(ws, PROGRESS_FILE), render_progress(state))
    _atomic_write(os.path.join(ws, NOTEBOOK_FILE), render_notebook(state))


def chapter(state, n=None):
    n = state["current"] if n is None else n
    for c in state["chapters"]:
        if c["n"] == n:
            return c
    return None


def open_mistakes(state, n=None):
    return [m for m in state["mistakes"] if m["status"] == "open" and (n is None or m["chapter"] == n)]


def record_result(state, qid, chapter_n, result, note=""):
    state["history"].append({"qid": qid, "result": result, "ts": now(), "chapter": chapter_n})
    existing = next((m for m in state["mistakes"] if m["qid"] == qid), None)
    if result in ("wrong", "skip"):
        if existing:
            existing["count"] += 1
            existing["status"] = "open"
            if note:
                existing["note"] = note
        else:
            state["mistakes"].append({"qid": qid, "chapter": chapter_n, "note": note, "status": "open", "count": 1})
    elif result == "right" and existing and existing["status"] == "open":
        existing["status"] = "fixed"


def chapter_results(state, n):
    right = sum(1 for h in state["history"] if h["chapter"] == n and h["result"] == "right")
    asked = sum(1 for h in state["history"] if h["chapter"] == n)
    return right, asked


def bar(done, total, width=10):
    filled = int(round(width * done / total)) if total else 0
    return "[" + "█" * filled + "░" * (width - filled) + "]"


def render_progress(state):
    zh = state["language"] == "zh"
    done = sum(1 for c in state["chapters"] if c["status"] in ("done", "verified"))
    total = len(state["chapters"])
    lines = ["# %s" % ("复习进度" if zh else "Study progress"), ""]
    lines.append("- %s: %s" % ("课程" if zh else "Course", state["course"]))
    lines.append("- %s: %s" % ("更新" if zh else "Updated", state["updated"]))
    lines.append("- %s: %s %d/%d" % ("章节" if zh else "Chapters", bar(done, total), done, total))
    lines.append("")
    lines.append("| # | %s | %s | %s |" % (("标题", "状态", "测验") if zh else ("Title", "Status", "Quiz")))
    lines.append("| --- | --- | --- | --- |")
    for c in state["chapters"]:
        right, asked = chapter_results(state, c["n"])
        mark = "→ " if c["n"] == state["current"] else ""
        lines.append("| %s%d | %s | %s | %d/%d |" % (mark, c["n"], c["title"], c["status"], right, asked))
    lines.append("")
    lines.append("## %s" % ("错题" if zh else "Mistakes"))
    om = [m for m in state["mistakes"] if m["status"] == "open"]
    if not om:
        lines.append("- (%s)" % ("暂无" if zh else "none"))
    for m in om:
        lines.append("- %s (ch%d, ×%d) %s" % (m["qid"], m["chapter"], m["count"], m.get("note", "")))
    lines.append("")
    conf = [n for n in state["notes"] if n["type"] == "confusion"]
    lines.append("## %s" % ("疑难点" if zh else "Confusions"))
    if not conf:
        lines.append("- (%s)" % ("暂无" if zh else "none"))
    for n in conf:
        lines.append("- ch%s: %s" % (n["chapter"], n["text"]))
    return "\n".join(lines) + "\n"


def render_notebook(state):
    zh = state["language"] == "zh"
    lines = ["# %s" % ("学习笔记" if zh else "Notebook"), ""]
    for c in state["chapters"]:
        notes = [n for n in state["notes"] if n["chapter"] == c["n"]]
        if not notes:
            continue
        lines.append("## %s %d: %s" % ("第" if zh else "Chapter", c["n"], c["title"]) if not zh
                     else "## 第 %d 章:%s" % (c["n"], c["title"]))
        for n in notes:
            lines.append("- [%s %s] %s" % (n["type"], n["ts"], n["text"]))
        lines.append("")
    return "\n".join(lines) + "\n"
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 322kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 322kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 322kUpdated Claude CodeCodexVerifiedInstall
skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.Stars: 198kUpdated Claude CodeCodexVerifiedInstall