Skip to content

Setup gradethis

To use gradethis in your learnr tutorial, you only need to load the gradethis package. Still, you can use gradethis_setup() to change the default values of many of the exercise checking or grading function arguments.

gradethis_setup()
Setup gradethis for use within learnr

Exercise Checking Functions

Choose one of these functions to use in the *-check chunk of your exercise.

grade_this()
Grade a student's submission using custom logic
grade_this_code()
Grade student code against a solution
debug_this()
Debug an exercise submission
.result .user .last_value .solution .solution_all .user_code .solution_code .solution_code_all .envir_prep .envir_result .evaluate_result .label .stage .engine
Checking environment objects for use in grade_this()

Signal A Final Grade

Helper functions to create and signal a final grade when used in custom checking logic in grade_this().

graded() pass() fail()
Signal a final grade for a student's submission
pass_if_equal() fail_if_equal()
Signal a passing or failing grade if two values are equal
pass_if() fail_if()
Signal a passing or failing grade if a condition is TRUE
fail_if_code_feedback()
Signal a failing grade if mistakes are detected in the submitted code
fail_if_error()
Fail if grading code produces an error

Generate Feedback Messages

Create feedback messages for use in graded() grades or in the exercise checking functions.

code_feedback() maybe_code_feedback() give_code_feedback()
Provide automated code feedback
random_praise() random_encouragement() give_praise() give_encouragement()
Random praise and encouragement
pipe_warning()
Inform the user about how gradethis interprets piped code

Helper Functions and Utilities

These functions are used by gradethis to work within learnr tutorials, or are available to help tutorial authors test their grading logic. Most users of gradethis will not need to use these functions.

gradethis_exercise_checker()
A checker function to use with learnr
gradethis_error_checker()
An error checking function for use with learnr
mock_this_exercise()
Mock a user submission to an exercise