-
Notifications
You must be signed in to change notification settings - Fork 240
Add new anybox question type to solve #382 #434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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()