forked from rstudio/gradethis
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rstudio#57) * Message creation changes in check_result (rstudio#48) * changes + tests to check_result messages * I think I covered all message cases for check_result * remove test_message_check_result.R * unit tests for checking messages [wip] * add default gradethis options to .onLoad * correct message changes + tests for check_result * uncomment incorrect tests and fix them * rename match/correct to .is_match/.is_correct * res returns a single bool using `all` and raises warning (rstudio#47) * make sure res returns a single bool using `all` * add reshape2, tibble, and tidyr to suggests section of DESCRPTION * user/solution into fxns and skip tests if no pkg * move common custom expect fxns to helper-expect.R * add a warning before calling all() when length(res) > * add documentation about == and identical * remove dependencies only from billboard test rstudio#47 (comment) * Glue message upgrade + tests (rstudio#57), doc+DESCRIPTION changes * upgrade glue_message ability (pair with barret) * upgrade glue message generation for check result/code * upgrade glue_message ability (pair with barret) * upgrade glue message generation for check result/code * fix R CMD check warnings * small doc changes + lint fixes * add \link to docs * add \code brackets * add \link * add \code brackets to docs * barret review changes
- Loading branch information
1 parent
cc918ba
commit a4cf671
Showing
33 changed files
with
1,727 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ | |
^man-roxygen$ | ||
^\.lintr$ | ||
^\.vscode$ | ||
^scripts/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,6 @@ Imports: | |
knitr, | ||
callr, | ||
learnr (>= 0.9.2.9001), | ||
stringr, | ||
readr, | ||
checkmate, | ||
testthat | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#' Generate Glue string from expression | ||
#' | ||
#' Checks and validates arguments passed into \code{glue}. | ||
#' | ||
#' @param glue_expression A glue character expression string. | ||
#' @param ... Values to be inserted into glue expression. | ||
#' @noRd | ||
glue_message <- function( | ||
glue_expression, | ||
... | ||
) { | ||
params <- list(...) | ||
param_names <- names(params) | ||
is_bool <- grepl("^\\.is_", param_names) | ||
bool_names <- param_names[is_bool] | ||
char_names <- param_names[!is_bool] | ||
|
||
if (length(bool_names) > 1) { | ||
params[bool_names] <- lapply(params[bool_names], function(x){x %||% NA}) # nolint | ||
} | ||
|
||
params[char_names] <- lapply(char_names, function(char_name) { | ||
x <- params[[char_name]] %||% "" # convert NULL strings to "" to work with glue | ||
chkm8_single_character(x, char_name) | ||
x | ||
}) | ||
|
||
ret <- glue::glue_data(params, glue_expression) | ||
return(ret) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
gradethis_default_options <- list( | ||
gradethis_glue_correct = "{ random_praise() } { .message } { .correct }", | ||
gradethis_glue_incorrect = "{ .message } { .incorrect } { random_encourage() }", | ||
|
||
gradethis_glue_pipe = paste0( | ||
"I see that you are using pipe operators (e.g. %>%), ", | ||
"so I want to let you know that this is how I am interpretting your code ", | ||
"before I check it:\n\n{deparse(unpipe_all(.user))}\n\n{.message}") | ||
) | ||
|
||
.onLoad <- function(libname, pkgname) { | ||
op <- options() | ||
toset <- !(names(gradethis_default_options) %in% names(op)) | ||
if (any(toset)) options(gradethis_default_options[toset]) | ||
|
||
invisible() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1 @@ | ||
#' @param correct A character string to display if the student answer matches | ||
#' a known answer. | ||
#' This character string will be run through \code{glue::\link[glue]{glue_data}} with \code{list(correct = TRUE, message = "<result message>")}. where message is the matched result message. | ||
#' \code{matched} is a boolean value about whether the submitted is found in a set of provided values. | ||
#' @param correct A character string to display if the student answer matches a known correct answer. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#' @param glue_correct A glue string that returns the final correct message displayed. | ||
#' Defaults to \code{getOption("gradethis_glue_correct")}. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#' @param glue_incorrect A glue string that returns the final incorrect message displayed. | ||
#' Defaults to \code{getOption("gradethis_glue_incorrect")}. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#' @param grader_args A list of parameters passed to \code{grader} functions (provided by \code{grade_learnr}). This contains: \describe{ | ||
#' @param grader_args A list of parameters passed to \code{grader} functions (provided by \code{\link{grade_learnr}}). | ||
#' This contains: \describe{ | ||
#' \item{\code{user_quo}}{Quoted R code submitted by the user. Ex: \code{rlang::\link[rlang]{quo}(1)} } | ||
#' \item{\code{solution_quo}}{[Optional] Quoted solution R code provided by the \code{*-solution} chunk for an exercise.} | ||
#' } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#' @param incorrect A character string to display if the student answer matches a known incorrect answer. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
#' @param learnr_args A list of all parameters passed to \code{\link{grade_learnr}} by \code{learnr}. See \url{https://rstudio.github.io/learnr/exercises.html#exercise_checking} for more details. | ||
#' @param learnr_args A list of all parameters passed to \code{\link{grade_learnr}} by \code{learnr}. | ||
#' See \url{https://rstudio.github.io/learnr/exercises.html#exercise_checking} for more details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#' @param x A formula, function, or value, that returns \code{TRUE} or \code{FALSE}. | ||
#' When comparing objects that are greater than length 1 (e.g., vectors, dataframes, matricies, etc) | ||
#' A boolean vector will be returned if the user uses \code{==}, not a single boolean value. | ||
#' \code{grader} will run the vector through \code{all(..., na.rm = TRUE)} to check for the boolean value. | ||
#' It is advised that the user use \code{identical()} instead of \code{==} in this case. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.