我一直无法使以下代码正常工作,有人知道为什么它没有通过 URL 将学生参加的漩涡课程的内容传送到 Google 表单中。
Sean Kross 的 Google_Forms_Course 存储库是我复制原始代码并完全按照 read.me 中所述进行设置的地方。这似乎是与 Google Forms 的交互问题,他的原始代码是前段时间编写的。这段代码的哪一部分可能不会与新的 API 交互......我真的不知道要找到我自己的解决方案......但我真的很想修复它。
# Get the swirl state
getState <- function(){
# Whenever swirl is running, its callback is at the top of its call stack.
# Swirl's state, named e, is stored in the environment of the callback.
environment(sys.function(1))$e
}
# Retrieve the log from swirl's state
getLog <- function(){
getState()$log
}
submit_log <- function(){
# Please edit the link below
pre_fill_link <- "Enter Google Form URL here"
# Do not edit the code below
if(!grepl("=$", pre_fill_link)){
pre_fill_link <- paste0(pre_fill_link, "=")
}
p <- function(x, p, f, l = length(x)){if(l < p){x <- c(x, rep(f, p - l))};x}
temp <- tempfile()
log_ <- getLog()
nrow_ <- max(unlist(lapply(log_, length)))
log_tbl <- data.frame(user = rep(log_$user, nrow_),
course_name = rep(log_$course_name, nrow_),
lesson_name = rep(log_$lesson_name, nrow_),
question_number = p(log_$question_number, nrow_, NA),
correct = p(log_$correct, nrow_, NA),
attempt = p(log_$attempt, nrow_, NA),
skipped = p(log_$skipped, nrow_, NA),
datetime = p(log_$datetime, nrow_, NA),
stringsAsFactors = FALSE)
write.csv(log_tbl, file = temp, row.names = FALSE)
encoded_log <- base64encode(temp)
browseURL(paste0(pre_fill_link, encoded_log))
}