Closed dave-mills closed 11 months ago
Example of an Rmd file with this feature:
---
title: "Example custom button text"
output:
learnr::tutorial:
progressive: yes
runtime: shiny_prerendered
description: Example learnr tutorial with custom continue buttons
---
```{r setup, include=FALSE}
library(learnr)
Question text goes here.
Solution text goes here.
Question 2 text.
The next button has the 'default' text for your langauge.
etc...
Customise 'continue' button text
This PR adds the ability to specify custom 'continue' button text for each subtopic with a
data-continue-text
attribute. It uses the same syntax as for adding the progressive reveal option to individual topics:Any subtopics without this attribute will still use the default "Continue" text, as defined by the translation files.
Rationale
We use learnr a lot for writing interactive modules for online or mixed-learning R, statistics and data management courses. Often, we use progressively revealed subtopics for self-assessed quizzes, and we wanted a way to replace the 'Continue' text with e.g. "Show Solution", or "Next Question". I made a hack-y version for us with a custom JavaScript file, but I thought it'd be nicer to have a built-in option.
Concerns
I understand that this may be a very niche feature, so you may not want to include it for that reason. I also realise that the custom text is not translatable with this setup, but given that each document only uses 1 language at a time right now, I figured that making the custom text translatable wasn't vital. But if/when learnr is updated to allow multiple languages at the same time this would need fixing.
PR task list:
devtools::document()
(btw - I didn't know if/how this could be testable. I'm not very familiar with R package development, so happy to add tests if needed or tidy up other package-dev things!)
Thanks for your time, and thanks for such a great package for building training resources!