problem_grade: Apply automatic grading to a problem object

View source: R/problem_grade.R

problem_gradeR Documentation

Apply automatic grading to a problem object

Description

Automatically converts a problem() object into a gradethis grade. problem_grade() is an S4 generic and tblcheck provides an internal method for problems with class "tblcheck_problem". In tblcheck, or for problems with this class, any problems are automatically turned into failing grades with gradethis::fail() and using the message provided by problem_message().

Usage

problem_grade(problem, max_diffs = 3, env = parent.frame(), ...)

## Default S3 method:
problem_grade(problem, max_diffs = 3, env = parent.frame(), ...)

## S3 method for class 'list'
problem_grade(problem, max_diffs = 3, env = parent.frame(), ...)

## S3 method for class 'gradethis_problem'
problem_grade(problem, max_diffs = 3, env = parent.frame(), ...)

## S3 method for class 'tblcheck_problem'
problem_grade(problem, max_diffs = 3, env = parent.frame(), ...)

Arguments

problem

A problem generated by tbl_check(), vec_check() or their related helper functions.

max_diffs

[numeric(1)]
The maximum number of mismatched values to display in an informative failure message. Passed to tbl_check_names() to determine the number of mismatched column names to display and the n_values argument of tbl_check_column() to determine the number of mismatched column values to display. Defaults to 3.

env

The environment used for grading.

...

Arguments passed on to gradethis::fail

hint

Include a code feedback hint with the failing message? This argument only applies to fail() and fail_if_equal() and the message is added using the default options of give_code_feedback() and maybe_code_feedback(). The default value of hint can be set using gradethis_setup() or the gradethis.fail.hint option.

encourage

Include a random encouraging phrase with random_encouragement()? The default value of encourage can be set using gradethis_setup() or the gradethis.fail.encourage option.

Value

A gradethis::fail() message or NULL invisibly.

See Also

Other Problem functions: problem_message(), problem_type(), problem()

Examples

.result <- 1:10
.solution <- letters[1:10]
problem <- vec_check()
problem_grade(problem)


rstudio/tblcheck documentation built on March 11, 2023, 5:42 p.m.