From 358a3e72f18c92cf44baa592a415651960fc241c Mon Sep 17 00:00:00 2001
From: jojohoch <joachim.hoch@iqb.hu-berlin.de>
Date: Wed, 27 Apr 2022 16:21:57 +0200
Subject: [PATCH] [player] Rename properties in the context of element value
 mapping

elementModels are described in the unitDefinition
elementCodes are saved in the unitState

Their values are mapped by the ElementModelElementCodeMappingService
---
 .../player/modules/verona/models/verona.ts    |  10 +-
 projects/player/src/app/app.component.ts      |  18 +--
 .../element-compound-group.component.ts       |   6 +-
 .../element-input-group.component.ts          |   8 +-
 .../element-interactive-group.component.html  |   2 +-
 .../element-interactive-group.component.ts    |   6 +-
 .../element-media-player-group.component.html |   4 +-
 .../element-media-player-group.component.ts   |  10 +-
 .../element-text-group.component.html         |   2 +-
 .../element-text-group.component.ts           |  10 +-
 .../element-text-input-group.component.ts     |   8 +-
 .../element-form-group.directive.ts           |  12 +-
 .../app/directives/unit-state.directive.ts    |   6 +-
 ...odel-element-code-mapping.service.spec.ts} | 130 +++++++++---------
 ...ent-model-element-code-mapping.service.ts} |  41 +++---
 .../src/app/services/unit-state.service.ts    |  78 +++++------
 16 files changed, 177 insertions(+), 174 deletions(-)
 rename projects/player/src/app/services/{unit-state-element-value-mapping.service.spec.ts => element-model-element-code-mapping.service.spec.ts} (99%)
 rename projects/player/src/app/services/{unit-state-element-value-mapping.service.ts => element-model-element-code-mapping.service.ts} (50%)

diff --git a/projects/player/modules/verona/models/verona.ts b/projects/player/modules/verona/models/verona.ts
index cebd74e42..a6fc2a80c 100644
--- a/projects/player/modules/verona/models/verona.ts
+++ b/projects/player/modules/verona/models/verona.ts
@@ -5,12 +5,12 @@ export type RunningState = 'running' | 'stopped';
 export type Progress = 'none' | 'some' | 'complete';
 export type PagingMode = 'separate' | 'concat-scroll' | 'concat-scroll-snap';
 export type StateReportPolicy = 'none' | 'eager' | 'on-demand';
