Created
June 14, 2026 06:00
-
-
Save benmarwick/1c49374197d6eb968429d650f84cbce9 to your computer and use it in GitHub Desktop.
ARCHY 208 SP26 Final Grade Calculations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(tidyverse) | |
| canvas_gradebook <- "2026-06-13T2142_Grades-ARCHY_208_A.csv" | |
| gb <- | |
| read_csv(canvas_gradebook) %>% | |
| filter(!is.na(`SIS Login ID`)) %>% | |
| # select only the relevant columns for this assignment | |
| # and those required to join | |
| select(Student, | |
| `SIS User ID`, | |
| contains(c("Poll everywhere responses module", | |
| "Lab report module", | |
| "Syllabus quiz", | |
| "Syllabus Quiz", | |
| "Final project:"))) |> | |
| pivot_longer(-c(Student, | |
| `SIS User ID`), | |
| names_to = "assignment") |> | |
| mutate(assignment_type = case_when( | |
| str_detect(assignment, "Poll everywhere responses module") ~ "participation", | |
| str_detect(assignment, "Lab report module") ~ "lab_report", | |
| str_detect(assignment, "uiz") ~ "lab_report", | |
| str_detect(assignment, "Final ") ~ "final_project" | |
| ), | |
| value = parse_number(value)) | |
| # # deal with the max allowed from each category, indicated here: | |
| # https://docs.google.com/spreadsheets/d/125OmDiWTJ-c6BLojGD8pSHzm3izEn63h/edit?rtpof=true | |
| participation_max <- 1.0 # / 4 | |
| lab_report_max <- 2.0 # / 4 | |
| final_project_max <- 1.0 # / 4 | |
| gb_assignments_long_max <- | |
| gb |> | |
| summarise(sum_points = sum(value, na.rm = TRUE), | |
| .by = c(Student, `SIS User ID`, assignment_type)) |> | |
| mutate(sum_points_type = case_when( | |
| assignment_type == "participation" ~ ifelse(sum_points > participation_max, | |
| participation_max, | |
| sum_points), | |
| assignment_type == "lab_report" ~ ifelse(sum_points > lab_report_max, | |
| lab_report_max, | |
| sum_points), | |
| assignment_type == "final_project" ~ ifelse(sum_points > final_project_max, | |
| final_project_max, | |
| sum_points) | |
| )) |> | |
| ungroup() |> | |
| pivot_wider(id_cols = c(Student, `SIS User ID`), | |
| names_from = assignment_type, | |
| values_from = sum_points_type) |> | |
| rowwise() |> | |
| mutate(total = sum(participation, | |
| lab_report, | |
| final_project), | |
| out_of_four = ifelse(total > 4, | |
| 4, | |
| total), | |
| ImportGrade = janitor::round_half_up(out_of_four, digits = 1) | |
| ) | |
| write_csv(gb_assignments_long_max, | |
| "gb__assignments_long_max_for_submitting.csv") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment