Generate a random praise or encouragement phrase. These functions are
designed for use within pass()
or fail()
messages, or anywhere else that
gradethis provides feedback to the student.
Usage
random_praise()
random_encouragement()
give_praise(expr, ..., location = "before", before = NULL, after = NULL)
give_encouragement(expr, ..., location = "after", before = NULL, after = NULL)
Arguments
- expr
A
graded()
grade or helper function, or a grading function — likegrade_this()
orgrade_result()
— or a character string. Praise will be added to any passing grades and encouragement will be added to any failing grade. Ifexpr
is a character string, then"{random_praise()}"
or"{random_encouragement()}"
is pasted before or after the string according tolocation
.- ...
Ignored.
- location
Should the praise or encouragement be added before or after the grade message?
- before, after
Text to be added before or after the praise or encouragement phrase.
Value
random_praise()
andrandom_encouragement()
each return a length-one string with a praising or encouraging phrase.give_praise()
andgive_encouragement()
add praise or encouragement phrases to passing and failing grades, respectively.
Functions
random_praise()
: Random praising phraserandom_encouragement()
: Random encouraging phrasegive_praise()
: Add praising message to a passing grade.give_encouragement()
: Add encouraging message to a failing grade.
Examples
replicate(5, glue::glue("Random praise: {random_praise()}"))
#> [1] "Random praise: Nice job!" "Random praise: That's glorious!"
#> [3] "Random praise: That's glorious!" "Random praise: Delightful!"
#> [5] "Random praise: Great work!"
replicate(5, glue::glue("Random encouragement: {random_encouragement()}"))
#> [1] "Random encouragement: Try it again. Perseverence is the key to success."
#> [2] "Random encouragement: That's okay: you learn more from mistakes than successes. Let's do it one more time."
#> [3] "Random encouragement: Give it another try."
#> [4] "Random encouragement: Try it again. Perseverence is the key to success."
#> [5] "Random encouragement: Try it again. You get better each time."
# give_praise() adds praise to passing grade messages
give_praise(pass("That's absolutely correct."))
#> <gradethis_graded: [Correct]
#> You aced it! That's absolutely correct.
#> >
# give_encouragement() encouragement to failing grade messages
give_encouragement(fail("Sorry, but no."))
#> <gradethis_graded: [Incorrect]
#> Sorry, but no. Try it again. Perseverence is the key to
#> success.
#> >