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 .envir_solution .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() fail_if_not_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

Interact with Objects

These functions help you access objects created by student and solution code.

user_object_get() solution_object_get() user_object_exists() solution_object_exists() user_object_list() solution_object_list()
Functions for interacting with objects created by student and solution 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
with_exercise()
Run an expression as if it were in an exercise's grade_this() block
gradethis_equal()
Compare the values of two objects to check whether they are equal