diff --git a/README.md b/README.md index 5f262cd..30e9146 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ Single-choice, multiple-select, numeric, bounded symbolic-expression, narrow dat ## Preserved local study tools -The React reader now includes six scientific calculators under **Study tools**, available without enrollment: dilution, buffer pH, enzyme kinetics, RC charging, diffusion timescale, and Ohm's law. Each shows units and model assumptions and links to related courses. Calculator scratch work is ungraded. +The React reader now includes six scientific calculators under **Study tools**, available without enrollment: dilution, buffer pH, enzyme kinetics, RC charging and discharging, diffusion timescale, and Ohm's law. Each shows units and model assumptions and links to related courses. Calculator scratch work is ungraded. **Bench practice** replays simulations of real bench procedures (micropipette gravimetric verification, decimal dilutions with the FDA BAM aerobic plate count, a Class II biosafety cabinet session with a spill, validating an autoclave waste cycle with biological indicators, and the first response to a needlestick, cut or eye splash) from the learner's own choices of action, with a checkpoint debrief at the end. Runs are formative, unrecorded and cannot train hand skill; see the [wet-lab practice plan](docs/WET_LAB_PRACTICE_PLAN.md). diff --git a/docs/ASSESSMENT_AND_STUDY_TOOLS.md b/docs/ASSESSMENT_AND_STUDY_TOOLS.md index a92dcc4..7ec9f24 100644 --- a/docs/ASSESSMENT_AND_STUDY_TOOLS.md +++ b/docs/ASSESSMENT_AND_STUDY_TOOLS.md @@ -17,7 +17,7 @@ The React **Case studio** exposes the existing self-assessed design tasks in all - **Retrieval cards:** cards appear with developed lessons; learners can use them for self-assessment. After revealing an answer, an enrolled learner can self-rate recall (again/hard/good/easy). The server stores each rating append-only with the card's text digest and schedules the next review with the documented `retrieval-schedule-v1` SM-2-style rule (10-minute relearn, then 1 day, 6 days, and interval × ease, capped at 365 days). A course **Review queue** lists due, not-yet-reviewed and later cards. Editing a card's text restarts its schedule. Ratings never change practice scores, objective evidence or grades; they are a study aid, not mastery evidence. - **Notes and bookmarks:** server-backed learner notes and course bookmarks can be exported or deleted with account data. - **Progress:** marked reading state is stored separately from quiz scores and does not certify mastery. -- **Scientific calculators:** the React **Study tools** page offers dilution, buffer pH, enzyme kinetics, RC charging, diffusion timescale, and Ohm's law. The main navigation and current course views link to it; each calculator has a direct `#/tools/` route, labeled units, model assumptions, related course links, input validation, and keyboard-accessible results. Calculations are local scratch work and do not submit answers or affect grades. The legacy implementations remain preserved. +- **Scientific calculators:** the React **Study tools** page offers dilution, buffer pH, enzyme kinetics, RC charging and discharging, diffusion timescale, and Ohm's law. The main navigation and current course views link to it; each calculator has a direct `#/tools/` route, labeled units, model assumptions, related course links, input validation, and keyboard-accessible results. Calculations are local scratch work and do not submit answers or affect grades. The legacy implementations remain preserved. ## Authoring and validation checklist @@ -30,6 +30,14 @@ When adding a course or changing a problem: 5. For biology or engineering cases, ask learners to distinguish a measurable result from a causal, functional, or translational conclusion. 6. Cite public comparators and write original notes and questions rather than importing restricted course text or answer keys. +## RC comparison exercise + +Open the RC charging and discharging calculator. With the default 100 kΩ and 10 μF, the time constant is 1 s. At 0.693147 s, predict the voltage remaining on an initially charged capacitor discharging through the resistor. It retains about half its initial voltage and one quarter of its initial energy because stored energy is proportional to voltage squared. Double the resistor and find the new time to half voltage (about 1.38629 s). The capacitor charging from zero in the separate step-response example reaches half the step at that same time. The exercise connects the local circuit readings on filter recovery and stored energy with the first-order circuit topics in sessions L13–L14. [MIT OCW 6.002, Spring 2007 calendar](https://ocw.mit.edu/courses/6-002-circuits-and-electronics-spring-2007/pages/calendar/) + +## Diffusion comparison exercise + +Open the Diffusion timescale calculator and enter a distance of 2 μm and a diffusivity of 1 × 10⁻¹² m²/s. The characteristic scale is 4 s. Along a line, an initially localized cloud reaches a root-mean-square displacement of 2 μm in 2 s. Across a plane it reaches the same radial RMS displacement in 1 s because each of the two independent coordinates contributes to the squared distance. Predict what happens at 4 μm, then check the calculator. All three times increase fourfold. These times describe ensemble spreading in free space. Arrival at a target requires specifying its geometry and boundary conditions. [MIT OpenCourseWare 18.366, Fall 2006, lecture 1](https://ocw.mit.edu/courses/18-366-random-walks-and-diffusion-fall-2006/aef0a2690183294e59ea8cb29f8dd448_lec01.pdf) + ## Current limitations The curriculum remains incomplete: all catalog packages are partial or planning-only, and no course passes the project's complete-course gate. There is no protected exam-key repository, timed exam mode, independent reviewer sign-off, full mastery model, general code-execution sandbox, collaborative annotation, or laboratory safety supervision. Practice indicators do not establish learning transfer, university equivalency, credit, or course completion. Specialized experimental activities require qualified review before formal instructional use. diff --git a/frontend/e2e/course-projects.spec.ts b/frontend/e2e/course-projects.spec.ts index 987d0ac..c02d46d 100644 --- a/frontend/e2e/course-projects.spec.ts +++ b/frontend/e2e/course-projects.spec.ts @@ -126,9 +126,9 @@ for (const plan of plans) { .getByRole("navigation", { name: "Lessons", exact: true }) .getByRole("link", { name: plan.title, exact: true }) .click(); - await expect( - page.getByRole("heading", { name: plan.title, exact: true }), - ).toBeVisible(); + const lessonTitle = page.locator("article.lesson-reader > h2"); + await expect(lessonTitle).toHaveText(plan.title); + await expect(lessonTitle).toBeVisible(); await expect( page.getByRole("heading", { name: "Worked example: a separate case", diff --git a/frontend/e2e/study-tools.spec.ts b/frontend/e2e/study-tools.spec.ts index bfb8c27..62ea5f5 100644 --- a/frontend/e2e/study-tools.spec.ts +++ b/frontend/e2e/study-tools.spec.ts @@ -23,7 +23,7 @@ test("public scientific calculators work with keyboard input and accessible resu { name: "Dilution", result: "0.5 mL" }, { name: "Buffer pH", result: "8.2" }, { name: "Enzyme kinetics", result: "66.6667 μM/min" }, - { name: "RC charging", result: "1 s" }, + { name: "RC charging and discharging", result: "1 s" }, { name: "Diffusion timescale", result: "10 s" }, { name: "Ohm’s law", result: "0.5 mA" }, ]; @@ -65,10 +65,26 @@ test("calculator navigation and results fit a narrow screen", async ({ await page.setViewportSize({ width: 390, height: 844 }); await page.goto("/#/tools/rc"); await expect( - page.getByRole("heading", { name: "RC charging", exact: true }), + page.getByRole("heading", { + name: "RC charging and discharging", + exact: true, + }), ).toBeVisible(); + await page.getByRole("spinbutton", { name: "Time (s)" }).fill("0.693147"); await page.getByRole("button", { name: "Calculate", exact: true }).click(); - await expect(page.getByText("63.2121 %", { exact: true })).toBeVisible(); + const results = page.getByRole("status"); + await expect( + results + .locator("dl > div") + .filter({ hasText: "Initial voltage remaining during discharge" }) + .locator("dd"), + ).toHaveText("50 %"); + await expect( + results + .locator("dl > div") + .filter({ hasText: "Initial energy remaining during discharge" }) + .locator("dd"), + ).toHaveText("25 %"); expect( await page.evaluate( () => document.documentElement.scrollWidth <= window.innerWidth, diff --git a/frontend/src/components/NotebookView.test.tsx b/frontend/src/components/NotebookView.test.tsx index 2db7e7f..ea67177 100644 --- a/frontend/src/components/NotebookView.test.tsx +++ b/frontend/src/components/NotebookView.test.tsx @@ -62,6 +62,35 @@ describe("cross-course notebook", () => { ); }); + it("recovers from an empty course filter and clears both filters together", async () => { + const user = userEvent.setup(); + const request = vi + .spyOn(api, "notebook") + .mockImplementation(async (query, courseId) => + query || courseId ? { ...page, items: [], total: 0 } : page, + ); + render( + , + ); + await screen.findByText("1 saved note"); + const courseFilter = screen.getByRole("combobox", { name: "Course" }); + const search = screen.getByRole("searchbox"); + await user.selectOptions(courseFilter, course.id); + expect( + await screen.findByText(/No notes match the current filters/), + ).toBeInTheDocument(); + await user.type(search, "missing"); + await waitFor(() => + expect(request).toHaveBeenLastCalledWith("missing", course.id, 0), + ); + await user.click(screen.getByRole("button", { name: "Clear filters" })); + expect(await screen.findByText("1 saved note")).toBeInTheDocument(); + expect(search).toHaveValue(""); + expect(courseFilter).toHaveValue(""); + expect(request).toHaveBeenLastCalledWith("", undefined, 0); + expect(screen.queryByRole("button", { name: "Clear filters" })).toBeNull(); + }); + it("asks public readers to start a private session without requesting notes", () => { const request = vi.spyOn(api, "notebook"); render( diff --git a/frontend/src/components/NotebookView.tsx b/frontend/src/components/NotebookView.tsx index 93d2ec4..e2de446 100644 --- a/frontend/src/components/NotebookView.tsx +++ b/frontend/src/components/NotebookView.tsx @@ -73,6 +73,7 @@ export function NotebookView({ setOffset(0); } + const hasFilters = Boolean(query || courseId); const items: NotebookNote[] = page?.items ?? []; const total = page?.total ?? 0; @@ -122,6 +123,18 @@ export function NotebookView({ ))} + {hasFilters ? ( + + ) : null} {loading ?

