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.
Reorganize and prune functions (rstudio#61)
* comment out unused functions, move fxns to separate R files * remove learnr dependency (broken) * move and edit view/add/remove tutorial fxns waiting for feature to be implement in rstudio before putting back in also removes learnr depedency * remove dependencies (clean up scripts and files) removes call to pryr in grade_learnr and replace with rlang equlivilant move unused functions to archive. these are flagged for deletion. move old tutorial files to archive, will be added in when api is finalized, and still deemed necessary. * lintr! * remove test and result function from archive. result was removed in rstudio#21
- Loading branch information
1 parent
a4cf671
commit 1fd6873
Showing
39 changed files
with
439 additions
and
482 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 |
---|---|---|
|
@@ -10,3 +10,4 @@ | |
^\.lintr$ | ||
^\.vscode$ | ||
^scripts/ | ||
^archive/ |
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,34 @@ | ||
#' Condition object | ||
#' Captures what the user passes into \code{\link{pass_if}} or \code{\link{fail_if}}, | ||
#' figures out what type of object was passed into \code{x}, | ||
#' and returns a \code{grader_condition} object that will be passed into \code{evaluate_condi} | ||
#' | ||
#' @param x expression to be evaluated | ||
#' @param message character string for message returned | ||
#' @param correct logical whether the condition is the correct answer | ||
#' | ||
#' @return a \code{grader_condition} object that contains | ||
#' the expression \code{x}, | ||
#' the message \code{message}, | ||
#' whether or not the expression is the correct answer or not, \code{correct}, | ||
#' the type of expression (formula, function, or value), \code{type} | ||
#' @export | ||
condition <- function(x, message, correct) { | ||
type <- | ||
if (rlang::is_formula(x)) { | ||
"formula" | ||
} else if (rlang::is_function(x)) { | ||
"function" | ||
} else { | ||
"value" | ||
} | ||
|
||
ret <- list( | ||
x = x, | ||
message = message, | ||
correct = correct, | ||
type = type | ||
) | ||
class(ret) <- "grader_condition" | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#' Get Code | ||
#' | ||
#' Helper methods around \code{rlang::\link[rlang]{eval_tidy}} | ||
#' to extract user code and solution code. | ||
#' | ||
#' @seealso \code{\link{check_result}}, \code{\link{test_result}}, and \code{\link{check_code}} | ||
#' @export | ||
#' @rdname get_code | ||
#' @param user,solution,expr An expression or quosure to evaluate. | ||
#' @param name Name to print if a \code{NULL} expression is provided. | ||
#' @inheritParams rlang::eval_tidy | ||
get_user_code <- function(user = NULL, env = rlang::caller_env()) { | ||
get_code(user, "user", env = env) | ||
} | ||
#' @export | ||
#' @rdname get_code | ||
get_solution_code <- function(solution = NULL, env = rlang::caller_env()) { | ||
get_code(solution, "solution", env = env) | ||
} | ||
#' @export | ||
#' @rdname get_code | ||
get_code <- function(expr = NULL, name = "<name not provided>", env = rlang::caller_env()) { | ||
if (is.null(expr)) { | ||
stop("'", name, "' not provided") | ||
} | ||
rlang::eval_tidy(expr, env = env) | ||
} |
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,15 @@ | ||
#' Pass if condition matches | ||
#' @template pass_fail_x_condition | ||
#' @param message chracter string for message returned | ||
#' @export | ||
pass_if <- function(x, message = NULL) { | ||
condition(x, message, correct = TRUE) | ||
} | ||
|
||
#' Fail if condition matches | ||
#' @template pass_fail_x_condition | ||
#' @param message chracter string for message returned | ||
#' @export | ||
fail_if <- function(x, message = NULL) { | ||
condition(x, message, correct = FALSE) | ||
} |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.