-export type UnitStateElementCodeStatus = 'NOT_REACHED' | 'DISPLAYED' | 'VALUE_CHANGED';
-export enum UnitStateElementCodeStatusValue { NOT_REACHED = 0, DISPLAYED = 1, VALUE_CHANGED = 2}
+export type ElementCodeStatus = 'NOT_REACHED' | 'DISPLAYED' | 'VALUE_CHANGED';
+export enum ElementCodeStatusValue { NOT_REACHED = 0, DISPLAYED = 1, VALUE_CHANGED = 2}
 
 export interface StatusChangeElement {
   id: string;
-  status: UnitStateElementCodeStatus;
+  status: ElementCodeStatus;
 }
 
 export interface PlayerConfig {
@@ -24,9 +24,9 @@ export interface PlayerConfig {
   enabledNavigationTargets?: NavigationTarget[]
 }
 
-export interface UnitStateElementCode {
+export interface ElementCode {
   id: string;
-  status: UnitStateElementCodeStatus;
+  status: ElementCodeStatus;
   value: InputElementValue;
 }
 
diff --git a/projects/player/src/app/app.component.ts b/projects/player/src/app/app.component.ts
index 6f784839b..c8fe26411 100644
--- a/projects/player/src/app/app.component.ts
+++ b/projects/player/src/app/app.component.ts
@@ -3,7 +3,7 @@ import { registerLocaleData } from '@angular/common';
 import localeDe from '@angular/common/locales/de';
 import { TranslateService } from '@ngx-translate/core';
 import { PlayerConfig, VopStartCommand } from 'verona/models/verona';
-import { UnitStateElementValueMappingService } from './services/unit-state-element-value-mapping.service';
+import { ElementModelElementCodeMappingService } from './services/element-model-element-code-mapping.service';
 import { VeronaSubscriptionService } from 'verona/services/verona-subscription.service';
 import { VeronaPostService } from 'verona/services/verona-post.service';
 import { NativeEventService } from './services/native-event.service';
@@ -37,7 +37,7 @@ export class AppComponent implements OnInit {
               private nativeEventService: NativeEventService,
               private unitStateService: UnitStateService,
               private mediaPlayerService: MediaPlayerService,
-              private unitStateElementValueMappingService: UnitStateElementValueMappingService,
+              private elementModelElementCodeMappingService: ElementModelElementCodeMappingService,
               private validatorService: ValidatorService,
               private sanitizationService: SanitizationService) {
     this.isStandalone =  window === window.parent;
@@ -77,8 +77,8 @@ export class AppComponent implements OnInit {
   }
 
   private initSession(message: VopStartCommand, unitDefinition: Unit): void {
-    this.initUnitStateElementValueMappingService(unitDefinition.pages);
-    this.unitStateService.unitStateElementCodes = message.unitState?.dataParts?.elementCodes ?
+    this.initElementModelElementCodeMappingService(unitDefinition.pages);
+    this.unitStateService.elementCodes = message.unitState?.dataParts?.elementCodes ?
       JSON.parse(message.unitState.dataParts.elementCodes) : [];
     this.veronaPostService.sessionId = message.sessionId;
     this.veronaPostService.stateReportPolicy = message.playerConfig?.stateReportPolicy || 'none';
@@ -88,16 +88,16 @@ export class AppComponent implements OnInit {
     this.scrollPages = this.pages.filter((page: Page): boolean => !page.alwaysVisible);
     this.playerConfig = message.playerConfig || {};
     // eslint-disable-next-line no-console
-    console.log('player: unitStateElementCodes', this.unitStateService.unitStateElementCodes);
+    console.log('player: unitStateElementCodes', this.unitStateService.elementCodes);
   }
 
-  private initUnitStateElementValueMappingService(pages: Page[]): void {
-    this.unitStateElementValueMappingService.dragNDropValueObjects = (
+  private initElementModelElementCodeMappingService(pages: Page[]): void {
+    this.elementModelElementCodeMappingService.dragNDropValueObjects = (
       UnitUtils.findUIElements(pages, 'drop-list').reduce(
         (accumulator: DragNDropValueObject[], currentValue: UIElement) => (
           (currentValue.value && (currentValue.value as DragNDropValueObject[]).length) ?
             accumulator.concat(currentValue.value as DragNDropValueObject) : accumulator), []));
-    console.log(this.unitStateElementValueMappingService.dragNDropValueObjects);
+    console.log(this.elementModelElementCodeMappingService.dragNDropValueObjects);
   }
 
   private onFocus(focused: boolean): void {
@@ -117,6 +117,6 @@ export class AppComponent implements OnInit {
     this.unitStateService.reset();
     this.mediaPlayerService.reset();
     this.validatorService.reset();
-    this.unitStateElementValueMappingService.reset();
+    this.elementModelElementCodeMappingService.reset();
   }
 }
diff --git a/projects/player/src/app/components/element-compound-group/element-compound-group.component.ts b/projects/player/src/app/components/element-compound-group/element-compound-group.component.ts
index 0c275c211..23feb33db 100644
--- a/projects/player/src/app/components/element-compound-group/element-compound-group.component.ts
+++ b/projects/player/src/app/components/element-compound-group/element-compound-group.component.ts
@@ -7,7 +7,7 @@ import {
 import { ClozeUtils } from 'common/util/cloze';
 import { UnitStateService } from '../../services/unit-state.service';
 import { ElementComponent } from 'common/directives/element-component.directive';
-import { UnitStateElementValueMappingService } from '../../services/unit-state-element-value-mapping.service';
+import { ElementModelElementCodeMappingService } from '../../services/element-model-element-code-mapping.service';
 import { MessageService } from 'common/services/message.service';
 import { VeronaSubscriptionService } from 'verona/services/verona-subscription.service';
 import { ValidatorService } from '../../services/validator.service';
@@ -34,7 +34,7 @@ export class ElementCompoundGroupComponent extends ElementFormGroupDirective imp
     private deviceService: DeviceService,
     public keypadService: KeypadService,
     public unitStateService: UnitStateService,
-    public unitStateElementValueMappingService: UnitStateElementValueMappingService,
+    public elementModelElementCodeMappingService: ElementModelElementCodeMappingService,
     public translateService: TranslateService,
     public messageService: MessageService,
     public veronaSubscriptionService: VeronaSubscriptionService,
@@ -55,7 +55,7 @@ export class ElementCompoundGroupComponent extends ElementFormGroupDirective imp
       const childModel = child.elementModel as InputElement;
       this.registerAtUnitStateService(
         childModel.id,
-        this.unitStateElementValueMappingService.mapToUnitState(childModel.value, childModel.type),
+        this.elementModelElementCodeMappingService.mapToElementCodeValue(childModel.value, childModel.type),
         child,
         this.pageIndex);
       if (childModel.type === 'text-field') {
diff --git a/projects/player/src/app/components/element-input-group/element-input-group.component.ts b/projects/player/src/app/components/element-input-group/element-input-group.component.ts
index 0e94c3e8e..7382f698c 100644
--- a/projects/player/src/app/components/element-input-group/element-input-group.component.ts
+++ b/projects/player/src/app/components/element-input-group/element-input-group.component.ts
@@ -7,7 +7,7 @@ import {
   RadioButtonGroupElement, RadioButtonGroupComplexElement, DropdownElement
 } from 'common/interfaces/elements';
 import { UnitStateService } from '../../services/unit-state.service';
-import { UnitStateElementValueMappingService } from '../../services/unit-state-element-value-mapping.service';
+import { ElementModelElementCodeMappingService } from '../../services/element-model-element-code-mapping.service';
 import { ElementFormGroupDirective } from '../../directives/element-form-group.directive';
 import { MessageService } from 'common/services/message.service';
 import { VeronaSubscriptionService } from 'verona/services/verona-subscription.service';
@@ -30,7 +30,7 @@ export class ElementInputGroupComponent extends ElementFormGroupDirective implem
 
   constructor(
     public unitStateService: UnitStateService,
-    public unitStateElementValueMappingService: UnitStateElementValueMappingService,
+    public elementModelElementCodeMappingService: ElementModelElementCodeMappingService,
     public translateService: TranslateService,
     public messageService: MessageService,
     public veronaSubscriptionService: VeronaSubscriptionService,
@@ -46,8 +46,8 @@ export class ElementInputGroupComponent extends ElementFormGroupDirective implem
   ngAfterViewInit(): void {
     this.registerAtUnitStateService(
       this.elementModel.id,
-      this.unitStateElementValueMappingService
-        .mapToUnitState((this.elementModel as InputElement).value, this.elementModel.type),
+      this.elementModelElementCodeMappingService
+        .mapToElementCodeValue((this.elementModel as InputElement).value, this.elementModel.type),
       this.elementComponent,
       this.pageIndex
     );
diff --git a/projects/player/src/app/components/element-interactive-group/element-interactive-group.component.html b/projects/player/src/app/components/element-interactive-group/element-interactive-group.component.html
index 1a6e963b1..64a320912 100644
--- a/projects/player/src/app/components/element-interactive-group/element-interactive-group.component.html
+++ b/projects/player/src/app/components/element-interactive-group/element-interactive-group.component.html
@@ -15,6 +15,6 @@
     *ngIf="elementModel.type === 'image'"
     #elementComponent
     [elementModel]="elementModel | cast: ImageElement"
-    (elementValueChanged)="unitStateService.changeElementValue($event)">
+    (elementValueChanged)="unitStateService.changeElementCodeValue($event)">
 </aspect-image>
 
diff --git a/projects/player/src/app/components/element-interactive-group/element-interactive-group.component.ts b/projects/player/src/app/components/element-interactive-group/element-interactive-group.component.ts
index fc9181b23..85a558bc2 100644
--- a/projects/player/src/app/components/element-interactive-group/element-interactive-group.component.ts
+++ b/projects/player/src/app/components/element-interactive-group/element-interactive-group.component.ts
@@ -9,7 +9,7 @@ import { UnitStateService } from '../../services/unit-state.service';
 import { ElementGroupDirective } from '../../directives/element-group.directive';
 import { ElementComponent } from 'common/directives/element-component.directive';
 import { NavigationService } from '../../services/navigation.service';
-import { UnitStateElementValueMappingService } from '../../services/unit-state-element-value-mapping.service';
+import { ElementModelElementCodeMappingService } from '../../services/element-model-element-code-mapping.service';
 
 @Component({
   selector: 'aspect-element-interactive-group',
@@ -26,14 +26,14 @@ export class ElementInteractiveGroupComponent extends ElementGroupDirective impl
     public unitStateService: UnitStateService,
     public veronaPostService: VeronaPostService,
     public navigationService: NavigationService,
-    private unitStateElementValueMappingService: UnitStateElementValueMappingService
+    private elementModelElementCodeMappingService: ElementModelElementCodeMappingService
   ) {
     super();
   }
 
   ngAfterViewInit(): void {
     const initialValue: InputElementValue = this.elementModel.type === 'image' ?
-      this.unitStateElementValueMappingService.mapToUnitState(
+      this.elementModelElementCodeMappingService.mapToElementCodeValue(
         (this.elementModel as ImageElement).magnifierUsed, this.elementModel.type) :
       null;
     this.registerAtUnitStateService(
diff --git a/projects/player/src/app/components/element-media-player-group/element-media-player-group.component.html b/projects/player/src/app/components/element-media-player-group/element-media-player-group.component.html
index 916f6f14d..90c163427 100644
--- a/projects/player/src/app/components/element-media-player-group/element-media-player-group.component.html
+++ b/projects/player/src/app/components/element-media-player-group/element-media-player-group.component.html
@@ -7,7 +7,7 @@
     [mediaStatusChanged]="mediaPlayerService.mediaStatusChanged"
     (onMediaValidStatusChanged)="mediaPlayerService.setValidStatusChanged($event)"
     (onMediaPlayStatusChanged)="mediaPlayerService.setActualPlayingMediaId($event)"
-    (elementValueChanged)="unitStateService.changeElementValue($event)">
+    (elementValueChanged)="unitStateService.changeElementCodeValue($event)">
 </aspect-audio>
 
 <aspect-video
@@ -19,5 +19,5 @@
     [savedPlaybackTime]="initialValue"
     (onMediaValidStatusChanged)="mediaPlayerService.setValidStatusChanged($event)"
     (onMediaPlayStatusChanged)="mediaPlayerService.setActualPlayingMediaId($event)"
-    (elementValueChanged)="unitStateService.changeElementValue($event)">
+    (elementValueChanged)="unitStateService.changeElementCodeValue($event)">
 </aspect-video>
diff --git a/projects/player/src/app/components/element-media-player-group/element-media-player-group.component.ts b/projects/player/src/app/components/element-media-player-group/element-media-player-group.component.ts
index 394c83897..4ee655d8a 100644
--- a/projects/player/src/app/components/element-media-player-group/element-media-player-group.component.ts
+++ b/projects/player/src/app/components/element-media-player-group/element-media-player-group.component.ts
@@ -8,7 +8,7 @@ import { MediaPlayerService } from '../../services/media-player.service';
 import { UnitStateService } from '../../services/unit-state.service';
 import { MediaPlayerElementComponent } from 'common/directives/media-player-element-component.directive';
 import { ElementGroupDirective } from '../../directives/element-group.directive';
-import { UnitStateElementValueMappingService } from '../../services/unit-state-element-value-mapping.service';
+import { ElementModelElementCodeMappingService } from '../../services/element-model-element-code-mapping.service';
 
 @Component({
   selector: 'aspect-element-media-player-group',
@@ -28,14 +28,14 @@ export class ElementMediaPlayerGroupComponent extends ElementGroupDirective impl
   constructor(
     public mediaPlayerService: MediaPlayerService,
     public unitStateService: UnitStateService,
-    private unitStateElementValueMappingService: UnitStateElementValueMappingService
+    private elementModelElementCodeMappingService: ElementModelElementCodeMappingService
   ) {
     super();
   }
 
   ngOnInit(): void {
-    this.initialValue = this.unitStateElementValueMappingService.mapToElementValue(
-      this.unitStateService.getUnitStateElement(this.elementModel.id)?.value, this.elementModel) as number;
+    this.initialValue = this.elementModelElementCodeMappingService.mapToElementModelValue(
+      this.unitStateService.getElementCodeById(this.elementModel.id)?.value, this.elementModel) as number;
     this.mediaPlayerService.registerMediaElement(
       this.elementModel.id,
       this.elementModel.player?.minRuns as number === 0
@@ -44,7 +44,7 @@ export class ElementMediaPlayerGroupComponent extends ElementGroupDirective impl
 
   ngAfterViewInit(): void {
     this.registerAtUnitStateService(this.elementModel.id,
-      this.unitStateElementValueMappingService.mapToUnitState(this.initialValue, this.elementModel.type),
+      this.elementModelElementCodeMappingService.mapToElementCodeValue(this.initialValue, this.elementModel.type),
       this.elementComponent,
       this.pageIndex);
   }
diff --git a/projects/player/src/app/components/element-text-group/element-text-group.component.html b/projects/player/src/app/components/element-text-group/element-text-group.component.html
index a1704e063..43101d2dc 100644
--- a/projects/player/src/app/components/element-text-group/element-text-group.component.html
+++ b/projects/player/src/app/components/element-text-group/element-text-group.component.html
@@ -4,7 +4,7 @@
     [savedText]="initialValue"
     (applySelection)="applySelection($event, elementComponent)"
     (startSelection)="startSelection($event, elementComponent)"
-    (elementValueChanged)="unitStateService.changeElementValue($event)">
+    (elementValueChanged)="unitStateService.changeElementCodeValue($event)">
 </aspect-text>
 
 <aspect-floating-marking-bar
diff --git a/projects/player/src/app/components/element-text-group/element-text-group.component.ts b/projects/player/src/app/components/element-text-group/element-text-group.component.ts
index 2843e8ef6..2a081ab52 100644
--- a/projects/player/src/app/components/element-text-group/element-text-group.component.ts
+++ b/projects/player/src/app/components/element-text-group/element-text-group.component.ts
@@ -9,7 +9,7 @@ import { TextMarker } from '../../classes/text-marker';
 import { NativeEventService } from '../../services/native-event.service';
 import { UnitStateService } from '../../services/unit-state.service';
 import { ElementGroupDirective } from '../../directives/element-group.directive';
-import { UnitStateElementValueMappingService } from '../../services/unit-state-element-value-mapping.service';
+import { ElementModelElementCodeMappingService } from '../../services/element-model-element-code-mapping.service';
 import { ElementComponent } from 'common/directives/element-component.directive';
 
 @Component({
@@ -33,7 +33,7 @@ export class ElementTextGroupComponent extends ElementGroupDirective implements
 
   constructor(
     private nativeEventService: NativeEventService,
-    private unitStateElementMapperService: UnitStateElementValueMappingService,
+    private unitStateElementMapperService: ElementModelElementCodeMappingService,
     public unitStateService: UnitStateService
   ) {
     super();
@@ -41,15 +41,15 @@ export class ElementTextGroupComponent extends ElementGroupDirective implements
 
   ngOnInit(): void {
     this.initialValue = this.unitStateElementMapperService
-      .mapToElementValue(
-        this.unitStateService.getUnitStateElement(this.elementModel.id)?.value, this.elementModel
+      .mapToElementModelValue(
+        this.unitStateService.getElementCodeById(this.elementModel.id)?.value, this.elementModel
       ) as string;
   }
 
   ngAfterViewInit(): void {
     this.registerAtUnitStateService(
       this.elementModel.id,
-      this.unitStateElementMapperService.mapToUnitState(this.initialValue, this.elementModel.type),
+      this.unitStateElementMapperService.mapToElementCodeValue(this.initialValue, this.elementModel.type),
       this.elementComponent,
       this.pageIndex);
   }
diff --git a/projects/player/src/app/components/element-text-input-group/element-text-input-group.component.ts b/projects/player/src/app/components/element-text-input-group/element-text-input-group.component.ts
index 010d5e44d..58a231e19 100644
--- a/projects/player/src/app/components/element-text-input-group/element-text-input-group.component.ts
+++ b/projects/player/src/app/components/element-text-input-group/element-text-input-group.component.ts
@@ -7,7 +7,7 @@ import {
   InputElement, TextAreaElement, TextFieldElement, SpellCorrectElement
 } from 'common/interfaces/elements';
 import { UnitStateService } from '../../services/unit-state.service';
-import { UnitStateElementValueMappingService } from '../../services/unit-state-element-value-mapping.service';
+import { ElementModelElementCodeMappingService } from '../../services/element-model-element-code-mapping.service';
 import { MessageService } from 'common/services/message.service';
 import { VeronaSubscriptionService } from 'verona/services/verona-subscription.service';
 import { ElementComponent } from 'common/directives/element-component.directive';
@@ -36,7 +36,7 @@ export class ElementTextInputGroupComponent extends ElementFormGroupDirective im
     private keyboardService: KeyboardService,
     public keypadService: KeypadService,
     public unitStateService: UnitStateService,
-    public unitStateElementValueMappingService: UnitStateElementValueMappingService,
+    public elementModelElementCodeMappingService: ElementModelElementCodeMappingService,
     public translateService: TranslateService,
     public messageService: MessageService,
     public veronaSubscriptionService: VeronaSubscriptionService,
@@ -53,8 +53,8 @@ export class ElementTextInputGroupComponent extends ElementFormGroupDirective im
   ngAfterViewInit(): void {
     this.registerAtUnitStateService(
       this.elementModel.id,
-      this.unitStateElementValueMappingService
-        .mapToUnitState((this.elementModel as InputElement).value, this.elementModel.type),
+      this.elementModelElementCodeMappingService
+        .mapToElementCodeValue((this.elementModel as InputElement).value, this.elementModel.type),
       this.elementComponent,
       this.pageIndex
     );
diff --git a/projects/player/src/app/directives/element-form-group.directive.ts b/projects/player/src/app/directives/element-form-group.directive.ts
index cef42642e..ce08286a4 100644
--- a/projects/player/src/app/directives/element-form-group.directive.ts
+++ b/projects/player/src/app/directives/element-form-group.directive.ts
@@ -7,7 +7,7 @@ import { TranslateService } from '@ngx-translate/core';
 import { Subject } from 'rxjs';
 import { InputElement, InputElementValue, SliderElement } from 'common/interfaces/elements';
 import { UnitStateService } from '../services/unit-state.service';
-import { UnitStateElementValueMappingService } from '../services/unit-state-element-value-mapping.service';
+import { ElementModelElementCodeMappingService } from '../services/element-model-element-code-mapping.service';
 import { ElementGroupDirective } from './element-group.directive';
 import { VopNavigationDeniedNotification } from 'verona/models/verona';
 import { MessageService } from 'common/services/message.service';
@@ -18,7 +18,7 @@ import { ValidatorService } from '../services/validator.service';
 export abstract class ElementFormGroupDirective extends ElementGroupDirective implements OnDestroy {
   form!: FormGroup;
   abstract unitStateService: UnitStateService;
-  abstract unitStateElementValueMappingService: UnitStateElementValueMappingService;
+  abstract elementModelElementCodeMappingService: ElementModelElementCodeMappingService;
   abstract translateService: TranslateService;
   abstract messageService: MessageService;
   abstract veronaSubscriptionService: VeronaSubscriptionService;
@@ -29,16 +29,16 @@ export abstract class ElementFormGroupDirective extends ElementGroupDirective im
   createForm(elementModels: InputElement[]): void {
     this.form = new FormGroup({});
     elementModels.forEach(elementModel => {
-      const initialValue = this.unitStateElementValueMappingService
-        .mapToElementValue(this.unitStateService.getUnitStateElement(elementModel.id)?.value, elementModel);
+      const initialValue = this.elementModelElementCodeMappingService
+        .mapToElementModelValue(this.unitStateService.getElementCodeById(elementModel.id)?.value, elementModel);
       const formControl = new FormControl(initialValue, this.getValidators(elementModel));
       this.form.addControl(elementModel.id, formControl);
       formControl.valueChanges
         .pipe(takeUntil(this.ngUnsubscribe))
         .subscribe((inputValue: InputElementValue) => {
-          this.unitStateService.changeElementValue({
+          this.unitStateService.changeElementCodeValue({
             id: elementModel.id,
-            value: this.unitStateElementValueMappingService.mapToUnitState(inputValue, elementModel.type)
+            value: this.elementModelElementCodeMappingService.mapToElementCodeValue(inputValue, elementModel.type)
           });
         });
       if (this.needsValidation(elementModel)) {
diff --git a/projects/player/src/app/directives/unit-state.directive.ts b/projects/player/src/app/directives/unit-state.directive.ts
index f4a7d1008..1b291808e 100644
--- a/projects/player/src/app/directives/unit-state.directive.ts
+++ b/projects/player/src/app/directives/unit-state.directive.ts
@@ -29,7 +29,7 @@ export class UnitStateDirective implements OnInit, OnDestroy {
     this.unitStateService.presentedPageAdded
       .pipe(takeUntil(this.ngUnsubscribe))
       .subscribe((): void => this.sendVopStateChangedNotification());
-    this.unitStateService.unitStateElementCodeChanged
+    this.unitStateService.elementCodeChanged
       .pipe(takeUntil(this.ngUnsubscribe))
       .subscribe((): void => this.sendVopStateChangedNotification());
   }
@@ -42,10 +42,10 @@ export class UnitStateDirective implements OnInit, OnDestroy {
   private sendVopStateChangedNotification(): void {
     // eslint-disable-next-line no-console
     console.log('player: this.unitStateService.unitStateElementCodes',
-      this.unitStateService.unitStateElementCodes);
+      this.unitStateService.elementCodes);
     const unitState: UnitState = {
       dataParts: {
-        elementCodes: JSON.stringify(this.unitStateService.unitStateElementCodes)
+        elementCodes: JSON.stringify(this.unitStateService.elementCodes)
       },
       presentationProgress: this.presentationProgress,
       responseProgress: this.validatorService.responseProgress,
diff --git a/projects/player/src/app/services/unit-state-element-value-mapping.service.spec.ts b/projects/player/src/app/services/element-model-element-code-mapping.service.spec.ts
similarity index 99%
rename from projects/player/src/app/services/unit-state-element-value-mapping.service.spec.ts
rename to projects/player/src/app/services/element-model-element-code-mapping.service.spec.ts
index 0390c0796..45a58d762 100644
--- a/projects/player/src/app/services/unit-state-element-value-mapping.service.spec.ts
+++ b/projects/player/src/app/services/element-model-element-code-mapping.service.spec.ts
@@ -1,5 +1,5 @@
 import { TestBed } from '@angular/core/testing';
-import { UnitStateElementValueMappingService } from './unit-state-element-value-mapping.service';
+import { ElementModelElementCodeMappingService } from './element-model-element-code-mapping.service';
 import {
   AudioElement,
   DragNDropValueObject,
@@ -8,20 +8,20 @@ import {
 } from 'common/interfaces/elements';
 
 
-describe('UnitStateElementValueMappingService', () => {
-  let service: UnitStateElementValueMappingService;
+describe('ElementModelElementCodeMappingService', () => {
+  let service: ElementModelElementCodeMappingService;
   beforeEach(() => {
     TestBed.configureTestingModule({});
-    service = TestBed.inject(UnitStateElementValueMappingService);
+    service = TestBed.inject(ElementModelElementCodeMappingService);
   });
 
   it('should be created', () => {
     expect(service).toBeTruthy();
   });
 
-  // mapToUnitState
+  // mapToElementCodeValue
 
-  it('should map the value of a drop-list element to its unitState value', () => {
+  it('should map the value of a drop-list elementModel to its elementCode value', () => {
     const dropListValue: DragNDropValueObject[] = [
       {
         stringValue: 'a',
@@ -38,92 +38,92 @@ describe('UnitStateElementValueMappingService', () => {
         id: 'value_3'
       }
     ];
-    expect(service.mapToUnitState(dropListValue, 'drop-list'))
+    expect(service.mapToElementCodeValue(dropListValue, 'drop-list'))
       .toEqual( ['value_1', 'value_2', 'value_3']);
   });
 
-  it('should map the value of a text element to its unitState value', () => {
+  it('should map the value of a text elementModel to its elementCode value', () => {
     const textValue =
       'Lorem <aspect-marked style="background-color: rgb(249, 248, 113);">ipsum</aspect-marked> dolor sit amet';
-    expect(service.mapToUnitState(textValue, 'text'))
+    expect(service.mapToElementCodeValue(textValue, 'text'))
       .toEqual( ['6-11-#f9f871']);
   });
 
-  it('should map the value of a text element to its unitState value - empty Array', () => {
+  it('should map the value of a text elementModel to its elementCode value - empty Array', () => {
     const textValue =
       'Lorem dolor sit amet';
-    expect(service.mapToUnitState(textValue, 'text'))
+    expect(service.mapToElementCodeValue(textValue, 'text'))
       .toEqual( []);
   });
 
-  it('should map the value of a audio element to its unitState value', () => {
-    const inputElementValue = service.mapToUnitState(2, 'audio');
-    expect(inputElementValue).toEqual(2);
+  it('should map the value of a audio elementModel to its elementCode value', () => {
+    expect(service.mapToElementCodeValue(2, 'audio'))
+      .toEqual(2);
   });
 
-  it('should map the value of a iamge element to its unitState value', () => {
-    const inputElementValue = service.mapToUnitState(true, 'audio');
-    expect(inputElementValue).toEqual(true);
+  it('should map the value of a iamge elementModel to its elementCode value', () => {
+    expect(service.mapToElementCodeValue(true, 'audio'))
+      .toEqual(true);
   });
 
-  it('should map the value of a iamge element to its unitState value', () => {
-    const inputElementValue = service.mapToUnitState(false, 'audio');
-    expect(inputElementValue).toEqual(false);
+  it('should map the value of a iamge elementModel to its elementCode value', () => {
+    expect(service.mapToElementCodeValue(false, 'audio'))
+      .toEqual(false);
   });
 
-  it('should map the value of a radio element to its unitState value', () => {
+  it('should map the value of a radio elementModel to its elementCode value', () => {
     for (let i = 0; i < 10; i++) {
-      const inputElementValue = service.mapToUnitState(i, 'radio');
-      expect(inputElementValue).toEqual(i + 1);
+      expect(service.mapToElementCodeValue(i, 'radio'))
+        .toEqual(i + 1);
     }
   });
 
-  it('should map the value of a radio-group-images element to its unitState value', () => {
+  it('should map the value of a radio-group-images elementModel to its elementCode value', () => {
     for (let i = 0; i < 10; i++) {
-      const inputElementValue = service.mapToUnitState(i, 'radio-group-images');
-      expect(inputElementValue).toEqual(i + 1);
+      expect(service.mapToElementCodeValue(i, 'radio-group-images'))
+        .toEqual(i + 1);
     }
   });
 
-  it('should map the value of a dropdown element to its unitState value', () => {
+  it('should map the value of a dropdown elementModel to its elementCode value', () => {
     for (let i = 0; i < 10; i++) {
-      const inputElementValue = service.mapToUnitState(i, 'dropdown');
-      expect(inputElementValue).toEqual(i + 1);
+      expect(service.mapToElementCodeValue(i, 'dropdown'))
+        .toEqual(i + 1);
     }
   });
 
-  it('should map the value of a toggle-button element to its unitState value', () => {
+  it('should map the value of a toggle-button elementModel to its elementCode value', () => {
     for (let i = 0; i < 10; i++) {
-      const inputElementValue = service.mapToUnitState(i, 'toggle-button');
-      expect(inputElementValue).toEqual(i + 1);
+      expect(service.mapToElementCodeValue(i, 'toggle-button'))
+        .toEqual(i + 1);
     }
   });
 
-  it('should map the value of a likert-row element to its unitState value', () => {
+  it('should map the value of a likert-row elementModel to its elementCode value', () => {
     for (let i = 0; i < 10; i++) {
-      const inputElementValue = service.mapToUnitState(i, 'likert-row');
-      expect(inputElementValue).toEqual(i + 1);
+      expect(service.mapToElementCodeValue(i, 'likert-row'))
+        .toEqual(i + 1);
     }
   });
 
-  it('should map the value of a text-field element to its unitState value', () => {
+  it('should map the value of a text-field elementModel to its elementCode value', () => {
     const textFieldValue =
       'TEST';
-    expect(service.mapToUnitState(textFieldValue, 'text-field'))
+    expect(service.mapToElementCodeValue(textFieldValue, 'text-field'))
       .toEqual( 'TEST');
   });
 
-  it('should map the value of a text-field element to its unitState value', () => {
+  it('should map the value of a text-field elementModel to its elementCode value', () => {
     const textFieldValue =
       null;
-    expect(service.mapToUnitState(textFieldValue, 'text-field'))
+    expect(service.mapToElementCodeValue(textFieldValue, 'text-field'))
       .toEqual( null);
   });
 
 
   // mapToElementValue
 
-  it('should map a unitState value to drop-list element value', () => {
+  it('should map a elementCode value to drop-list elementModel value', () => {
     service.dragNDropValueObjects =  [
       {
         'stringValue': 'a',
@@ -194,11 +194,11 @@ describe('UnitStateElementValueMappingService', () => {
         'id': 'value_5'
       }
     ];
-    expect(service.mapToElementValue(['value_5'], elementModel))
+    expect(service.mapToElementModelValue(['value_5'], elementModel))
       .toEqual(expectedValue);
   });
 
-  it('should not map but return the drop-list element value', () => {
+  it('should not map but return the drop-list elementModel value', () => {
     service.dragNDropValueObjects =  [
       {
         'stringValue': 'a',
@@ -263,11 +263,11 @@ describe('UnitStateElementValueMappingService', () => {
         'itemBackgroundColor': '#c9e0e0'
       }
     };
-    expect(service.mapToElementValue(undefined, elementModel))
+    expect(service.mapToElementModelValue(undefined, elementModel))
       .toEqual(elementModel.value);
   });
 
-  it('should map a unitState value to drop-list element value with imageSrc', () => {
+  it('should map a elementCode value to drop-list elementModel value with imageSrc', () => {
     service.dragNDropValueObjects = [
       {
         'stringValue': 'a',
@@ -349,11 +349,11 @@ describe('UnitStateElementValueMappingService', () => {
         id: 'value_2'
       }
     ];
-    expect(service.mapToElementValue(['value_1', 'value_2'], elementModel))
+    expect(service.mapToElementModelValue(['value_1', 'value_2'], elementModel))
       .toEqual(expectedValue);
   });
 
-  it('should map a unitState value to drop-list element value - an empty array', () => {
+  it('should map a elementCode value to drop-list elementModel value - an empty array', () => {
     service.dragNDropValueObjects = [
       {
         'stringValue': 'a',
@@ -423,11 +423,11 @@ describe('UnitStateElementValueMappingService', () => {
         'itemBackgroundColor': '#c9e0e0'
       }
     };
-    expect(service.mapToElementValue([], elementModel ))
+    expect(service.mapToElementModelValue([], elementModel ))
       .toEqual([]);
   });
 
-  it('should map a unitState value to text element value (text)', () => {
+  it('should map a elementCode value to text elementModel value (text)', () => {
     const elementModel: TextElement = {
       'type': 'text',
       'id': 'text_1',
@@ -467,11 +467,11 @@ describe('UnitStateElementValueMappingService', () => {
     };
     const expectedValue =
       'Lorem <aspect-marked style="background-color: rgb(249, 248, 113);">ipsum</aspect-marked> dolor sit amet';
-    expect(service.mapToElementValue(['6-11-#f9f871'], elementModel))
+    expect(service.mapToElementModelValue(['6-11-#f9f871'], elementModel))
       .toEqual(expectedValue);
   });
 
-  it('should not map but return the text element value (text)', () => {
+  it('should not map but return the text elementModel value (text)', () => {
     const elementModel: TextElement = {
       'type': 'text',
       'id': 'text_1',
@@ -509,11 +509,11 @@ describe('UnitStateElementValueMappingService', () => {
         'lineHeight': 135
       }
     };
-    expect(service.mapToElementValue([], elementModel))
+    expect(service.mapToElementModelValue([], elementModel))
       .toEqual(elementModel.text);
   });
 
-  it('should not map but return the text element value (text)', () => {
+  it('should not map but return the text elementModel value (text)', () => {
     const elementModel: TextElement = {
       'type': 'text',
       'id': 'text_1',
@@ -551,11 +551,11 @@ describe('UnitStateElementValueMappingService', () => {
         'lineHeight': 135
       }
     };
-    expect(service.mapToElementValue(undefined, elementModel))
+    expect(service.mapToElementModelValue(undefined, elementModel))
       .toEqual(elementModel.text);
   });
 
-  it('should map a unitState value to audio element value', () => {
+  it('should map a elementCode value to audio elementModel value', () => {
     const elementModel: AudioElement =  {
       'type': 'audio',
       'id': 'audio_2',
@@ -601,11 +601,11 @@ describe('UnitStateElementValueMappingService', () => {
         'playbackTime': 0
       }
     };
-    expect(service.mapToElementValue( 2, elementModel))
+    expect(service.mapToElementModelValue( 2, elementModel))
       .toEqual(2);
   });
 
-  it('should not map but return the audio element value (player.playbackTime)', () => {
+  it('should not map but return the audio elementModel value (player.playbackTime)', () => {
     const elementModel: AudioElement =  {
       'type': 'audio',
       'id': 'audio_2',
@@ -651,11 +651,11 @@ describe('UnitStateElementValueMappingService', () => {
         'playbackTime': 0
       }
     };
-    expect(service.mapToElementValue( undefined, elementModel))
+    expect(service.mapToElementModelValue( undefined, elementModel))
       .toEqual(0);
   });
 
-  it('should map a unitState value to image element value', () => {
+  it('should map a elementCode value to image elementModel value', () => {
     const elementModel: ImageElement =  {
       'type': 'image',
       'id': 'image_1',
@@ -684,11 +684,11 @@ describe('UnitStateElementValueMappingService', () => {
         'zIndex': 0
       }
     };
-    expect(service.mapToElementValue( true, elementModel))
+    expect(service.mapToElementModelValue( true, elementModel))
       .toEqual(true);
   });
 
-  it('should not map but return the image element value (magnifierUsed)', () => {
+  it('should not map but return the image elementModel value (magnifierUsed)', () => {
     const elementModel: ImageElement =  {
       'type': 'image',
       'id': 'image_1',
@@ -717,11 +717,11 @@ describe('UnitStateElementValueMappingService', () => {
         'zIndex': 0
       }
     };
-    expect(service.mapToElementValue( undefined, elementModel))
+    expect(service.mapToElementModelValue( undefined, elementModel))
       .toEqual(false);
   });
 
-  it('should map a unitState value to text-field element value', () => {
+  it('should map a elementCode value to text-field elementModel value', () => {
     const elementModel: TextFieldElement = {
       'type': 'text-field',
       'id': 'text-field_1',
@@ -772,11 +772,11 @@ describe('UnitStateElementValueMappingService', () => {
         'lineHeight': 135
       }
     };
-    expect(service.mapToElementValue( 'TEST', elementModel))
+    expect(service.mapToElementModelValue( 'TEST', elementModel))
       .toEqual('TEST');
   });
 
-  it('should not map but return the text-field element value', () => {
+  it('should not map but return the text-field elementModel value', () => {
     const elementModel: TextFieldElement = {
       'type': 'text-field',
       'id': 'text-field_1',
@@ -827,7 +827,7 @@ describe('UnitStateElementValueMappingService', () => {
         'lineHeight': 135
       }
     };
-    expect(service.mapToElementValue( undefined, elementModel))
+    expect(service.mapToElementModelValue( undefined, elementModel))
       .toEqual(null);
   });
 
diff --git a/projects/player/src/app/services/unit-state-element-value-mapping.service.ts b/projects/player/src/app/services/element-model-element-code-mapping.service.ts
similarity index 50%
rename from projects/player/src/app/services/unit-state-element-value-mapping.service.ts
rename to projects/player/src/app/services/element-model-element-code-mapping.service.ts
index 69c15ce94..8ab16032a 100644
--- a/projects/player/src/app/services/unit-state-element-value-mapping.service.ts
+++ b/projects/player/src/app/services/element-model-element-code-mapping.service.ts
@@ -8,56 +8,59 @@ import {
 @Injectable({
   providedIn: 'root'
 })
-export class UnitStateElementValueMappingService {
+
+export class ElementModelElementCodeMappingService {
   dragNDropValueObjects!: DragNDropValueObject[];
 
-  mapToElementValue = (unitStateValue: InputElementValue | undefined, elementModel: UIElement): InputElementValue => {
+  mapToElementModelValue = (
+    elementCodeValue: InputElementValue | undefined, elementModel: UIElement
+  ): InputElementValue => {
     switch (elementModel.type) {
       case 'drop-list':
-        return (unitStateValue !== undefined) ?
-          (unitStateValue as string[]).map(id => this.getDragNDropValueObjectById(id)) as DragNDropValueObject[] :
+        return (elementCodeValue !== undefined) ?
+          (elementCodeValue as string[]).map(id => this.getDragNDropValueObjectById(id)) as DragNDropValueObject[] :
           (elementModel as InputElement).value;
       case 'text':
-        return (unitStateValue !== undefined) ?
-          TextMarker.restoreMarkings(unitStateValue as string[], (elementModel as TextElement).text) :
+        return (elementCodeValue !== undefined) ?
+          TextMarker.restoreMarkings(elementCodeValue as string[], (elementModel as TextElement).text) :
           (elementModel as TextElement).text;
       case 'audio':
-        return unitStateValue !== undefined ?
-          unitStateValue as number :
+        return elementCodeValue !== undefined ?
+          elementCodeValue as number :
           (elementModel as AudioElement).player.playbackTime;
       case 'video':
-        return unitStateValue !== undefined ?
-          unitStateValue as number :
+        return elementCodeValue !== undefined ?
+          elementCodeValue as number :
           (elementModel as VideoElement).player.playbackTime;
       case 'image':
-        return unitStateValue !== undefined ?
-          unitStateValue as boolean :
+        return elementCodeValue !== undefined ?
+          elementCodeValue as boolean :
           (elementModel as ImageElement).magnifierUsed;
       case 'radio':
       case 'radio-group-images':
       case 'dropdown':
       case 'toggle-button':
       case 'likert-row':
-        return unitStateValue !== undefined ? unitStateValue as number - 1 : (elementModel as InputElement).value;
+        return elementCodeValue !== undefined ? elementCodeValue as number - 1 : (elementModel as InputElement).value;
       default:
-        return unitStateValue !== undefined ? unitStateValue : (elementModel as InputElement).value;
+        return elementCodeValue !== undefined ? elementCodeValue : (elementModel as InputElement).value;
     }
   };
 
-  mapToUnitState = (elementValue: InputElementValue, elementType: UIElementType): InputElementValue => {
+  mapToElementCodeValue = (elementModelValue: InputElementValue, elementType: UIElementType): InputElementValue => {
     switch (elementType) {
       case 'drop-list':
-        return (elementValue as DragNDropValueObject[]).map(object => object.id);
+        return (elementModelValue as DragNDropValueObject[]).map(object => object.id);
       case 'text':
-        return TextMarker.getMarkingData(elementValue as string);
+        return TextMarker.getMarkingData(elementModelValue as string);
       case 'radio':
       case 'radio-group-images':
       case 'dropdown':
       case 'toggle-button':
       case 'likert-row':
-        return elementValue as number + 1;
+        return elementModelValue as number + 1;
       default:
-        return elementValue;
+        return elementModelValue;
     }
   };
 
diff --git a/projects/player/src/app/services/unit-state.service.ts b/projects/player/src/app/services/unit-state.service.ts
index ce461128f..e839f337b 100644
--- a/projects/player/src/app/services/unit-state.service.ts
+++ b/projects/player/src/app/services/unit-state.service.ts
@@ -4,9 +4,9 @@ import { DOCUMENT } from '@angular/common';
 import {
   Progress,
   StatusChangeElement,
-  UnitStateElementCode,
-  UnitStateElementCodeStatus,
-  UnitStateElementCodeStatusValue
+  ElementCode,
+  ElementCodeStatus,
+  ElementCodeStatusValue
 } from 'verona/models/verona';
 import { IntersectionDetector } from '../classes/intersection-detector';
 import { InputElementValue, ValueChangeElement } from 'common/interfaces/elements';
@@ -15,9 +15,9 @@ import { InputElementValue, ValueChangeElement } from 'common/interfaces/element
   providedIn: 'root'
 })
 export class UnitStateService {
-  private _unitStateElementCodes!: UnitStateElementCode[];
+  private _elementCodes!: ElementCode[];
   private _presentedPageAdded = new Subject<number>();
-  private _unitStateElementCodeChanged = new Subject<UnitStateElementCode>();
+  private _elementCodeChanged = new Subject<ElementCode>();
   private presentedPages: number[] = [];
   private elementPageMap: { [elementId: string]: number } = {};
   private intersectionDetector!: IntersectionDetector;
@@ -26,25 +26,25 @@ export class UnitStateService {
     this.intersectionDetector = new IntersectionDetector(document, '0px 0px 0px 0px');
   }
 
-  getUnitStateElement(id: string): UnitStateElementCode | undefined {
-    return this.unitStateElementCodes
-      .find((elementCode: UnitStateElementCode): boolean => elementCode.id === id);
+  getElementCodeById(id: string): ElementCode | undefined {
+    return this.elementCodes
+      .find((elementCode: ElementCode): boolean => elementCode.id === id);
   }
 
   isRegistered(id: string): boolean {
-    return !!(this.getUnitStateElement(id));
+    return !!(this.getElementCodeById(id));
   }
 
-  set unitStateElementCodes(unitStateElementCodes: UnitStateElementCode[]) {
-    this._unitStateElementCodes = unitStateElementCodes;
+  set elementCodes(unitStateElementCodes: ElementCode[]) {
+    this._elementCodes = unitStateElementCodes;
   }
 
-  get unitStateElementCodes(): UnitStateElementCode[] {
-    return this._unitStateElementCodes;
+  get elementCodes(): ElementCode[] {
+    return this._elementCodes;
   }
 
-  get unitStateElementCodeChanged(): Observable<UnitStateElementCode> {
-    return this._unitStateElementCodeChanged.asObservable();
+  get elementCodeChanged(): Observable<ElementCode> {
+    return this._elementCodeChanged.asObservable();
   }
 
   get presentedPageAdded(): Observable<number> {
@@ -63,31 +63,31 @@ export class UnitStateService {
                   domElement: Element,
                   pageIndex: number): void {
     this.elementPageMap[elementId] = pageIndex;
-    this.addUnitStateElementCode(elementId, elementValue);
+    this.addElementCode(elementId, elementValue);
     this.intersectionDetector.observe(domElement, elementId);
     this.intersectionDetector.intersecting
       .subscribe((id: string) => {
-        this.changeElementStatus({ id: id, status: 'DISPLAYED' });
+        this.changeElementCodeStatus({ id: id, status: 'DISPLAYED' });
         this.intersectionDetector.unobserve(id);
       });
   }
 
-  changeElementValue(elementValue: ValueChangeElement): void {
+  changeElementCodeValue(elementValue: ValueChangeElement): void {
     // eslint-disable-next-line no-console
     console.log(`player: changeElementValue ${elementValue.id}: ${elementValue.value}`);
-    this.setUnitStateElementCodeStatus(elementValue.id, 'VALUE_CHANGED');
-    this.setUnitStateElementCodeValue(elementValue.id, elementValue.value);
+    this.setElementCodeStatus(elementValue.id, 'VALUE_CHANGED');
+    this.setElementCodeValue(elementValue.id, elementValue.value);
   }
 
-  changeElementStatus(elementStatus: StatusChangeElement): void {
+  changeElementCodeStatus(elementStatus: StatusChangeElement): void {
     // eslint-disable-next-line no-console
     console.log(`player: changeElementStatus ${elementStatus.id}: ${elementStatus.status}`);
-    this.setUnitStateElementCodeStatus(elementStatus.id, elementStatus.status);
+    this.setElementCodeStatus(elementStatus.id, elementStatus.status);
   }
 
   reset(): void {
     this.elementPageMap = {};
-    this.unitStateElementCodes = [];
+    this.elementCodes = [];
     this.presentedPages = [];
   }
 
@@ -100,21 +100,21 @@ export class UnitStateService {
     }, []);
   }
 
-  private setUnitStateElementCodeValue(id: string, value: InputElementValue): void {
-    const unitStateElementCode = this.getUnitStateElement(id);
+  private setElementCodeValue(id: string, value: InputElementValue): void {
+    const unitStateElementCode = this.getElementCodeById(id);
     if (unitStateElementCode) {
       unitStateElementCode.value = value;
-      this._unitStateElementCodeChanged.next(unitStateElementCode);
+      this._elementCodeChanged.next(unitStateElementCode);
     }
   }
 
-  private setUnitStateElementCodeStatus(id: string, status: UnitStateElementCodeStatus): void {
-    const unitStateElementCode = this.getUnitStateElement(id);
+  private setElementCodeStatus(id: string, status: ElementCodeStatus): void {
+    const unitStateElementCode = this.getElementCodeById(id);
     if (unitStateElementCode) {
       // Set status only if it is higher than the old status
-      if (UnitStateElementCodeStatusValue[status] >= UnitStateElementCodeStatusValue[unitStateElementCode.status]) {
+      if (ElementCodeStatusValue[status] >= ElementCodeStatusValue[unitStateElementCode.status]) {
         unitStateElementCode.status = status;
-        this._unitStateElementCodeChanged.next(unitStateElementCode);
+        this._elementCodeChanged.next(unitStateElementCode);
         this.checkPresentedPageStatus(id);
       }
     }
@@ -125,10 +125,10 @@ export class UnitStateService {
     if (this.presentedPages.indexOf(pageIndex) === -1) {
       const notDisplayedElements = Object.entries(this.elementPageMap)
         .filter((map: [string, number]): boolean => map[1] === pageIndex)
-        .map((pageElement: [string, number]): UnitStateElementCode | undefined => this
-          .getUnitStateElement(pageElement[0]))
-        .filter(pageElement => pageElement && UnitStateElementCodeStatusValue[pageElement.status] <
-          UnitStateElementCodeStatusValue.DISPLAYED);
+        .map((pageElement: [string, number]): ElementCode | undefined => this
+          .getElementCodeById(pageElement[0]))
+        .filter(pageElement => pageElement && ElementCodeStatusValue[pageElement.status] <
+          ElementCodeStatusValue.DISPLAYED);
       if (notDisplayedElements.length === 0) {
         this.presentedPages.push(pageIndex);
         this._presentedPageAdded.next(pageIndex);
@@ -139,11 +139,11 @@ export class UnitStateService {
     }
   }
 
-  private addUnitStateElementCode(id: string, value: InputElementValue): void {
-    if (!this.getUnitStateElement(id)) {
-      const unitStateElementCode: UnitStateElementCode = { id: id, value: value, status: 'NOT_REACHED' };
-      this.unitStateElementCodes.push(unitStateElementCode);
-      this._unitStateElementCodeChanged.next(unitStateElementCode);
+  private addElementCode(id: string, value: InputElementValue): void {
+    if (!this.getElementCodeById(id)) {
+      const unitStateElementCode: ElementCode = { id: id, value: value, status: 'NOT_REACHED' };
+      this.elementCodes.push(unitStateElementCode);
+      this._elementCodeChanged.next(unitStateElementCode);
     } else {
       this.checkPresentedPageStatus(id);
     }
-- 
GitLab