| Title: | Convert R Markdown or Quarto Content into Interactive Tutorials |
|---|---|
| Description: | Helps teachers convert existing '.Rmd' and '.qmd' teaching material into interactive tutorials for 'learnr' or 'quarto-live'. Conversion preserves narrative text, setup chunks, and major chunk options, supports teacher tags, and provides explicit validation and conversion reports. |
| Authors: | Aurélien Nicosia [aut, cre] |
| Maintainer: | Aurélien Nicosia <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.4.3 |
| Built: | 2026-06-12 11:50:25 UTC |
| Source: | https://github.com/aureliennicosiaulaval/tutorizer |
Render a generated tutorial and return render status
check_tutorial(file, language = c("en", "fr"))check_tutorial(file, language = c("en", "fr"))
file |
Path to tutorial '.Rmd' to render. |
language |
Message language ('"en"' or '"fr"'). |
Invisibly, the render output path or the error object.
## Not run: check_tutorial("analysis-tutorial.Rmd") ## End(Not run)## Not run: check_tutorial("analysis-tutorial.Rmd") ## End(Not run)
Converts every matching source file in 'dir', with resilient per-file error handling and a summary report.
convert_folder( dir = ".", pattern = "\\.(Rmd|qmd)$", recursive = FALSE, output_dir = NULL, format = c("learnr", "quarto-live"), assessment = c("code", "mcq", "both"), overwrite = FALSE, language = c("en", "fr"), seed = NULL, verbose = TRUE, question_bank = NULL, mcq_source = c("inline", "bank", "mixed"), lint_strict = FALSE )convert_folder( dir = ".", pattern = "\\.(Rmd|qmd)$", recursive = FALSE, output_dir = NULL, format = c("learnr", "quarto-live"), assessment = c("code", "mcq", "both"), overwrite = FALSE, language = c("en", "fr"), seed = NULL, verbose = TRUE, question_bank = NULL, mcq_source = c("inline", "bank", "mixed"), lint_strict = FALSE )
dir |
Folder containing source files. |
pattern |
Regex pattern used to select files. |
recursive |
Logical; recurse into subdirectories? |
output_dir |
Optional output directory. |
format |
Output format ('"learnr"' or '"quarto-live"'). |
assessment |
Assessment mode ('"code"', '"mcq"', '"both"'). |
overwrite |
Logical; overwrite existing outputs? |
language |
Message/template language ('"en"' or '"fr"'). |
seed |
Optional integer seed injected in setup chunk. |
verbose |
Logical; print progress and summary? |
question_bank |
Optional path(s) or 'tutorize_question_bank' object. |
mcq_source |
MCQ generation source ('"inline"', '"bank"', '"mixed"'). |
lint_strict |
Logical; fail conversion when lint reports errors. |
A 'tutorize_folder_report' object (invisibly).
## Not run: report <- convert_folder("labs", recursive = TRUE) print(report) ## End(Not run)## Not run: report <- convert_folder("labs", recursive = TRUE) print(report) ## End(Not run)
'convert_to_tutorial()' is kept for compatibility with earlier versions. New code should use [tutorize()].
convert_to_tutorial( input_file, output_file = NULL, assessment = c("code", "mcq", "both"), format = c("learnr", "quarto-live"), add_mcq = NULL, question_bank = NULL, mcq_source = c("inline", "bank", "mixed"), lint_strict = FALSE )convert_to_tutorial( input_file, output_file = NULL, assessment = c("code", "mcq", "both"), format = c("learnr", "quarto-live"), add_mcq = NULL, question_bank = NULL, mcq_source = c("inline", "bank", "mixed"), lint_strict = FALSE )
input_file |
Path to source '.Rmd' or '.qmd' file. |
output_file |
Optional output path. If 'NULL', a default path is used. |
assessment |
Assessment mode: '"code"', '"mcq"', or '"both"'. |
format |
Output format: '"learnr"' or '"quarto-live"'. |
add_mcq |
Deprecated. Use 'assessment' instead. |
question_bank |
Optional path(s) or 'tutorize_question_bank' object. |
mcq_source |
MCQ generation source: '"inline"', '"bank"', '"mixed"'. |
lint_strict |
Logical; fail conversion when lint reports errors. |
Invisibly, the generated output file path.
## Not run: convert_to_tutorial("analysis.Rmd") ## End(Not run)## Not run: convert_to_tutorial("analysis.Rmd") ## End(Not run)
Export a profile-aware LMS manifest
export_lms_manifest( input, output_file = NULL, profile = c("generic", "canvas", "moodle"), include_solutions = TRUE, language = c("en", "fr") )export_lms_manifest( input, output_file = NULL, profile = c("generic", "canvas", "moodle"), include_solutions = TRUE, language = c("en", "fr") )
input |
Source '.Rmd'/'.qmd' file. |
output_file |
Optional output path. Default uses input stem. |
profile |
Manifest profile ('"generic"', '"canvas"', '"moodle"'). |
include_solutions |
Logical; mark exercise solutions as available. |
language |
Manifest language ('"en"' or '"fr"'). |
A 'tutorize_lms_manifest' object.
Export a tutorial-ready package scaffold (opt-in)
export_tutorial_package( input, path = ".", package_name = NULL, overwrite = FALSE )export_tutorial_package( input, path = ".", package_name = NULL, overwrite = FALSE )
input |
Source '.Rmd'/'.qmd' file. |
path |
Parent directory where the package directory will be created. |
package_name |
Optional package name. Derived from input by default. |
overwrite |
Logical; replace existing package directory if present. |
Invisibly returns the created package path.
Opens a lightweight prompt flow (format, assessment, output directory, overwrite) and converts the currently active file.
launch_tutorizeR_addin()launch_tutorizeR_addin()
Invisibly returns the 'tutorize_report' object, or 'NULL' when cancelled.
Prompts for folder and conversion options, then converts all matching files.
launch_tutorizeR_folder_addin()launch_tutorizeR_folder_addin()
Invisibly returns a 'tutorize_folder_report' object, or 'NULL' when cancelled.
Opens a gadget with Source, Output, Diff, Lint and Logs tabs.
launch_tutorizeR_preview_addin()launch_tutorizeR_preview_addin()
Invisibly returns a 'tutorize_report' object or 'NULL'.
Lint source pedagogical constraints before conversion
lint_source( input, question_bank = NULL, language = c("en", "fr"), strict = FALSE )lint_source( input, question_bank = NULL, language = c("en", "fr"), strict = FALSE )
input |
Source '.Rmd' or '.qmd' file. |
question_bank |
Optional 'tutorize_question_bank' object. |
language |
Message language ('"en"' or '"fr"'). |
strict |
Logical; if 'TRUE', stop when lint errors are present. |
A 'tutorize_lint_report' object.
Load a reusable MCQ question bank from YAML/JSON files
load_question_bank( path, recursive = TRUE, format = c("auto", "yaml", "json"), strict = TRUE, language = c("en", "fr") )load_question_bank( path, recursive = TRUE, format = c("auto", "yaml", "json"), strict = TRUE, language = c("en", "fr") )
path |
File or directory path(s) containing question bank files. |
recursive |
Logical; recurse into subdirectories when 'path' is a directory. |
format |
Input format: '"auto"', '"yaml"', or '"json"'. |
strict |
Logical; if 'TRUE', validation errors stop execution. |
language |
Language for validation messages ('"en"' or '"fr"'). |
A 'tutorize_question_bank' object.
Print method for folder conversion reports
## S3 method for class 'tutorize_folder_report' print(x, ...)## S3 method for class 'tutorize_folder_report' print(x, ...)
x |
A 'tutorize_folder_report' object. |
... |
Unused. |
'x', invisibly.
Print method for lint reports
## S3 method for class 'tutorize_lint_report' print(x, ...)## S3 method for class 'tutorize_lint_report' print(x, ...)
x |
A 'tutorize_lint_report' object. |
... |
Unused. |
'x', invisibly.
Print method for LMS manifest exports
## S3 method for class 'tutorize_lms_manifest' print(x, ...)## S3 method for class 'tutorize_lms_manifest' print(x, ...)
x |
A 'tutorize_lms_manifest' object. |
... |
Unused. |
'x', invisibly.
Print method for tutorize conversion reports
## S3 method for class 'tutorize_report' print(x, ...)## S3 method for class 'tutorize_report' print(x, ...)
x |
A 'tutorize_report' object. |
... |
Unused. |
'x', invisibly.
Looks up a message key in language dictionaries and interpolates named
placeholders (for example, "{name}").
tr(key, ..., language = NULL)tr(key, ..., language = NULL)
key |
Dot-separated translation key (e.g. '"messages.render_ok"'). |
... |
Named interpolation values. |
language |
Optional language ('"en"' or '"fr"'). |
A translated character string.
'tutorize()' is the canonical high-level API. It converts an existing '.Rmd' or '.qmd' source document into a tutorial-ready document for 'learnr' or 'quarto-live'.
tutorize( input, output_dir = NULL, format = c("learnr", "quarto-live"), assessment = c("code", "mcq", "both"), overwrite = FALSE, language = c("en", "fr"), seed = NULL, verbose = TRUE, output_file = NULL, question_bank = NULL, mcq_source = c("inline", "bank", "mixed"), lint_strict = FALSE )tutorize( input, output_dir = NULL, format = c("learnr", "quarto-live"), assessment = c("code", "mcq", "both"), overwrite = FALSE, language = c("en", "fr"), seed = NULL, verbose = TRUE, output_file = NULL, question_bank = NULL, mcq_source = c("inline", "bank", "mixed"), lint_strict = FALSE )
input |
Path to source '.Rmd' or '.qmd' file. |
output_dir |
Optional output directory. Defaults to source directory. |
format |
Output format: '"learnr"' (default) or '"quarto-live"'. |
assessment |
Assessment mode: '"code"', '"mcq"', or '"both"'. |
overwrite |
Logical; overwrite existing output file? |
language |
Message/template language: '"en"' (default) or '"fr"'. |
seed |
Optional integer seed injected into setup chunk. |
verbose |
Logical; show progress and diagnostic messages? |
output_file |
Optional explicit output file path. Useful for wrappers. |
question_bank |
Optional path(s) or 'tutorize_question_bank' object. |
mcq_source |
MCQ generation source: '"inline"', '"bank"', '"mixed"'. |
lint_strict |
Logical; fail conversion when lint reports errors. |
A 'tutorize_report' object (invisibly).
## Not run: rep <- tutorize("analysis.qmd", format = "learnr", assessment = "both") print(rep) ## End(Not run)## Not run: rep <- tutorize("analysis.qmd", format = "learnr", assessment = "both") print(rep) ## End(Not run)
Performs defensive checks for file path, format, assessment, and extension.
validate_input( input, format = c("learnr", "quarto-live"), assessment = c("code", "mcq", "both"), language = c("en", "fr") )validate_input( input, format = c("learnr", "quarto-live"), assessment = c("code", "mcq", "both"), language = c("en", "fr") )
input |
Path to source '.Rmd' or '.qmd' document. |
format |
Target output format ('"learnr"' or '"quarto-live"'). |
assessment |
Assessment mode ('"code"', '"mcq"', or '"both"'). |
language |
Language for validation messages ('"en"' or '"fr"'). |
Invisibly returns 'TRUE' if validation succeeds.
Validate output path and overwrite strategy
validate_output( output_file, input_file, overwrite = FALSE, language = c("en", "fr") )validate_output( output_file, input_file, overwrite = FALSE, language = c("en", "fr") )
output_file |
Destination output file path. |
input_file |
Source file path. |
overwrite |
Logical; allow replacing an existing output. |
language |
Language for validation messages ('"en"' or '"fr"'). |
Invisibly returns 'TRUE' if validation succeeds.
Validate a 'tutorize_question_bank' object
validate_question_bank(bank, strict = TRUE, language = c("en", "fr"))validate_question_bank(bank, strict = TRUE, language = c("en", "fr"))
bank |
A question bank object from [load_question_bank()]. |
strict |
Logical; if 'TRUE', stop on validation errors. |
language |
Language for validation messages ('"en"' or '"fr"'). |
A 'tutorize_lint_report' object.
Write a conversion report to JSON or YAML
write_tutorize_report(report, file, format = c("json", "yaml"), pretty = TRUE)write_tutorize_report(report, file, format = c("json", "yaml"), pretty = TRUE)
report |
A 'tutorize_report' object. |
file |
Output file path. |
format |
Output serialization format ('"json"' or '"yaml"'). |
pretty |
Logical; pretty-print JSON output. |
Invisibly returns 'file'.