// 奇遇题库 import {readJsonFile} from '../util' import { FILENAME } from '../../consts' export interface DicQuestion { // 题目id readonly id: number; // 题干 readonly question: string; // 答案 readonly answer: Array; // 正确答案 readonly correct: number; } const str = readJsonFile(FILENAME.DIC_QUESTION); let arr = JSON.parse(str); export const dicQuestion = new Map(); arr.forEach(o => { o.answer = parseAnswer(o.a1, o.a2, o.a3, o.a4) dicQuestion.set(o.id, o); }); function parseAnswer(a1: string, a2: string, a3: string, a4: string) { let answer = new Array(); if(a1) answer.push(a1); if(a2) answer.push(a2); if(a3) answer.push(a3); if(a4) answer.push(a4); return answer; }