Description Usage Arguments Examples
This S3 class encapsulates a question for interactive lesson scenarios.
1 |
q_text |
the text that will be displayed in the console prompting the user to action. |
q_tester |
an instance of class QuestionTester. |
q_type |
the type can be one of |
hints |
a list of hints that will be displayed in consecutive order for each incorrect answer. |
1 2 3 4 5 6 7 8 9 10 11 | ## Instantiate a QuestionTester that tests for a character vector with a single
## "word" of length 5
## The feedback_generator generates some appropriate messages depending on the answer
t1 <- QuestionTester(
function(x){is.character(x) && length(x)==1 && nchar(x)==5},
function(x){
if(! is.character(x)) "that is no word"
else if(nchar(x) < 5) paste0(x, " has ", nchar(x), " characters and that is not 5")
}
)
q1 <- Question("Please give a word of length 5", t1)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.