Add a string-type question to a dataframe, validating and/or transforming inputs.
Usage
add_string_question(
question,
image = NA,
explanation = NA,
correct = NA,
keywords = NA,
df = NA
)Arguments
- question
Question text
- image
Image filename (optional)
- explanation
Explanation for the correct answer (optional)
- correct
Correct answer, string
- keywords
Vector of strings to insert into the question text
- df
Dataframe to add question to
Value
The provided dataframe df, with an additional row. If a dataframe
is not provided, a new one is created.
Examples
df <- examling::build_question_df()
df <- add_string_question(
question = "What color is a male cardinal?",
correct = "Red",
df = df
)
df
#> question image correct incorrect explanation
#> 1 What color is a male cardinal? NA Red NA NA
df <- examling::build_question_df()
df <- add_string_question(
question = "What color is a %1?",
correct = "Red",
keywords = "male cardinal",
df = df
)
df
#> question image correct incorrect explanation
#> 1 What color is a male cardinal? NA Red NA NA