diff --git a/projects/common/models/elements/compound-elements/cloze/cloze-child-elements/drop-list-simple.ts b/projects/common/models/elements/compound-elements/cloze/cloze-child-elements/drop-list-simple.ts index dc42abf27ffec836172725387e9b94200d0d29b4..18f4cc92d2f6d5ae8bc7f0b614ea3100af2af745 100644 --- a/projects/common/models/elements/compound-elements/cloze/cloze-child-elements/drop-list-simple.ts +++ b/projects/common/models/elements/compound-elements/cloze/cloze-child-elements/drop-list-simple.ts @@ -1,6 +1,6 @@ import { ElementFactory } from 'common/util/element.factory'; import { - BasicStyles, DragNDropValueObject, InputElement, UIElementValue, AnswerScheme, + BasicStyles, DragNDropValueObject, InputElement, UIElementValue, AnswerScheme, AnswerSchemeValue } from 'common/models/elements/element'; import { Type } from '@angular/core'; @@ -42,7 +42,7 @@ export class DropListSimpleElement extends InputElement { } hasAnswerScheme(): boolean { - return true; + return Boolean(this.getAnswerScheme); } getAnswerScheme(dropLists: Array<DropListElement | DropListSimpleElement>): AnswerScheme { @@ -62,7 +62,7 @@ export class DropListSimpleElement extends InputElement { return [this, ...valueDropLists] .map(dropList => dropList.value as DragNDropValueObject[]) .flat() - .map(option => ({ value: option.id, label: option.stringValue as string })); // TODO: imageValueSrc + .map(option => ({ value: option.id, label: option.text as string })); } setProperty(property: string, value: UIElementValue) { diff --git a/projects/common/models/elements/compound-elements/cloze/cloze-child-elements/text-field-simple.ts b/projects/common/models/elements/compound-elements/cloze/cloze-child-elements/text-field-simple.ts index cdce6dd3a0a9e9b9b6668ef83c0aecdd670ffcae..f2ee44ef9ae874336050ef841ea53cc54f2ffab6 100644 --- a/projects/common/models/elements/compound-elements/cloze/cloze-child-elements/text-field-simple.ts +++ b/projects/common/models/elements/compound-elements/cloze/cloze-child-elements/text-field-simple.ts @@ -47,7 +47,7 @@ export class TextFieldSimpleElement extends InputElement { } hasAnswerScheme(): boolean { - return true; + return Boolean(this.getAnswerScheme); } getAnswerScheme(): AnswerScheme { diff --git a/projects/common/models/elements/compound-elements/cloze/cloze-child-elements/toggle-button.ts b/projects/common/models/elements/compound-elements/cloze/cloze-child-elements/toggle-button.ts index 185b4b2e2d9dc01187229f6084ae72e114ba6937..b65e7984266e2011153acd1c996951524485edf4 100644 --- a/projects/common/models/elements/compound-elements/cloze/cloze-child-elements/toggle-button.ts +++ b/projects/common/models/elements/compound-elements/cloze/cloze-child-elements/toggle-button.ts @@ -1,5 +1,7 @@ import { ElementFactory } from 'common/util/element.factory'; -import { BasicStyles, InputElement, AnswerScheme, AnswerSchemeValue } from 'common/models/elements/element'; +import { + BasicStyles, InputElement, AnswerScheme, AnswerSchemeValue +} from 'common/models/elements/element'; import { Type } from '@angular/core'; import { ElementComponent } from 'common/directives/element-component.directive'; import { @@ -35,7 +37,7 @@ export class ToggleButtonElement extends InputElement { } hasAnswerScheme(): boolean { - return true; + return Boolean(this.getAnswerScheme); } getAnswerScheme(): AnswerScheme { 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 32d132be77b79101ab42c904d549efd4473b6c7e..3def2ba473aab3dba510a59c2d54f862f22d5f35 100644 --- a/projects/common/models/elements/compound-elements/likert/likert-row.ts +++ b/projects/common/models/elements/compound-elements/likert/likert-row.ts @@ -1,5 +1,7 @@ import { Type } from '@angular/core'; -import { InputElement, AnswerScheme, AnswerSchemeValue, TextImageLabel } from 'common/models/elements/element'; +import { + InputElement, AnswerScheme, AnswerSchemeValue, TextImageLabel +} from 'common/models/elements/element'; import { ElementComponent } from 'common/directives/element-component.directive'; import { LikertRadioButtonGroupComponent @@ -20,7 +22,7 @@ export class LikertRowElement extends InputElement { } hasAnswerScheme(): boolean { - return true; + return Boolean(this.getAnswerScheme); } getAnswerScheme(): AnswerScheme { @@ -36,10 +38,11 @@ export class LikertRowElement extends InputElement { } private getAnswerSchemeValues(): AnswerSchemeValue[] { - console.log(this.value); return [ - { value: !this.value && this.value !== 0 ? 'null' : (this.value as number + 1).toString(), - label: this.rowLabel.text } // TODO Image + { + value: !this.value && this.value !== 0 ? 'null' : (this.value as number + 1).toString(), + label: this.rowLabel.text + } // TODO Image ]; } diff --git a/projects/common/models/elements/element.ts b/projects/common/models/elements/element.ts index 509e778bfbb3560b477ca6ab670c01f46175985d..55bf5b0cdbd4fd3ec8c861b65f691d29c7cf9ebb 100644 --- a/projects/common/models/elements/element.ts +++ b/projects/common/models/elements/element.ts @@ -73,10 +73,9 @@ export abstract class UIElement { } hasAnswerScheme(): boolean { - return false; + return Boolean(this.getAnswerSchemeValues); } - abstract getComponentFactory(): Type<ElementComponent>; abstract getElementComponent(): Type<ElementComponent>; } @@ -101,7 +100,6 @@ export abstract class InputElement extends UIElement { abstract getAnswerScheme(options?: unknown): AnswerScheme; } - export abstract class CompoundElement extends UIElement { abstract getChildElements(): UIElement[]; } @@ -115,7 +113,7 @@ export abstract class PlayerElement extends UIElement { } hasAnswerScheme(): boolean { - return true; + return Boolean(this.getAnswerScheme); } getAnswerScheme(): AnswerScheme { diff --git a/projects/common/models/elements/input-elements/checkbox.ts b/projects/common/models/elements/input-elements/checkbox.ts index cd4136357b5a85d6775a93f6c5698e210d6ac439..cd471ccf7269f0ad79b19edaf29a0c7e5176b6ab 100644 --- a/projects/common/models/elements/input-elements/checkbox.ts +++ b/projects/common/models/elements/input-elements/checkbox.ts @@ -1,6 +1,8 @@ import { Type } from '@angular/core'; import { ElementFactory } from 'common/util/element.factory'; -import { BasicStyles, InputElement, PositionedUIElement, PositionProperties, AnswerScheme, AnswerSchemeValue } from 'common/models/elements/element'; +import { + BasicStyles, InputElement, PositionedUIElement, PositionProperties, AnswerScheme, AnswerSchemeValue +} from 'common/models/elements/element'; import { ElementComponent } from 'common/directives/element-component.directive'; import { CheckboxComponent } from 'common/components/input-elements/checkbox.component'; @@ -15,7 +17,7 @@ export class CheckboxElement extends InputElement implements PositionedUIElement } hasAnswerScheme(): boolean { - return true; + return Boolean(this.getAnswerScheme); } getAnswerScheme(): AnswerScheme { diff --git a/projects/common/models/elements/input-elements/drop-list.ts b/projects/common/models/elements/input-elements/drop-list.ts index 43d63b33295ee2060b5b82bc72cb813d818be953..2d80abd953d050c717b4d35028fa96ff868ff608 100644 --- a/projects/common/models/elements/input-elements/drop-list.ts +++ b/projects/common/models/elements/input-elements/drop-list.ts @@ -51,7 +51,7 @@ export class DropListElement extends InputElement implements PositionedUIElement } hasAnswerScheme(): boolean { - return true; + return Boolean(this.getAnswerScheme); } getAnswerScheme(options: Array<DropListElement | DropListSimpleElement>): AnswerScheme { @@ -66,13 +66,13 @@ export class DropListElement extends InputElement implements PositionedUIElement }; } - private getAnswerSchemeValues( dropLists: Array<DropListElement | DropListSimpleElement>): AnswerSchemeValue[] { - const valueDropLists = dropLists.filter(dropList => dropList.connectedTo.includes(this.id) ); + private getAnswerSchemeValues(dropLists: Array<DropListElement | DropListSimpleElement>): AnswerSchemeValue[] { + const valueDropLists = dropLists.filter(dropList => dropList.connectedTo.includes(this.id)); if (valueDropLists.length || this.isSortingList()) { return [this, ...valueDropLists] .map(dropList => dropList.value as DragNDropValueObject[]) .flat() - .map(option => ({ value: option.id, label: option.stringValue as string })); // TODO: imageValueSrc + .map(option => ({ value: option.id, label: option.text as string })); } return []; } diff --git a/projects/common/models/elements/input-elements/dropdown.ts b/projects/common/models/elements/input-elements/dropdown.ts index 234c1921fec2198ea487dac69f97d5d0b58fce07..e336c0aca9a4fb69aa8620dfad6803df6ae8a327 100644 --- a/projects/common/models/elements/input-elements/dropdown.ts +++ b/projects/common/models/elements/input-elements/dropdown.ts @@ -24,7 +24,7 @@ export class DropdownElement extends InputElement implements PositionedUIElement } hasAnswerScheme(): boolean { - return true; + return Boolean(this.getAnswerScheme); } getAnswerScheme(): AnswerScheme { @@ -40,7 +40,8 @@ export class DropdownElement extends InputElement implements PositionedUIElement } private getAnswerSchemeValues(): AnswerSchemeValue[] { - return this.options.map((option, index) => ({ value: (index + 1).toString(), label: option })); + return this.options + .map((option, index) => ({ value: (index + 1).toString(), label: option.text })); } getElementComponent(): Type<ElementComponent> { diff --git a/projects/common/models/elements/input-elements/radio-button-group-complex.ts b/projects/common/models/elements/input-elements/radio-button-group-complex.ts index d31bbc7c7092a231794afd71eb6cd4b098d6e7ef..c739530488005c39aa7ff1b32f066e4e3265e89d 100644 --- a/projects/common/models/elements/input-elements/radio-button-group-complex.ts +++ b/projects/common/models/elements/input-elements/radio-button-group-complex.ts @@ -3,7 +3,7 @@ import { ElementFactory } from 'common/util/element.factory'; import { BasicStyles, InputElement, OptionElement, PositionedUIElement, PositionProperties, TextImageLabel, - AnswerScheme, AnswerSchemeValue, + AnswerScheme, AnswerSchemeValue } from 'common/models/elements/element'; import { ElementComponent } from 'common/directives/element-component.directive'; import { RadioGroupImagesComponent } from 'common/components/input-elements/radio-group-images.component'; @@ -25,7 +25,7 @@ export class RadioButtonGroupComplexElement extends InputElement implements Posi } hasAnswerScheme(): boolean { - return true; + return Boolean(this.getAnswerScheme); } getAnswerScheme(): AnswerScheme { @@ -41,8 +41,8 @@ export class RadioButtonGroupComplexElement extends InputElement implements Posi } private getAnswerSchemeValues(): AnswerSchemeValue[] { - return this.columns - .map((option, index) => ({ value: (index + 1).toString(), label: option.text })); //TODO iMAGE + return this.options + .map((option, index) => ({ value: (index + 1).toString(), label: option.text })); } getElementComponent(): Type<ElementComponent> { diff --git a/projects/common/models/elements/input-elements/radio-button-group.ts b/projects/common/models/elements/input-elements/radio-button-group.ts index 89e555c612312016e0cdfb4ab330826de24ffc04..eb5746c79ec25bfc49eb2164443e1761a9d256ef 100644 --- a/projects/common/models/elements/input-elements/radio-button-group.ts +++ b/projects/common/models/elements/input-elements/radio-button-group.ts @@ -35,7 +35,7 @@ export class RadioButtonGroupElement extends InputElement implements PositionedU } hasAnswerScheme(): boolean { - return true; + return Boolean(this.getAnswerScheme); } getAnswerScheme(): AnswerScheme { @@ -51,8 +51,8 @@ export class RadioButtonGroupElement extends InputElement implements PositionedU } private getAnswerSchemeValues(): AnswerSchemeValue[] { - return this.richTextOptions - .map((option, index) => ({ value: (index + 1).toString(), label: option })); + return this.options + .map((option, index) => ({ value: (index + 1).toString(), label: option.text })); } getElementComponent(): Type<ElementComponent> { diff --git a/projects/common/models/elements/input-elements/slider.ts b/projects/common/models/elements/input-elements/slider.ts index 8cd2ceb5ba191fbd35fb675124279192260d5600..b65104a47070ae0a263a45c4c3db29b33e906c8b 100644 --- a/projects/common/models/elements/input-elements/slider.ts +++ b/projects/common/models/elements/input-elements/slider.ts @@ -35,7 +35,7 @@ export class SliderElement extends InputElement implements PositionedUIElement { } hasAnswerScheme(): boolean { - return true; + return Boolean(this.getAnswerScheme); } getAnswerScheme(): AnswerScheme { diff --git a/projects/common/models/elements/input-elements/spell-correct.ts b/projects/common/models/elements/input-elements/spell-correct.ts index 7b18ae065ed41540142ac2584107ab340bbfc0f9..6a0cd1d09859f45acc5b2d7ea1cb418936823650 100644 --- a/projects/common/models/elements/input-elements/spell-correct.ts +++ b/projects/common/models/elements/input-elements/spell-correct.ts @@ -35,7 +35,7 @@ export class SpellCorrectElement extends InputElement implements PositionedUIEle } hasAnswerScheme(): boolean { - return true; + return Boolean(this.getAnswerScheme); } getAnswerScheme(): AnswerScheme { diff --git a/projects/common/models/elements/input-elements/text-area.ts b/projects/common/models/elements/input-elements/text-area.ts index 9c9ba32e000e515af25b5f9cfe267b94b46df004..4e221196999a8b8c460ad9693fc109b70fea31a6 100644 --- a/projects/common/models/elements/input-elements/text-area.ts +++ b/projects/common/models/elements/input-elements/text-area.ts @@ -47,7 +47,7 @@ export class TextAreaElement extends InputElement implements PositionedUIElement } hasAnswerScheme(): boolean { - return true; + return Boolean(this.getAnswerScheme); } getAnswerScheme(): AnswerScheme { diff --git a/projects/common/models/elements/input-elements/text-field.ts b/projects/common/models/elements/input-elements/text-field.ts index 3ced6845e32f98207b3a427f813275ea3bcc4805..64acc9138bb286b8446a81db70534efd032e7fc2 100644 --- a/projects/common/models/elements/input-elements/text-field.ts +++ b/projects/common/models/elements/input-elements/text-field.ts @@ -54,7 +54,7 @@ export class TextFieldElement extends InputElement implements PositionedUIElemen } hasAnswerScheme(): boolean { - return true; + return Boolean(this.getAnswerScheme); } getAnswerScheme(): AnswerScheme { diff --git a/projects/common/models/section.ts b/projects/common/models/section.ts index 3eae3dba822670a52b7929c6117e9ad6389f2522..c72f14d4740388caa1bf151611f6373285d6e917 100644 --- a/projects/common/models/section.ts +++ b/projects/common/models/section.ts @@ -1,7 +1,7 @@ import { Type } from '@angular/core'; import { IDManager } from 'common/util/id-manager'; import { - CompoundElement, PositionedUIElement, UIElement, UIElementValue, AnswerScheme + CompoundElement, PositionedUIElement, UIElement, UIElementValue, AnswerScheme, PlayerElement, InputElement } from 'common/models/elements/element'; import { ButtonElement } from 'common/models/elements/button/button'; import { TextElement } from 'common/models/elements/text/text'; @@ -104,9 +104,8 @@ export class Section { getAnswerScheme(dropLists: UIElement[]): AnswerScheme[] { return this.getAllElements() .filter(element => element.hasAnswerScheme()) - .map(element => - (element.type === 'drop-list' || element.type === 'drop-list-simple') ? - (element as InputElement).getAnswerScheme(dropLists) : - (element as InputElement | PlayerElement | TextElement | ImageElement).getAnswerScheme()); + .map(element => ((element.type === 'drop-list' || element.type === 'drop-list-simple') ? + (element as InputElement).getAnswerScheme(dropLists) : + (element as InputElement | PlayerElement | TextElement | ImageElement).getAnswerScheme())); } }