Searching notes…

: null} {error ? ( @@ -167,8 +180,8 @@ export function NotebookView({ ) : total === 0 ? (

- {query.trim() - ? "No notes match that search. Try another term or clear the course filter." + {hasFilters + ? "No notes match the current filters. Clear filters to view all saved notes." : courses.length ? "No saved lesson notes yet. Open a lesson in My learning and add a private note." : "Enroll in a course to start saving lesson notes."} diff --git a/frontend/src/components/StudyTools.test.tsx b/frontend/src/components/StudyTools.test.tsx index 6101ff5..ade5372 100644 --- a/frontend/src/components/StudyTools.test.tsx +++ b/frontend/src/components/StudyTools.test.tsx @@ -40,10 +40,9 @@ describe("study tools", () => { expect( screen.getByRole("spinbutton", { name: "Resistance (kΩ)" }), ).toHaveValue(100); - expect(screen.getByRole("link", { name: "RC charging" })).toHaveAttribute( - "aria-current", - "page", - ); + expect( + screen.getByRole("link", { name: "RC charging and discharging" }), + ).toHaveAttribute("aria-current", "page"); await user.click(screen.getByRole("button", { name: "Calculate" })); expect(screen.getByText("1 s")).toBeInTheDocument(); expect(screen.getByText("63.2121 %")).toBeInTheDocument(); diff --git a/frontend/src/studyTools.test.ts b/frontend/src/studyTools.test.ts index 051f7df..ef8d791 100644 --- a/frontend/src/studyTools.test.ts +++ b/frontend/src/studyTools.test.ts @@ -63,6 +63,20 @@ describe("scientific study calculations", () => { expect(calculate("rc", { time: "0" })[1].value).toBe(0); }); + it("compares normalized voltage and energy during source-free RC discharge", () => { + const results = (time: string) => + calculate("rc", { time }).map((item) => item.value); + expect(results("0")).toEqual([1, 0, 100, 100]); + const [, charged, voltage, energy] = results("1"); + expect(charged + voltage).toBeCloseTo(100); + expect(voltage).toBeCloseTo(36.787944); + expect(energy).toBeCloseTo(13.533528); + const [, , halfVoltage, quarterEnergy] = results(String(Math.log(2))); + expect(halfVoltage).toBeCloseTo(50); + expect(quarterEnergy).toBeCloseTo(25); + expect(results("50")[2]).toBeGreaterThan(0); + }); + it("converts micrometres and preserves the square-distance diffusion scaling", () => { const baseline = calculate("diffusion")[0]; expect(baseline.unit).toBe("s"); @@ -73,6 +87,16 @@ describe("scientific study calculations", () => { ).toBeCloseTo(20); }); + it("distinguishes the characteristic timescale from 1D and 2D RMS spreading times", () => { + const times = (length: string) => + calculate("diffusion", { length, diffusivity: "1e-12" }).map( + (item) => item.value, + ); + expect(times("2")).toEqual([4, 2, 1]); + expect(times("4")).toEqual([16, 8, 4]); + expect(times("0")).toEqual([0, 0, 0]); + }); + it("uses mA and mW and preserves current direction while power remains positive", () => { const result = calculate("ohm", { voltage: "-5", resistance: "2" }); expect(result[0]).toEqual({ label: "Current", value: -2.5, unit: "mA" }); diff --git a/frontend/src/studyTools.ts b/frontend/src/studyTools.ts index 36c003f..fb33465 100644 --- a/frontend/src/studyTools.ts +++ b/frontend/src/studyTools.ts @@ -106,12 +106,13 @@ export const studyTools: StudyTool[] = [ }, { id: "rc", - title: "RC charging", + title: "RC charging and discharging", description: - "Find the time constant and fraction of an ideal voltage step reached.", - equation: "τ = RC; fraction charged = 1 − exp(−t/τ)", + "Compare voltage during charging with voltage and stored energy during discharge through the same resistor.", + equation: + "τ = RC; charging V/Vstep = 1 − exp(−t/τ); discharge V/V₀ = exp(−t/τ); E/E₀ = (V/V₀)²", assumptions: - "Assumes an ideal series RC circuit, an initially uncharged capacitor, and a constant voltage step. Resistance is entered in kΩ and capacitance in μF.", + "One ideal capacitor starts at zero volts and charges toward a constant source voltage. A second, initially charged capacitor discharges through the same resistance with the source removed. With 100 kΩ and 10 μF, enter 0.693147 s. The discharging capacitor then retains about half its initial voltage and one quarter of its initial energy because stored energy is proportional to voltage squared.", fields: [ { id: "resistance", @@ -135,8 +136,8 @@ export const studyTools: StudyTool[] = [ id: "diffusion", title: "Diffusion timescale", description: - "Estimate how diffusion time scales with distance and diffusivity.", - equation: "t ≈ L²/D", + "Compare a characteristic diffusion time with the time for a cloud to spread along a line or across a plane.", + equation: "tscale = L²/D; ⟨r²⟩ = 2dDt", assumptions: "This is a characteristic timescale. Geometry, boundary conditions, advection, and reactions determine a full transport solution.", fields: [ @@ -253,25 +254,45 @@ export function calculateStudyTool( throw new Error( "These inputs exceed the calculator’s numeric range. Use smaller or larger values.", ); + const elapsed = values.time / tau; + const remaining = Math.exp(-elapsed); result = [ { label: "Time constant", value: tau, unit: "s" }, { label: "Voltage step reached", - value: -Math.expm1(-values.time / tau) * 100, + value: -Math.expm1(-elapsed) * 100, + unit: "%", + }, + { + label: "Initial voltage remaining during discharge", + value: remaining * 100, + unit: "%", + }, + { + label: "Initial energy remaining during discharge", + value: remaining ** 2 * 100, unit: "%", }, ]; break; } - case "diffusion": + case "diffusion": { + const scale = (values.length * 1e-6) ** 2 / values.diffusivity; result = [ + { label: "Characteristic diffusion time", value: scale, unit: "s" }, { - label: "Characteristic diffusion time", - value: (values.length * 1e-6) ** 2 / values.diffusivity, + label: "Time to RMS distance on a line", + value: scale / 2, + unit: "s", + }, + { + label: "Time to RMS distance in a plane", + value: scale / 4, unit: "s", }, ]; break; + } case "ohm": { const current = values.voltage / values.resistance; result = [