Automatically grade a table resulting from student code using
gradethis::grade_this()
and tbl_grade()
to compare the
student's result with the author's solution.
grade_this_table(
correct = NULL,
pre_check = NULL,
post_check = NULL,
pass_if_equal = TRUE,
...,
max_diffs = 3,
cols = NULL,
check_class = TRUE,
check_names = TRUE,
check_column_order = FALSE,
check_dimensions = TRUE,
check_groups = TRUE,
check_columns = TRUE,
check_column_class = check_columns,
check_column_values = check_columns,
hint = getOption("gradethis.fail.hint", FALSE),
encourage = getOption("gradethis.fail.encourage", FALSE),
pass.praise = NULL
)
[character(1)]
The message shown to the student when
their .result
matches the exercise .solution
, if pass_if_equal
is
TRUE
.
[expression]
Code to run before or after the
table or vector grading is performed. The pre check runs before calling
gradethis::pass_if_equal()
so that you can modify or adjust the student's
.result
or the .solution
if there are parts of either that need to be
ignored. These arguments can also be used in conjunction with the
pass_if_equal
option when the grading requirements are more involved.
[logical(1)]
When TRUE
(default), the .result
is compared to the .solution
with gradethis::pass_if_equal()
after the
pre check and before calling the tblcheck grading function. When
FALSE
, you will need to include your own call to gradethis::pass()
in
either pre_check
or post_check
for the student to be able to receive a
passing grade.
Additional arguments passed to graded()
or additional data to be
included in the feedback object.
[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.
[tidy-select
]
A selection of columns
to compare between object
and expected
. Differences in other columns
will be ignored. If NULL
, the default, all columns will be checked.
[logical(1)]
Whether to check that object
and
expected
have the same classes with tbl_check_class()
.
[logical(1)]
Whether to check that object
and
expected
have the same column names with tbl_check_names()
.
[logical(1)]
Whether to check that the columns
of object
are in the same order as expected
with tbl_check_names()
.
Defaults to FALSE
.
[logical(1)]
Whether to check that object
and
expected
have the same number of rows and columns
with tbl_check_dimensions()
.
[logical(1)]
Whether to check that object
and
expected
have the same groups
with dplyr::group_vars()
.
[logical(1)]
Whether to check that all columns
have the same contents with tbl_check_column()
.
[logical(1)]
Whether to check that each
columns has the same class in object
and expected
.
[logical(1)]
Whether to check that each
column has the same values in object
and expected
.
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.
Incude a random encouraging phrase with
random_encouragement()
? The default value of encourage
can be set
using gradethis_setup()
or the gradethis.fail.encourage
option.
Logical TRUE
or FALSE
to determine whether a praising
phrase should be automatically prepended to any pass()
or
pass_if_equal()
messages. Sets the gradethis.pass.praise
option.
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
.
Other graders:
grade_this_vector()
ex <- gradethis::mock_this_exercise(
.solution_code = tibble(x = 1:3, y = letters[x]),
.user_code = tibble(x = 1:3, y = c("A", "b", "c"))
)
## Grading Tables ----
grade_this_table()(ex)
#> #> grade_this_table()(ex)
#> Error in rlang::eval_bare(x, env): could not find function "tibble"
#> <tblcheck_graded: [Neutral]
#> A problem occurred with the grading code for this exercise.
#> >
# Roughly equivalent to...
gradethis::grade_this({
gradethis::pass_if_equal()
tbl_grade()
gradethis::fail()
})(ex)
#> Warning: restarting interrupted promise evaluation
#> #> (gradethis::grade_this({
#> #> gradethis::pass_if_equal()
#> #> tbl_grade()
#> #> gradethis::fail()
#> #> }))(ex)
#> Error in rlang::eval_bare(x, env): could not find function "tibble"
#> <gradethis_graded: [Neutral]
#> A problem occurred with the grading code for this exercise.
#> >