-
Notifications
You must be signed in to change notification settings - Fork 240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Collect and report users's tutorial state for the current session in the Shiny app #562
Conversation
… update this state
Always update until the correct answer is submitted
Sounds great to me - I probably wont have a chance to play with it this week but I will take a look as soon as I can. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exciting!
Later we should talk about possibly exposing a reactive()
value instead of a reactiveVal()
, but the end user interface will not change.
Should we consider other information, like timestamp? Or should that be saved for the event logging.
0de2fd4
to
284c176
Compare
This reverts commit cc2355a.
A final question @schloerke: I refactored the tutorial state setting into fairly minimal |
Agreed. Let's export |
Co-authored-by: Barret Schloerke <barret@rstudio.com>
@davidkane9 Would I believe the only functionality that isn't covered is |
This PR addresses a common problem of tutorial app authors wanting to know the current state of the user's progress in the tutorial, for example to know which questions/exercises have received submissions, what answer was submitted and whether that answer was correct or incorrect.
To achieve this we now establish a reactive values list in
session$userData$tutorial_state
that is available to app authors in the shiny process. Authors can interact with this reactive list usingcontext = "server"
chunks but the reactive value is not accessible to submitted exercise code.As implemented, the reactive list is a named list with names matching the question or exercise label and containing:
type
: one of"question"
or"exercise"
answer
: the user's submitted answer as a character vector of possibly variable lengthcorrect
: A logicalTRUE
orFALSE
value of length 0 or 1. LogicalNA
values indicate the answer was not checked.timestamp
: A character timestamp in UTC indicating when the event was recorded, e.g."2021-08-10 14:56:38.834 UTC"
.The
tutorial_user_state.Rmd
tutorial in the sandbox demonstrates the structure and behavior of thetutorial_state
reactive. Here's a snapshot:The latest question submission is always reported, since landing on the correct answer is a terminal action. Exercise submissions are reported in the same way: submissions are always reported to the state reactive until the user reaches the correct answer. Thereafter, additional exercise submission events are ignored. (Technical note: if a student submits any code after the correct submission, the correct exercise submission event won't survive if the tutorial is reloaded in the browser.)
The final aspect of this PR is a minor change to scrub
correct
andfeedback
items from question and exercise submissions (respectively) for client storage only. For local storage, we keep these items. Regardless, thetutorial_state
is reconstructed on tutorial start when restoring tutorial state from storage. This ensures that thecorrect
flag intutorial_state
is accurate wrt. the current tutorial source in case the tutorial was updated after the users' state was stored. Note that when client storage is used, under certain conditions, it is possible that an exercise may not be re-checked on startup.cc @rundel The goal here is partly to give learnrhash and others an easy-to-access and lightweight representation of the current tutorial state. Rather than extracting submissions from the state objects in the tutorial storage, learnrhash can simply hash/encode the current users state of the tutorial.
Related PRs and Issues
correct
flag #393 by giving authors/developers a consistent place to find question/exercise state, includingcorrect