|
@@ -26,6 +26,8 @@ import KeepLookQuestion from '../model/keep-look-question'
|
|
|
import PlayQuestion from '../model/play-question'
|
|
|
import ErrorMode from '../model/error-mode'
|
|
|
import ResultFinish from '../model/result-finish'
|
|
|
+import { QuestionType } from '../unit'
|
|
|
+import request from '@/helpers/request'
|
|
|
|
|
|
export default defineComponent({
|
|
|
name: 'unit-detail',
|
|
@@ -38,35 +40,96 @@ export default defineComponent({
|
|
|
visiableError: false,
|
|
|
visiableAnswer: false,
|
|
|
visiableResult: false,
|
|
|
+ id: route.query.id,
|
|
|
+ examDetail: {} as any,
|
|
|
currentIndex: 0,
|
|
|
- questionList: [1, 2, 3, 4, 5],
|
|
|
- answerList: {},
|
|
|
- time: 30 * 60 * 1000,
|
|
|
+ questionList: [],
|
|
|
+ time: 0,
|
|
|
visiableSure: false,
|
|
|
- childs: [
|
|
|
- { name: 'John', id: 0 },
|
|
|
- { name: 'Joao', id: 1 },
|
|
|
- { name: 'Jean', id: 2 }
|
|
|
- ]
|
|
|
+ resultInfo: {} as any,
|
|
|
+ resultStatusType: 'SUCCESS', // 'SUCCESS' | 'FAIL'
|
|
|
+ visiableExam: false, // 考试已结束
|
|
|
+ nextStatus: false
|
|
|
})
|
|
|
|
|
|
+ const getExamDetails = async () => {
|
|
|
+ try {
|
|
|
+ const { data } = await request.post(
|
|
|
+ '/api-student/studentUnitExamination/startExamination',
|
|
|
+ {
|
|
|
+ requestType: 'form',
|
|
|
+ data: {
|
|
|
+ studentUnitExaminationId: state.id
|
|
|
+ }
|
|
|
+ }
|
|
|
+ )
|
|
|
+ const { questionJson, studentAnswerJson, ...res } = data
|
|
|
+ const temp = questionJson || []
|
|
|
+ temp.forEach((item: any) => {
|
|
|
+ item.userAnswer = []
|
|
|
+ })
|
|
|
+ state.questionList = temp
|
|
|
+
|
|
|
+ state.examDetail = { ...res } || {}
|
|
|
+ } catch {
|
|
|
+ //
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @description 下一题 | 测试完成
|
|
|
+ */
|
|
|
+ const onNextQuestion = async () => {
|
|
|
+ try {
|
|
|
+ const questionList = state.questionList || []
|
|
|
+ const userAnswerList: any = [] // 所有题目的答案
|
|
|
+ // let currentResult = false // 当前题目是否已经答题
|
|
|
+ questionList.forEach((question: any) => {
|
|
|
+ // 格式化所有题目的答案
|
|
|
+ if (question.userAnswer && question.userAnswer.length > 0) {
|
|
|
+ userAnswerList.push({
|
|
|
+ questionId: question.id,
|
|
|
+ details: question.userAnswer
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ // 判断是否是最后一题
|
|
|
+ if (state.questionList.length === state.currentIndex + 1) {
|
|
|
+ state.visiableSure = true
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ swipeRef.value?.next()
|
|
|
+ } catch {
|
|
|
+ //
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ onMounted(() => {
|
|
|
+ getExamDetails()
|
|
|
+ })
|
|
|
return () => (
|
|
|
<div class={styles.unitDetail}>
|
|
|
<Cell center class={styles.unitSection}>
|
|
|
{{
|
|
|
- title: () => <div class={styles.unitTitle}>长笛level1上册测验一</div>,
|
|
|
+ title: () => <div class={styles.unitTitle}>{state.examDetail.unitExaminationName}</div>,
|
|
|
label: () => (
|
|
|
<div class={styles.unitCount}>
|
|
|
<div class={styles.qNums}>
|
|
|
<Icon class={styles.icon} name={iconQuestionNums} />
|
|
|
- 题目数量 <span class={styles.num}>1</span>/4
|
|
|
+ 题目数量{' '}
|
|
|
+ <span class={styles.num} style={{ paddingLeft: '6px' }}>
|
|
|
+ {state.currentIndex + 1}
|
|
|
+ </span>
|
|
|
+ /{state.examDetail.questionNum}
|
|
|
</div>
|
|
|
<div class={styles.qNums}>
|
|
|
<Icon class={styles.icon} name={iconCountDown} />
|
|
|
剩余时长:
|
|
|
<CountDown
|
|
|
ref={countDownRef}
|
|
|
- time={state.time}
|
|
|
+ v-model:time={state.time}
|
|
|
format={'mm:ss'}
|
|
|
autoStart={false}
|
|
|
/>
|
|
@@ -88,21 +151,44 @@ export default defineComponent({
|
|
|
state.currentIndex = index
|
|
|
}}
|
|
|
>
|
|
|
- <SwipeItem>
|
|
|
- <ChoiceQuestion v-model:value={state.answerList[0]} type="checkbox" />
|
|
|
- </SwipeItem>
|
|
|
- <SwipeItem>
|
|
|
- <ChoiceQuestion v-model:value={state.answerList[1]} type="radio" />
|
|
|
- </SwipeItem>
|
|
|
- <SwipeItem>
|
|
|
- <DragQuestion />
|
|
|
- </SwipeItem>
|
|
|
- <SwipeItem>
|
|
|
- <KeepLookQuestion />
|
|
|
- </SwipeItem>
|
|
|
- <SwipeItem>
|
|
|
- <PlayQuestion />
|
|
|
- </SwipeItem>
|
|
|
+ {state.questionList.map((item: any, index: number) => (
|
|
|
+ // item.questionTypeCode === QuestionType.PLAY && (
|
|
|
+ // <SwipeItem>
|
|
|
+ // <KeepLookQuestion v-model:value={item.userAnswer} data={item} index={index + 1} />
|
|
|
+ // <PlayQuestion
|
|
|
+ // v-model:value={item.userAnswer}
|
|
|
+ // data={item}
|
|
|
+ // index={index + 1}
|
|
|
+ // unitId={state.id as any}
|
|
|
+ // />
|
|
|
+ // </SwipeItem>
|
|
|
+ // )
|
|
|
+ <SwipeItem>
|
|
|
+ {item.questionTypeCode === QuestionType.RADIO && (
|
|
|
+ <ChoiceQuestion
|
|
|
+ v-model:value={item.userAnswer}
|
|
|
+ index={index + 1}
|
|
|
+ data={item}
|
|
|
+ type="radio"
|
|
|
+ />
|
|
|
+ )}
|
|
|
+ {item.questionTypeCode === QuestionType.CHECKBOX && (
|
|
|
+ <ChoiceQuestion
|
|
|
+ v-model:value={item.userAnswer}
|
|
|
+ index={index + 1}
|
|
|
+ data={item}
|
|
|
+ type="checkbox"
|
|
|
+ />
|
|
|
+ )}
|
|
|
+ {item.questionTypeCode === QuestionType.SORT && (
|
|
|
+ <DragQuestion v-model:value={item.userAnswer} data={item} index={index + 1} />
|
|
|
+ )}
|
|
|
+ {item.questionTypeCode === QuestionType.LINK && (
|
|
|
+ <KeepLookQuestion v-model:value={item.userAnswer} data={item} index={index + 1} />
|
|
|
+ )}
|
|
|
+ {item.questionTypeCode === QuestionType.PLAY && <PlayQuestion />}
|
|
|
+ </SwipeItem>
|
|
|
+ ))}
|
|
|
</Swipe>
|
|
|
|
|
|
<OSticky position="bottom" background="white">
|
|
@@ -124,16 +210,12 @@ export default defineComponent({
|
|
|
block
|
|
|
round
|
|
|
type="primary"
|
|
|
- onClick={() => {
|
|
|
- if (state.questionList.length - 1 === state.currentIndex) {
|
|
|
- state.visiableSure = true
|
|
|
- } else {
|
|
|
- // swipeRef.value?.next()
|
|
|
- state.visiableError = true
|
|
|
- }
|
|
|
- }}
|
|
|
+ onClick={onNextQuestion}
|
|
|
+ loading={state.nextStatus}
|
|
|
+ disabled={state.nextStatus}
|
|
|
>
|
|
|
- {state.questionList.length - 1 === state.currentIndex ? '测验完成' : '下一题'}
|
|
|
+ 提交
|
|
|
+ {/* {state.questionList.length === state.currentIndex + 1 ? '提交' : '提交'} */}
|
|
|
</Button>
|
|
|
<Image
|
|
|
src={iconButtonList}
|