Skip to content
Snippets Groups Projects
test-controller.interfaces.ts 3.88 KiB
Newer Older
  • Learn to ignore specific revisions
  • // used everywhere
    export interface TaggedString {
        tag: string;
        value: string;
    
    export interface KeyValuePairString {
      [K: string]: string;
    
    export enum WindowFocusState {
      PLAYER = 'PLAYER',
      HOST = 'HOST',
      UNKNOWN = 'UNKNOWN'
    
    // testcontroller restrictions +++++++++++++++++++++++++++++++++++
    
    export interface StartLockData {
    
    mechtelm's avatar
    mechtelm committed
        title: string;
    
    mechtelm's avatar
    mechtelm committed
        prompt: string;
    
    mechtelm's avatar
    mechtelm committed
        codes: CodeInputData[];
    
    export interface CodeInputData {
    
    mechtelm's avatar
    mechtelm committed
        testletId: string;
    
        prompt: string;
        code: string;
        value: string;
    }
    
    // for backend ++++++++++++++++++++++++++++++++++++++++++++++++++++++
    export interface KeyValuePair {
        [K: string]: string;
    }
    
    
    export interface UnitData {
        xml: string;
        restorepoint: string;
    
    mechtelm's avatar
    mechtelm committed
        laststate: KeyValuePair[];
    
    mechtelm's avatar
    mechtelm committed
    export interface TestData {
    
      xml: string;
    
    mechtelm's avatar
    mechtelm committed
      mode: string;
    
      laststate: StateReportEntry[];
    
    export enum TestControllerState {
      INIT = 'INIT',
      LOADING = 'LOADING',
    
    paf's avatar
    paf committed
      RUNNING = 'RUNNING',
    
      TERMINATING = 'TERMINATING',
    
    paf's avatar
    paf committed
      TERMINATED = 'TERMINATED',
      PAUSED = 'PAUSED',
    
      ERROR = 'ERROR'
    }
    
    export enum AppFocusState {
      HAS = 'HAS',
      HAS_NOT = 'HAS_NOT',
      DEAD = 'DEAD'
    }
    
    export enum TestStateKey {
      CURRENT_UNIT_ID = 'CURRENT_UNIT_ID',
      TESTLETS_TIMELEFT = 'TESTLETS_TIMELEFT',
      FOCUS = 'FOCUS',
      CONTROLLER = 'CONTROLLER'
    }
    
    export enum TestLogEntryKey {
      LOADCOMPLETE = 'LOADCOMPLETE',
    }
    
    export interface StateReportEntry {
      key: string; // TestStateKey | TestLogEntryKey | UnitStateKey | PlayerLogKey (unknown, up to the player)
      timeStamp: number;
      content: string
    }
    
    export interface UnitStateData {
      unitDbKey: string;
      dataPartsAllString: string;
      unitStateDataType: string;
    
    export enum UnitPlayerState {
      LOADING = 'LOADING',
      RUNNING = 'RUNNING',
      PAGE_NAVIGATING = 'PAGE_NAVIGATING',
    }
    
    export enum UnitStateKey {
      PRESENTATION_PROGRESS = 'PRESENTATION_PROGRESS',
      RESPONSE_PROGRESS = 'RESPONSE_PROGRESS',
      CURRENT_PAGE_ID = 'CURRENT_PAGE_ID',
      PLAYER = 'PLAYER'
    }
    
    export interface UnitLogData {
      bookletDbId: number;
      unitDbKey: string;
      timestamp: number;
      entry: string;
    }
    
    
    
    
    export interface UnitMenuButtonData {
      sequenceId: number;
      label: string;
      isCurrent: boolean;
    
      isDisabled: boolean;
    
    paf's avatar
    paf committed
      testletMarker: string;
    
    // for testcontroller service ++++++++++++++++++++++++++++++++++++++++
    
    mechtelm's avatar
    mechtelm committed
    
    
    paf's avatar
    paf committed
    
    
    mechtelm's avatar
    mechtelm committed
    
    
    mechtelm's avatar
    mechtelm committed
    export enum MaxTimerDataType {
    
    mechtelm's avatar
    mechtelm committed
        STARTED = 'STARTED',
    
    mechtelm's avatar
    mechtelm committed
        STEP = 'STEP',
        CANCELLED = 'CANCELLED',
    
    mechtelm's avatar
    mechtelm committed
        INTERRUPTED = 'INTERRUPTED',
    
    mechtelm's avatar
    mechtelm committed
        ENDED = 'ENDED'
    
    mechtelm's avatar
    mechtelm committed
    }
    
    
    export interface UnitNaviButtonData {
      sequenceId: number;
      disabled: boolean;
    
      shortLabel: string;
      longLabel: string;
      testletLabel: string;
    
      isCurrent: boolean;
    }
    
    
    // for unithost ++++++++++++++++++++++++++++++++++++++++++++++++++++++
    
    export interface PageData {
        index: number;
        id: string;
    
    mechtelm's avatar
    mechtelm committed
        type: '#next' | '#previous' | '#goto';
    
        disabled: boolean;
    }
    
    mechtelm's avatar
    mechtelm committed
    
    export interface ReviewDialogData {
      loginname: string;
      bookletname: string;
      unitDbKey: string;
      unitTitle: string;
    }
    
    mechtelm's avatar
    mechtelm committed
    
    export enum NoUnitFlag {
    
    paf's avatar
    paf committed
      END = 'end',
      ERROR = 'error'
    
    mechtelm's avatar
    mechtelm committed
    }
    
    
    export interface PendingUnitData {
      playerId: string;
      unitState: string;
      unitDefinition: string;
    }
    
    
    mechtelm's avatar
    mechtelm committed
    export interface KeyValuePairNumber {
      [K: string]: number;
    }
    
    paf's avatar
    paf committed
      NEXT = '#next',
      ERROR = '#error',
      PREVIOUS = '#previous',
      FIRST = '#first',
      LAST = '#last',
      END = '#end',
      MENU = '#menu',
      PAUSE = '#pause'
    
    
    
    export const commandKeywords = [
        'pause',
        'goto',
        'terminate',
    
    ];
    export type CommandKeyword = (typeof commandKeywords)[number];
    export function isKnownCommand (keyword: string): keyword is CommandKeyword {
        return (commandKeywords as readonly string[]).includes(keyword);
    }
    
    export interface Command {
        keyword: CommandKeyword;
    
    paf's avatar
    paf committed
        id: number; // a unique id for each command, to make sure each one get only performed once (even in polling mode)
    
        arguments: string[];
    
        timestamp: number;