<script setup lang="ts">
import type { PaperQuestionType } from '@/types'
import CourseExamCard from '../components/CourseExamCard.vue'
import { getPaper } from '../api'
const route = useRoute()
const courseId = $ref(route.query.course_id as string)
const semesterId = $ref(route.query.semester_id as string)
const paperId = $ref(route.query.paper_id as string)
const type = $ref(parseInt(route.query.type as string))
const detail = reactive({ status: 1 })
const questionList = ref<PaperQuestionType[]>([])
provide('questionList', questionList)
// 获取试卷详情
function fetchInfo() {
  getPaper({ course_id: courseId, semester_id: semesterId, paper_id: paperId, type }).then(res => {
    Object.assign(detail, res.data)
    questionList.value = res.data.question
  })
}
onMounted(() => {
  fetchInfo()
})
</script>

<template>
  <CourseExamCard :status="detail.status" @update="fetchInfo"></CourseExamCard>
</template>
