Skip to content

back button now focuses module - #148

Merged
jdang00 merged 1 commit into
mainfrom
stage
Apr 23, 2026
Merged

jdang00 merged 1 commit into
mainfrom
stage

Conversation

@jdang00

@jdang00 jdang00 commented Apr 23, 2026 •

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Added new participation lab assignment to the Pediatrics course
    • Introduced additional extra credit opportunities (bonus quizzes and reading assignment)
    • Updated quiz naming for better clarity
  • Improvements

    • Enhanced navigation to preserve selected class context when navigating back from module and quiz views

@vercel

vercel Bot commented Apr 23, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
learnterms Ready Ready Preview, Comment Apr 23, 2026 9:24pm

@coderabbitai

coderabbitai Bot commented Apr 23, 2026 •

Copy link
Copy Markdown
Contributor

Walkthrough

This PR extends navigation routing across multiple components by passing classId as a query parameter through the component hierarchy, allowing back-navigation links to preserve the selected class context. Additionally, seed data for the "Pediatrics" course is updated with modified participation points and extra credit items.

Changes

Cohort / File(s) Summary
Grade Calculator Seed Data
src/convex/gradeCalculatorCatalog.ts
Updated "Pediatrics" course "Participation" total from 9 to 10 points, added "Lab 9: Child Abuse Reflection Assignment" (1 point), renamed quiz-8, and extended "Extra Credit" with additional bonus quiz and book-reading instances.
Component classId Navigation Props
src/lib/components/MainQuiz.svelte, src/lib/components/MobileInfo.svelte, src/lib/components/ModuleInfo.svelte, src/lib/components/QuizSideBar.svelte
Enhanced navigation components to accept and pass classId as a prop, deriving module-selection URLs with classId query parameter for back-navigation links instead of linking to generic /classes route.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • some minor model and select changes #79: Both PRs modify MainQuiz.svelte and component prop handling—this PR adds classId routing through navigation components while the related PR expands MainQuiz props and integrations.

Poem

🐰 A trail of breadcrumbs, each bearing a name,
ClassId threads through, makes routing the same,
Where back-buttons knew not the path they came,
Now teachers and learners find their way back—no blame! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'back button now focuses module' is vague and does not clearly convey the main change. The PR actually implements class-specific navigation with classId parameters across multiple components, not just a module focus feature. Consider a more descriptive title that captures the core change, such as 'Add classId parameter to back navigation links' or 'Implement class-aware navigation in components'.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch stage

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
src/lib/components/MobileInfo.svelte (1)

2-2: Add explicit types for the props.

Since this file uses <script lang="ts">, the newly added classId (and existing module) prop is currently typed as any. For consistency with ModuleInfo.svelte (which types classId: Id<'class'>), and to catch mis-wiring from callers at build time, consider:

♻️ Proposed typing
-	let { module, classId } = $props();
 	import { ArrowLeft } from 'lucide-svelte';
 	import { resolve } from '$app/paths';
