const overview = {
  studentCount: 452,
  actualCount: 450,
  absentCount: 2,
  breachCount: 4,
  avgScore: 75,
  maxScore: 100,
  minScore: 40,
  passCount: 400,
  passRate: 90,
  excellentCount: 145,
  excellentRate: 20,
};
// 分数段
let scoreRange = [];
let totalScore = 100;
let scoreDist = 10;
let scoreCount = Math.ceil(totalScore / scoreDist);
for (let i = 0; i < scoreCount; i++) {
  scoreRange.push({
    minScore: i * scoreDist,
    maxScore: (i + 1) * scoreDist,
    studentCount: getRandomNumer(0, 100),
    rate: getRandomNumer(10, 30, 2),
  });
}

// 学院
let college = [];
let collegeCount = 32;
for (let i = 0; i < collegeCount; i++) {
  college.push({
    college: "学院" + (i + 1),
    avgScore: getRandomNumer(0, 100),
    maxScore: getRandomNumer(90, 100),
    minScore: getRandomNumer(0, 30),
    passCount: getRandomNumer(40, 60),
    passRate: getRandomNumer(50, 100, 2),
    excellentCount: getRandomNumer(20, 30),
    excellentRate: getRandomNumer(5, 20, 2),
  });
}
// 班级
let classList = [];
let classCount = 30;
for (let i = 0; i < classCount; i++) {
  classList.push({
    className: "班级" + (i + 1),
    avgScore: getRandomNumer(0, 100),
    maxScore: getRandomNumer(90, 100),
    minScore: getRandomNumer(0, 30),
    passCount: getRandomNumer(40, 60),
    passRate: getRandomNumer(50, 100, 2),
    excellentCount: getRandomNumer(20, 30),
    excellentRate: getRandomNumer(5, 20, 2),
  });
}

// 教师
let teacher = [];
let teacherCount = 30;
let teacherClass = [];
for (let i = 0; i < teacherCount; i++) {
  teacher.push({
    teacher: "老师" + (i + 1),
    avgScore: getRandomNumer(0, 100),
    maxScore: getRandomNumer(90, 100),
    minScore: getRandomNumer(0, 30),
    passCount: getRandomNumer(40, 60),
    passRate: getRandomNumer(50, 100, 2),
    excellentCount: getRandomNumer(20, 30),
    excellentRate: getRandomNumer(5, 20, 2),
  });
  const classCount = getRandomNumer(1, 6);
  for (let j = 0; j < classCount; j++) {
    teacherClass.push({
      teacher: "老师" + (i + 1),
      className: "班级名称" + (j + 1),
      avgScore: getRandomNumer(0, 100),
      maxScore: getRandomNumer(90, 100),
      minScore: getRandomNumer(0, 30),
      passCount: getRandomNumer(40, 60),
      passRate: getRandomNumer(50, 100, 2),
      excellentCount: getRandomNumer(20, 30),
      excellentRate: getRandomNumer(5, 20, 2),
    });
  }
}

// 试题
let objective = [];
let objectiveMainCount = 3;
let objectiveSubCount = getRandomNumer(5, 10);
for (let i = 0; i < objectiveMainCount; i++) {
  for (let j = 0; j < objectiveSubCount; j++) {
    objective.push({
      title: "客观题",
      mainNumber: i + 1,
      subNumber: j + 1,
      score: 3,
      avgScore: getRandomNumer(0, 3, 2),
      scoreRate: getRandomNumer(20, 100, 2),
      fullScoreRate: getRandomNumer(20, 100, 2),
    });
  }
}
// objective = objective.slice(0, 10);
let subjective = [];
let subjectiveMainCount = 4;
let subjectiveSubCount = getRandomNumer(2, 4);
for (let i = 0; i < subjectiveMainCount; i++) {
  for (let j = 0; j < subjectiveSubCount; j++) {
    subjective.push({
      title: "主观题",
      mainNumber: i + 1,
      subNumber: j + 1,
      score: 3,
      avgScore: getRandomNumer(0, 3, 2),
      scoreRate: getRandomNumer(20, 100, 2),
      fullScoreRate: getRandomNumer(20, 100, 2),
    });
  }
}

// 大题分析
const mainQuestionAnalysis = [];
const mainCount = getRandomNumer(35, 50);
for (let i = 0; i < mainCount; i++) {
  mainQuestionAnalysis.push({
    title: `主观主观题${i + 1}`,
    mainNumber: i + 1,
    score: 20,
    maxScore: getRandomNumer(15, 20),
    minScore: getRandomNumer(10, 20),
    avgScore: getRandomNumer(5, 15),
    scoreRate: getRandomNumer(20, 100, 2),
    zeroScoreCount: getRandomNumer(0, 10),
    fullScoreCount: getRandomNumer(0, 10),
  });
}

const data = {
  overview,
  scoreRange,
  college,
  classData: classList,
  teacher,
  teacherClass,
  objective,
  subjective,
  mainQuestionAnalysis,
};

function getRandomNumer(min, max, precision = 0) {
  return tofixed(Math.random() * (max - min) + min, precision);
}

function tofixed(num, precision = 0) {
  if (!num) return num;
  if (precision) {
    return parseFloat(num.toFixed(precision));
  } else {
    return Math.round(num);
  }
}

export default data;
