|
|
@ -1,4 +1,4 @@ |
|
|
|
import {ScrollView, Swiper, SwiperItem, View} from "@tarojs/components"; |
|
|
|
import {ScrollView, Swiper, SwiperItem, Text, View} from "@tarojs/components"; |
|
|
|
import {FC, useEffect, useState} from "react"; |
|
|
|
import {FC, useEffect, useState} from "react"; |
|
|
|
import HVideo from "@/components/video/video"; |
|
|
|
import HVideo from "@/components/video/video"; |
|
|
|
import {CurEndParam, curriculum, HourPlayData} from "@/api"; |
|
|
|
import {CurEndParam, curriculum, HourPlayData} from "@/api"; |
|
|
@ -10,6 +10,7 @@ import ShortAnswer from "@/components/topic/shortAnswer"; |
|
|
|
import unique_ident from "@/hooks/unique_ident"; |
|
|
|
import unique_ident from "@/hooks/unique_ident"; |
|
|
|
import CustomPageContainer from "@/components/custom-page-container/custom-page-container"; |
|
|
|
import CustomPageContainer from "@/components/custom-page-container/custom-page-container"; |
|
|
|
import MyButton from "@/components/button/MyButton"; |
|
|
|
import MyButton from "@/components/button/MyButton"; |
|
|
|
|
|
|
|
import {formatMinute} from "@/utils/time"; |
|
|
|
|
|
|
|
|
|
|
|
interface Props { |
|
|
|
interface Props { |
|
|
|
id: number, |
|
|
|
id: number, |
|
|
@ -100,28 +101,34 @@ const Course: FC<Props> = ({id, courseId, preview, curEnd}: Props) => { |
|
|
|
setNewRecord(record) |
|
|
|
setNewRecord(record) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function init() { |
|
|
|
function init(show = true) { |
|
|
|
record = [] |
|
|
|
record = [] |
|
|
|
setTime(0) |
|
|
|
show && setShow(false) |
|
|
|
setShow(false) |
|
|
|
|
|
|
|
setIndex(0) |
|
|
|
|
|
|
|
setValidate(false) |
|
|
|
setValidate(false) |
|
|
|
setNewRecord([]) |
|
|
|
setNewRecord([]) |
|
|
|
|
|
|
|
setTime(0) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (process.env.TARO_ENV === 'h5') { |
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
|
|
setIndex(0) |
|
|
|
|
|
|
|
}, 200) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
setIndex(0) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** 再来一次 */ |
|
|
|
/** 再来一次 */ |
|
|
|
function onceMore() { |
|
|
|
function onceMore() { |
|
|
|
const oldTime: number = time |
|
|
|
const oldTime: number = time |
|
|
|
init() |
|
|
|
init(false) |
|
|
|
setTimeout(() => { |
|
|
|
setTimeout(() => { |
|
|
|
setShow(true) |
|
|
|
|
|
|
|
setTime(oldTime) |
|
|
|
setTime(oldTime) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** 重新看 */ |
|
|
|
/** 重新看 */ |
|
|
|
function again() { |
|
|
|
function again() { |
|
|
|
if (frequency === 0 && show) { |
|
|
|
if (examAll?.[time]?.length) { |
|
|
|
const {id: question_id, question_type} = examAll?.[time]?.[0] |
|
|
|
const {id: question_id, question_type} = examAll?.[time]?.[0] |
|
|
|
curriculum.answerRecord(id, { |
|
|
|
curriculum.answerRecord(id, { |
|
|
|
is_pass: false, |
|
|
|
is_pass: false, |
|
|
@ -159,7 +166,24 @@ const Course: FC<Props> = ({id, courseId, preview, curEnd}: Props) => { |
|
|
|
seek(time) |
|
|
|
seek(time) |
|
|
|
init() |
|
|
|
init() |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
Taro.showToast({title: '答案错误', icon: 'error', duration: 3000}) |
|
|
|
if ((frequency - 1) !== 0) { |
|
|
|
|
|
|
|
Taro.showModal({ |
|
|
|
|
|
|
|
title: '考试未通过', |
|
|
|
|
|
|
|
content: '剩余考试次数:' + (frequency - 1), |
|
|
|
|
|
|
|
confirmText: '重考', |
|
|
|
|
|
|
|
success({confirm}) { |
|
|
|
|
|
|
|
confirm && onceMore() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
Taro.showModal({ |
|
|
|
|
|
|
|
title: '考试未通过', |
|
|
|
|
|
|
|
content: '请重新学习', |
|
|
|
|
|
|
|
success({confirm}) { |
|
|
|
|
|
|
|
confirm && again() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, [newRecord]) |
|
|
|
}, [newRecord]) |
|
|
|
|
|
|
|
|
|
|
@ -186,18 +210,17 @@ const Course: FC<Props> = ({id, courseId, preview, curEnd}: Props) => { |
|
|
|
position='bottom' |
|
|
|
position='bottom' |
|
|
|
round |
|
|
|
round |
|
|
|
onAfterLeave={again} |
|
|
|
onAfterLeave={again} |
|
|
|
onClickOverlay={again} |
|
|
|
|
|
|
|
> |
|
|
|
> |
|
|
|
|
|
|
|
<View className='text-center mt-2 text-muted'> |
|
|
|
|
|
|
|
<Text className='mr-2'>{formatMinute(time)}考题</Text> |
|
|
|
|
|
|
|
<Text>{index + 1}/{examAll?.[time]?.length}</Text> |
|
|
|
|
|
|
|
</View> |
|
|
|
<Swiper |
|
|
|
<Swiper |
|
|
|
style={{height: "60vh"}} |
|
|
|
style={{height: "60vh"}} |
|
|
|
snapToEdge |
|
|
|
snapToEdge |
|
|
|
current={index} |
|
|
|
current={index} |
|
|
|
onChange={(e) => { |
|
|
|
onChange={(e) => setIndex(e.detail.current)}> |
|
|
|
if ((e.target as any)?.current) { |
|
|
|
{examAll?.[time]?.map((d) => |
|
|
|
setIndex((e.target as any).current) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}}> |
|
|
|
|
|
|
|
{examAll?.[time]?.map((d, index) => |
|
|
|
|
|
|
|
<SwiperItem key={d.id}> |
|
|
|
<SwiperItem key={d.id}> |
|
|
|
<ScrollView style='height:70vh' scrollY> |
|
|
|
<ScrollView style='height:70vh' scrollY> |
|
|
|
{d.question_type === 1 && |
|
|
|
{d.question_type === 1 && |
|
|
@ -205,42 +228,50 @@ const Course: FC<Props> = ({id, courseId, preview, curEnd}: Props) => { |
|
|
|
frequency={frequency} |
|
|
|
frequency={frequency} |
|
|
|
data={d as Multi} |
|
|
|
data={d as Multi} |
|
|
|
onAnswer={onAnswer} |
|
|
|
onAnswer={onAnswer} |
|
|
|
onUpAndDown={(index) => setIndex(index)} |
|
|
|
|
|
|
|
index={index} |
|
|
|
|
|
|
|
validate={validate} |
|
|
|
validate={validate} |
|
|
|
end={index === examAll?.[time].length - 1} |
|
|
|
|
|
|
|
/>} |
|
|
|
/>} |
|
|
|
{d.question_type === 2 && |
|
|
|
{d.question_type === 2 && |
|
|
|
<Judge |
|
|
|
<Judge |
|
|
|
frequency={frequency} |
|
|
|
frequency={frequency} |
|
|
|
onUpAndDown={(index) => setIndex(index)} |
|
|
|
|
|
|
|
index={index} |
|
|
|
|
|
|
|
data={d as ShareSubject} |
|
|
|
data={d as ShareSubject} |
|
|
|
validate={validate} |
|
|
|
validate={validate} |
|
|
|
onAnswer={onAnswer} |
|
|
|
onAnswer={onAnswer} |
|
|
|
end={index === examAll?.[time].length - 1} |
|
|
|
|
|
|
|
/>} |
|
|
|
/>} |
|
|
|
{d.question_type === 3 && |
|
|
|
{d.question_type === 3 && |
|
|
|
<ShortAnswer |
|
|
|
<ShortAnswer |
|
|
|
frequency={frequency} |
|
|
|
frequency={frequency} |
|
|
|
data={d as ShareSubject} |
|
|
|
data={d as ShareSubject} |
|
|
|
onAnswer={onAnswer} |
|
|
|
onAnswer={onAnswer} |
|
|
|
onUpAndDown={(index) => setIndex(index)} |
|
|
|
|
|
|
|
index={index} |
|
|
|
|
|
|
|
validate={validate} |
|
|
|
validate={validate} |
|
|
|
end={index === examAll?.[time].length - 1} |
|
|
|
|
|
|
|
/>} |
|
|
|
/>} |
|
|
|
</ScrollView> |
|
|
|
</ScrollView> |
|
|
|
</SwiperItem> |
|
|
|
</SwiperItem> |
|
|
|
)} |
|
|
|
)} |
|
|
|
</Swiper> |
|
|
|
</Swiper> |
|
|
|
<View className='statistics'> |
|
|
|
<View> |
|
|
|
<View>{frequency}次机会</View> |
|
|
|
<View className='statistics'> |
|
|
|
<View>{index + 1}/{examAll?.[time]?.length}</View> |
|
|
|
<View>考试次数:{frequency}</View> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
(index + 1) === examAll?.[time]?.length && <View> |
|
|
|
|
|
|
|
{!validate && <MyButton width={150} fillet onClick={() => setValidate(true)}>交卷</MyButton>} |
|
|
|
|
|
|
|
{frequency > 0 && validate && <MyButton width={150} fillet onClick={onceMore}>重考</MyButton>} |
|
|
|
|
|
|
|
{frequency === 0 && validate && <MyButton width={150} fillet onClick={again}>重新学习</MyButton>} |
|
|
|
|
|
|
|
</View> |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
{!validate && <MyButton width={150} fillet onClick={() => setValidate(true)}>提交</MyButton>} |
|
|
|
</View> |
|
|
|
{frequency > 0 && validate && <MyButton width={150} fillet onClick={onceMore}>再来一次</MyButton>} |
|
|
|
<View className='upAndDown'> |
|
|
|
{frequency === 0 && validate && <MyButton width={150} fillet onClick={again}>重新学习</MyButton>} |
|
|
|
<View> |
|
|
|
|
|
|
|
{index !== 0 && <MyButton size='mini' width={150} onClick={() => setIndex(index - 1)}>上一题</MyButton>} |
|
|
|
|
|
|
|
</View> |
|
|
|
|
|
|
|
<View> |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
(index + 1) !== examAll?.[time]?.length |
|
|
|
|
|
|
|
&& <MyButton size='mini' width={150} onClick={() => setIndex(index + 1)}>下一题</MyButton> |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
</View> |
|
|
|
|
|
|
|
</View> |
|
|
|
</View> |
|
|
|
</View> |
|
|
|
</CustomPageContainer> |
|
|
|
</CustomPageContainer> |
|
|
|
</View> |
|
|
|
</View> |
|
|
|