Spaces:
Sleeping
Sleeping
Remove generation debug and timed controls
Browse filesFiles changed (2)
733 unmodified lines7347357367377387397404 unmodified lines74574674774874975075175275375475575675775852 unmodified lines811812813814815816817733 unmodified linesexpect(await screen.findByLabelText("0 minutes 0 seconds remaining")).toBeTruthy();});it("passes the configured timer into challenge generation", async () => {const user = userEvent.setup();mocks.session.mockResolvedValueOnce({ authenticated: false })4 unmodified linesawait user.type(await screen.findByLabelText("Display name"), "Alice");await user.click(screen.getByRole("button", { name: /continue/i }));await user.click(screen.getByRole("switch", { name: "Timed challenge" }));const timerInput = await screen.findByLabelText(/time limit in minutes/i);await user.clear(timerInput);await user.type(timerInput, "15");await user.click(screen.getByRole("button", { name: /start challenge/i }));await waitFor(() => expect(mocks.startChallenge).toHaveBeenCalled());expect(mocks.startChallenge).toHaveBeenCalledWith(expect.objectContaining({ timer_minutes: 15 }));expect(await screen.findByRole("heading", { name: "src/demo.py" })).toBeTruthy();});52 unmodified linesexpect(screen.getByText(/35 chat messages\/student/)).toBeTruthy();expect(mocks.publishChallengeRound).toHaveBeenCalledWith({time_limit_enabled: false,timer_minutes: 30,chat_messages_per_student: 35,visibility: "public",});733 unmodified lines7347357367377387397404 unmodified lines74574674774874975075175275375475575652 unmodified lines809810811812813814815733 unmodified linesexpect(await screen.findByLabelText("0 minutes 0 seconds remaining")).toBeTruthy();});it("creates personal challenges untimed and without debug mode", async () => {const user = userEvent.setup();mocks.session.mockResolvedValueOnce({ authenticated: false })4 unmodified linesawait user.type(await screen.findByLabelText("Display name"), "Alice");await user.click(screen.getByRole("button", { name: /continue/i }));await user.click(screen.getByRole("button", { name: /start challenge/i }));await waitFor(() => expect(mocks.startChallenge).toHaveBeenCalled());expect(mocks.startChallenge).toHaveBeenCalledWith(expect.objectContaining({ timer_minutes: 0, debug_mode: false }));expect(screen.queryByRole("switch", { name: "Timed challenge" })).toBeNull();expect(screen.queryByRole("switch", { name: /debug mode/i })).toBeNull();expect(await screen.findByRole("heading", { name: "src/demo.py" })).toBeTruthy();});52 unmodified linesexpect(screen.getByText(/35 chat messages\/student/)).toBeTruthy();expect(mocks.publishChallengeRound).toHaveBeenCalledWith({time_limit_enabled: false,timer_minutes: 0,chat_messages_per_student: 35,visibility: "public",});
92 unmodified lines9394959697989910026 unmodified lines127128129130131132133308 unmodified lines44244344444544644744844939 unmodified lines489490491492493494495496622 unmodified lines11191120112111221123112411251126112792 unmodified linesconst [pendingFunctionJump, setPendingFunctionJump] = useState<string | null>(null);const [diffResult, setDiffResult] = useState<{ diff: string; has_changes: boolean } | null>(null);const [diffOpen, setDiffOpen] = useState(false);const [timerEnabled, setTimerEnabled] = useState(false);const [timerMinutes, setTimerMinutes] = useState(30);const [timerRemaining, setTimerRemaining] = useState<number | null>(null);const [hintResult, setHintResult] = useState<HintResult | null>(null);const [messages, setMessages] = useState<ChatMessage[]>([]);26 unmodified linesconst [nestingLevel, setNestingLevel] = useState(3);const [numBugs, setNumBugs] = useState(1);const [refactoring, setRefactoring] = useState(false);const [debugMode, setDebugMode] = useState(false);const [message, setMessage] = useState("");const [roundCode, setRoundCode] = useState("");const [publishedRound, setPublishedRound] = useState<{ round_id: string; artifact_hash: string; tests_hash: string; timer_minutes: number; chat_messages_per_student: number; visibility: "private" | "public"; status: "prepared" | "open" | "closed" } | null>(null);308 unmodified linesnesting_level: nestingLevel,num_bugs: numBugs,refactoring_enabled: refactoring,debug_mode: debugMode,timer_minutes: timerEnabled ? timerMinutes : 0,});const created = await waitForChallenge(jobId, (_jobStatus, nextProgress, message) => {if (typeof nextProgress === "number") setProgress(nextProgress);39 unmodified linessetBusy(true);try {setPublishedRound(await api.publishChallengeRound({time_limit_enabled: timerEnabled,timer_minutes: timerMinutes,chat_messages_per_student: roundChatMessageLimit,visibility: session?.role === "instructor" ? roundVisibility : "public",}));622 unmodified lines<label>Injected bugs<div className="range-line"><input type="range" min={1} max={3} value={numBugs} onChange={(event) => setNumBugs(Number(event.target.value))} /><output>{numBugs}</output></div><small>Independent faults to locate</small></label></div><div className="option-row"><div><strong>Refactoring camouflage</strong><small>Obfuscate names and inflate control flow</small></div><button type="button" className={`switch ${refactoring ? "switch-on" : ""}`} role="switch" aria-checked={refactoring} onClick={() => setRefactoring((value) => !value)}><span /></button></div><div className="option-row"><div><strong>Debug mode</strong><small>Show more generation details</small></div><button type="button" className={`switch ${debugMode ? "switch-on" : ""}`} role="switch" aria-checked={debugMode} onClick={() => setDebugMode((value) => !value)}><span /></button></div><div className="option-row"><div><strong>Timed challenge</strong><small>Off means students can work without a countdown.</small></div><button type="button" className={`switch ${timerEnabled ? "switch-on" : ""}`} role="switch" aria-label="Timed challenge" aria-checked={timerEnabled} onClick={() => setTimerEnabled((enabled) => !enabled)}><span /></button></div>{timerEnabled && <label>Time limit in minutes<input type="number" min={1} max={120} step={1} value={timerMinutes} onChange={(event) => setTimerMinutes(Number(event.target.value))} /></label>}<button className="button button-primary start-button" disabled={busy}>{busy ? <LoaderCircle className="spin" size={17} /> : <Sparkles size={17} />}Start challenge<ChevronRight size={17} /></button>{busy && <div className="progress-copy" role="status"><div className="progress-label"><span>{status || "Preparing challenge"}</span><strong>{progress}%</strong></div><div className="progress-track" role="progressbar" aria-label="Challenge setup progress" aria-valuemin={0} aria-valuemax={100} aria-valuenow={progress}><span style={{ width: `${progress}%` }} /></div><small>Progress updates as each generation step starts.</small></div>}</>}92 unmodified lines93949596979826 unmodified lines125126127128129130308 unmodified lines43944044144244344444544639 unmodified lines486487488489490491492493622 unmodified lines11161117111811191120112192 unmodified linesconst [pendingFunctionJump, setPendingFunctionJump] = useState<string | null>(null);const [diffResult, setDiffResult] = useState<{ diff: string; has_changes: boolean } | null>(null);const [diffOpen, setDiffOpen] = useState(false);const [timerRemaining, setTimerRemaining] = useState<number | null>(null);const [hintResult, setHintResult] = useState<HintResult | null>(null);const [messages, setMessages] = useState<ChatMessage[]>([]);26 unmodified linesconst [nestingLevel, setNestingLevel] = useState(3);const [numBugs, setNumBugs] = useState(1);const [refactoring, setRefactoring] = useState(false);const [message, setMessage] = useState("");const [roundCode, setRoundCode] = useState("");const [publishedRound, setPublishedRound] = useState<{ round_id: string; artifact_hash: string; tests_hash: string; timer_minutes: number; chat_messages_per_student: number; visibility: "private" | "public"; status: "prepared" | "open" | "closed" } | null>(null);308 unmodified linesnesting_level: nestingLevel,num_bugs: numBugs,refactoring_enabled: refactoring,debug_mode: false,timer_minutes: 0,});const created = await waitForChallenge(jobId, (_jobStatus, nextProgress, message) => {if (typeof nextProgress === "number") setProgress(nextProgress);39 unmodified linessetBusy(true);try {setPublishedRound(await api.publishChallengeRound({time_limit_enabled: false,timer_minutes: 0,chat_messages_per_student: roundChatMessageLimit,visibility: session?.role === "instructor" ? roundVisibility : "public",}));622 unmodified lines<label>Injected bugs<div className="range-line"><input type="range" min={1} max={3} value={numBugs} onChange={(event) => setNumBugs(Number(event.target.value))} /><output>{numBugs}</output></div><small>Independent faults to locate</small></label></div><div className="option-row"><div><strong>Refactoring camouflage</strong><small>Obfuscate names and inflate control flow</small></div><button type="button" className={`switch ${refactoring ? "switch-on" : ""}`} role="switch" aria-checked={refactoring} onClick={() => setRefactoring((value) => !value)}><span /></button></div><button className="button button-primary start-button" disabled={busy}>{busy ? <LoaderCircle className="spin" size={17} /> : <Sparkles size={17} />}Start challenge<ChevronRight size={17} /></button>{busy && <div className="progress-copy" role="status"><div className="progress-label"><span>{status || "Preparing challenge"}</span><strong>{progress}%</strong></div><div className="progress-track" role="progressbar" aria-label="Challenge setup progress" aria-valuemin={0} aria-valuemax={100} aria-valuenow={progress}><span style={{ width: `${progress}%` }} /></div><small>Progress updates as each generation step starts.</small></div>}</>}
frontend/src/App.test.tsx+5-7
frontend/src/App.tsx+4-10