Skip to content
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

Do not reset question submissions #270

Merged
merged 4 commits into from
Aug 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ learnr 0.10.0 (unreleased)

* Missing package dependencies will ask to be installed at tutorial run time. (@isteves, [#253](https://github.com/rstudio/learnr/issues/253))

* When questions are tried again, the existing answer will remain, not forcing the user to restart from scratch. ([#270](https://github.com/rstudio/learnr/issues/270))


## Bug fixes

Expand Down
10 changes: 8 additions & 2 deletions R/quiz.R
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,10 @@ question_module_server_impl <- function(
if (is.null(submitted_answer())) {
# has not submitted, show regular answers
return(
question_ui_initialize(question, submitted_answer())
# if there is an existing input$answer, display it.
# if there is no answer... init with NULL
# Do not re-render the UI for every input$answer change
question_ui_initialize(question, isolate(input$answer))
)
}

Expand Down Expand Up @@ -526,7 +529,10 @@ question_module_server_impl <- function(
observeEvent(input$action_button, {

if (button_type() == "try_again") {
init_question(NULL)
# maintain current submission / do not randomize answer order
# only reset the submitted answers
# does NOT reset input$answer
submitted_answer(NULL)

# submit "reset" to server
reset_question_submission_event(
Expand Down