+	import type { Doc, Id } from '../../convex/_generated/dataModel';
+
+	let {
+		module,
+		classId
+	}: {
+		module: { data: Doc<'module'> };
+		classId: Id<'class'>;
+	} = $props();
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/lib/components/MobileInfo.svelte` at line 2, The props in
MobileInfo.svelte are currently implicitly any; add explicit TypeScript types to
the destructured props so they match ModuleInfo.svelte (e.g., type the module
prop appropriately and set classId: Id<'class'>) by updating the prop
declaration that reads let { module, classId } = $props() to include the correct
types for module and classId so callers are type-checked at build time.
src/lib/components/QuizSideBar.svelte (1)

15-17: Dedupe the moduleSelectionHref derivation.

The exact same derivation now exists in three components (ModuleInfo.svelte, QuizSideBar.svelte, MobileInfo.svelte). Consider extracting a small helper such as buildClassesHref(classId) in $lib/utils so future route/query-param changes only need to be made in one place.

♻️ Example helper
// $lib/utils/navigation.ts
import { resolve } from '$app/paths';

export function buildClassesHref(classId: string): string {
	return `${resolve('/classes')}?classId=${encodeURIComponent(classId)}`;
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/lib/components/QuizSideBar.svelte` around lines 15 - 17,
moduleSelectionHref is duplicated across ModuleInfo.svelte, QuizSideBar.svelte,
and MobileInfo.svelte; extract a helper (e.g., buildClassesHref in
$lib/utils/navigation.ts) that wraps resolve('/classes') and encodeURIComponent
for classId, then replace the moduleSelectionHref derivation in each component
with a call to buildClassesHref(classId) (importing the helper) so route/query
logic lives in one place.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/lib/components/ModuleInfo.svelte`:
- Around line 38-40: The URL query string is currently appended outside
resolve(), which violates svelte/no-navigation-without-resolve; update the code
so resolve() receives the full path including the query (e.g., call
resolve(`/classes?classId=${encodeURIComponent(String(classId))}`)) and do the
same change for moduleSelectionHref in ModuleInfo.svelte and the analogous
variables in QuizSideBar.svelte and MobileInfo.svelte; to avoid duplication,
extract the encodeURIComponent(String(classId)) logic into a shared helper
(e.g., a util like formatClassIdQuery or buildClassHref) and use that helper
when constructing the resolve() argument.

---

Nitpick comments:
In `@src/lib/components/MobileInfo.svelte`:
- Line 2: The props in MobileInfo.svelte are currently implicitly any; add
explicit TypeScript types to the destructured props so they match
ModuleInfo.svelte (e.g., type the module prop appropriately and set classId:
Id<'class'>) by updating the prop declaration that reads let { module, classId }
= $props() to include the correct types for module and classId so callers are
type-checked at build time.

In `@src/lib/components/QuizSideBar.svelte`:
- Around line 15-17: moduleSelectionHref is duplicated across ModuleInfo.svelte,
QuizSideBar.svelte, and MobileInfo.svelte; extract a helper (e.g.,
buildClassesHref in $lib/utils/navigation.ts) that wraps resolve('/classes') and
encodeURIComponent for classId, then replace the moduleSelectionHref derivation
in each component with a call to buildClassesHref(classId) (importing the
helper) so route/query logic lives in one place.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e5b74e29-da8b-446b-9e0c-f6dd22cfdc12

📥 Commits

Reviewing files that changed from the base of the PR and between 8b9a1c1 and bb0b1fd.

📒 Files selected for processing (5)
  • src/convex/gradeCalculatorCatalog.ts
  • src/lib/components/MainQuiz.svelte
  • src/lib/components/MobileInfo.svelte
  • src/lib/components/ModuleInfo.svelte
  • src/lib/components/QuizSideBar.svelte

Comment on lines +38 to +40
const moduleSelectionHref = $derived(
`${resolve('/classes')}?classId=${encodeURIComponent(String(classId))}`
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

SvelteKit 2 resolve function from $app/paths query parameters support

💡 Result:

Yes, in SvelteKit 2 (specifically version 2.54.0 and later), the resolve function from $app/paths supports query parameters. It accepts pathnames with query strings (?${string}) and hash fragments (#${string}) via updated types: PathnameWithSearchOrHash and RouteIdWithSearchOrHash. This is a type-only change; runtime handling of ? and # was already supported. Examples: - resolve('/products?page=2') now type-checks correctly. - resolve('/blog/[slug]?foo=bar', { slug: 'hello' }) works with route params. This enables goto(resolve('/path?query=1')) without TypeScript errors or lint issues from svelte/no-navigation-without-resolve. An earlier PR (#14756) added optional { searchParams, hash } object params, but the primary query string support comes from PR #15458 merged March 3, 2026, released in 2.54.0 (March 11, 2026). As of 2026-04-23, latest is 2.57.1, so fully supported in current versions. Official docs confirm via type signatures: function resolve<T extends RouteIdWithSearchOrHash | PathnameWithSearchOrHash>(...args: ResolveArgs): ResolvedPathname;

Citations:


🏁 Script executed:

cat package.json | grep -A 2 '@sveltejs/kit'

Repository: jdang00/learnterms

Length of output: 175


🏁 Script executed:

fd -e svelte -type f | grep -E '(ModuleInfo|QuizSideBar|MobileInfo)' | head -20

Repository: jdang00/learnterms

Length of output: 232


🏁 Script executed:

rg "const.*Href.*\$derived" --type svelte -A 2

Repository: jdang00/learnterms

Length of output: 92


🏁 Script executed:

fd -name "ModuleInfo.svelte" -o -name "QuizSideBar.svelte" -o -name "MobileInfo.svelte"

Repository: jdang00/learnterms

Length of output: 292


🏁 Script executed:

rg "const.*Href.*\$derived" -A 2 --glob "*.svelte"

Repository: jdang00/learnterms

Length of output: 44


🏁 Script executed:

cat -n src/lib/components/ModuleInfo.svelte | sed -n '35,45p'

Repository: jdang00/learnterms

Length of output: 440


🏁 Script executed:

fd "\.svelte$" | head -30

Repository: jdang00/learnterms

Length of output: 1245


🏁 Script executed:

rg "QuizSideBar|MobileInfo" --glob "*.svelte" -l

Repository: jdang00/learnterms

Length of output: 96


🏁 Script executed:

rg "Href.*\$derived" --glob "*.svelte" -B 1 -A 1

Repository: jdang00/learnterms

Length of output: 44


🏁 Script executed:

fd "\.svelte$" | xargs grep -l "classId"

Repository: jdang00/learnterms

Length of output: 1498


🏁 Script executed:

fd "\.svelte$" | xargs grep -l "moduleSelectionHref\|classSelectionHref"

Repository: jdang00/learnterms

Length of output: 573


🏁 Script executed:

cat -n src/lib/components/MainQuiz.svelte | sed -n '1,50p'

Repository: jdang00/learnterms

Length of output: 2190


🏁 Script executed:

rg "resolve.*classId|classId.*resolve" src/lib/components/QuizSideBar.svelte -B 2 -A 2

Repository: jdang00/learnterms

Length of output: 264


🏁 Script executed:

rg "resolve.*classId|classId.*resolve" src/lib/components/MobileInfo.svelte -B 2 -A 2

Repository: jdang00/learnterms

Length of output: 189


🏁 Script executed:

cat -n src/lib/components/QuizSideBar.svelte | grep -E "resolve|Href" -B 2 -A 2

Repository: jdang00/learnterms

Length of output: 1254


🏁 Script executed:

find . -name ".eslintrc*" -o -name "eslint.config.*" | head -5

Repository: jdang00/learnterms

Length of output: 305


🏁 Script executed:

cat -n src/lib/components/ModuleInfo.svelte | head -1

Repository: jdang00/learnterms

Length of output: 87


🏁 Script executed:

rg "no-navigation-without-resolve" --type-list | head -5

Repository: jdang00/learnterms

Length of output: 451


🏁 Script executed:

find node_modules/@sveltejs/kit -name "*.d.ts" | xargs grep -l "resolve" | head -3

Repository: jdang00/learnterms

Length of output: 230


🏁 Script executed:

cat eslint.config.js

Repository: jdang00/learnterms

Length of output: 901


🏁 Script executed:

cat node_modules/@sveltejs/kit/src/runtime/app/paths/public.d.ts

Repository: jdang00/learnterms

Length of output: 1307


🏁 Script executed:

rg "no-navigation-without-resolve" eslint.config.js

Repository: jdang00/learnterms

Length of output: 44


🏁 Script executed:

cat node_modules/@sveltejs/kit/src/types/index.d.ts | grep -A 10 "RouteIdWithSearchOrHash\|PathnameWithSearchOrHash" | head -30

Repository: jdang00/learnterms

Length of output: 141


🏁 Script executed:

cat node_modules/@sveltejs/kit/src/runtime/app/paths/types.d.ts

Repository: jdang00/learnterms

Length of output: 721


🏁 Script executed:

rg "svelte/no-navigation-without-resolve" node_modules/eslint-plugin-svelte -A 5 | head -50

Repository: jdang00/learnterms

Length of output: 3147


🏁 Script executed:

find . -path ./node_modules -prune -o -name "*utils*" -type f | grep -E "\.(ts|js|svelte)$" | head -20

Repository: jdang00/learnterms

Length of output: 44


🏁 Script executed:

rg "resolve.*?search|searchParams" node_modules/@sveltejs/kit --type ts --type js -A 2 | head -50

Repository: jdang00/learnterms

Length of output: 3913


🏁 Script executed:

cat node_modules/@sveltejs/kit/src/runtime/app/paths/client.js 2>/dev/null || cat node_modules/@sveltejs/kit/dist/client.js | head -50

Repository: jdang00/learnterms

Length of output: 3011


🏁 Script executed:

rg "no-navigation-without-resolve" node_modules/eslint-plugin-svelte/docs -A 20 | head -60

Repository: jdang00/learnterms

Length of output: 140


🏁 Script executed:

find node_modules/eslint-plugin-svelte -name "*.md" -o -name "*.js" | xargs grep -l "no-navigation-without-resolve" | head -3

Repository: jdang00/learnterms

Length of output: 248


🏁 Script executed:

cat node_modules/eslint-plugin-svelte/docs/rules/no-navigation-without-resolve.md 2>/dev/null | head -100

Repository: jdang00/learnterms

Length of output: 44


🏁 Script executed:

cat node_modules/eslint-plugin-svelte/lib/rules/no-navigation-without-resolve.js | head -150

Repository: jdang00/learnterms

Length of output: 6199


🏁 Script executed:

rg "resolve.*\?" src/lib/components -A 1 -B 1

Repository: jdang00/learnterms

Length of output: 989


🏁 Script executed:

cat node_modules/@sveltejs/kit/src/runtime/app/paths/client.js | grep -A 5 "resolve_route"

Repository: jdang00/learnterms

Length of output: 714


🏁 Script executed:

rg "resolve.*\?" src/lib/components/MobileMenu.svelte -B 2 -A 2

Repository: jdang00/learnterms

Length of output: 223


🏁 Script executed:

python3 << 'EOF'
# Check SvelteKit 2.53.4 resolve() signature in package.json and types
import json
import os

pkg_path = 'node_modules/@sveltejs/kit/package.json'
if os.path.exists(pkg_path):
    with open(pkg_path) as f:
        pkg = json.load(f)
        print(f"Version: {pkg.get('version')}")
        print(f"Main: {pkg.get('main')}")
EOF

Repository: jdang00/learnterms

Length of output: 88


🏁 Script executed:

# Check if the resolve() function handles query strings in pathname
rg "resolve_route\(" node_modules/@sveltejs/kit/src/utils -A 10 | head -40

Repository: jdang00/learnterms

Length of output: 900


🏁 Script executed:

cat node_modules/@sveltejs/kit/src/utils/routing.js | head -30

Repository: jdang00/learnterms

Length of output: 901


🏁 Script executed:

rg "PathnameWithSearchOrHash|RouteIdWithSearchOrHash" node_modules/@sveltejs/kit/src/types -A 2 | head -50

Repository: jdang00/learnterms

Length of output: 549


🏁 Script executed:

rg "Pathname|PathnameWithSearchOrHash" node_modules/@sveltejs/kit/src/types/ambient.d.ts -B 1 -A 1

Repository: jdang00/learnterms

Length of output: 621


🏁 Script executed:

# Verify resolve() actual behavior with query strings
cat node_modules/@sveltejs/kit/src/utils/routing.js | tail -20

Repository: jdang00/learnterms

Length of output: 602


Move the query string inside the resolve() call to satisfy the lint rule.

The svelte/no-navigation-without-resolve rule expects the entire URL (including query params) to be constructed within resolve(). SvelteKit's resolve() API already supports query strings and hash fragments directly in the pathname:

-	const moduleSelectionHref = $derived(
-		`${resolve('/classes')}?classId=${encodeURIComponent(String(classId))}`
-	);
+	const moduleSelectionHref = $derived(
+		resolve(`/classes?classId=${encodeURIComponent(String(classId))}`)
+	);

This pattern is duplicated across ModuleInfo.svelte, QuizSideBar.svelte, and MobileInfo.svelte. Consider extracting the encodeURIComponent logic into a shared utility to reduce duplication.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const moduleSelectionHref = $derived(
`${resolve('/classes')}?classId=${encodeURIComponent(String(classId))}`
);
const moduleSelectionHref = $derived(
resolve(`/classes?classId=${encodeURIComponent(String(classId))}`)
);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/lib/components/ModuleInfo.svelte` around lines 38 - 40, The URL query
string is currently appended outside resolve(), which violates
svelte/no-navigation-without-resolve; update the code so resolve() receives the
full path including the query (e.g., call
resolve(`/classes?classId=${encodeURIComponent(String(classId))}`)) and do the
same change for moduleSelectionHref in ModuleInfo.svelte and the analogous
variables in QuizSideBar.svelte and MobileInfo.svelte; to avoid duplication,
extract the encodeURIComponent(String(classId)) logic into a shared helper
(e.g., a util like formatClassIdQuery or buildClassHref) and use that helper
when constructing the resolve() argument.

@jdang00
jdang00 merged commit a31dff2 into main Apr 23, 2026
1 check passed

This branch was successfully deployed

1 active deployment
Preview — bb0b1fdf Deployed Apr 23, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant