Skip to content

Commit

Permalink
Revert "updates mark_my_file to get extra info out"
Browse files Browse the repository at this point in the history
This reverts commit 1ea9764.
  • Loading branch information
MansMeg committed Sep 15, 2023
1 parent b0be250 commit f8b8e7e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
19 changes: 5 additions & 14 deletions R/mark_my_assignment.R
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,11 @@ run_test_suite <- function(caller, tasks = NULL, mark_file = NULL, quiet = FALSE
}

if(!is.null(mark_file)){
del_out <- delete_circular_calls(mark_file)
mark_file <- del_out$txt_out
forbidden_rows <- del_out$remove_row
if(length(forbidden_rows)>0)
return(list(test_res=NULL,forbidden_rows=forbidden_rows))
mark_file <- delete_circular_calls(mark_file)
tf_path <- tempfile(pattern = "mark_file", fileext = ".txt")
writeLines(text = mark_file, con = tf_path)
source(file = tf_path, local = mark_my_env)
unlink(x = tf_path)

}

# tasks <- "task2"
Expand All @@ -122,13 +117,12 @@ run_test_suite <- function(caller, tasks = NULL, mark_file = NULL, quiet = FALSE
env = mark_my_env,
stop_on_failure = FALSE,
...)

mark_my_env$test_res <- test_res

# Source in after code
after_paths <- file.path(mark_my_run_code_dir(), run_code_paths[grepl("after",run_code_paths)])
for(i in seq_along(after_paths)) source(file = after_paths[i], local = mark_my_env)

return(list(test_res = test_res,forbidden_rows=forbidden_rows))
test_res
}

#' @title
Expand All @@ -142,7 +136,6 @@ run_test_suite <- function(caller, tasks = NULL, mark_file = NULL, quiet = FALSE
cheer <- function() {
cat(sample(x = c("Yay! All done!",
"Good work!",
"Brilliant!",
"You're a coding rockstar!",
"Keep up the good work!",
"Everything's correct!"), 1))
Expand Down Expand Up @@ -186,14 +179,12 @@ delete_circular_calls <- function(mark_file){

warn_msg <- paste0("\n> ", msg_statement, "\ndue to: ", msg_forbidden, "\n")

forbidden_rows = c()
if(any(remove_row)){
warning("The following statement(s) were ignored/removed when running mark_my_file():\n",
warn_msg)
forbidden_rows = txt_in[remove_row]
txt_out <- txt_in[!remove_row]
}
return(list(txt_out = txt_out, remove_row=forbidden_rows))
return(txt_out)
}

#' Forbidden functions for \code{mark_my_file()}
Expand All @@ -206,7 +197,7 @@ delete_circular_calls <- function(mark_file){
forbidden_functions <- function(){
ns <- ls(name = "package:markmyassignment")
forbidden <- c("install.packages", "utils::install.packages",
"devtools::install_github", "install_github", "data", "system","setwd")
"devtools::install_github", "install_github", "data", "system")
c(forbidden, ns, paste0("markmyassignment::", ns))
}

Expand Down
2 changes: 1 addition & 1 deletion R/mark_my_file.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ mark_my_file <- function(tasks = NULL, mark_file=file.choose(), assignment_path
test_results <- run_test_suite(caller = "mark_my_file", tasks, mark_file, quiet, ...)
}

test_results_df <- as.data.frame(test_results$test_res)
test_results_df <- as.data.frame(test_results)
if(!any(test_results_df$error) & sum(test_results_df$failed) == 0 & is.null(tasks) & !quiet) cheer()

if(!is.null(assignment_path)) remove_assignment()
Expand Down

0 comments on commit f8b8e7e

Please sign in to comment.