Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions backend/prisma/seedAdvanced.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,48 @@ async function seedAdvanced(prisma, teacherId) {
content: JSON.stringify({ gameKey: "sparbots" }),
},
});
const coveDetails = {
title: "Qubit Cove",
description: "Explore islands and measure a qubit to see a 0 or a 1.",
level: "K-2",
published: true,
};
const cove = await prisma.module.upsert({
where: { slug: "advanced-quantum-qubit-cove" },
update: coveDetails,
create: { slug: "advanced-quantum-qubit-cove", ...coveDetails },
});
const coveUnitData = {
moduleId: cove.id,
title: "The quantum islands",
order: 1,
};
const coveUnit = await prisma.unit.upsert({
where: { id: "qubit-cove-islands" },
update: coveUnitData,
create: { id: "qubit-cove-islands", teacherId, ...coveUnitData },
});
const coveLessonData = {
unitId: coveUnit.id,
title: "My first qubit",
order: 1,
};
const coveLesson = await prisma.lesson.upsert({
where: { id: "qubit-cove-expedition" },
update: coveLessonData,
create: { id: "qubit-cove-expedition", ...coveLessonData },
});
const coveActivityData = {
lessonId: coveLesson.id,
title: coveDetails.title,
kind: "INTERACT",
order: 1,
content: JSON.stringify({ gameKey: "qubit_cove" }),
};
await prisma.activity.upsert({
where: { id: "qubit_cove" },
update: coveActivityData,
create: { id: "qubit_cove", ...coveActivityData },
});
}
module.exports = { seedAdvanced };
2 changes: 1 addition & 1 deletion backend/src/routes/__tests__/advancedProgress.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ describe.each(ADVANCED_ACTIVITIES)(
expect(mocks.prisma.progress.upsert).toHaveBeenCalledTimes(1);
mocks.prisma.avatar.findUnique.mockResolvedValue({
stage: "SPECIALIZED",
archetype: "QUANTUM",
archetype: advanced.specialty === "QUANTUM" ? "AI" : "QUANTUM",
});
expect(
(await request(app).post("/progress/checkpoint").send(checkpoint))
Expand Down
43 changes: 43 additions & 0 deletions prisma/seedAdvanced.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,48 @@ async function seedAdvanced(prisma, teacherId) {
content: JSON.stringify({ gameKey: "sparbots" }),
},
});
const coveDetails = {
title: "Qubit Cove",
description: "Explore islands and measure a qubit to see a 0 or a 1.",
level: "K-2",
published: true,
};
const cove = await prisma.module.upsert({
where: { slug: "advanced-quantum-qubit-cove" },
update: coveDetails,
create: { slug: "advanced-quantum-qubit-cove", ...coveDetails },
});
const coveUnitData = {
moduleId: cove.id,
title: "The quantum islands",
order: 1,
};
const coveUnit = await prisma.unit.upsert({
where: { id: "qubit-cove-islands" },
update: coveUnitData,
create: { id: "qubit-cove-islands", teacherId, ...coveUnitData },
});
const coveLessonData = {
unitId: coveUnit.id,
title: "My first qubit",
order: 1,
};
const coveLesson = await prisma.lesson.upsert({
where: { id: "qubit-cove-expedition" },
update: coveLessonData,
create: { id: "qubit-cove-expedition", ...coveLessonData },
});
const coveActivityData = {
lessonId: coveLesson.id,
title: coveDetails.title,
kind: "INTERACT",
order: 1,
content: JSON.stringify({ gameKey: "qubit_cove" }),
};
await prisma.activity.upsert({
where: { id: "qubit_cove" },
update: coveActivityData,
create: { id: "qubit_cove", ...coveActivityData },
});
}
module.exports = { seedAdvanced };
9 changes: 9 additions & 0 deletions prompts/2026-11-18-qubit-cove.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Qubit Cove

User request: “create the first game for k-2 using the quantum specialty. Should be based on super mario 64”

