From 6a3253b6a8d6612664a00d47229f2418416ef525 Mon Sep 17 00:00:00 2001 From: jojohoch <joachim.hoch@iqb.hu-berlin.de> Date: Wed, 18 Dec 2024 14:23:58 +0100 Subject: [PATCH] Fix variable infos for likert and likert row --- .../elements/compound-elements/likert/likert-row.ts | 11 ++++++++++- .../elements/compound-elements/likert/likert.ts | 8 +++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/projects/common/models/elements/compound-elements/likert/likert-row.ts b/projects/common/models/elements/compound-elements/likert/likert-row.ts index 1e134f4dc..1abd3c4ac 100644 --- a/projects/common/models/elements/compound-elements/likert/likert-row.ts +++ b/projects/common/models/elements/compound-elements/likert/likert-row.ts @@ -8,7 +8,11 @@ import { } from 'common/components/compound-elements/likert/likert-radio-button-group.component'; import { environment } from 'common/environment'; import { VariableInfo, VariableValue } from '@iqb/responses'; -import { AbstractIDService, InputElementProperties, TextImageLabel, UIElementType } from 'common/interfaces'; +import { + AbstractIDService, + InputElementProperties, + TextImageLabel, UIElementType +} from 'common/interfaces'; import { InstantiationEror } from 'common/errors'; export class LikertRowElement extends InputElement implements LikertRowProperties { @@ -41,6 +45,11 @@ export class LikertRowElement extends InputElement implements LikertRowPropertie } } + // eslint-disable-next-line class-methods-use-this + getVariableInfos(options?: unknown): VariableInfo[] { + return []; + } + getVariableInfoOfRow(options: TextImageLabel[]): VariableInfo { return { id: this.id, diff --git a/projects/common/models/elements/compound-elements/likert/likert.ts b/projects/common/models/elements/compound-elements/likert/likert.ts index 9eaabcbb0..3b6e7dc2e 100644 --- a/projects/common/models/elements/compound-elements/likert/likert.ts +++ b/projects/common/models/elements/compound-elements/likert/likert.ts @@ -13,7 +13,7 @@ import { VariableInfo } from '@iqb/responses'; import { AbstractIDService, OptionElement, - PositionedUIElement, TextImageLabel, + TextImageLabel, UIElementProperties, UIElementType, UIElementValue @@ -123,11 +123,13 @@ export class LikertElement extends CompoundElement implements OptionElement, Lik } getVariableInfos(): VariableInfo[] { - return this.rows.map(row => row.getVariableInfoOfRow(this.options)); + return [...super.getVariableInfos(), ...this.rows.map(row => row.getVariableInfoOfRow(this.options))]; } getBlueprint(): LikertElement { - return { ...this, rows: this.rows.map(el => el.getBlueprint()), id: undefined, alias: undefined }; + return { + ...this, rows: this.rows.map(el => el.getBlueprint()), id: undefined, alias: undefined + }; } } -- GitLab