combine_resp()
is a generic function that combine student responses from Moodle Responses report(s) (not Grades report).
If the Moodle responses report has response column(s) that contained embedded answers (Cloze), you have an option to split them into different parts (one column for each).
Other functionality are similar to check_sub()
such as: encode & filter student's attempts by state (i.e., "Finished" or "In progress") and started time ("Started on" column),
cleans column names for easy manipulation, extracts student ID from "Email address", and unites "First name" and "Surname" column into "Name".
Usage
combine_resp(
data,
extract_id_from = c("Email address", "Institution", "Department", "ID number"),
id_regex = ".*",
sep_name = " ",
state = c("Finished", "In progress"),
encode = c(1, 0),
choose_encode = c("max", "min", "all"),
choose_time = c("first", "last", "all"),
split_cloze = F,
part_glue = "_part_",
sep_col = "_p_"
)
Arguments
- data
A data.frame or named list of data.frame of Moodle Responses report(s) (not Grades report)
- extract_id_from
(Character) Choose 1 column to extract ID from
- id_regex
(Character) A regular expression used to extract ID from column "Email address" in the Moodle Quiz report. 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
A character in the new "Name" column that separate original "First name" and "Surname".
- state
A character vector to match values in "State" column of the Moodle Quiz report
- encode
An encoding numeric vector corresponding to
state
. For example: by default, in the "State" column, "Finished" values will be encoded as1
, and "In progress" will be encoded as0
.- choose_encode
A character to filter student's attempt by the
encode
ing."max" (default): return rows that have maximum encoding of each students.
"min": return rows that have minimum encoding of each students.
"all": no filter applied, return all rows.
- choose_time
A character to filter student's attempt by started time (determined by "Started on" column in Moodle Quiz report). This filter applies after
choose_encode
has been applied to the data."first" (default): return rows that represent first attempt of each students.
"last": return rows that represent last attempt of each students.
"all": no filter applied, return all rows after applying
choose_encode
- split_cloze
(Logical) If the
data
has at least one response column(s) that contained embedded answers (Cloze),split_cloze = TRUE
will split them into different parts (one column for each). If thedata
has no Cloze response columns,split_cloze = TRUE
will result in error message. IfFALSE
(default), no Cloze column will be split.- part_glue
(Character) If
split_cloze = TRUE
and cloze response columns is presented,part_glue
represent a character that glues the names of "Response" column and each "Parts" of Cloze columns together.- sep_col
(Character) If
data
is a named list of data.frame,sep_col
indicate a character separation between names of list and "State" or "Response" columns.
Value
A data.frame, its output content is determined by class of its first argument: data
.
If the
data
is a data.frame; the output is an encoded, filtered, and cleaned data.frame of Moodle Responses report.If the
data
is a named list of data.frame; the output is the same as previously described, but all Moodle Quiz reports are full-joined together by column "Name" and "ID". So that, "Response" columns from each data.frame are sit together in a single data.frame. The resulting response columns are in this format (default): "<listNames>-Responses-<number>"
Examples
# Combine Response from 1 Quiz
combine_resp(responses_ls$Quiz_1, id_regex = "[:digit:]+")
#> # A tibble: 26 × 10
#> Name ID Insti…¹ Depar…² State Encode Started Grade…³ Respo…⁴
#> <chr> <chr> <lgl> <lgl> <chr> <dbl> <dttm> <chr> <chr>
#> 1 Lance… 004 NA NA Fini… 1 2022-04-19 19:19:00 Not ye… intuit…
#> 2 Sydne… 002 NA NA Fini… 1 2022-04-19 16:32:00 Not ye… Tarzan…
#> 3 Itzel… 016 NA NA Fini… 1 2022-04-19 12:36:00 Not ye… not to…
#> 4 Hakam… 001 NA NA Fini… 1 2022-04-19 06:46:00 Not ye… “A der…
#> 5 Hamoo… 012 NA NA Fini… 1 2022-04-19 03:23:00 Not ye… At las…
#> 6 Domin… 007 NA NA Fini… 1 2022-04-19 09:03:00 Not ye… the po…
#> 7 Zhjad… 009 NA NA Fini… 1 2022-04-19 02:17:00 Not ye… upon t…
#> 8 Jorda… 013 NA NA Fini… 1 2022-04-19 12:10:00 Not ye… “In ti…
#> 9 Kevin… 025 NA NA Fini… 1 2022-04-19 03:41:00 Not ye… A FRIE…
#> 10 Angel… 018 NA NA Fini… 1 2022-04-19 01:48:00 Not ye… very f…
#> # … with 16 more rows, 1 more variable: Response_2 <chr>, and abbreviated
#> # variable names ¹Institution, ²Department, ³Grade_2.00, ⁴Response_1
# Combine Response from multiple quizzes into 1 data frame
combine_resp(responses_ls, id_regex = "[:digit:]+")
#> # A tibble: 26 × 9
#> Name ID Quiz_…¹ Quiz_…² Quiz_…³ Quiz_…⁴ Quiz_…⁵ Quiz_…⁶ Quiz_…⁷
#> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 Lance Xiong 004 Finish… intuit… she re… Finish… The ne… you in… While …
#> 2 Sydney Halamic… 002 Finish… Tarzan… the me… Finish… “I sho… “God k… in bri…
#> 3 Itzel Palomino 016 Finish… not to… - Finish… left s… you kn… in the…
#> 4 Hakam el-Farooq 001 Finish… “A der… “I fea… Finish… Toward… his pr… close …
#> 5 Hamood al-Farha 012 Finish… At las… Findin… Finish… necess… victor… there …
#> 6 Dominique Solis 007 Finish… the po… though… Finish… a cowa… Tarzan… were f…
#> 7 Zhjade Alarid 009 Finish… upon t… and fo… Finish… Hazel … - they f…
#> 8 Jordan Tan 013 Finish… “In ti… warrio… Finish… - freedo… The ap…
#> 9 Kevin Vasquez 025 Finish… A FRIE… Thus, … Finish… not da… west, … last C…
#> 10 Angela Carrillo 018 Finish… very f… “they … Finish… “I sho… they c… -
#> # … with 16 more rows, and abbreviated variable names ¹Quiz_1_State,
#> # ²Quiz_1_Response_1, ³Quiz_1_Response_2, ⁴Quiz_2_State, ⁵Quiz_2_Response_1,
#> # ⁶Quiz_2_Response_2, ⁷Quiz_2_Response_3