<template>
  <div class="report-page report-summary">
    <div class="report-body">
      <div class="report-body-head">
        <h2>{{ props.partNo }}、科目试卷特征量数</h2>
        <p class="report-name"></p>
      </div>

      <div class="report-part summary-part">
        <div class="summary-title">
          <div>{{ props.paper.projectName }}自命题成绩分析</div>
          <div>({{ props.paper.courseName }}-{{ props.paper.courseCode }})</div>
        </div>
        <div class="summary-body">
          <div class="summary-item">
            <div class="summary-item-body">
              <p>满分：{{ props.paper.totalScore }}</p>
              <p>最高分：{{ props.paper.maxScore }}</p>
              <p>有效样本数：{{ props.paper.totalCount }}</p>
            </div>
          </div>
          <div class="summary-item">
            <div class="summary-item-body">
              <p>平均分：{{ props.paper.avgScore }}</p>
              <p>标准差：{{ props.paper.stdev }}</p>
              <p>差异系数：{{ props.paper.coefficient }}</p>
            </div>
          </div>
          <div class="summary-item">
            <div class="summary-item-body">
              <p>信度：{{ props.paper.reliability1 }}</p>
              <p>难度系数：{{ props.paper.difficulty }}</p>
            </div>
          </div>
        </div>
      </div>

      <div class="report-part result-part">
        <p>
          本科目最高分{{ props.paper.maxScore }}，有效样本数{{
            props.paper.totalCount
          }}，平均分{{ props.paper.avgScore }}，标准差值{{
            props.paper.stdev
          }}，差异系数{{ props.paper.coefficient }}，信度{{
            props.paper.reliability1
          }}，{{ reliabilityEvaluate }}，难度系数{{
            props.paper.difficulty
          }}，{{ difficultyEvaluate }}。
        </p>
      </div>

      <div class="report-part summary-intro">
        <h4 class="report-part-title">说明</h4>
        <div class="summary-intro-list">
          <div class="summary-intro-item">
            <span>有效样本数</span
            >总分为起始计算分及以上的试卷数量，如无自定义系统默认满分100的，默认为40，满分150的默认为50，满分300的默认为160；
          </div>
          <div class="summary-intro-item">
            <span>平均分、标准差、差异系数、信度、难度系数</span
            >均基于有效样本分析计算;
          </div>
          <div class="summary-intro-item">
            <span>差异系数</span
            >是一组数据的标准差与其均值的百分比，是测算数据离散程度的相对指标，是一种相对差异量数，离散系数大，代表其数据的离散程度大，其平均数的代表性就差，反之亦然；
          </div>
          <div class="summary-intro-item">
            <span>信度</span
            >一致性、稳定性及可家性，采用克伦巴蒜口系数：“信度值最好在0.8以上，0.7-0.8之间可以接受；分量表的信度
            系数最好在0.7以上，0.6-0.7还可以接受。低于0.6的试卷，若所涉学科知识或能力要素井不庞杂，则页检讨是否存在试题内容或能力要求过偏，超出本专业考生能力范围
            或存在不届于所在学科领域的试题内容或能力要求；
          </div>
          <div class="summary-intro-item">
            <span>难度系数</span
            >为科目平均分与科目满分的比值，滩度值在0.5-0.6之间则试题难度较为适宜或评分松紧适宜，高于0.6则可能试题总体上较易或评分过“松”，低于0.5则可能试题总体上较难或评分过“紧”。
          </div>
        </div>
      </div>
    </div>
    <div class="report-pfoot"></div>
  </div>
</template>

<script setup lang="ts">
import { SASPaper } from "@/types";
import { onMounted } from "vue";

const props = defineProps<{
  paper: SASPaper;
  partNo: string;
}>();

interface EvaluateItemType {
  range: number[];
  value: string;
}

const reliabilityEvaluateModel = [
  {
    range: [0.7, 1],
    value: "适宜",
  },
  {
    range: [0.6, 0.7],
    value: "可以接受",
  },
  {
    range: [0, 0.6],
    value: "过低",
  },
];
const difficultyEvaluateModel = [
  {
    range: [0.6, 1],
    value: "试卷试题总体上较易或评分过“松”",
  },
  {
    range: [0.5, 0.6],
    value: "试题难度较为适宜或评分松紧适宜",
  },
  {
    range: [0, 0.5],
    value: "试卷试题总体上较难或评分过“紧”",
  },
];

let reliabilityEvaluate = $ref("");
let difficultyEvaluate = $ref("");

onMounted(() => {
  reliabilityEvaluate = getEvaluate(
    reliabilityEvaluateModel,
    props.paper.reliability1
  );
  difficultyEvaluate = getEvaluate(
    difficultyEvaluateModel,
    props.paper.difficulty
  );
});

function getEvaluate(model: EvaluateItemType[], val: number): string {
  const m = model.find((item, index) => {
    if (index) return item.range[0] <= val && item.range[1] > val;
    return item.range[0] <= val && item.range[1] >= val;
  });
  return m ? m.value : "";
}
</script>
