Adds a small, ungraded form for the reader to fill in identifying
information before starting a tutorial: name and email required, an ID
optional, by default. Unlike question(), nothing here is graded and
there is no model answer to reveal – it is auto-saved to the browser's
localStorage as the reader types and restored on their next visit, the
same as every other field here. A confirmation button, matching the one
on every question() in both style and behavior, gives the reader an
explicit way to confirm their entry and see the required fields checked
right away, instead of only finding out when they later try to download:
it reads "Submit" until they successfully do, at which point it switches
to "Edit" (like a "reflection_editable" question()) since any further
click is revising an already-confirmed entry, not submitting for the
first time. Pair with download_answers_button() so a reader can turn
their work in.
Arguments
- fields
A named character vector of field key/label pairs to collect. Defaults to name, email, and an optional ID, matching 'tutorial.helpers”s
info_section.Rmd. A field named"email"is additionally checked for an"@"character, regardless of whether it isrequired.- required
Character vector of keys (from
fields) the reader must fill in. Defaults to whichever of"name"and"email"are actually present infields, so ID is optional by default and supplying customfieldsdoes not require also supplyingrequired. A required field left blank, or an"email"field missing an"@", is flagged inline (on blur, and again when the button is clicked) and blocksdownload_answers_button()until it's fixed. Passing a key that is not infieldsis an error.- id
Stable identifier used to key the saved values in
localStorage. Defaults to"student-info"; change it if a single tutorial embeds more than onestudent_info()form.Button label shown before the reader has successfully confirmed their entry.
Button label shown instead of
submit_buttonfrom then on – mirrorsquestion()'sedit_buttonfor a"reflection_editable"question exactly, including persisting across a reload.
Examples
student_info()
student_info(fields = c(name = "Full name:", section = "Section:"), required = "name")