Allow cross-book doenet exercises - #1404
Open
oscarlevin wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes Doenet exercises failing to load when embedded from a different (base) course by ensuring embedded iframe URLs are rendered in anonymous “browsing” mode, avoiding the book server’s active-course mismatch redirect.
Changes:
- Append
?mode=browsingto baked Doenet iframesrcURLs during question build (_process_single_question). - Add an Alembic migration to backfill existing stored Doenet questions’ iframe URLs to include
?mode=browsing.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
components/rsptx/build_tools/core.py |
Updates Doenet iframe URL rewriting to append ?mode=browsing at build time. |
migrations/versions/5c11e34a2611_fix_doenet_iframe_course_mismatch.py |
Backfills existing doenet questions’ stored HTML to add (and remove on downgrade) the browsing-mode query param. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
1116
to
1120
| dbtext = re.sub( | ||
| r'(<iframe.*?)src="(.*?.html)"', | ||
| rf'\1 src="/ns/books/published/{course_name}/\2"', | ||
| rf'\1 src="/ns/books/published/{course_name}/\2?mode=browsing"', | ||
| dbtext, | ||
| ) |
Comment on lines
+45
to
+47
| # The negative lookahead on the closing quote keeps this idempotent -- a row | ||
| # already carrying ?mode=browsing (e.g. rebuilt after this fix shipped) is | ||
| # left untouched rather than getting a second query string appended. |
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.
Loading a doenet exercise that lives in another book redirected the iframe to the change course page. This adds the "?mode=browsing" param to the iframe url so the exercise appears. I tested it locally and seems to work.
Claude also provided a migration for existing books. I put that on a second commit in case you don't want to deal with it and just let the books rebuild.