Created
November 2, 2020 14:52
-
-
Save sebastiansauer/c942b2dded75620a67269cbc9aa66a14 to your computer and use it in GitHub Desktop.
Extracting solutions from metainfo file in r-exams package
This file contains 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
extract_solutions <- function(file) { | |
require(tidyverse) | |
# input: | |
# file: the output file from the exam2nops call storing the exams meta info | |
# output: | |
# list of solutions for each exam variant and each question | |
exammetainfo <- readRDS(file) | |
sols <- list() | |
for (i in 1:length(exammetainfo)) { | |
sols[[i]] <- exammetainfo[[i]] %>% | |
map(~ pluck(.x, "metainfo", "solution")) | |
} | |
return(sols) | |
} | |
# Example (not run) | |
metainfofile <- "output/metainfo.rds" | |
extract_solutions(metainfofile) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment