Fix AI Literacy Course lesson-item ordering#36
Merged
Conversation
CourseShell.itemsOf() sorted items by leadingNumber(it.title), but the title had already had its "N-" ordering prefix stripped by itemTitle(). The leadingNumber regex (\d+) then matched the first digit anywhere in the stripped title, so items whose text contains a number (e.g. "5-lesson-1-recap-quiz" -> "Lesson 1 Recap Quiz") sorted on that embedded "1" and jumped ahead of the genuinely-first items (e.g. "1-objectives" -> "Objectives", which had no digit left and sorted last). Every lesson came out scrambled and no longer matched the numbered course sequence. Sort instead by the numeric prefix of the original file/dir name, captured into Item.order before itemTitle() strips it, and anchor leadingNumber to ^(\d+) so it can only read the ordering prefix. Bump CourseInstaller.INSTALL_VERSION 2 -> 3 so existing installs re-extract and regenerate index.html with the corrected order.
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.
Tip: disable this comment in your organization's Code Review settings.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
The AI Literacy Course presented lesson items in the wrong order — it did not match the numbered sequence in the course bundle (
1-objectives.mp4,2-what-is-ai.mp4, …7-lesson-1-worksheet.zip).Root cause
CourseShell.itemsOf()sorted withcompareBy({ leadingNumber(it.title) }, { it.title }), butItem.titlehad already had itsN-ordering prefix stripped byitemTitle(). The oldleadingNumberregex(\d+)then matched the first digit anywhere in the stripped title. Two failures compounded:1-objectives→"Objectives"had no digit left →Int.MAX_VALUE→ sorted last.5-lesson-1-recap-quiz→"Lesson 1 Recap Quiz", picked up the embedded1→ sorted first.Result for Lesson 1 (buggy): Project Time → Recap Quiz → Worksheet → AI Or Not Quiz → How AI Can Help Us → Objectives → What Is AI.
Section-level ordering was already correct (
sectionOrder()keys off the raw folder name); only intra-section item order was broken.Fix
order: InttoItem, computed vialeadingNumber(...)from the original file/dir name (beforeitemTitle()strips the prefix), and sort byit.orderthen title.leadingNumberto^(\d+)so it can only read the leading ordering prefix, never a digit embedded later in the name.After the fix, Lesson 1 renders: Objectives → What Is AI → AI Or Not Quiz → How AI Can Help Us → Lesson 1 Recap Quiz → Lesson 1 Project Time → Lesson 1 Worksheet.
CourseShell.generate()only runs duringCourseInstaller.ensureInstalled(), which is gated by an install-version marker, soINSTALL_VERSIONis bumped 2 → 3 to force existing installs to re-extract and regenerateindex.htmlwith the corrected order.Verification
.cgpand installed on device (Samsung S22). Confirmed lessons now list items in numbered order. (Surfaced and fixed a separate pre-existing issue in the process:pdfjs.zipis a build-time downloaded asset, and a bareassemblePluginwithout a priordownloadAssetsships a viewer-less.cgp; re-fetched before the device test — see note below.)Note / possible follow-up
./gradlew assemblePluginsilently produces a broken plugin if the downloaded assets (pdfjs.zip,ai-literacy-course.zip) aren't present, with no build-time warning — onlyscripts/update-libs.shrunsdownloadAssetsfirst. A follow-up could makeassemblePluginfail fast (or depend ondownloadAssets) when those assets are missing. Not included here to keep this PR scoped to the ordering fix.