Add new anybox question type to solve #382#434
Add new anybox question type to solve #382#434elmstedt wants to merge 6 commits intorstudio:mainfrom
Conversation
# Conflicts: # R/question_anybox.R # man/question_anybox.Rd
|
|
| structure(learnr::question( | ||
| text = text, | ||
| ..., | ||
| type = "learnr_anybox", | ||
| correct = correct, | ||
| incorrect = incorrect, | ||
| allow_retry = allow_retry, | ||
| random_answer_order = random_answer_order | ||
| ), min_right = min_right, max_wrong = max_wrong) |
There was a problem hiding this comment.
Please add min_right and max_wrong to the options param in learnr::question
| min_right = 1, | ||
| max_wrong = 0 | ||
| ) { | ||
| structure(learnr::question( |
There was a problem hiding this comment.
Please do not namespace the functions using learnr:: within the learnr package
| min_right <- max(attr(question, "min_right"), 1) | ||
| max_wrong <- max(attr(question, "max_wrong"), 0) |
There was a problem hiding this comment.
will then retrieve these from question$options
| ans <- question[["answers"]] | ||
| anss <- vapply(ans, `[[`, character(1), "option") | ||
| corr <- vapply(ans, `[[`, logical(1), "correct") | ||
| cor_ans <- anss[corr] | ||
| check <- match(value, cor_ans) | ||
| right <- cor_ans[stats::na.omit(check)] | ||
| wrong <- ans[match(setdiff(value, cor_ans), anss)] | ||
| missed <- ans[match(setdiff(cor_ans, value), anss)] |
There was a problem hiding this comment.
Cosmetic request: Could you expand on the variable names being created? Thank you
|
I also don't know if this logic should be merged into the default checkbox logic, or if it should be made into a separate exported function. |
Solves #382
This creates a question type which has multiple correct questions but for which it is not required to select all of the correct options before proceeding. A successfully answered question will add messages indicating which correct responses were missed as well as which incorrect responses were selected.
In order to pass the additional arguments
min_rightandmax_wrongtoquestion_anybox(), I added them as attributes to the question object returned bylearnr::question(). This feels a bit kludgy, but I wanted to not alter the structure of the question object to avoid any potential conflicts. Giving the object two additional attributes seemed the least invasive.PR task list:
devtools::document()