Skip to content

Use textAreaInput() in question_text() initialization #455

@dtkaplan

Description

@dtkaplan

In the tutorials I write I often have essay questions. I have a custom question type for this purpose. But I realize that the current question_text() will support essays: it's just a matter of calling it with the right arguments, e.g.

```{r essay-14}
question_text("What do you think about this?", 
   answer("nice", correct=TRUE), allow_retry=TRUE, incorrect=NULL, 
   try_again_button = "Edit answer.", options=list(nrows=6))
```

I realize that this is not what question_text() was originally intended for, but it works fine and the change is very simple: change textInput to textAreaInput and perhaps allow the number of rows to be set via the question options.

question_ui_initialize.learnr_text <- function(question, value, ...) {
  textAreaInput( 
    question$ids$answer,
    label = question$question,
    placeholder = question$options$placeholder,
    value = value,
    rows = question$options$nrows %||% 1  # Keep it small for backward compatibility
  )
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions