clean_moodle: Clean Moodle Quiz report

View source: R/clean_moodle.R

clean_moodleR Documentation

Clean Moodle Quiz report

Description

Clean Moodle Quiz report for easier manipulation in R. It extracts student ID from "Email address" column; unites "First name" and "Surname" column; converts dash ("-"), which can be presented when student not given answer, to NA; and forces "Grade" and "Q. x /x" to numeric value (if any of "Not yet graded", "Requires grading", or "-" is presented it will be NA).

Usage

clean_moodle(
  data,
  extract_id = TRUE,
  extract_id_from = c("Email address", "Institution", "Department", "ID number"),
  id_regex = ".*",
  sep_name = " ",
  dash_na = TRUE,
  force_numeric = TRUE
)

Arguments

data

A data.frame of Moodle Quiz report.

extract_id

(Logical) TRUE: An "ID" column will be created by extracting characters from "Email address" column using regular expression as id_regex. If FALSE: "Email address" column will be renamed to "Email".

extract_id_from

(Character) Choose column to extract ID from one of: "Email address", "Institution", "Department", and "ID number" (a custom one).

id_regex

(Character) Regular expression used to extract ID from "Email address". The default is ".*" meaning all characters. If your student email addresses has numeric IDs in them, try "[:digit:]+" to extract digits from the email. Note: Regular expression syntax is the same as stringr.

sep_name

(Character) A character in the new "Name" column that separate original "First name" and "Surname".

dash_na

(Logical) TRUE: format dash "-" in any columns to NA. If FALSE: leave dash "-" as is

force_numeric

(Logical) TRUE: force "Grade" and "Q. x /x" columns to numeric type (if any of "Not yet graded", "Requires grading", or "-" is presented it will be NA). If FALSE: leave "Grade" and "Q. x /x" columns as is.

Value

A data.frame with cleaner column names and better formatted data. Although the column names are cleaned, some metadata is lost such as maximum score of quiz and questions. Check out get_quiz_attr() for get these metadata.

Examples

clean_moodle(grades_ls$Quiz_1,
             id_regex = "[:digit:]+")

Lightbridge-KS/moodleQuiz documentation built on Sept. 27, 2022, 1:27 p.m.