424 lines
11 KiB
Vue
424 lines
11 KiB
Vue
<template>
|
|
<div class="exam-preview">
|
|
|
|
<div class="exam-content">
|
|
<!-- 考试信息 -->
|
|
<div class="exam-info">
|
|
<h4>{{ detailData.title || detailData.name || '考试标题' }}</h4>
|
|
<div class="exam-meta">
|
|
<n-space>
|
|
<n-tag type="error" size="small">
|
|
<template #icon>
|
|
<n-icon><ClipboardOutline /></n-icon>
|
|
</template>
|
|
考试
|
|
</n-tag>
|
|
<span v-if="detailData.questionCount || detailData.questions?.length" class="question-count">
|
|
题目数量: {{ detailData.questionCount || detailData.questions?.length || 0 }}
|
|
</span>
|
|
<span v-if="detailData.duration" class="duration">
|
|
考试时长: {{ formatDuration(detailData.duration) }}
|
|
</span>
|
|
<span v-if="detailData.totalScore" class="total-score">
|
|
总分: {{ detailData.totalScore }}分
|
|
</span>
|
|
</n-space>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 考试状态和时间 -->
|
|
<div class="exam-status">
|
|
<n-card size="small" style="margin-bottom: 16px;">
|
|
<n-descriptions :column="2" size="small">
|
|
<!-- <n-descriptions-item label="考试状态">
|
|
<n-tag :type="getStatusType(detailData.status)" size="small">
|
|
{{ getStatusText(detailData.status) }}
|
|
</n-tag>
|
|
</n-descriptions-item>
|
|
<n-descriptions-item v-if="detailData.passScore" label="及格分数">
|
|
{{ detailData.passScore }}分
|
|
</n-descriptions-item> -->
|
|
<n-descriptions-item v-if="detailData.startTime" label="开始时间">
|
|
{{ formatTime(detailData.startTime) }}
|
|
</n-descriptions-item>
|
|
<n-descriptions-item v-if="detailData.endTime" label="结束时间">
|
|
{{ formatTime(detailData.endTime) }}
|
|
</n-descriptions-item>
|
|
</n-descriptions>
|
|
</n-card>
|
|
</div>
|
|
|
|
<!-- 考试说明 -->
|
|
<div v-if="detailData.description || detailData.instruction" class="exam-description">
|
|
<h5>考试说明</h5>
|
|
<div class="description-content">
|
|
{{ detailData.description || detailData.instruction || '暂无考试说明' }}
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 题目预览 -->
|
|
<!-- <div class="questions-preview">
|
|
<h5>题目预览</h5>
|
|
|
|
<div v-if="detailData.questions && detailData.questions.length > 0" class="questions-list">
|
|
<div
|
|
v-for="(question, index) in displayQuestions"
|
|
:key="question.id || index"
|
|
class="question-item"
|
|
>
|
|
<n-card size="small" style="margin-bottom: 12px;">
|
|
<div class="question-header">
|
|
<span class="question-number">第{{ index + 1 }}题</span>
|
|
<n-tag size="small" :type="getQuestionTypeColor(question.type)">
|
|
{{ getQuestionTypeText(question.type) }}
|
|
</n-tag>
|
|
<span v-if="question.score" class="question-score">{{ question.score }}分</span>
|
|
</div>
|
|
|
|
<div class="question-content">
|
|
<div class="question-text">{{ question.title || question.content || question.question }}</div>
|
|
|
|
<div v-if="question.options && question.options.length > 0" class="question-options">
|
|
<div
|
|
v-for="(option, optionIndex) in question.options"
|
|
:key="optionIndex"
|
|
class="option-item"
|
|
>
|
|
<span class="option-label">{{ getOptionLabel(optionIndex) }}.</span>
|
|
<span class="option-text">{{ option.content || option.text || option }}</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div v-if="question.answer || question.correctAnswer" class="question-answer">
|
|
<span class="answer-label">参考答案:</span>
|
|
<span class="answer-content">{{ question.answer || question.correctAnswer }}</span>
|
|
</div>
|
|
</div>
|
|
</n-card>
|
|
</div>
|
|
|
|
<div v-if="detailData.questions.length > maxDisplayQuestions" class="show-more">
|
|
<n-button v-if="!showAllQuestions" @click="showAllQuestions = true">
|
|
显示全部 {{ detailData.questions.length }} 道题目
|
|
</n-button>
|
|
<n-button v-else @click="showAllQuestions = false">
|
|
收起题目
|
|
</n-button>
|
|
</div>
|
|
</div>
|
|
|
|
<div v-else class="no-questions">
|
|
<n-empty description="暂无题目" size="small" />
|
|
</div>
|
|
</div> -->
|
|
|
|
<!-- 考试详细信息 -->
|
|
<div class="exam-details">
|
|
<n-divider />
|
|
<n-descriptions :column="2" bordered size="small">
|
|
<n-descriptions-item label="考试名称">
|
|
{{ detailData.title || detailData.name || '-' }}
|
|
</n-descriptions-item>
|
|
<n-descriptions-item label="创建时间">
|
|
{{ formatTime(detailData.createTime) }}
|
|
</n-descriptions-item>
|
|
<n-descriptions-item label="更新时间">
|
|
{{ formatTime(detailData.updateTime) }}
|
|
</n-descriptions-item>
|
|
<!-- <n-descriptions-item label="允许重考">
|
|
{{ detailData.allowRetake ? '是' : '否' }}
|
|
</n-descriptions-item>
|
|
<n-descriptions-item label="成绩公布">
|
|
{{ detailData.showScore ? '立即公布' : '稍后公布' }}
|
|
</n-descriptions-item> -->
|
|
</n-descriptions>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
// import { ref, computed } from 'vue'
|
|
import {
|
|
NSpace,
|
|
NTag,
|
|
NIcon,
|
|
NCard,
|
|
NDescriptions,
|
|
NDescriptionsItem,
|
|
NDivider,
|
|
} from 'naive-ui'
|
|
import { ClipboardOutline } from '@vicons/ionicons5'
|
|
|
|
interface Props {
|
|
sectionData: any
|
|
detailData: any
|
|
courseId: string
|
|
}
|
|
|
|
defineProps<Props>()
|
|
const emit = defineEmits<{
|
|
error: [message: string]
|
|
edit: [sectionData: any, detailData: any]
|
|
}>()
|
|
|
|
// const showAllQuestions = ref(false)
|
|
// const maxDisplayQuestions = 5
|
|
|
|
// 显示的题目列表
|
|
// const displayQuestions = computed(() => {
|
|
// if (!props.detailData?.questions) return []
|
|
|
|
// return showAllQuestions.value
|
|
// ? props.detailData.questions
|
|
// : props.detailData.questions.slice(0, maxDisplayQuestions)
|
|
// })
|
|
|
|
// 格式化时长
|
|
const formatDuration = (minutes: number | string) => {
|
|
const num = typeof minutes === 'string' ? parseInt(minutes) : minutes
|
|
if (isNaN(num)) return '-'
|
|
|
|
if (num < 60) return `${num}分钟`
|
|
const hours = Math.floor(num / 60)
|
|
const remainingMinutes = num % 60
|
|
return `${hours}小时${remainingMinutes}分钟`
|
|
}
|
|
|
|
// 格式化时间
|
|
const formatTime = (time: string | undefined) => {
|
|
if (!time) return '-'
|
|
try {
|
|
return new Date(time).toLocaleString('zh-CN')
|
|
} catch {
|
|
return time
|
|
}
|
|
}
|
|
|
|
// 获取状态文本
|
|
// const getStatusText = (status: number | string | undefined) => {
|
|
// const statusMap: Record<string, string> = {
|
|
// '0': '未开始',
|
|
// '1': '进行中',
|
|
// '2': '已结束',
|
|
// '3': '已暂停'
|
|
// }
|
|
// return statusMap[status?.toString() || '0'] || '未知状态'
|
|
// }
|
|
|
|
// 获取状态类型
|
|
// const getStatusType = (status: number | string | undefined): 'default' | 'success' | 'warning' | 'error' => {
|
|
// const typeMap: Record<string, 'default' | 'success' | 'warning' | 'error'> = {
|
|
// '0': 'default',
|
|
// '1': 'success',
|
|
// '2': 'warning',
|
|
// '3': 'error'
|
|
// }
|
|
// return typeMap[status?.toString() || '0'] || 'default'
|
|
// }
|
|
|
|
// 获取题目类型文本
|
|
// const getQuestionTypeText = (type: number | string | undefined) => {
|
|
// const typeMap: Record<string, string> = {
|
|
// '1': '单选题',
|
|
// '2': '多选题',
|
|
// '3': '判断题',
|
|
// '4': '填空题',
|
|
// '5': '简答题',
|
|
// '6': '论述题'
|
|
// }
|
|
// return typeMap[type?.toString() || '1'] || '单选题'
|
|
// }
|
|
|
|
// 获取题目类型颜色
|
|
// const getQuestionTypeColor = (type: number | string | undefined): 'default' | 'primary' | 'info' | 'success' | 'warning' | 'error' => {
|
|
// const colorMap: Record<string, 'default' | 'primary' | 'info' | 'success' | 'warning' | 'error'> = {
|
|
// '1': 'primary',
|
|
// '2': 'info',
|
|
// '3': 'success',
|
|
// '4': 'warning',
|
|
// '5': 'error',
|
|
// '6': 'default'
|
|
// }
|
|
// return colorMap[type?.toString() || '1'] || 'primary'
|
|
// }
|
|
|
|
// // 获取选项标签
|
|
// const getOptionLabel = (index: number) => {
|
|
// return String.fromCharCode(65 + index) // A, B, C, D...
|
|
// }
|
|
</script>
|
|
|
|
<style scoped>
|
|
.exam-preview {
|
|
padding: 16px;
|
|
}
|
|
|
|
.empty-state {
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
min-height: 200px;
|
|
}
|
|
|
|
.exam-content {
|
|
max-width: 100%;
|
|
}
|
|
|
|
.exam-info {
|
|
margin-bottom: 16px;
|
|
}
|
|
|
|
.exam-info h4 {
|
|
margin: 0 0 8px 0;
|
|
font-size: 16px;
|
|
color: #333;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.exam-meta {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 12px;
|
|
font-size: 13px;
|
|
color: #666;
|
|
}
|
|
|
|
.exam-description {
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.exam-description h5 {
|
|
margin: 0 0 8px 0;
|
|
font-size: 14px;
|
|
color: #333;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.description-content {
|
|
background: #f8f9fa;
|
|
padding: 12px;
|
|
border-radius: 6px;
|
|
font-size: 14px;
|
|
line-height: 1.6;
|
|
color: #555;
|
|
}
|
|
|
|
.questions-preview h5 {
|
|
margin: 0 0 12px 0;
|
|
font-size: 14px;
|
|
color: #333;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.question-item {
|
|
margin-bottom: 12px;
|
|
}
|
|
|
|
.question-header {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
margin-bottom: 8px;
|
|
}
|
|
|
|
.question-number {
|
|
font-weight: 600;
|
|
color: #333;
|
|
}
|
|
|
|
.question-score {
|
|
margin-left: auto;
|
|
color: #ff6b35;
|
|
font-weight: 500;
|
|
}
|
|
|
|
.question-content {
|
|
margin-top: 8px;
|
|
}
|
|
|
|
.question-text {
|
|
font-size: 14px;
|
|
line-height: 1.6;
|
|
color: #333;
|
|
margin-bottom: 12px;
|
|
}
|
|
|
|
.question-options {
|
|
margin: 12px 0;
|
|
}
|
|
|
|
.option-item {
|
|
display: flex;
|
|
align-items: flex-start;
|
|
margin-bottom: 6px;
|
|
font-size: 13px;
|
|
line-height: 1.5;
|
|
}
|
|
|
|
.option-label {
|
|
font-weight: 500;
|
|
color: #666;
|
|
margin-right: 8px;
|
|
min-width: 20px;
|
|
}
|
|
|
|
.option-text {
|
|
color: #555;
|
|
}
|
|
|
|
.question-answer {
|
|
margin-top: 12px;
|
|
padding: 8px 12px;
|
|
background: #f0f9ff;
|
|
border-radius: 6px;
|
|
border-left: 3px solid #1890ff;
|
|
}
|
|
|
|
.answer-label {
|
|
font-weight: 500;
|
|
color: #1890ff;
|
|
margin-right: 8px;
|
|
}
|
|
|
|
.answer-content {
|
|
color: #333;
|
|
}
|
|
|
|
.show-more {
|
|
text-align: center;
|
|
margin-top: 16px;
|
|
}
|
|
|
|
.no-questions {
|
|
padding: 20px;
|
|
text-align: center;
|
|
}
|
|
|
|
.exam-details {
|
|
margin-top: 20px;
|
|
}
|
|
|
|
.question-count,
|
|
.duration,
|
|
.total-score {
|
|
white-space: nowrap;
|
|
}
|
|
|
|
/* 响应式调整 */
|
|
@media (max-width: 768px) {
|
|
.exam-preview {
|
|
padding: 12px;
|
|
}
|
|
|
|
.exam-meta {
|
|
flex-direction: column;
|
|
align-items: flex-start;
|
|
gap: 8px;
|
|
}
|
|
|
|
.question-header {
|
|
flex-wrap: wrap;
|
|
}
|
|
}
|
|
</style> |