Writes the output of moodle_grades() to a CSV file with
readr::write_csv().
Arguments
- con
A DBI connection.
- path
Output CSV path.
- tutorial_id
Tutorial identifier. Required.
- rule
Scoring rule passed to
gradebook().- grade_item
Column name for the Moodle grade item. Defaults to
tutorial_id.- id_column
Column name for the exported student identifier. Defaults to
"useridnumber", a common Moodle mapping target for institutional student identifiers.- grade_value
Which gradebook value to export. Use
"percent"for a 0-100 grade or"score"for the raw score.- digits
Number of decimal places used to round exported grades. Use
NULLto disable rounding.- include_unregistered
If
TRUE, include attempted questions that were not registered withregister_questions().- group_id
Optional registered student group identifier. If supplied, only students in that registered group are exported.
Examples
db_path <- tempfile(fileext = ".sqlite")
csv_path <- tempfile(fileext = ".csv")
con <- init_tracking_db(db_path, overwrite = TRUE)
register_questions(con, "module_01", c("q1", "q2"))
#> # A tibble: 2 × 6
#> question_id tutorial_id question_label question_type max_score created_at
#> <chr> <chr> <chr> <chr> <dbl> <chr>
#> 1 q1 module_01 q1 NA 1 2026-06-24T12:…
#> 2 q2 module_01 q2 NA 1 2026-06-24T12:…
track_attempt(con, "student_001", "module_01", "q1", "mean(x)", score = 1, max_score = 1)
export_moodle_grades(con, csv_path, tutorial_id = "module_01")
DBI::dbDisconnect(con)