Type: | Package |
Title: | Helper Functions to Work with 'Moodle' Data |
Version: | 1.0.1 |
Maintainer: | Aleksander Dietrichson <dietrichson@gmail.com> |
Description: | A collection of functions to connect to a 'Moodle' database, cache relevant tables locally and generate learning analytics. 'Moodle' is an open source Learning Management System (LMS) developed by MoodleHQ. For more information about Moodle, visit https://moodle.org. |
License: | MIT + file LICENSE |
URL: | https://github.com/chi2labs/moodleR, https://chi2labs.github.io/moodleR/ |
Encoding: | UTF-8 |
VignetteBuilder: | knitr |
Suggests: | knitr, rmarkdown, prettyunits, lubridate, testthat |
Imports: | DBI, dplyr, ggplot2, tidytext, ggwordcloud, utils, stringr, rlang, scales, RMariaDB, glue, config, anytime, cli, lifecycle, RSQLite, usethis, RPostgres |
RdMacros: | lifecycle |
RoxygenNote: | 7.2.1 |
NeedsCompilation: | no |
Packaged: | 2022-08-15 14:24:05 UTC; r227303 |
Author: | Aleksander Dietrichson [aut, cre], Chi Square Laboratories [cph], Darko Miletic [ctb], Pablo Pagnone [ctb], Alex Ondrus [ctb] |
Repository: | CRAN |
Date/Publication: | 2022-08-15 14:50:02 UTC |
moodleR: Helper Functions to Work with 'Moodle' Data
Description
A collection of functions to connect to a 'Moodle' database, cache relevant tables locally and generate learning analytics. 'Moodle' is an open source Learning Management System (LMS) developed by MoodleHQ. For more information about Moodle, visit https://moodle.org.
A collection of functions to connect to a 'Moodle' database, cache relevant tables locally and generate learning analytics. 'Moodle' is an open source Learning Management System (LMS) developed by MoodleHQ. For more information about Moodle, visit https://moodle.org.
Author(s)
Maintainer: Aleksander Dietrichson dietrichson@gmail.com
Other contributors:
Chi Square Laboratories [copyright holder]
Darko Miletic [contributor]
Pablo Pagnone [contributor]
Alex Ondrus [contributor]
See Also
Useful links:
Useful links:
Check Cached Data
Description
Checks that the cached data is available.
Usage
check_mdl_cache()
Value
invisible(NULL)
Examples
## Not run:
check_mdl_cache()
## End(Not run)
Example Config yml File
Description
Opens an example config file in the active editor. If you already have a config.yml file cut-and-paste the "moodleR" section, and update the respective fields. Alternatively use "save as" to save this file as config.yml It is recommended that you check the config with config::get()
Usage
example_config_yml()
Value
invisible(TRUE) on success
Examples
## Not run:
example_config_yml()
## End(Not run)
Moodle Configuration Table
Description
Get the complete moodle configuration table. Different from most mdl_* functions this function calls dplyr::collect() before returning (as a config-table is not going to cause memory overflow).
Usage
mdl_config(con = mdl_get_connection(), tbl_prefix = "mdl_")
Arguments
con |
database connection object |
tbl_prefix |
table prefix |
Value
A tibble
Get Courses
Description
Returns a reference to the (cached) course table, with the most relevant columns selected.
Usage
mdl_courses(con = mdl_get_connection(), tbl_prefix = "mdl_")
Arguments
con |
a database connection object |
tbl_prefix |
prefix for tables |
Details
For convenience a join with the category table is made, and "category_name" added
Value
A dbplyr reference object.
Creates a Local Cache
Description
Create local cache from a Moodle Database.
Usage
mdl_create_cache(
con = mdl_get_connection(use_cache = FALSE),
format = c("sqlite"),
tbl_prefix = "mdl_",
output_dir = mdl_get_cache_dir(),
output_filename = mdl_get_cache_filename()
)
Arguments
con |
a database connection (to a moodle database) |
format |
output format (mysql, csv) |
tbl_prefix |
Moodle DB table prefix |
output_dir |
where does the cache go |
output_filename |
filename (in the case of sqlite output), or prefix (in_case of CSV download) |
Value
invisible(NULL)
Raw query for discussion posts
Description
Raw query for discussion posts
Usage
mdl_enrolments_query(tbl_prefix)
Arguments
tbl_prefix |
for moodle |
Value
character vector with moodle query
Get Forum Posts
Description
Returns a reference to the (cached) forum_posts table, with the most relevant columns selected.
Usage
mdl_forum_posts(con = mdl_get_connection(), tbl_prefix = "mdl_")
Arguments
con |
a database connection object |
tbl_prefix |
table prefix |
Details
For convenience two additional columns: forum_name and thread_name; are added.
Value
A dbplyr reference object.
Connection to Cached Moodle Data
Description
Connection to Cached Moodle Data
Usage
mdl_get_cache_connection(access = c("RO", "RWC"))
Arguments
access |
Specifies RO or RWC access |
Value
a DBI connection object
Get the Cache Directory
Description
The cache directory can be set in the config-file (moodleR:->cache_dir:), which is recommended. If it is not present, or no config is found, a tempdir() will be returned.
Usage
mdl_get_cache_dir()
Value
Character vector with path
Get the Cache Filename
Description
The cache filename ("mdl_cache.sqlite" by default), can be set in the config-file((moodleR:->cache_dir:).
Usage
mdl_get_cache_filename()
Value
Character vector with path
Connect to Moodle Data
Description
Returns a connection to a Moodle database or the cached version if available.e
Usage
mdl_get_connection(use_cache = TRUE, config = "default")
Arguments
use_cache |
If TRUE (the default) connection to the local cache is returned. |
config |
Select configuration from config file |
Value
a DBI connection object
Get Grades
Description
Returns a reference to the (cached) grades table, with the most relevant columns selected.
Usage
mdl_grades(con = mdl_get_connection(), tbl_prefix = "mdl_")
Arguments
con |
database connection object |
tbl_prefix |
table prefix |
Value
A dbplyr reference object
Examples
## Not run:
# Get the course grades for courseid 52
course_grades <- mdl_grades() %>%
filter(courseid == 52, item_type == "course") %>%
collect()
# Get the other grades items:
grades_items_grades <- mdl_grades() %>%
filter(courseid == 52, item_type != "course") %>%
collect()
## End(Not run)
Raw query for grades
Description
Raw query for grades
Usage
mdl_grades_query(tbl_prefix)
Arguments
tbl_prefix |
for moodle |
Value
character vector with moodle query
Access Moodle's Logs
Description
Returns a reference to the log-table.
Usage
mdl_log(con = mdl_get_connection(), tbl_prefix = "mdl_")
Arguments
con |
A database connection object |
tbl_prefix |
table prefix |
Value
A dbplyr reference object.
Raw query for discussion posts
Description
Raw query for discussion posts
Usage
mdl_posts_query(tbl_prefix)
Arguments
tbl_prefix |
for moodle |
Value
character vector with moodle query
Get Moodle Users
Description
Returns a reference to the (cached) users table, with the most relevant columns selected.
Usage
mdl_users(con = mdl_get_connection(), tbl_prefix = "mdl_")
Arguments
con |
database connection object |
tbl_prefix |
table prefix |
Value
A dbplyr reference object
Wordcloud Plot
Description
Create a simple wordcloud plot based on a mdl_posts object.
Usage
## S3 method for class 'mdl_forum_posts'
plot(x, use_base_graphics = FALSE, ...)
Arguments
x |
a lazy tbl reference or data.frame. |
use_base_graphics |
Should base graphics be produces instead of ggplot? |
... |
passed to ggplot or base graphics |
Value
A ggplot
Plot Moodle Grades
Description
Histogram (density) of normalized grades
Usage
## S3 method for class 'mdl_grades'
plot(x, use_base_graphics = FALSE, ...)
Arguments
x |
a lazy tbl reference |
use_base_graphics |
Should base graphics be used (instead of ggplot) |
... |
passed along to ggplot or base graphic function |
Value
A ggplot or base graphic plot
Print Moodle Courses Summary
Description
Overrides generic print function to pretty-print a summary of the course information.
Usage
## S3 method for class 'mdl_courses_summary'
print(x, ...)
Arguments
x |
an object used to select a method. |
... |
further arguments passed to or from other methods. |
Value
invisible(x). Typically called for its side effect which is a pretty-print of the relevant information.
Print Moodle Grades Summary
Description
Overrides generic print function to pretty-print a summary of the grades from the gradebook.
Usage
## S3 method for class 'mdl_grades_summary'
print(x, ...)
Arguments
x |
an object used to select a method. |
... |
further arguments passed to or from other methods. |
Value
invisible(x). Typically called for its side effect which is a pretty-print of the relevant information.
Print Moodle Forum Post Summary
Description
Overrides generic print function to pretty-print a summary of the Moodle posts.
Usage
## S3 method for class 'mdl_post_summary'
print(x, ...)
Arguments
x |
an object used to select a method. |
... |
further arguments passed to or from other methods. |
Value
invisible(x). Typically called for its side effect which is a pretty-print of the relevant information.
Print Moodle Users Summary
Description
Overrides generic print function to pretty-print a summary of the users.
Usage
## S3 method for class 'mdl_users_summary'
print(x, ...)
Arguments
x |
an object used to select a method. |
... |
further arguments passed to or from other methods. |
Value
invisible(x). Typically called for its side effect which is a pretty-print of the relevant information.
Summary of mdl_courses Object
Description
Provides summary statistics for moodle courses
Usage
## S3 method for class 'mdl_courses'
summary(object, ...)
Arguments
object |
a lazy tbl reference with class mdl_grades |
... |
currently ignored |
Value
a tibble with the summary.
Summary of mdl_forum_posts Object
Description
Provides summary statistics for forum posts.
Usage
## S3 method for class 'mdl_forum_posts'
summary(object, ...)
Arguments
object |
a lazy tbl reference with class mdl_grades |
... |
currently ignored |
Value
a tibble with the summary.
Summary of mdl_grades Object
Description
Provides summary statistics for moodle grades
Usage
## S3 method for class 'mdl_grades'
summary(object, ...)
Arguments
object |
a lazy tbl reference with class mdl_grades |
... |
currently ignored |
Value
a tibble with the summary.
Summary of mdl_users Object
Description
Provides summary statistics for moodle courses
Usage
## S3 method for class 'mdl_users'
summary(object, ...)
Arguments
object |
a lazy tbl reference with class mdl_grades |
... |
currently ignored |
Value
a tibble with the summary.