<!--
 * @desc 合规评测
 * @author linyuanjie
 * @date 2023/10/17
-->

<template>
  <el-dialog
    title="合规评测"
    :close-on-click-modal="false"
    :visible.sync="showDialog"
    width="700px"
    center
    :before-close="handleClose"
  >
    <div class="quiz-content">
      <div class="quiz-title f18 fwb clr_333 tc mb24">
        {{ quizItem.title }}（得分：{{ quizItem.finalMark }}）
      </div>
      <div
        v-for="(questionItem, index) in quizItem.items"
        :key="index"
        class="qustion-item mb24"
      >
        <div class="question-title mb12">
          {{ index + 1 }}.{{ questionItem.label }}（分值：{{
            questionItem.mark
          }}）
        </div>
        <div
          v-for="(item, idx) in questionItem.options"
          :key="idx"
          class="mb12"
        >
          <el-radio
            v-model="questionItem.answered"
            :label="item.no"
            class="mr10"
            disabled
          >
            <span>{{ item.text }}</span>
            <span class="clr_success">{{
              item.no === questionItem.answer ? "（正确答案）" : ""
            }}</span>
            <span class="clr_danger">{{
              questionItem.answered !== questionItem.answer &&
              item.no === questionItem.answered
                ? "（选择错误）"
                : ""
            }}</span>
          </el-radio>
        </div>
      </div>
    </div>
    <span slot="footer" class="dialog-footer">
      <el-button @click="handleClose">关 闭</el-button>
    </span>
  </el-dialog>
</template>

<script>
export default {
  name: "quizDialog",
  props: {
    showDialog: {
      type: Boolean,
      required: true,
      default: false
    },
    quizItem: {
      type: Object,
      default: () => ({})
    }
  },
  data() {
    return {};
  },
  methods: {
    handleClose() {
      this.$emit("update:showDialog", false);
    }
  }
};
</script>
