From dbd71501d9addda58112f4da0c4f9e7c32e0b09a Mon Sep 17 00:00:00 2001 From: jonmcalder Date: Thu, 27 Oct 2016 00:53:45 +0200 Subject: [PATCH] Allow for the hint to (potentially) be sampled from a 'list' of multiple hints. If multiple hints are provided, they should be separated by a ";". This closes issue #561. --- R/post.R | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/R/post.R b/R/post.R index 68d4907..298bdb8 100644 --- a/R/post.R +++ b/R/post.R @@ -23,11 +23,13 @@ post_mult_question.default <- function(e, choices) { post_result.default <- function(e, passed, feedback, hint) { swirl_out(feedback) if(!passed) { - # If hint is specified, print it. Otherwise, just skip a line. + # If a hint is specified, print it. + # If multiple hints are provided (separated by ";"), print a random hint. + # Otherwise, just skip a line. if(!is.null(hint)) { # Suppress extra space if multiple choice is_mult <- is(e$current.row, "mult_question") - swirl_out(hint, skip_after = !is_mult) + swirl_out(sample(unlist(strsplit(hint, ";")), 1), skip_after = !is_mult) } else { message() }