diff --git a/DESCRIPTION b/DESCRIPTION index e401729..fb7e478 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: learnitdown Type: Package -Version: 1.7.0 +Version: 1.8.0 Title: R Markdown, Bookdown and Learnr Additions for Learning Material Description: Extension to R Markdown, Bookdown and Learnr for building better learning and e-learning material: H5P integration, course-contextual divs, diff --git a/NEWS.md b/NEWS.md index c512028..dac77bd 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,10 @@ # learnitdown 1.7.0 -- `webshot_shiny()` now also accepts the path to a PNG file (the screenshot of the app) instead of the url to the Shiny application. This allows to create the webshot image in case the app cannot be accessed directly (for instance, a login in Posit Connect is required). The corresponding RStudio addin is modified to ask fpr a PNG screenshot if no suitable code is selected. +- Shiny and learnr events are now recorded in the "events" table instead of "shiny" or "learnr" tables. + +# learnitdown 1.7.0 + +- `webshot_shiny()` now also accepts the path to a PNG file (the screenshot of the app) instead of the url to the Shiny application. This allows to create the webshot image in case the app cannot be accessed directly (for instance, a login in Posit Connect is required). The corresponding RStudio addin is modified to ask for a PNG screenshot if no suitable code is selected. # learnitdown 1.6.0 diff --git a/R/learnitdown_learnr.R b/R/learnitdown_learnr.R index 778a6dd..ebc6de0 100644 --- a/R/learnitdown_learnr.R +++ b/R/learnitdown_learnr.R @@ -68,7 +68,7 @@ record_learnr <- function(tutorial_id, tutorial_version, user_id, event, data) { } # Try to access the database - m <- try(mongo(collection = "learnr", db = db, url = glue(url)), + m <- try(mongo(collection = "events", db = db, url = glue(url)), silent = TRUE) if (inherits(m, "try-error")) { options(learnitdown_learnr_record = FALSE) @@ -198,7 +198,7 @@ record_learnr <- function(tutorial_id, tutorial_version, user_id, event, data) { use_db <- isTRUE(getOption("learnitdown_learnr_record", default = TRUE)) if (use_db) { m <- try({ - m <- mongo(collection = "learnr", db = db, url = glue(url)) + m <- mongo(collection = "events", db = db, url = glue(url)) m$insert(toJSON(entry, auto_unbox = TRUE)) if (debug) message("Learnr event '", entry$verb, "' inserted into database.") @@ -237,7 +237,7 @@ record_learnr <- function(tutorial_id, tutorial_version, user_id, event, data) { # url.server <- glue:glue(Sys.getenv("MONGO_URL_SERVER") # if (isTRUE(server.db)) # url <- url.server -# mdb <- mongolite::mongo(collection = "learnr", db = db, url = url) +# mdb <- mongolite::mongo(collection = "events", db = db, url = url) # if (mdb$count()) # mdb$find() #} @@ -354,7 +354,7 @@ Thanks. subject = subject, address = address) invisible(data) } else { - message("No alearnr activity locally recorded") + message("No learnr activity locally recorded") invisible(character(0)) } } diff --git a/R/learnitdown_shiny.R b/R/learnitdown_shiny.R index 26807a9..6af016d 100644 --- a/R/learnitdown_shiny.R +++ b/R/learnitdown_shiny.R @@ -217,7 +217,7 @@ read_shinylogs <- function(file, version = "0", res } -.record_shinylogs <- function(file, url, db, collection = "shiny", +.record_shinylogs <- function(file, url, db, collection = "events", version = "0", log.errors = TRUE, log.outputs = FALSE, debug = Sys.getenv("LEARNITDOWN_DEBUG", 0) != 0) { @@ -290,7 +290,7 @@ debug = Sys.getenv("LEARNITDOWN_DEBUG", 0) != 0) { #' @export #' #' @seealso [read_shinylogs()], [trackEvents()] -record_shiny <- function(path, url, db, collection = "shiny", +record_shiny <- function(path, url, db, collection = "events", version = "0", log.errors = TRUE, log.outputs = FALSE, drop.dir = FALSE, debug = Sys.getenv("LEARNITDOWN_DEBUG", 0) != 0) { debug <- isTRUE(debug) @@ -564,7 +564,7 @@ debug = Sys.getenv("LEARNITDOWN_DEBUG", 0) != 0) { Sys.getenv('SHINY_PORT') == "" is_server_up <- function(url, db) { - res <- try(mongo(collection = "shiny", db = db, url = url), + res <- try(mongo(collection = "events", db = db, url = url), silent = TRUE) !inherits(res, "try-error") } diff --git a/inst/WORDLIST b/inst/WORDLIST index 92858cf..25791ab 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -47,6 +47,7 @@ shinylogs toc UI unserialize +webshot Wordpress xAPI YAML diff --git a/man/record_shiny.Rd b/man/record_shiny.Rd index 6c2df1c..a86a395 100644 --- a/man/record_shiny.Rd +++ b/man/record_shiny.Rd @@ -8,7 +8,7 @@ record_shiny( path, url, db, - collection = "shiny", + collection = "events", version = "0", log.errors = TRUE, log.outputs = FALSE, diff --git a/man/webshot_shiny.Rd b/man/webshot_shiny.Rd index 00629db..2647a50 100644 --- a/man/webshot_shiny.Rd +++ b/man/webshot_shiny.Rd @@ -6,7 +6,7 @@ \usage{ webshot_shiny( url, - app = basename(url), + app = NULL, imgdir = "images/shinyapps", img = paste0(imgdir, "/", app, ".png"), width = 790, @@ -18,9 +18,11 @@ webshot_shiny( ) } \arguments{ -\item{url}{The URL to launch the Shiny app. If both \verb{app =} and \verb{baseurl =}} +\item{url}{The URL to launch the Shiny app, or to a screenshot of the app in +PNG format.} -\item{app}{The name of the Shiny application. +\item{app}{The name of the Shiny application. If \code{NULL}, the base name of the +URL without the extension is used. are provided, you don't need to specify it.} \item{imgdir}{The directory without trailing "/" where images relative