Repository navigation
feat(site): add stage 3-6 checkpoints and A1-B1 placement test #1378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
b7ae8c3
feat(site): add stage 3-6 checkpoints and A1-B1 placement test
krambertech 872a78c
fix(site): cover every lesson in checkpoints and place by the first f…
krambertech 1ce3ca8
Merge remote-tracking branch 'origin/main' into t3/checkpoints-and-pl…
krambertech File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import { msg } from "@lingui/core/macro"; | ||
| import { LearnPage } from "../learn/learn-page"; | ||
|
|
||
| export const PLACEMENT_TITLE = msg`Estonian placement test · Lymi`; | ||
| export const PLACEMENT_BLURB = msg`Find where to start in the free Estonian grammar course: eighteen questions from A1 basics to B1 sentences, with a suggested starting stage and links to each rule.`; | ||
|
|
||
| export default function LearnPlacementPage({ locale }: { locale: string }) { | ||
| return <LearnPage target={{ kind: "placement" }} locale={locale} />; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import { Trans } from "@lingui/react/macro"; | ||
| import { useCallback, useContext } from "react"; | ||
| import { STAGES } from "../../lib/learn/catalogue"; | ||
| import { drawBalanced } from "../../lib/learn/placement"; | ||
| import { Button } from "../Button"; | ||
| import { LoadProblem } from "./Drill"; | ||
| import { type DrillSource, drillSlugs, type Question, questionsOf } from "./drill-banks"; | ||
| import { useDrillSession } from "./drill-session"; | ||
| import { DrillRunner } from "./DrillRunner"; | ||
| import { SectionContext, useLesson } from "./lesson-context"; | ||
| import { QuizCard } from "./Quiz"; | ||
|
|
||
| function drawStageQuestions(sources: readonly DrillSource[], count: number): Question[] { | ||
| return drawBalanced(questionsOf(sources), count, (question) => question.source.lesson); | ||
| } | ||
|
|
||
| export function Checkpoint({ stageIndex, count = 20 }: { stageIndex: number; count?: number }) { | ||
| const { slug, finishSection } = useLesson(); | ||
| const section = useContext(SectionContext); | ||
| const stage = STAGES[stageIndex]; | ||
| const slugs = (stage?.lessons ?? []) | ||
| .map((lesson) => lesson.slug) | ||
| .filter((item): item is string => !!item && item !== slug && drillSlugs.has(item)); | ||
|
|
||
| const { session, open, more } = useDrillSession( | ||
| () => slugs, | ||
| (sources) => drawStageQuestions(sources, count), | ||
| ); | ||
| const finish = useCallback(() => { | ||
| if (section) finishSection(section); | ||
| }, [section, finishSection]); | ||
|
|
||
| const title = <Trans>Stage checkpoint</Trans>; | ||
| if (session.status === "open") | ||
| return ( | ||
| <DrillRunner | ||
| key={session.set} | ||
| id="checkpoint" | ||
| lesson={slug} | ||
| title={title} | ||
| questions={session.questions} | ||
| sources={session.sources} | ||
| repeats={false} | ||
| onFinish={finish} | ||
| end={ | ||
| <Button variant="primary" onClick={more}> | ||
| <Trans>Try a new set</Trans> | ||
| </Button> | ||
| } | ||
| /> | ||
| ); | ||
| return ( | ||
| <QuizCard title={title}> | ||
| <Button variant="primary" loading={session.status === "loading"} onClick={open}> | ||
| <Trans>Start checkpoint</Trans> | ||
| </Button> | ||
| {session.status === "idle" && session.failed && <LoadProblem />} | ||
| </QuizCard> | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,167 @@ | ||
| import { Trans, useLingui } from "@lingui/react/macro"; | ||
| import { ArrowLeft, ArrowRight } from "lucide-react"; | ||
| import { lessonPath, STAGES } from "../../lib/learn/catalogue"; | ||
| import type { ruleScores } from "../../lib/learn/drill"; | ||
| import { drawPlacementStage, firstFailedStage, PER_STAGE } from "../../lib/learn/placement"; | ||
| import { localizedPath } from "../../lib/routes"; | ||
| import { Button, buttonClass } from "../Button"; | ||
| import { LoadProblem } from "./Drill"; | ||
| import { type DrillSource, drillSlugs, type Question, questionsOf } from "./drill-banks"; | ||
| import { useDrillSession } from "./drill-session"; | ||
| import { DrillRunner } from "./DrillRunner"; | ||
| import { LearnLayout } from "./LearnLayout"; | ||
| import { QuizCard } from "./Quiz"; | ||
|
|
||
| function placementSlugs(): string[] { | ||
| return STAGES.flatMap((stage) => { | ||
| const drilled = stage.lessons | ||
| .map((lesson) => lesson.slug) | ||
| .filter((slug): slug is string => !!slug && drillSlugs.has(slug)); | ||
| if (drilled.length <= PER_STAGE) return drilled; | ||
| const mid = Math.floor(drilled.length / 2); | ||
| return [drilled[0] as string, drilled[mid] as string, drilled[drilled.length - 1] as string]; | ||
| }); | ||
| } | ||
|
|
||
| function drawPlacement(sources: readonly DrillSource[]): Question[] { | ||
| const bySlug = new Map(sources.map((source) => [source.lesson, source])); | ||
| return STAGES.flatMap((stage) => { | ||
| const stageSources = stage.lessons | ||
| .map((lesson) => (lesson.slug ? bySlug.get(lesson.slug) : undefined)) | ||
| .filter((source): source is DrillSource => !!source); | ||
| return drawPlacementStage(questionsOf(stageSources), (question) => question.source.lesson); | ||
| }); | ||
| } | ||
|
|
||
| function PlacementResult({ scores }: { scores: ReturnType<typeof ruleScores> }) { | ||
| const { i18n } = useLingui(); | ||
| const stageOfLesson = new Map<string, number>(); | ||
| STAGES.forEach((stage, index) => { | ||
| for (const lesson of stage.lessons) { | ||
| if (lesson.slug) stageOfLesson.set(lesson.slug, index); | ||
| } | ||
| }); | ||
|
|
||
| const totals = STAGES.map((stage, index) => ({ index, stage, right: 0, total: 0 })); | ||
| for (const score of scores) { | ||
| const slug = score.rule.split("/")[0] ?? ""; | ||
| const idx = stageOfLesson.get(slug); | ||
| if (idx !== undefined && totals[idx]) { | ||
| totals[idx].right += score.right; | ||
| totals[idx].total += score.total; | ||
| } | ||
| } | ||
| const active = totals.filter((entry) => entry.total > 0); | ||
| const failed = firstFailedStage(totals); | ||
| const weak = failed === undefined ? undefined : totals[failed]; | ||
| const targetStage = weak?.stage ?? STAGES[STAGES.length - 1]; | ||
| const targetNumber = (weak?.index ?? STAGES.length - 1) + 1; | ||
| const startLesson = weak | ||
| ? targetStage?.lessons.find((lesson) => lesson.slug) | ||
| : targetStage?.lessons.findLast((lesson) => lesson.slug); | ||
|
|
||
| return ( | ||
| <div className="grid w-full gap-4 rounded-xl bg-(--tray) p-4.5"> | ||
| <div className="grid gap-1"> | ||
| <span className="text-sm font-medium text-(--form)"> | ||
| {weak ? ( | ||
| <Trans> | ||
| Recommended start · Stage {targetNumber} ({targetStage?.level}) | ||
| </Trans> | ||
| ) : ( | ||
| <Trans>At least two of three right in every stage</Trans> | ||
| )} | ||
| </span> | ||
| <p className="text-xl/snug font-semibold tracking-tight"> | ||
| {weak && targetStage ? ( | ||
| <Trans>Start with {i18n._(targetStage.name)}</Trans> | ||
| ) : ( | ||
| <Trans>You can start at the end of the course.</Trans> | ||
| )} | ||
| </p> | ||
| {startLesson?.slug && ( | ||
| <a | ||
| href={lessonPath(startLesson.slug, i18n.locale)} | ||
| className={buttonClass("primary", "md", "mt-2 justify-self-start")} | ||
| > | ||
| <Trans>Open {i18n._(startLesson.name)}</Trans> | ||
| <ArrowRight aria-hidden="true" data-icon="inline-end" /> | ||
| </a> | ||
| )} | ||
| </div> | ||
| <ul className="m-0 grid list-none gap-1.5 border-t border-edge pt-3 p-0 text-sm"> | ||
| {active.map(({ index, stage, right, total }) => ( | ||
| <li key={stage.hue} className="flex items-center justify-between gap-3"> | ||
| <span className="text-ink-secondary"> | ||
| <Trans> | ||
| Stage {index + 1} · {stage.level} · {i18n._(stage.name)} | ||
| </Trans> | ||
| </span> | ||
| <span className="font-medium tabular-nums"> | ||
| <Trans> | ||
| {right} of {total} | ||
| </Trans> | ||
| </span> | ||
| </li> | ||
| ))} | ||
| </ul> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| export function PlacementView() { | ||
| const { i18n } = useLingui(); | ||
| const { session, open, more } = useDrillSession(placementSlugs, drawPlacement); | ||
|
|
||
| return ( | ||
| <LearnLayout languages={{ page: "learnPlacement" }}> | ||
| <div className="mx-auto grid max-w-[720px] gap-6 px-5 pt-5 pb-24"> | ||
| <header className="grid gap-3"> | ||
| <a | ||
| href={localizedPath("learn", i18n.locale)} | ||
| className="relative inline-flex items-center gap-1.5 justify-self-start rounded-xs text-sm font-medium text-ink-secondary before:absolute before:inset-x-0 before:-inset-y-3 hoverable:hover:text-ink" | ||
| > | ||
| <ArrowLeft aria-hidden="true" className="size-4 rtl:-scale-x-100" /> | ||
| <Trans>All lessons</Trans> | ||
| </a> | ||
| <h1 className="mt-3 text-[clamp(2.75rem,7vw,4.25rem)] leading-none font-semibold tracking-[-0.035em] text-balance"> | ||
| <Trans>Find your level</Trans> | ||
| </h1> | ||
| <p className="max-w-[44ch] text-[clamp(1.125rem,2vw,1.3125rem)] text-pretty text-ink-secondary"> | ||
| <Trans> | ||
| Eighteen short questions from A1 basics to B1 sentences. No hints beforehand — at the | ||
| end we suggest where in the course to start. | ||
| </Trans> | ||
| </p> | ||
| </header> | ||
| {session.status === "open" ? ( | ||
| <DrillRunner | ||
| key={session.set} | ||
| id="placement" | ||
| lesson="tasemetest" | ||
| title={<Trans>Placement test</Trans>} | ||
| questions={session.questions} | ||
| sources={session.sources} | ||
| repeats={false} | ||
| afterScore={(scores) => <PlacementResult scores={scores} />} | ||
| end={ | ||
| <Button variant="secondary" onClick={more}> | ||
| <Trans>Take again</Trans> | ||
| </Button> | ||
| } | ||
| /> | ||
| ) : ( | ||
| <QuizCard title={<Trans>Placement test</Trans>}> | ||
| <p className="text-md text-ink-secondary"> | ||
| <Trans>Takes about 10 minutes. Includes audio and short typed answers.</Trans> | ||
| </p> | ||
| <Button variant="primary" loading={session.status === "loading"} onClick={open}> | ||
| <Trans>Start placement test</Trans> | ||
| </Button> | ||
| {session.status === "idle" && session.failed && <LoadProblem />} | ||
| </QuizCard> | ||
| )} | ||
| </div> | ||
| </LearnLayout> | ||
| ); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Every answered checkpoint question currently shows its teaching explanation:
DrillRunnerdelegates toDrillRound, which unconditionally suppliesitem.explainto the round components. Settingrepeats={false}only disables retries; it does not disable that feedback. This contradicts the checkpoint contract indocs/design/estonian-lessons.md:94(“No explanations”) and teaches rules while the assessment is still measuring them. Add an assessment mode that withholds explanations until the run has finished, while preserving the existing feedback for ordinary drills.Useful? React with 👍 / 👎.