Learn R Programming

gradeR (version 2.0.1)

calcGradesForGradescope: The grading function for Gradescope.

Description

This function grades one R script assignment submission and writes results out to a properly-formatted json file for Gradescope. Supports R scripts (.r, .R) as well as R Markdown (.Rmd) and Quarto (.qmd) documents.

Usage

calcGradesForGradescope(
  submission_file,
  test_file,
  which_results = "gradescope",
  suppress_warnings = TRUE
)

Value

Invisibly returns NULL. The function's primary purpose is the side effect of writing a JSON results file.

Arguments

submission_file

the path to the assignment submission file (e.g. "hw1.r", "hw1.Rmd", or "hw1.qmd"). For Rmd/Qmd files, R code will be automatically extracted.

test_file

the path to the .r file with test_that tests (e.g. "hw1_tests.R")

which_results

Choose either "testing" or "gradescope". If equal to "gradescope", the json file is written to /autograder/results/results.json. Otherwise, results.json is written to your current working directory.

suppress_warnings

If FALSE, warnings are fatal; if set to TRUE, warnings will not prematurely terminate running of student submission scripts.

Examples

Run this code
if (FALSE) {
# For local testing
calcGradesForGradescope("student_hw1.r", "hw1_tests.R", which_results = "testing")

# For Gradescope autograder (inside Gradescope environment)
# calcGradesForGradescope("hw1.r", "hw1_tests.R", which_results = "gradescope")

# Works with R Markdown files too
# calcGradesForGradescope("student_hw1.Rmd", "hw1_tests.R", which_results = "testing")
}

Run the code above in your browser using DataLab