Skip to contents

combine_grades() is a generic function that combine, adjust, and filter student grades from Moodle Grades report(s) (not Responses report). This function can combine "Grade/xx" columns from multiple Moodle Grades reports into a single data.frame. Furthermore, you can adjust or weight maximum score of each quizzes and "Total" score will be computed. If the report contains multiple attempts per student, you can also filter grades of each student by score ("Grade/xx" column) and start time ("Started on" column), e.g. the first best score of each students. Like check_sub(), this function also cleans column names for easy manipulation, extracts student ID from "Email address", and unites "First name" and "Surname" column into "Name".

Usage

combine_grades(
  data,
  extract_id_from = c("Email address", "Institution", "Department", "ID number"),
  id_regex = ".*",
  sep_name = " ",
  new_max_grade = NULL,
  round_digits = 3,
  choose_grade = c("max", "min", "mean", "all"),
  choose_time = c("first", "last", "all"),
  force_grade = F,
  sep_col = "_"
)

Arguments

data

A data.frame or named list of data.frame of Moodle Grades report(s) (not Responses 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".

new_max_grade

(Numeric) A desired new maximum grade(s) to adjust. If NULL (default): the new maximum grade is/are equal to the old maximum grade from the Moodle Grades report (in "Grade/xx" columns). Note: The new maximum grade will be appended at the "Grade_*" column names.

  • If the data is a data.frame; enter new_max_grade as length 1 numeric vector to indicate the new maximum grade of that quiz.

  • If the data is a named list of data.frame; enter new_max_grade as numeric vector to indicate new maximum grades corresponding to each quizzes (the element of list of data.frame). Length of new_max_grade must equal to length of list of data.frame.

round_digits

Length 1 numeric vector to indicate digits to round grades. If NULL: no round digits.

choose_grade

A character to filter student's attempt by score ("Grade/xx" column), useful when quiz has multiple attempts for each students.

  • "max" (default): return rows that have maximum score of each students.

  • "min": return rows that have minimum score of each students.

  • "mean": compute and return mean score 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). This filter applies after choose_grade 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_grade

force_grade

(Logical) If grade of any students was found to be "Not yet graded", you will get an error message. The purpose of this is to warn you that you might have forgotten to grade some students. If you want to bypass this behavior, set force_grade = TRUE.

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 "Grade" 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 a cleaned data.frame of Moodle Grades report, whether it was adjusted or filtered depends on other arguments.

  • If the data is a named list of data.frame; the output is the same as previously described, but all Moodle Grades reports are full-joined together by column "Name" and "ID". So that, "Grades_" columns from each data.frame are sit together in a single data.frame, and "Total_" column is added at the last column to indicate sum of all quizzes grades.

Examples

# Combine and Readjust Grades of Quiz 1
combine_grades(grades_ls$Quiz_1,
               id_regex = "[:digit:]+",
               new_max_grade = 100)
#> # A tibble: 26 × 15
#>    Name      ID    Insti…¹ Depar…² State Grade…³ Started                Q1    Q2
#>    <chr>     <chr> <lgl>   <lgl>   <chr>   <dbl> <dttm>              <dbl> <dbl>
#>  1 Jada Roq… 017   NA      NA      Fini…    94.7 2021-06-02 08:28:00   2.6   2.6
#>  2 Ronin Ali 001   NA      NA      Fini…    97.4 2021-06-02 14:21:00   7.9   2.6
#>  3 Jerry Ho… 002   NA      NA      Fini…    94.7 2021-06-02 16:04:00   2.6   2.6
#>  4 Nathan B… 026   NA      NA      Fini…   100   2021-06-02 00:00:00   7.9   2.6
#>  5 Rohith H… 024   NA      NA      Fini…   100   2021-06-02 14:47:00   7.9   2.6
#>  6 Joy Ellis 013   NA      NA      Fini…   100   2021-06-02 03:56:00   7.9   2.6
#>  7 Jeremy N… 023   NA      NA      Fini…    92.1 2021-06-02 08:09:00   7.9   2.6
#>  8 Christop… 003   NA      NA      Fini…    94.7 2021-06-02 00:49:00   2.6   2.6
#>  9 Israel M… 018   NA      NA      Fini…   100   2021-06-02 15:36:00   7.9   2.6
#> 10 Zubaida … 022   NA      NA      Fini…   100   2021-06-02 23:11:00   7.9   2.6
#> # … with 16 more rows, 6 more variables: Q3 <dbl>, Q4 <dbl>, Q5 <dbl>,
#> #   Q6 <dbl>, Q7 <dbl>, Q8 <dbl>, and abbreviated variable names ¹​Institution,
#> #   ²​Department, ³​Grade_100

# Combine Grades of All Quizzes
combine_grades(grades_ls,
               id_regex = "[:digit:]+")
#> # A tibble: 26 × 9
#>    Name            ID    Quiz_…¹ Quiz_…² Quiz_…³ Quiz_…⁴ Quiz_…⁵ Quiz_…⁶ Total…⁷
#>    <chr>           <chr> <chr>     <dbl> <chr>     <dbl> <chr>     <dbl>   <dbl>
#>  1 Jada Roquemore  017   Finish…    9.47 Finish…    7.77 Finish…    9.99    27.2
#>  2 Ronin Ali       001   Finish…    9.74 Finish…    8.14 Finish…    9.28    27.2
#>  3 Jerry Hoffpauir 002   Finish…    9.47 Finish…    6.66 Finish…    9.99    26.1
#>  4 Nathan Babbitt  026   Finish…   10    Finish…    7.4  Finish…    9.99    27.4
#>  5 Rohith Huynh    024   Finish…   10    Finish…   10    Finish…    9.99    30.0
#>  6 Joy Ellis       013   Finish…   10    Finish…    5.55 Finish…    9.99    25.5
#>  7 Jeremy Nelson   023   Finish…    9.21 Finish…   10    Finish…    9.28    28.5
#>  8 Christopher Di… 003   Finish…    9.47 Finish…    8.88 Finish…    9.99    28.3
#>  9 Israel Munoz    018   Finish…   10    Finish…    8.51 Finish…    9.99    28.5
#> 10 Zubaida al-Att… 022   Finish…   10    Finish…    8.88 Finish…    9.99    28.9
#> # … with 16 more rows, and abbreviated variable names ¹​Quiz_1_State,
#> #   ²​Quiz_1_Grade_10, ³​Quiz_2_State, ⁴​Quiz_2_Grade_10, ⁵​Quiz_3_State,
#> #   ⁶​Quiz_3_Grade_10, ⁷​Total_30