Builds a simple wide grade table suitable for Moodle CSV import mapping: one student identifier column and one grade item column. In Moodle, the teacher maps the identifier column to the matching user field and the grade item column to an existing grade item.
Arguments
- con
A DBI connection.
- 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")
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)
moodle_grades(con, tutorial_id = "module_01")
#> # A tibble: 1 × 2
#> useridnumber module_01
#> <chr> <dbl>
#> 1 student_001 50
DBI::dbDisconnect(con)