diff --git a/runestone/selectquestion/js/selectone.js b/runestone/selectquestion/js/selectone.js index 576ad0d5d..3ef525bf9 100644 --- a/runestone/selectquestion/js/selectone.js +++ b/runestone/selectquestion/js/selectone.js @@ -39,7 +39,8 @@ export default class SelectOne extends RunestoneBase { this.selector_id = $(opts.orig).first().attr("id"); this.primaryOnly = $(opts.orig).data("primary"); this.ABExperiment = $(opts.orig).data("ab"); - this.toggle = $(opts.orig).data("toggle"); + this.toggleOptions = $(opts.orig).data("toggleoptions"); + this.toggleLabels = $(opts.orig).data("togglelabels"); opts.orig.id = this.selector_id; } /** @@ -81,8 +82,11 @@ export default class SelectOne extends RunestoneBase { if (this.timedWrapper) { data.timedWrapper = this.timedWrapper; } - if (this.toggle) { - data.toggle = this.toggle; + if (this.toggleOptions) { + data.toggleOptions = this.toggleOptions; + } + if (this.toggleLabels) { + data.toggleLabels = this.toggleLabels; } let opts = this.origOpts; let selectorId = this.selector_id; @@ -121,14 +125,25 @@ export default class SelectOne extends RunestoneBase { self.containerDiv = res.question.containerDiv; self.realComponent.selectorId = selectorId; } else { - /////////////////////////// - if (data.toggle) { + if (data.toggleOptions) { + var toggleLabels = data.toggleLabels.replace("togglelabels:", "").trim(); + if (toggleLabels) { + toggleLabels = toggleLabels.split(","); + for (var t = 0; t < toggleLabels.length; t++) { + toggleLabels[t] = toggleLabels[t].trim(); + } + } var toggleQuestions = this.questions.split(", "); var toggleUI = ""; + // check so that only the first toggle select question on the assignments page has a preview panel created, then all toggle select previews use this same panel if (!document.getElementById("component-preview")) { toggleUI += - '
'; + '
' + + '
' + + '
' + + '
'; } + // dropdown menu containing the question options toggleUI += '