Build an original exploration platformer for the Bright Boost Quantum specialty.
Use a lighthouse hub, three freely ordered beacon experiments, optional sparks,
and forgiving jumps. Let learners prepare and measure simulated qubits with
certain and equally likely outcomes. Keep the existing Set 3 specialty gate and
activity completion flow.
5 changes: 3 additions & 2 deletions scripts/__tests__/seedAdvanced.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe.each([
"../../prisma/seedAdvanced.cjs",
"../../backend/prisma/seedAdvanced.cjs",
])("advanced seed %s", (file) => {
it("seeds both canonical chains idempotently with the first specialty activity", async () => {
it("seeds all canonical chains idempotently with the first specialty activity", async () => {
function table() {
const rows = new Map<string, Record<string, unknown>>();
return {
Expand Down Expand Up @@ -58,6 +58,7 @@ describe.each([
gameKey: advanced.activityId,
});
}
for (const entity of Object.values(db)) expect(entity.rows.size).toBe(2);
for (const entity of Object.values(db))
expect(entity.rows.size).toBe(ADVANCED_ACTIVITIES.length);
});
});
9 changes: 9 additions & 0 deletions shared/progression/advanced.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ export const BIOTRAIL_LESSON_ID = "biotrail-field-lab";
export const SPARBOTS_SLUG = "advanced-ai-sparbots";
export const SPARBOTS_ACTIVITY_ID = "sparbots";
export const SPARBOTS_LESSON_ID = "sparbots-training-tower";
export const QUBIT_COVE_SLUG = "advanced-quantum-qubit-cove";
export const QUBIT_COVE_LESSON_ID = "qubit-cove-expedition";
export const QUBIT_COVE_ACTIVITY_ID = "qubit_cove";
export const ADVANCED_ACTIVITIES = [
{
slug: BIOTRAIL_SLUG,
Expand All @@ -18,6 +21,12 @@ export const ADVANCED_ACTIVITIES = [
activityId: SPARBOTS_ACTIVITY_ID,
specialty: "AI",
},
{
slug: QUBIT_COVE_SLUG,
lessonId: QUBIT_COVE_LESSON_ID,
activityId: QUBIT_COVE_ACTIVITY_ID,
specialty: "QUANTUM",
},
] as const;
export const ADVANCED_SPECIALTIES: Readonly<Record<string, string>> =
Object.fromEntries(
Expand Down
43 changes: 43 additions & 0 deletions src/components/games/QubitCoveActivity.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { lazy, Suspense } from "react";
import { useTranslation } from "react-i18next";
import { Link } from "react-router-dom";
import { useAuth } from "@/contexts/AuthContext";
import { useSpecialty } from "@/contexts/SpecialtyContext";
import { Button } from "@/components/ui/button";
import type { GameResult } from "./shared/GameShell";
const QubitCoveGame = lazy(() => import("./qubitCove/QubitCoveGame"));
export default function QubitCoveActivity({
onComplete,
}: {
onComplete?: (result: GameResult) => void;
}) {
const { t } = useTranslation();
const { user } = useAuth();
const { status, data, refresh } = useSpecialty();
if (status === "loading")
return <p role="status">{t("specialty.loading")}</p>;
if (status === "error")
return (
<div role="alert">
<p>{t("specialty.loadError")}</p>
<Button onClick={refresh}>{t("specialty.retry")}</Button>
</div>
);
if (!user || !data?.unlocked || data.specialty !== "QUANTUM")
return (
<p>
<Link to="/student/specialty">
{t("specialty.qubitCove.gameLocked")}
</Link>
</p>
);
return (
<Suspense fallback={<p role="status">{t("specialty.loading")}</p>}>
<QubitCoveGame
key={user.id}
storageScope={user.id}
onComplete={onComplete}
/>
</Suspense>
);
}
85 changes: 85 additions & 0 deletions src/components/games/__tests__/QubitCoveActivity.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import { fireEvent, render, screen } from "@testing-library/react";
import { MemoryRouter } from "react-router-dom";
import { expect, it, vi } from "vitest";
import QubitCoveActivity from "../QubitCoveActivity";
import type { GameResult } from "../shared/GameShell";

const state = vi.hoisted(() => ({
user: { id: "learner" } as { id: string } | null,
status: "loading",
data: { unlocked: true, specialty: "QUANTUM" },
refresh: vi.fn(),
}));
vi.mock("@/contexts/AuthContext", () => ({
useAuth: () => ({ user: state.user }),
}));
vi.mock("@/contexts/SpecialtyContext", () => ({ useSpecialty: () => state }));
vi.mock("react-i18next", () => ({
useTranslation: () => ({ t: (key: string) => key }),
}));
vi.mock("../qubitCove/QubitCoveGame", () => ({
default: ({
storageScope,
onComplete,
}: {
storageScope: string;
onComplete: (result: GameResult) => void;
}) => (
<button
onClick={() =>
onComplete({
gameKey: "qubit_cove",
total: 3,
score: 3,
streakMax: 0,
roundsCompleted: 3,
})
}
>
{storageScope}
</button>
),
}));

it("checks the earned specialty, scopes the game to the student and forwards completion", async () => {
const onComplete = vi.fn();
const activity = () => (
<MemoryRouter>
<QubitCoveActivity onComplete={onComplete} />
</MemoryRouter>
);
const { rerender } = render(activity());
expect(screen.getByRole("status")).toHaveTextContent("specialty.loading");
state.status = "error";
rerender(activity());
fireEvent.click(screen.getByRole("button"));
expect(state.refresh).toHaveBeenCalledOnce();

state.status = "ready";
for (const data of [
{ unlocked: true, specialty: "AI" },
{ unlocked: true, specialty: "BIOTECH" },
{ unlocked: false, specialty: "QUANTUM" },
]) {
state.data = data;
rerender(activity());
expect(screen.getByRole("link")).toHaveAttribute(
"href",
"/student/specialty",
);
}
state.data = { unlocked: true, specialty: "QUANTUM" };
state.user = null;
rerender(activity());
expect(screen.getByRole("link")).toBeInTheDocument();
state.user = { id: "learner" };
rerender(activity());
fireEvent.click(await screen.findByRole("button", { name: "learner" }));
expect(onComplete).toHaveBeenCalledExactlyOnceWith({
gameKey: "qubit_cove",
score: 3,
total: 3,
streakMax: 0,
roundsCompleted: 3,
});
});
4 changes: 3 additions & 1 deletion src/components/games/gameRegistry.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import BioTrailActivity from "./BioTrailActivity";
import QubitCoveActivity from "./QubitCoveActivity";
import SparBotsActivity from "./SparBotsActivity";
import type { ComponentType } from "react";
import type { GameResult } from "./shared/GameShell";
Expand Down Expand Up @@ -46,7 +47,8 @@ export const GAME_COMPONENTS: Record<string, ComponentType<GameProps>> = {
fast_lane: FastLaneGame, // "Fast Lane Signals" (Set 2)
qualify_tune_race: QualifyTuneRaceGame, // "Qualify, Tune, Race" (Set 2)

// Advanced Biotech: independently gated by server specialty state.
// Advanced games are independently gated by server specialty state.
qubit_cove: QubitCoveActivity,
biotrail: BioTrailActivity,
sparbots: SparBotsActivity,

Expand Down
Loading
Loading