Skip to content
Snippets Groups Projects
  • rhenck's avatar
    6d1ad52c
    Re-implement DropList element · 6d1ad52c
    rhenck authored
    - Replace Material Droplist with native HTML events
    - Remove simple-drop-list element; Cloze elements now use the normal 
    DropList element
    - Add example units
    6d1ad52c
    History
    Re-implement DropList element
    rhenck authored
    - Replace Material Droplist with native HTML events
    - Remove simple-drop-list element; Cloze elements now use the normal 
    DropList element
    - Add example units
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
unit.ts 772 B
import packageJSON from '../../../package.json';
import { Page } from 'common/models/page';
import { AnswerScheme, UIElement } from 'common/models/elements/element';

export class Unit {
  type = 'aspect-unit-definition';
  version: string;
  pages: Page[] = [];

  constructor(unit?: Partial<Unit>) {
    this.version = packageJSON.config.unit_definition_version;
    this.pages = unit?.pages?.map(page => new Page(page)) || [new Page()];
  }

  getAllElements(elementType?: string): UIElement[] {
    return this.pages.map(page => page.getAllElements(elementType)).flat();
  }

  getAnswerScheme(): AnswerScheme[] {
    const dropLists = [
      ...this.getAllElements('drop-list')
    ];
    return this.pages.map(page => page.getAnswerScheme(dropLists)).flat();
  }
}