<script setup lang="ts">
import { getQuestions } from '../../api'

const route: any = useRoute()

onMounted(() => {
  getCurrentQuestions()
})

// 获取题
let list: any = $ref()
const getCurrentQuestions = function () {
  getQuestions({ experiment_id: route.query.id }).then(res => {
    list = res.data.items
  })
}

const selectAnswer = ['302', '202']
</script>

<template>
  <el-dialog
    title="2023商业数据分析大赛决赛试题"
    :close-on-click-modal="false"
    width="50%"
    @update:modelValue="$emit('update:modelValue')"
  >
    <el-card class="box-card" v-for="(item, index) in list" :key="item.id">
      <template #header>
        <div class="card-header">
          <span>{{ index + 1 }}.{{ item.title }}</span>
          <el-form-item label="本题分值" style="margin: 0"> {{ item.score }} </el-form-item>
        </div>
      </template>
      <div class="text item">
        正确答案：{{ ['302', '202'].includes(item.type) ? item.answer_info?.name : item?.answer || '上传成功' }}
      </div>
    </el-card>
  </el-dialog>
</template>
<style lang="scss" scoped>
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.text {
  font-size: 14px;
}

.item {
  // margin-bottom: 18px;
}

.box-card {
  margin-bottom: 20px;
}
</style>
