knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
R package {moodleQuiz}
contains high-level functions for cleaning, encoding, filtering, and combining student's score and responses from Moodle Quiz report.
You can install the development version from GitHub with:
# install.packages("remotes") remotes::install_github("Lightbridge-KS/moodleQuiz")
The 4 main functions of the {moodleQuiz}
are as follows:
check_sub()
: check student's submission of the Moodle quiz report by looking at the state
column.
combine_resp()
: combine student's responses (Response x
) from the Responses report.
count_resp()
: count how many responses each student answered from the Responses report.
combine_grades()
: filter, adjust, and combine student's grade from Grade/xx
column.
All of theses 4 main functions are generic function that operate on data frame and list of data frames of Moodle Quiz report. The latter will be particularly useful when performing a data aggregation across multiple Moodle quiz report of the same type.
A long time ago, I've build a Shiny app for my colleagues to manipulate Moodle Quiz report. As the app grows bigger, I realized that I have to separate the business logic from the application logic, so that the app can be maintainable. Instead, I've focus on writing functions, and shift my aim to build system of functions to manipulate Moodle Quiz report as easy as possible for R user.
Afterwards, My collection of functions become this {moodleQuiz}
package which drives the logic of this shiny app to facilitate the process of retrieve and combine student's score from SELECx (a Moodle platform from Faculty of Medicine Siriraj Hospital, Mahidol University, Thailand).
library(moodleQuiz) library(dplyr)
Let's say I have a Moodle Grades Report data frame of "Quiz_1"
glimpse(grades_ls$Quiz_1)
Combine & Adjust Grades of Quiz 1
How to choose the maximum score of each student and readjust maximum grades to 100?
Calling combine_grades()
will do that in one step, plus it also cleans column names and extracts numeric student ID from Email address.
grades_ls$Quiz_1 %>% combine_grades( extract_id_from = "Email address", # Extract Student ID from Email id_regex = "[:digit:]+", # Regular expression to extract student ID choose_grade = "max", # Choose only maximum grade of each student new_max_grade = 100 # Adjust maximum grade to 100 ) %>% select(Name, ID, starts_with("G"), starts_with("Q"))
Combine Grades for All Quizzes
Supposed in a semester student have to do a graded assignment in a multiple quizzes, you can put each individual Grades Report in a list.
Now it's a list of data frames (here as grades_ls
).
grades_ls %>% purrr::map_lgl(is.data.frame)
Supply a list of data frames into combine_grades()
, you can combine and weight grades from multiple quizzes into one data frame with a sum of student's score in the Total_x
column.
grades_ls %>% combine_grades( extract_id_from = "Email address", # Extract Student ID from Email id_regex = "[:digit:]+", # Regular expression to extract student ID choose_grade = "max", # Choose only maximum grade of each student new_max_grade = c(25, 25, 50) # Adjust maximum grade to 100 ) %>% select(Name, ID, contains("Grade"), starts_with("Total"))
Last updated: r Sys.Date()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.