2.1 General Structure
Generally, an autograder script will look something like:
rm(list = ls())
#--------------Set This------#
#loc <- "local" # either "local", or "gradescope"
loc <- "gradescope"
#------DON'T TOUCH THIS------#
#Setting working directory to source file location
if(loc=="local"){
setwd(dirname(rstudioapi::getSourceEditorContext()$path))
}
source("inputs.R")
source(paste0(here::here(),"/helper_functions/autograder_setup.R",""))
source(paste0(here::here(),"/helper_functions/misc_helper_functions.R",""))
source("inputs.R")
#----------------------------#
if(status!="Error"){
#Answer Key Goes Here...
#Question 1 Solution
#Question 2 Solution, etc.
#Autograder Code Goes Here...
#Testing Student's Question 1 Against Question 1 Solution
#Testing Student's Question 2 Against Question 2 Solution, etc.
# ----------------------------------------------------------- #
JSONmaker(test.results, loc)
}
Under #Answer Key Goes Here...
, TAs insert the assignment solutions. To distinguish solutions from the student’s answers (so they can be compared), we tend to follow the convention of appending “_test
” to the answer key’s variable name.
- For example, if Question 1 on the homework asks the student to create a tibble named
basketball_data
, the answer key’s corresponding tibble will be namedbasketball_data_test
.
Under #Autograder Code Goes Here...
, TAs insert their code for the autograder. Question by question, this code will compare the student’s solution to the corresponding answer key. As a reminder…
For any Public Question, we program a series of “Checks” (lines of code) to test the student’s answer for a range of attributes and return dynamic feedback. See Public Questions.
For any Private Question, we employ a group of built-in functions to test the student’s answer for a fixed set of attributes and return basic feedback. See Private Questions.
The autograder only evaluates the student’s final result, the R object – it does not grade the code required to produce it.
Accordingly, students can receive full credit for a question even if their code is vastly different from the answer key. The feedback our Checks generate guide students towards the recommended, class-based solution.
The student’s R object does not need to be identical to the answer key to receive full credit. See Correct Check for more details.