knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
The moodleR package contains functions and algorithms to access Moodle$^{TM}$ data and perform reporting and/or learning analytics based in these data. For more information about Moodle go to www.moodle.org. For more information about $\chi^\color{red}2$ (chi square) Laboratories and the work we do in learning analytics, visit our website: www.chi2labs.com.
To install the latest stable release from CRAN use:
install.packages("moodleR")
To install the latest development version:
devtools::install("chi2labs/moodleR")
After which the package is attached in the usual way.
library(moodleR)
When connecting to a moodle database moodleR will look for database information in a config file (config.yml). The fields that need to be included can be seen in the snipped below:
default: moodleR: user: "root" password: "root" dbname: "moodle38" host: "localhost" port: 3306
Once the connection information available you can get a connection to the database by calling mdl_get_connection()
, with the use_cache
set to false:
mdl_con <- mdl_get_connection(use_cache = FALSE)
The reason for use_cache = FALSE
will be explained below.
The moodleR package allows you to create a cache of the most relevant data on your local computer.
There are several reasons you would want to cache data locally rather than operating directly on a moodle database:
The moodleR package provides a method moodle_cache
which allows for local caching of the data.
When you run the moodle_cache
function moodleR will create a local directory mdl_cache
in your working directory. In this directory an sqlite database, mdl_cache.sqlite
, will be created to contain the cached tables.
mdl_create_cache()
The output should look something like this:
#> Gettng Moodle DB connection #> Gettng sqlite connection #> Directory ' /home/sasha/chi2/moodleR/mdl_cache' used by default. #> Set config variable in moodleR:mdl_cache_dir to override. #> This message is displayed once per session. #> Filename 'mdl_cache.sqlite' used by default. #> Set config variable in moodleR:mdl_cache_dir to override. #> Cache file created: /home/sasha/chi2/moodleR/mdl_cache/mdl_cache.sqlite #> Downloading course table #> Joining, by = "categoryid" #> Caching course table #> Downloading discussion posts table #> Caching discussion posts table #> Downloading user table #> Caching user table #> Downloading grades table #> Caching grades table #> Downloading config table #> Downloading log table #> Caching log table #> Downloading roles table #> Caching role table #> Downloading enrolments #> Caching enrolments
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.