Report question: skip a broken card and tell the server
A generated matching card arrived on a phone with three identical definitions (the generation guards now drop those), but there was no way to get past a bad card from inside a session. The feed chrome (deck study, review, mistakes and exam) now has the red "!" control: one tap records the question, skips to the next card and shows an Undo toast. - lib/question-reports.ts: the local list (freezmo.reports.v1, zod on read, capped 200) is the skip state — reported cards leave every session type, count as "not attempted" in the results instead of wrong, and Undo takes a report back. A deck where everything is reported stays studiable so it can be regenerated. - POST /api/reports appends one JSON line per report to REPORTS_DIR/reports.jsonl (shared/freezmo/reports in production, the dev data dir in dev). Deliberately write-only: the question text is readable on the server (that is the point — prompt tuning) but never over HTTP, since the app has no auth. Best effort: offline reports stay local. - The button: a red outlined rounded square with "!", the chrome's control size, in both feed headers (hidden on the results slide). - config: REPORTS_DIR + RATE_LIMIT_REPORTS (20); the deploy creates the shared reports dir; the dev unit and AGENTS.md note the new server data location. - Suites: phase-1 (append + validation + no GET), phase-2 (button, toast, server POST, local copy, skip counter, hidden next session, Undo, exam pool). SW -> freezmo-v38.
This commit is contained in:
parent
f202653017
commit
9cea13496a
16 changed files with 496 additions and 15 deletions
|
|
@ -4,6 +4,7 @@ import { useCallback, useEffect, useRef, useState } from "react";
|
|||
|
||||
import { ActivityRenderer } from "@/components/activities";
|
||||
import { XIcon } from "@/components/icons";
|
||||
import { ReportQuestionButton } from "@/components/ReportQuestionButton";
|
||||
import { ProgressBar } from "@/components/ui";
|
||||
import type { Activity, Deck } from "@/lib/schemas";
|
||||
import { useI18n } from "@/lib/i18n";
|
||||
|
|
@ -48,6 +49,8 @@ export function SessionFeed({
|
|||
useWakeLock(true);
|
||||
const [index, setIndex] = useState(0);
|
||||
const [results, setResults] = useState<Record<string, SessionResult>>({});
|
||||
/** Ids reported during this run: skipped, so they are not "missed". */
|
||||
const [skipped, setSkipped] = useState<string[]>([]);
|
||||
const [runId] = useState(0);
|
||||
const [remaining, setRemaining] = useState(timerSeconds ?? 0);
|
||||
const scrollRef = useRef<HTMLDivElement>(null);
|
||||
|
|
@ -135,7 +138,9 @@ export function SessionFeed({
|
|||
|
||||
const finished = index >= total;
|
||||
const correct = items.filter((item) => results[item.activity.id]?.correct).length;
|
||||
const score = total > 0 ? Math.round((correct / total) * 100) : 0;
|
||||
/** What the results slide counts: reported cards were never attempted. */
|
||||
const attemptedTotal = Math.max(0, total - skipped.length);
|
||||
const score = attemptedTotal > 0 ? Math.round((correct / attemptedTotal) * 100) : 0;
|
||||
|
||||
return (
|
||||
<div className="frost-bg fixed inset-0 flex flex-col fade-in-mobile">
|
||||
|
|
@ -168,6 +173,16 @@ export function SessionFeed({
|
|||
{formatClock(remaining)}
|
||||
</span>
|
||||
) : null}
|
||||
{!finished && items[index] ? (
|
||||
<ReportQuestionButton
|
||||
deck={items[index].deck}
|
||||
activity={items[index].activity}
|
||||
onSkip={() => {
|
||||
setSkipped((current) => [...current, items[index].activity.id]);
|
||||
goTo(index + 1);
|
||||
}}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="flex items-center justify-between gap-2 text-[11px] font-semibold text-[var(--text-muted)]">
|
||||
<span className="min-w-0 truncate">{title}</span>
|
||||
|
|
@ -211,7 +226,7 @@ export function SessionFeed({
|
|||
>
|
||||
<div className="mx-auto flex min-h-full w-full max-w-xl flex-col gap-4 px-4 pb-24 pt-24 [justify-content:safe_center]">
|
||||
{finished
|
||||
? renderResults({ results, items, correct, total, score })
|
||||
? renderResults({ results, items, correct, total: attemptedTotal, score })
|
||||
: (
|
||||
<div className="card space-y-2 p-5 text-center">
|
||||
<p className="text-sm font-semibold text-[var(--text-muted)]">{t("review.results")}</p>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue