Skip to content
Snippets Groups Projects
test-mode.ts 1.46 KiB
Newer Older
  • Learn to ignore specific revisions
  • // @ts-ignore
    import testModes from './test-modes.json';
    
    // this file is generated by 'generateTestModeClass' script from 'app/config/test-modes.json' and 'app/config/mode-options.json'
    // do not change anything here directly!
    
    export class TestMode {
    	canReview: false;
    	saveResponses: false;
    	forceTimeRestrictions: false;
    	forceNaviRestrictions: false;
    	presetCode: true;
    	showTimeLeft: true;
    	showUnitMenu: false;
    
    	modeId: string = "DEMO";
    
    	public constructor (loginMode: string = 'DEMO') {
    
    			const regExPattern = /(DEMO|MONITOR-GROUP|HOT|REVIEW|TRIAL)/;
    
    			if (regExPattern.test(loginMode.toUpperCase())) {
    				const mode = loginMode.toUpperCase().match(regExPattern)[0];
    				const modeConfig = testModes[mode];
    				this.canReview = modeConfig.config.canReview;
    				this.saveResponses = modeConfig.config.saveResponses;
    				this.forceTimeRestrictions = modeConfig.config.forceTimeRestrictions;
    				this.forceNaviRestrictions = modeConfig.config.forceNaviRestrictions;
    				this.presetCode = modeConfig.config.presetCode;
    				this.showTimeLeft = modeConfig.config.showTimeLeft;
    				this.showUnitMenu = modeConfig.config.showUnitMenu;
    
    				this.isMonitorable = modeConfig.config.isMonitorable;
    
    				this.modeId = mode;
    
    			} else {
    				console.error('TestConfig: invalid loginMode - take DEMO');
    			}
    		} else {
    			console.error('TestConfig: empty loginMode - take DEMO');
    		}
    	}
    }