Skip to content

Allow cross-book doenet exercises - #1404

Open
oscarlevin wants to merge 2 commits into
RunestoneInteractive:mainfrom
oscarlevin:doenet-external
Open

Allow cross-book doenet exercises#1404
oscarlevin wants to merge 2 commits into
RunestoneInteractive:mainfrom
oscarlevin:doenet-external

Conversation

@oscarlevin

Copy link
Copy Markdown
Collaborator

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.

@oscarlevin
oscarlevin requested a review from bnmnetp as a code owner August 21, 2026 22:23
Copilot AI lite review requested due to automatic review settings August 21, 2026 22:23

Copilot AI 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.

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=browsing to baked Doenet iframe src URLs 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.
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.

2 participants