Title: | 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>. |
Authors: | Aleksander Dietrichson [aut, cre], Chi Square Laboratories [cph], Darko Miletic [ctb], Pablo Pagnone [ctb], Alex Ondrus [ctb] |
Maintainer: | Aleksander Dietrichson <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.0.1 |
Built: | 2024-11-17 05:26:37 UTC |
Source: | https://github.com/chi2labs/moodler |
Checks that the cached data is available.
check_mdl_cache()
check_mdl_cache()
invisible(NULL)
## Not run: check_mdl_cache() ## End(Not run)
## Not run: check_mdl_cache() ## End(Not run)
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()
example_config_yml()
example_config_yml()
invisible(TRUE) on success
## Not run: example_config_yml() ## End(Not run)
## Not run: example_config_yml() ## End(Not run)
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).
mdl_config(con = mdl_get_connection(), tbl_prefix = "mdl_")
mdl_config(con = mdl_get_connection(), tbl_prefix = "mdl_")
con |
database connection object |
tbl_prefix |
table prefix |
A tibble
Returns a reference to the (cached) course table, with the most relevant columns selected.
mdl_courses(con = mdl_get_connection(), tbl_prefix = "mdl_")
mdl_courses(con = mdl_get_connection(), tbl_prefix = "mdl_")
con |
a database connection object |
tbl_prefix |
prefix for tables |
For convenience a join with the category table is made, and "category_name" added
A dbplyr reference object.
Create local cache from a Moodle Database.
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() )
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() )
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) |
invisible(NULL)
Returns a reference to the (cached) forum_posts table, with the most relevant columns selected.
mdl_forum_posts(con = mdl_get_connection(), tbl_prefix = "mdl_")
mdl_forum_posts(con = mdl_get_connection(), tbl_prefix = "mdl_")
con |
a database connection object |
tbl_prefix |
table prefix |
For convenience two additional columns: forum_name and thread_name; are added.
A dbplyr reference object.
Connection to Cached Moodle Data
mdl_get_cache_connection(access = c("RO", "RWC"))
mdl_get_cache_connection(access = c("RO", "RWC"))
access |
Specifies RO or RWC access |
a DBI connection object
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.
mdl_get_cache_dir()
mdl_get_cache_dir()
Character vector with path
The cache filename ("mdl_cache.sqlite" by default), can be set in the config-file((moodleR:->cache_dir:).
mdl_get_cache_filename()
mdl_get_cache_filename()
Character vector with path
Returns a connection to a Moodle database or the cached version if available.e
mdl_get_connection(use_cache = TRUE, config = "default")
mdl_get_connection(use_cache = TRUE, config = "default")
use_cache |
If TRUE (the default) connection to the local cache is returned. |
config |
Select configuration from config file |
a DBI connection object
Returns a reference to the (cached) grades table, with the most relevant columns selected.
mdl_grades(con = mdl_get_connection(), tbl_prefix = "mdl_")
mdl_grades(con = mdl_get_connection(), tbl_prefix = "mdl_")
con |
database connection object |
tbl_prefix |
table prefix |
A dbplyr reference object
## 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)
## 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)
Returns a reference to the log-table.
mdl_log(con = mdl_get_connection(), tbl_prefix = "mdl_")
mdl_log(con = mdl_get_connection(), tbl_prefix = "mdl_")
con |
A database connection object |
tbl_prefix |
table prefix |
A dbplyr reference object.
Returns a reference to the (cached) users table, with the most relevant columns selected.
mdl_users(con = mdl_get_connection(), tbl_prefix = "mdl_")
mdl_users(con = mdl_get_connection(), tbl_prefix = "mdl_")
con |
database connection object |
tbl_prefix |
table prefix |
A dbplyr reference object
Create a simple wordcloud plot based on a mdl_posts object.
## S3 method for class 'mdl_forum_posts' plot(x, use_base_graphics = FALSE, ...)
## S3 method for class 'mdl_forum_posts' plot(x, use_base_graphics = FALSE, ...)
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 |
A ggplot
Histogram (density) of normalized grades
## S3 method for class 'mdl_grades' plot(x, use_base_graphics = FALSE, ...)
## S3 method for class 'mdl_grades' plot(x, use_base_graphics = FALSE, ...)
x |
a lazy tbl reference |
use_base_graphics |
Should base graphics be used (instead of ggplot) |
... |
passed along to ggplot or base graphic function |
A ggplot or base graphic plot
Overrides generic print function to pretty-print a summary of the course information.
## S3 method for class 'mdl_courses_summary' print(x, ...)
## S3 method for class 'mdl_courses_summary' print(x, ...)
x |
an object used to select a method. |
... |
further arguments passed to or from other methods. |
invisible(x). Typically called for its side effect which is a pretty-print of the relevant information.
Overrides generic print function to pretty-print a summary of the grades from the gradebook.
## S3 method for class 'mdl_grades_summary' print(x, ...)
## S3 method for class 'mdl_grades_summary' print(x, ...)
x |
an object used to select a method. |
... |
further arguments passed to or from other methods. |
invisible(x). Typically called for its side effect which is a pretty-print of the relevant information.
Overrides generic print function to pretty-print a summary of the Moodle posts.
## S3 method for class 'mdl_post_summary' print(x, ...)
## S3 method for class 'mdl_post_summary' print(x, ...)
x |
an object used to select a method. |
... |
further arguments passed to or from other methods. |
invisible(x). Typically called for its side effect which is a pretty-print of the relevant information.
Overrides generic print function to pretty-print a summary of the users.
## S3 method for class 'mdl_users_summary' print(x, ...)
## S3 method for class 'mdl_users_summary' print(x, ...)
x |
an object used to select a method. |
... |
further arguments passed to or from other methods. |
invisible(x). Typically called for its side effect which is a pretty-print of the relevant information.
Provides summary statistics for moodle courses
## S3 method for class 'mdl_courses' summary(object, ...)
## S3 method for class 'mdl_courses' summary(object, ...)
object |
a lazy tbl reference with class mdl_grades |
... |
currently ignored |
a tibble with the summary.
Provides summary statistics for forum posts.
## S3 method for class 'mdl_forum_posts' summary(object, ...)
## S3 method for class 'mdl_forum_posts' summary(object, ...)
object |
a lazy tbl reference with class mdl_grades |
... |
currently ignored |
a tibble with the summary.
Provides summary statistics for moodle grades
## S3 method for class 'mdl_grades' summary(object, ...)
## S3 method for class 'mdl_grades' summary(object, ...)
object |
a lazy tbl reference with class mdl_grades |
... |
currently ignored |
a tibble with the summary.
Provides summary statistics for moodle courses
## S3 method for class 'mdl_users' summary(object, ...)
## S3 method for class 'mdl_users' summary(object, ...)
object |
a lazy tbl reference with class mdl_grades |
... |
currently ignored |
a tibble with the summary.