Make 'continue' button customisable in sub-topics #777
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:### Subtopic Heading {data-continue-text: "Show Next Section"}
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!