<script setup>
import { getQuestions } from '../../api'

const route = useRoute()

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

// 获取题
const list = ref([])
const getCurrentQuestions = function () {
  getQuestions({ experiment_id: route.query.id }).then((res) => {
    list.value = res.data.items
  })
}
</script>

<template>
  <el-dialog
    title="试题"
    :close-on-click-modal="false"
    width="50%"
    @update:modelValue="(value) => $emit('update:modelValue', value)">
    <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;
}

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