R/grade_file.R

Defines functions grade_file

Documented in grade_file

#' 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))
}
emse-p4a-gwu/p4aGrader documentation built on May 16, 2020, 1:43 a.m.