Use Custom `trace`-Functions to Inspect Log Events
inspect_log_events.Rmd
This example shows how to use the package
ShinyItemBuilder
with a custom trace
-function,
to show log events live in the R console window, while interacting with
a CBA ItemBuilder task. We will use the item provided as
demo03
.
library(shiny)
library(ShinyItemBuilder)
item_pool <- getDemoPool(name="demo02")
assessment_config <- getConfig()
assessment_config$trace <- function(pool, session, item, e){
tmp <- jsonlite::fromJSON(e$trace)
for (i in 1:dim(tmp$logEntriesList)[1]){
d <- names(tmp$logEntriesList$details[i,])[!is.na(tmp$logEntriesList$details[i,])]
cat(paste0("Type: ", tmp$logEntriesList[i,"type"], "\n",
"Time: ", lubridate::seconds(lubridate::ymd_hms(tmp$logEntriesList[i,"timestamp"])), "\n",
"Details: ", length(d), " Attributes \n\n"))
}
}
shinyApp(assessmentOutput(pool = item_pool,
config = assessment_config,
overwrite=T),
renderAssessment)