#' This function is for the grader.
#' It gives the test results as a data frame.
#' This function tests a single file.
#' @param file_name is the file path that we want to test.
#' @export
grade_file <- function(file_name, function_names){
source_code_lines <- drop_after_ignore_rest(readLines(file_name))
table <- grade(source_code_lines)
results <- list()
for (i in 1:length(function_names)) {
function_name <- function_names[i]
df <- data.frame(
fileName = file_name,
functionName = function_name,
testPassed = table[[function_name]])
df$testNumber <- seq(nrow(df))
results[[i]] <- df
}
return(do.call(rbind, results))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.