From d68294b650e18d4ec25d3f471327da2027e0c4f0 Mon Sep 17 00:00:00 2001 From: Sander Looise Date: Tue, 14 Nov 2023 10:56:46 +0100 Subject: [PATCH] inline choice fixes --- .../qti-inline-choice-interaction.ts | 9 ++++++--- .../qti-lookup-outcome-value/qti-lookup-outcome-value.ts | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/lib/qti-components/qti-interaction/qti-inline-choice-interaction/qti-inline-choice-interaction.ts b/src/lib/qti-components/qti-interaction/qti-inline-choice-interaction/qti-inline-choice-interaction.ts index 9ed500f6..9f5af1f0 100755 --- a/src/lib/qti-components/qti-interaction/qti-inline-choice-interaction/qti-inline-choice-interaction.ts +++ b/src/lib/qti-components/qti-interaction/qti-inline-choice-interaction/qti-inline-choice-interaction.ts @@ -53,11 +53,10 @@ export class QtiInlineChoiceInteraction extends Interaction { `; } - firstUpdated(val) { - super.firstUpdated(val); + connectedCallback() { + super.connectedCallback(); this.addEventListener('on-dropdown-selected', this.choiceSelected); const choices = Array.from(this.querySelectorAll('qti-inline-choice')); - this.options = [ { textContent: this.dataPrompt, @@ -72,6 +71,10 @@ export class QtiInlineChoiceInteraction extends Interaction { ]; } + disconnectedCallback() { + this.removeEventListener('on-dropdown-selected', this.choiceSelected); + } + public validate(): boolean { const selectedOption = this.options.find(option => option.selected); return selectedOption ? selectedOption.value !== '' : false; diff --git a/src/lib/qti-components/qti-response-processing/qti-rule/qti-lookup-outcome-value/qti-lookup-outcome-value.ts b/src/lib/qti-components/qti-response-processing/qti-rule/qti-lookup-outcome-value/qti-lookup-outcome-value.ts index ad938701..ecd3a5a5 100644 --- a/src/lib/qti-components/qti-response-processing/qti-rule/qti-lookup-outcome-value/qti-lookup-outcome-value.ts +++ b/src/lib/qti-components/qti-response-processing/qti-rule/qti-lookup-outcome-value/qti-lookup-outcome-value.ts @@ -23,7 +23,7 @@ export class QtiLookupOutcomeValue extends QtiRule { if (outcomeVariable.interpolationTable) { value = outcomeVariable.interpolationTable.get(parseInt(this.childExpression.calculate())); } - if (!value) { + if (value === null || value === undefined) { console.warn('lookupOutcomeValue: value is null or undefined'); return 0; }