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

question_text() uses textAreaInput() if rows or cols are provided #460

Merged
merged 5 commits into from Jan 5, 2021

Conversation

gadenbuie
Copy link
Member

@gadenbuie gadenbuie commented Dec 30, 2020

Fixes #455

This PR adds rows and cols as parameters of question_text(). When provided, the text input UI will use textAreaInput() instead of textInput().

I used rows and cols as the parameter names so we can inherit documentation from textAreaInput(), but I'd be happy to update the parameter names or documentation to specifically mention that they change the input UI.

Reprex

Here's an example to try to create an "essay" input as described in #455. The question will always be graded as incorrect, but by setting allow_retry = TRUE and changing the try_again_button text, the input feels less binary correct/incorrect.

---
title: "Tutorial"
output: learnr::tutorial
runtime: shiny_prerendered
---

```{r setup, include=FALSE}
library(learnr)
```

## Text Questions

```{r question-text}
question_text("What's the best number of them all?", answer("42", TRUE))
```

```{r question-text-area}
question_text(
  "Why?", 
  answer("", correct = TRUE), # Question will always be "incorrect"
  rows = 5, 
  correct = NULL,
  incorrect = NULL,
  allow_retry = TRUE,
  try_again_button = "Edit Answer"
)
```

PR task list:

  • Update NEWS
  • Add tests (if possible)
  • Update documentation with devtools::document()

R/question_text.R Outdated Show resolved Hide resolved
@schloerke
Copy link
Collaborator

cc @dtkaplan @davidkane9

Does this PR address #455?

I think we'll hold off on a dedicated learnr_text_area() function for now. If you find yourself using a consistent set of rows/cols... please open a new issue and we can open the discussion to add learnr_text_area() and default to learnr_text_area(rows = m, cols = n)

Thank you! and Thank you @gadenbuie!

man/question_text.Rd Outdated Show resolved Hide resolved
@dtkaplan
Copy link

dtkaplan commented Jan 4, 2021 via email

@gadenbuie gadenbuie merged commit 3995bb7 into master Jan 5, 2021
@gadenbuie gadenbuie deleted the question-text-area branch January 5, 2021 15:59
@davidkane9
Copy link
Contributor

davidkane9 commented Jan 5, 2021 via email

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.

Use textAreaInput() in question_text() initialization
4 participants