Skip to content

Use GET parameters from URL to update code/exercise element #764

Answered by gadenbuie
MarHai asked this question in Q&A
Discussion options

You must be logged in to vote

It is possible to update the text in a code box dynamically from the Shiny server that runs the learnr tutorial, which means that you could in theory use the query parameters to initialize the code boxes. There are probably more than a few edge cases you'd want to think through (or end up running into).

The process for updating an exercise code box from the server isn't very straightforward and it requires writing a little bit of JavaScript. I'd recommend taking a look at my answer to a similar question on Posit Community.

First, you'd include a chunk of JavaScript in your learnr document.

```{js echo=FALSE}
//
// A custom Shiny message handler that updates the code in any exercise
// Fro…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@MarHai
Comment options

Answer selected by MarHai
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants