[LearnR] How to setup a secure code evaluator like rstudio.cloud does?

When we use the self-hosted version of Learn R or hosted version in shinyapps io , the user can print out variables that contain the tutorial source code or answer using the code evaluator.

For example in shinyapps io hosted version, the user can run
.server_context to get the source code of the current rmd:

See image here: https://imgur.com/hrWvWxG

But interestingly in rstudio cloud hosted version, the code evaluator seems to be sandboxed, and all "sensitive" variables cannot be run through the evaluator.

See image here: https://imgur.com/a/7Yyioev

Can I get some advice on how to implement such a secure code evaluator?

Thanks!