Skip to content
Snippets Groups Projects
test-controller.interfaces.ts 4.44 KiB
Newer Older
  • Learn to ignore specific revisions
  • // used everywhere
    export interface TaggedString {
    
    paflov's avatar
    paflov committed
      tag: string;
      value: string;
    
    export interface KeyValuePairString {
      [K: string]: string;
    
    export enum WindowFocusState {
      PLAYER = 'PLAYER',
      HOST = 'HOST',
      UNKNOWN = 'UNKNOWN'
    
    // testcontroller restrictions +++++++++++++++++++++++++++++++++++
    
    export interface StartLockData {
    
    paflov's avatar
    paflov committed
      title: string;
      prompt: string;
      codes: CodeInputData[];
    
    export interface CodeInputData {
    
    paflov's avatar
    paflov committed
      testletId: string;
      prompt: string;
      code: string;
      value: string;
    
    }
    
    // for backend ++++++++++++++++++++++++++++++++++++++++++++++++++++++
    export interface KeyValuePair {
    
    paflov's avatar
    paflov committed
      [K: string]: string;
    
    paflov's avatar
    paflov committed
      xml: string;
      restorepoint: string;
      laststate: KeyValuePair[];
    
    mechtelm's avatar
    mechtelm committed
    export interface TestData {
    
      xml: string;
    
    mechtelm's avatar
    mechtelm committed
      mode: string;
    
      laststate: StateReportEntry[];
    
    paflov's avatar
    paflov committed
      CURRENT_UNIT_ID = 'CURRENT_UNIT_ID',
      TESTLETS_TIMELEFT = 'TESTLETS_TIMELEFT',
      TESTLETS_CLEARED_CODE = 'TESTLETS_CLEARED_CODE',
      FOCUS = 'FOCUS',
      CONTROLLER = 'CONTROLLER',
      CONNECTION = 'CONNECTION'
    
    }
    
    /**
     * TestState.FOCUS
     * In what state is the whole controller?
     */
    
    export enum TestControllerState {
    
    paflov's avatar
    paflov committed
      INIT = 'INIT',
      LOADING = 'LOADING',
      RUNNING = 'RUNNING',
      TERMINATED = 'TERMINATED',
      FINISHED = 'FINISHED',
      PAUSED = 'PAUSED',
      ERROR = 'ERROR'
    
    /**
     * TestState.FOCUS
     * Do the application-window has focus or not (because another window or tab has it)?
     */
    
    export enum AppFocusState {
      HAS = 'HAS',
    
    /**
     * TestState.CONNECTION
     * What kind of connection to the server do we have to receive possible commands from a group-monitor?
    
    paflov's avatar
    paflov committed
     * This can get a third special-value called LOST, which is set *by the backend* on connection loss.
    
     */
    export enum TestStateConnectionValue {
    
    paflov's avatar
    paflov committed
      WEBSOCKET = 'WEBSOCKET',
      POLLING = 'POLLING'
    
    }
    
    export enum TestLogEntryKey {
    
    paflov's avatar
    paflov committed
      LOADCOMPLETE = 'LOADCOMPLETE'
    
    }
    
    export interface StateReportEntry {
      key: string; // TestStateKey | TestLogEntryKey | UnitStateKey | PlayerLogKey (unknown, up to the player)
      timeStamp: number;
    
    }
    
    export interface UnitStateData {
      unitDbKey: string;
      dataPartsAllString: string;
      unitStateDataType: string;
    
    export enum UnitPlayerState {
      LOADING = 'LOADING',
      RUNNING = 'RUNNING',
    
    paflov's avatar
    paflov committed
      PAGE_NAVIGATING = 'PAGE_NAVIGATING'
    
    }
    
    export enum UnitStateKey {
      PRESENTATION_PROGRESS = 'PRESENTATION_PROGRESS',
      RESPONSE_PROGRESS = 'RESPONSE_PROGRESS',
      CURRENT_PAGE_ID = 'CURRENT_PAGE_ID',
    
      CURRENT_PAGE_NR = 'CURRENT_PAGE_NR',
      PAGE_COUNT = 'PAGE_COUNT',
    
      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
    export enum MaxTimerDataType {
    
    paflov's avatar
    paflov committed
      STARTED = 'STARTED',
      STEP = 'STEP',
      CANCELLED = 'CANCELLED',
      INTERRUPTED = 'INTERRUPTED',
      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 {
    
    paflov's avatar
    paflov committed
      index: number;
      id: string;
      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 = [
    
    paflov's avatar
    paflov committed
      'pause',
      'goto',
      'terminate',
      'resume',
      'debug'
    
    ];
    export type CommandKeyword = (typeof commandKeywords)[number];
    
    paflov's avatar
    paflov committed
    export function isKnownCommand(keyword: string): keyword is CommandKeyword {
      return (commandKeywords as readonly string[]).includes(keyword);
    
    }
    
    export interface Command {
    
    paflov's avatar
    paflov committed
      keyword: CommandKeyword;
      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;