Code to load dependencies
library(tidyverse)
library(data.table)
library(kableExtra)
In this report, you’ll find some data on the usage of the online training “Privacy Basics for Researchers”. This online module was created by Research Data Management Support at Utrecht University (NL) to provide a researcher-friendly introduction into the General Data Protection Regulation (GDPR), with a focus on how it applies to scientific research performed at Utrecht University (UU).
A description of and a registration link to the online module can be found on the RDM Support website. The module is embedded within the Utrecht University Moodle platform, “ULearning”, but the raw module materials are also available online via Zenodo.
This report is primarily meant for internal monitoring purposes at the moment. We may adjust this report in a later stage, or move it to another web address!
To obtain the data for this report from the ULearning platform, the following steps should be followed by a teacher/administrator in the ULearning platform:
@students.uu.nl
should get “Student”@umcutrecht.nl
should get “MED”@uu.nl
email addresses: go to the Employees page on intranet and search for their name or email address. Use the abbreviation of the faculty in which they are listed on the intranet.raw
folder. Add the date of downloading in the downloaded csv file “YYYYMMDD_courseid_838_participants.csv”raw
folder. Add the date of downloading in the downloaded csv file “YYYYMMDD_progress.pbfr.csv”raw
folder as “YYYYMMDD_PBfR-Quiz.csv”.The raw data are not shared because they contain personal data (e.g., names, email addresses and information about participants’ progress in the module).
We first have to read and clean the data to get usable data frames. We don’t want to include people who were involved in the creation of the course or who provided feedback on it; we only need the actual users; people who enrolled after the launch of the course with the intention to actually learn something new!
library(tidyverse)
library(data.table)
library(kableExtra)
# UU colors: https://www.uu.nl/en/organisation/corporate-identity/brand-policy/colour
<- c(
UU_pallette "#FFE6AB", # Lighter yellow
"#FFCD00", # UU yellow
"#F3965E", # Orange
"#C00A35", # Red
"#AA1555", # Bordeaux-red
"#6E3B23", # Brown
"#24A793", # Green
"#5287C6", # Blue
"#001240", # Dark blue
"#5B2182", # Purple
"#000000" # Black
)
<- "#FFCD00"
uucol
<- list(
styling theme_classic(),
theme(legend.text = element_text(size = 10),
legend.position = "bottom",
legend.title = element_blank(),
axis.title.x = element_text(size = 11),
axis.text.y = element_text(size = 11),
axis.ticks = element_blank(),
panel.background = element_blank(),
panel.border=element_blank(),
panel.grid.major=element_blank(),
panel.grid.minor=element_blank(),
plot.background=element_blank())
)
# 1. Read existing processed files
<- read.csv("data/processed/avg_progress_cats.csv")
avg_progress_cats <- read.csv("data/processed/nr_participants.csv")
nr_participants <- read.csv("data/processed/quizscores.csv")
quizscores <- read.csv("data/processed/total_quiz_scores.csv")
total_quiz_scores
# 2. Read latest raw files
# See which files are in the raw folder
<- data.frame(filename = list.files(path = "data/raw", pattern = ".csv"))
data_files
# Get the dates from the file names
$filenamedates <- as.Date(str_extract(pattern = "[0-9]+[0-9]+[0-9]+",
data_filesstring = data_files$filename),
format = "%Y%m%d")
# Sort by date using data.table::setorder (descending = most recent files first)
setorder(data_files, filenamedates, na.last = FALSE)
# Read the 3 files from the most recent date
<- read.csv(paste0("data/raw/",
participants $filename[
data_filesstr_detect(data_files$filename[1:3],
"courseid_838_participants.csv")
]))<- read.csv(paste0("data/raw/",
progress $filename[
data_filesstr_detect(data_files$filename[1:3],
"progress.pbfr.csv")
]))<- read.csv(paste0("data/raw/",
quiz $filename[
data_filesstr_detect(data_files$filename[1:3],
"PBfR-Quiz.csv")
]))
# Save the date for the coming calculations
<- as.Date(data_files$filenamedates[1], "%Y-%m-%d") date
# Filter participants to only contain the correct participants
<- participants %>% filter(!(Groups == "Red" & !is.na(Groups)))
participants_2
# Filter progress and quiz dataframes based on participants
<- progress %>% semi_join(select(participants_2,
progress_2
Email.address), by = join_by(Email.address)) %>%
# Also add Groups
left_join(select(participants_2, Groups, Email.address))
<- quiz %>% semi_join(select(participants_2,
quiz_2
Email.address),by = join_by(Email.address)) %>%
# Also add Groups
left_join(select(participants_2, Groups, Email.address))
# Calculate nr of participants of most recent download
<- data.frame(date = date,
new_row total = dim(participants_2)[1],
uu = sum(grepl("@uu.nl$",
$Email.address)),
participants_2uu_students = sum(grepl("@students.uu.nl$",
$Email.address)),
participants_2
# other = total - uu - students
other = dim(participants_2)[1] -
sum(grepl("@uu.nl$", participants_2$Email.address)) -
sum(grepl("@students.uu.nl$", participants_2$Email.address)),
# Faculties
DGK = sum(participants_2$Groups=="DGK"),
REBO = sum(participants_2$Groups=="REBO"),
FSW = sum(participants_2$Groups=="FSW"),
GEO = sum(participants_2$Groups=="GEO"),
GW = sum(participants_2$Groups=="GW"),
BETA = sum(participants_2$Groups=="BETA"),
MED = sum(participants_2$Groups=="MED"),
UB = sum(participants_2$Groups=="UB"),
UBD = sum(participants_2$Groups=="UBD"),
Student = sum(participants_2$Groups=="Student"),
External = sum(participants_2$Groups=="External")
)
# Convert date to date type
$date <- as.Date(nr_participants$date, "%Y-%m-%d")
nr_participants
# Paste new row below the existing data
<- rbindlist(list(nr_participants, new_row),
nr_participants_all use.names = TRUE,
fill = TRUE)
As of 2024-12-02, there are 220 participants enrolled in the course. 141 of them are enrolled with their “@uu.nl” email address, and 53 of them with the “@students.uu.nl” email address. 26 participants are either from an external institution or have used a personal email address to enroll in the course.
In the below bar chart, you can see the development of the number of participants in the course over time.
# From wide to long
<- pivot_longer(data = nr_participants_all,
nr_participants_long cols = c(uu, uu_students, other)
#names_to = "variable",
#values_to = "value"
)
# Set the order of the variable levels
$name <- factor(nr_participants_long$name, levels = c("uu", "uu_students", "other"))
nr_participants_long
# Create a stacked bar plot
# Calculate midpoints for label positioning
<- nr_participants_long %>%
nr_participants_long group_by(date) %>%
arrange(desc(name)) %>%
mutate(midpoint = cumsum(value) - 0.5 * value,
prev_height = lag(cumsum(value), default = 0))
# Adjust y-axis limits
<- max(nr_participants_long$midpoint) + max(nr_participants_long$value) / 2
y_max
# Adjust label positioning
ggplot(nr_participants_long, aes(x = date, y = value, fill = name)) +
geom_bar(stat = "identity") +
geom_text(aes(label = ifelse(value > 0, value, ""),
y = prev_height + value / 2, group = name),
vjust = 0.5, color = "black", size = 3.5) +
ylim(0, y_max) + # Set y-axis limits
labs(title = "Course participants over time",
x = "Date", y = "Number of participants",
fill = "Type of participant") +
scale_fill_manual(name = "Group",
labels = c("uu" = "UU staff",
"uu_students" = "UU students",
"other" = "Others"),
values = UU_pallette) +
styling
On 2024-12-02, this was the division of faculties in the module (total: 220):
# Select the faculties and total values per date
<- nr_participants_all %>%
nrs_faculties select(date, DGK:External, total) %>%
filter(!is.na(DGK))
# make a long dataframe
<- nrs_faculties %>%
nrs_faculties_long pivot_longer(cols = -date,
names_to = "Faculty",
values_to = "Participants") %>%
mutate(date = as.character(date))
# make it wide again so that the df is in the right format for the table
<- nrs_faculties_long %>%
nrs_faculties_wide pivot_wider(names_from = date,
values_from = Participants)
# Create the table with kableExtra
kable(nrs_faculties_wide, format = "html", output = FALSE,
caption = "<b>Participants per faculty</b>",
table.attr='cellpadding="3", cellspacing="3"') %>%
kable_styling(bootstrap_options = c("striped",
"hover",
"condensed",
"responsive"),
fixed_thead = T) %>%
# Highligh the last row (total) in yellow and bold
# Source: https://haozhu233.github.io/kableExtra/awesome_table_in_html.html
row_spec(length(nrs_faculties_wide$Faculty),
bold = T, color = "black", background = uucol)
Faculty | 2024-01-08 | 2024-02-01 | 2024-03-01 | 2024-04-02 | 2024-05-07 | 2024-06-03 | 2024-07-02 | 2024-08-02 | 2024-09-02 | 2024-10-01 | 2024-11-01 | 2024-12-02 |
---|---|---|---|---|---|---|---|---|---|---|---|---|
DGK | 15 | 16 | 16 | 16 | 16 | 17 | 17 | 17 | 17 | 17 | 18 | 33 |
REBO | 6 | 7 | 7 | 7 | 7 | 7 | 7 | 7 | 8 | 18 | 20 | 21 |
FSW | 18 | 21 | 21 | 21 | 21 | 22 | 22 | 24 | 26 | 29 | 31 | 31 |
GEO | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 8 | 8 | 8 | 8 | 10 |
GW | 9 | 9 | 9 | 11 | 13 | 13 | 13 | 15 | 16 | 16 | 16 | 20 |
BETA | 13 | 16 | 16 | 16 | 17 | 18 | 18 | 20 | 20 | 20 | 21 | 22 |
MED | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 |
UB | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 |
UBD | 1 | 2 | 2 | 3 | 3 | 3 | 3 | 3 | 3 | 3 | 3 | 4 |
Student | 13 | 14 | 17 | 19 | 26 | 27 | 27 | 30 | 30 | 41 | 46 | 49 |
External | 9 | 11 | 11 | 13 | 14 | 16 | 18 | 20 | 21 | 21 | 22 | 22 |
total | 94 | 107 | 111 | 119 | 131 | 138 | 141 | 152 | 157 | 181 | 193 | 220 |
Below you can see the average progress per group of participants for each block in the course as of 2024-12-02.
<- progress_2 %>%
progress_3 # Delete columns we won't use
select(-starts_with("X")) %>%
# Turn character completion into numeric 0 or 1
mutate_at(vars(-Email.address, -Groups),
~ifelse(. == "Completed", 1, 0)) %>%
# Turn Groups variable into a factor
mutate(Groups = factor(Groups,
levels = c("DGK", "REBO", "FSW", "GEO", "GW",
"BETA", "MED", "UB", "UBD",
"Student", "External")),
#Create a factor variable for alternative group membership (UU, student or other)
group = as.factor(ifelse(grepl("@uu.nl$",
Email.address),"uu",
ifelse(grepl("@students.uu.nl$",
Email.address),"uu_students",
"other"))))
# Set order of the factor levels
$group <- factor(progress_3$group,
progress_3levels = c("uu", "uu_students", "other"))
# Group blocks into sections for easier visualization
<- progress_3 %>%
latest_progress_long pivot_longer(cols = -c(Email.address, Groups, group),
names_to = "block",
values_to = "completion") %>%
mutate(chapter = ifelse(startsWith(block, "Welcome") |
startsWith(block, "Introduction.to.Personal.Data.under.the.GDPR") |
startsWith(block, "GDPR") |
startsWith(block, "What.is.Personal.Data") |
startsWith(block, "Special.Categories.of.Personal.Data") |
startsWith(block, "Roles.in.the.GDPR"),
"Chapter 1", ifelse(
startsWith(block, "Introduction.to.Lawfulness") |
startsWith(block, "Legal.Basis.for.Processing.Data") |
startsWith(block, "Public.Interest") |
startsWith(block, "Consent") |
startsWith(block, "How.to.Inform.Data.Subjects") |
startsWith(block, "Data.Subject.Rights"),
"Chapter 2", ifelse(
startsWith(block, "Introduction.to.Planning.Your.Project") |
startsWith(block, "Privacy.by.Design.and.Privacy.by.Default") |
startsWith(block, "Demonstrating.Compliance") |
startsWith(block, "Privacy.Scan.and.DPIA") |
startsWith(block, "Common.Privacy.Risks") |
startsWith(block, "Reporting.a.Data.Breach"),
"Chapter 3", ifelse(
startsWith(block, "Introduction.to.Practical.Measures") |
startsWith(block, "Levels.of.Data.Security") |
startsWith(block, "Access.Control") |
startsWith(block, "Encryption") |
startsWith(block, "Pseudonymisation.and.Anonymisation") |
startsWith(block, "De.identification.in.Practice") |
startsWith(block, "Processing.Tools"),
"Chapter 4", ifelse(
startsWith(block, "Introduction.to.Storing.and.Sharing.Personal.Data") |
startsWith(block, "Storing.Personal.Data") |
startsWith(block, "Agreements.in.Research") |
startsWith(block, "Sharing.Personal.Data") |
startsWith(block, "Making.Personal.Data.FAIR"),
"Chapter 5", ifelse(
startsWith(block, "Final.Quiz") |
startsWith(block, "Evaluate.this.course") |
startsWith(block, "Available.Support.at.Utrecht.University"),
"Chapter 6", "Not assigned"
)
)
)
)
)
)
)
# Count people per faculty who appear in the progress file
<- progress_3 %>% count(Groups)
n
# Save completion rate per faculty
<- latest_progress_long %>%
progress_per_fac group_by(Groups) %>%
summarise(avg_completion_rate = mean(completion) * 100) %>%
left_join(n) %>%
mutate(date = date)
# Plot progress per faculty
%>%
progress_per_fac mutate(graph_label = paste0(Groups, "\n (n = ", n, ")")) %>%
ggplot(aes(x = graph_label,
y = avg_completion_rate)) +
geom_bar(stat = "identity",
position = position_dodge(0.9),
fill = uucol) +
geom_text(aes(label = paste0(round(avg_completion_rate, 0), "%"),
y = avg_completion_rate + 2), # Adjust label position as needed
size = 3.5, color = "black", position = position_dodge(0.9)) +
labs(x = "Faculty", y = "Average progress (%)",
title = paste0("Average progress (%) per faculty on ", date)) +
styling
# Plot average progress score (per person) per chapter
%>%
latest_progress_long group_by(chapter) %>%
summarise(avg_completion_rate = mean(completion)) %>%
ungroup() %>%
ggplot(aes(x = chapter,
y = avg_completion_rate * 100)) +
geom_bar(stat = "identity",
position = position_dodge(0.9),
fill = uucol) +
geom_text(aes(label = paste0(round(avg_completion_rate * 100, 0), "%"),
y = avg_completion_rate * 100 + 2), # Adjust label position as needed
size = 3.5, color = "black", position = position_dodge(0.9)) +
labs(x = "Chapter", y = "Average progress (%)",
title = paste0("Average progress (%) on ", date)) +
styling
Below, you can see the average progress over time. On July 11th, the ULearning platform got an update. Therefore, from then onwards, the progress for every user was set to 0 again, hence the drop in progress in July 2023.
<- progress_3 %>%
progress_4_fac # From wide to long format based on the Email address and group
pivot_longer(cols = -c(Email.address, Groups, group),
names_to = "block",
values_to = "completion") %>%
group_by(Email.address, Groups) %>%
# Calculate average completion rate per participant
summarise(progress = mean(completion)) %>%
# Put date in a new date column for all rows in the dataframe
mutate(date = as.Date(rep(date, n())))
<- progress_3 %>%
progress_4_group # From wide to long format based on the Email address and group
pivot_longer(cols = -c(Email.address, Groups, group),
names_to = "block",
values_to = "completion") %>%
group_by(Email.address, group) %>%
# Calculate average completion rate per participant
summarise(progress = mean(completion)) %>%
# Put date in a new date column for all rows in the dataframe
mutate(date = as.Date(rep(date, n())))
# Calculate new progress per faculty dataframe
<- progress_4_fac %>%
avg_progress_new_fac group_by(Groups, date) %>%
summarise(n = n(), # nr of people underlying each average
avg_progress = mean(progress) * 100)
# Calculate new progress per group dataframe
<- progress_4_group %>%
avg_progress_new_group group_by(group, date) %>%
summarise(n = n(), # nr of people underlying each average
avg_progress = mean(progress) * 100)
# In the old dataframe, make date as actual date + make group a factor
$date <- as.Date(avg_progress_cats$date, "%Y-%m-%d")
avg_progress_cats$group <- factor(avg_progress_cats$group,
avg_progress_catslevels = c("uu",
"uu_students",
"other"))
# Combine old and new data in 1 dataframe
<- bind_rows(avg_progress_cats,
avg_progress_cats_new
avg_progress_new_fac,
avg_progress_new_group)
# Plot average progress over time per group
!is.na(avg_progress_cats_new$group),] %>%
avg_progress_cats_new[ggplot(aes(x = date,
y = avg_progress,
color = group)) +
geom_point() +
geom_line(linewidth = 1) +
labs(x = "Date",
y = "Average Progress (%)",
title = "Average Progress Over Time per Group") +
scale_color_manual(name = "Group",
labels = c("uu" = "UU staff",
"uu_students" = "UU students",
"other" = "Others"),
values = UU_pallette) +
styling
<- quiz_2 %>%
quiz_3 # Remove duplicate rows in the dataset: take Finished if the participant has
# both a State = Finished and In progress.
group_by(Last.name) %>%
mutate(has_finished = any(State == "Finished")) %>%
filter(!((State == "In progress" | State == "In Progress") & has_finished)) %>%
select(-has_finished)
# Make character grades numeric, and "-" into NA
== "-"] <- NA
quiz_3[quiz_3 <- quiz_3 %>%
quiz_3 mutate(Grade = as.numeric(Grade.10.0)) %>%
mutate_at(vars(starts_with("Q..")),
as.numeric)
# Create a factor variable for group membership (UU, student or other)
$group <- as.factor(ifelse(grepl("@uu.nl$",
quiz_3$Email.address),
quiz_3"uu",
ifelse(grepl("@students.uu.nl$",
$Email.address),
quiz_3"uu_students",
"other")))
# Rename question columns into something human-readable
colnames(quiz_3) <- gsub("^Q\\.\\.([0-9]+)\\.\\..*",
"Q\\1",
names(quiz_3))
# Summarize the new quiz data per group
<- quiz_3 %>%
quiz_4 # Make sure group is a factor variable
mutate(group = factor(group, levels = c("uu",
"uu_students",
"other"))) %>%
# Group by UU / Students / Other / All for summary calculations
group_by(group) %>%
# For every group, save the sample size, total grade, and mean grade per question
summarise(
n = n(),
total_grade = mean(Grade, na.rm = TRUE),
across(starts_with("Q"),
~ mean(., na.rm = TRUE)/0.6*100)
%>%
) # Also save the date in the dataframe
mutate(date = as.Date(date, "%Y-%m-%d")) %>%
# Rearrange the columns for easier readability
select(date, group, n, total_grade, starts_with("Q"))
# Summarize the new quiz data per faculty
<- quiz_3 %>%
quiz_4_fac # Group by faculty for summary calculations
group_by(Groups) %>%
# For every faculty, save the sample size, total grade, and mean grade per question
summarise(
n = n(),
total_grade = mean(Grade, na.rm = TRUE),
across(starts_with("Q"),
~ mean(., na.rm = TRUE)/0.6*100)
%>%
) # Also save the date in the dataframe
mutate(date = as.Date(date, "%Y-%m-%d")) %>%
# Rearrange the columns for easier readability
select(date, Groups, n, total_grade, starts_with("Q"))
# Summarize new quiz data total (not per group)
<- quiz_3 %>%
quiz_4_total ungroup() %>%
# Save the sample size, total grade, and mean grade per question
summarise(
n = sum(!is.na(Grade)),
total_grade = mean(Grade, na.rm = TRUE),
across(starts_with("Q"), ~mean(., na.rm = TRUE) / 0.6 * 100)
%>%
) # Also save the date in the dataframe
mutate(date = as.Date(date, "%Y-%m-%d")) %>%
# Rearrange the columns for easier readability
select(date, n, total_grade, starts_with("Q"))
# Make date variables in old dataframes date too in order to merge
$date <- as.Date(quizscores$date, "%Y-%m-%d")
quizscores$date <- as.Date(total_quiz_scores$date, "%Y-%m-%d")
total_quiz_scores
# Append new quizscores to old quiz scores
<- bind_rows(quizscores, quiz_4, quiz_4_fac)
quizscores_new $group <- factor(quizscores_new$group,
quizscores_newlevels = c("uu",
"uu_students",
"other"))
<- bind_rows(total_quiz_scores, quiz_4_total) total_quiz_scores_new
Below you can see the average final score on the quiz for the latest quiz results.
%>%
quiz_4_fac mutate(graph_label = paste0(Groups, "\n (n = ", n, ")")) %>%
ggplot(aes(x = graph_label,
y = total_grade)) +
geom_bar(stat = "identity",
position = position_dodge(0.9),
fill = uucol) +
geom_text(aes(label = round(total_grade, 2),
y = total_grade + 0.5), # Adjust label position as needed
size = 3.5, color = "black", position = position_dodge(0.9)) +
labs(x = "Faculty", y = "Average grade",
title = paste0("Average grade per faculty on ", date)) +
styling
Below is a table with the average scores (in %) per question in the most recent quiz data.
<- quiz_4_total %>%
latestquiz_total_long select(starts_with("Q")) %>%
gather(key = "Question", value = "Score")
# Convert "Question" to a factor with the correct order
$Question <- factor(latestquiz_total_long$Question,
latestquiz_total_longlevels = paste0("Q", 1:16))
# Plot
ggplot(latestquiz_total_long, aes(x = Question,
y = Score)) +
geom_bar(stat = "identity", fill = uucol) +
labs(x = "Question",
y = "Average Score",
title = "Average Score per Quiz Question (%)") +
geom_text(aes(label = sprintf("%.0f", Score)), vjust = -0.5, size = 3.5) +
styling
Below you can find the number of attempts (either in Progress or Finished)
<- quizscores_new %>%
quizscores_attempts select(date,
group,%>%
n) filter(!is.na(group))
# Line plot
%>%
quizscores_attempts ggplot(aes(x = date, y = n, color = group)) +
geom_line(linewidth = 1) +
geom_point(alpha = 0.7) +
labs(x = "Date",
y = "Number of attempts",
title = "Number of quiz attempts made over time per group") +
scale_color_manual(values = UU_pallette,
name = "Group", # Set the legend title
labels = c("uu" = "UU staff",
"uu_students" = "UU students",
"other" = "Others")) + # Set the legend labels
styling
# number of participants
write.csv(nr_participants_all,
"data/processed/nr_participants.csv",
row.names = FALSE)
# progress
write.csv(avg_progress_cats_new,
"data/processed/avg_progress_cats.csv",
row.names = FALSE)
# quiz
write.csv(quizscores_new,
"data/processed/quizscores.csv",
row.names = FALSE)
write.csv(total_quiz_scores_new,
"data/processed/total_quiz_scores.csv",
row.names = FALSE)