grade_this_vector | R Documentation |
Automatically grade a vector resulting from student code using
gradethis::grade_this()
and vec_grade()
to compare the
student's result with the author's solution.
grade_this_vector( correct = NULL, pre_check = NULL, post_check = NULL, pass_if_equal = TRUE, ..., max_diffs = 3, check_class = TRUE, ignore_class = NULL, check_length = TRUE, check_levels = TRUE, check_values = TRUE, tolerance = sqrt(.Machine$double.eps), check_names = TRUE, hint = getOption("gradethis.fail.hint", FALSE), encourage = getOption("gradethis.fail.encourage", FALSE), pass.praise = NULL )
correct |
|
pre_check, post_check |
|
pass_if_equal |
|
... |
Additional arguments passed to |
max_diffs |
|
check_class |
|
ignore_class |
If an element is named, differences will only be ignored between the pair
of the element and its name.
For example, If all the classes of |
check_length |
|
check_levels |
|
check_values |
|
tolerance |
|
check_names |
|
hint |
Include a code feedback hint with the failing message? This
argument only applies to |
encourage |
Include a random encouraging phrase with
|
pass.praise |
Logical |
The returned feedback is equivalent to gradethis grading code
using grade_this()
with the following
components:
First the pre_check
code, if any, is evaluated. If this code calls
pass()
, fail()
, or their
equivalents, that feedback is provided immediately.
If pass_if_equal
is TRUE
, then
pass_if_equal()
is called to compare the
.result
to the
.solution
. The message in correct
is used for the feedback.
The appropriate tblcheck grading function is called, returning any feedback:
grade_this_table()
returns the results from tbl_grade()
grade_this_vector()
returns the results from vec_grade()
The post_check
code, if any, is evaluated and any feedback from a call
to pass()
, fail()
, or
their equivalents is returned.
Finally, if no other feedback is returned, the feedback from
gradethis::fail()
is provided to the student, using the options
fail.message
, fail.hint
and fail.encourage
.
vec_grade()
Other graders:
grade_this_table()
ex <- gradethis::mock_this_exercise( .solution_code = tibble::tibble(x = 1:3, y = letters[x]), .user_code = tibble::tibble(x = 1:3, y = c("A", "b", "c")) ) #' ## Grading Vectors ---- # Here we use `pre_check` to modify `.result` and grade_this_vector( pre_check = { .result <- .result$y .solution <- .solution$y } )(ex) # Roughly equivalent to... gradethis::grade_this({ .result <- .result$y .solution <- .solution$y gradethis::pass_if_equal() vec_grade() gradethis::fail() })(ex)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.