Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
x-learn
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
x-learn
Commits
9fcde797
提交
9fcde797
authored
10月 19, 2021
作者:
lihuihui
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: 修改答题
上级
ed6d5f10
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
70 行增加
和
15 行删除
+70
-15
examCard.vue
src/components/exam/examCard.vue
+70
-15
没有找到文件。
src/components/exam/examCard.vue
浏览文件 @
9fcde797
...
...
@@ -5,13 +5,13 @@
<el-button
icon=
"el-icon-arrow-left"
circle
@
click=
"$router.back()"
></el-button>
<div
class=
"title"
>
{{
title
}}
</div>
<div
class=
"right"
>
<div
class=
"count"
>
12:00
</div>
<div
class=
"count"
>
{{
examTimeText
}}
</div>
</div>
</div>
<div
class=
"exam-main"
>
<div
class=
"left"
>
<question-list
:data=
"currentExam"
>
<template
#
index
>
{{
index
+
1
}}
/
100
</
template
>
<template
#
index
>
{{
index
+
1
}}
/
{{
data
.
questions
.
total_question_count
}}
</
template
>
</question-list>
</div>
<div
class=
"right"
>
...
...
@@ -33,7 +33,7 @@
<div
class=
"txt"
>
{{ currentItem.sign ? '已标记' : '标记' }}
</div>
</div>
<div
class=
"end-exam-btn"
>
<div
class=
"btn"
v-if=
"hasSubmitBtn"
@
click=
"submitExam"
>
交卷
</div>
<div
class=
"btn"
v-if=
"hasSubmitBtn"
@
click=
"submitExam
()
"
>
交卷
</div>
</div>
</div>
</div>
...
...
@@ -56,8 +56,12 @@ export default {
},
data
()
{
return
{
index
:
0
,
questionList
:
[]
// 所有试题
index
:
0
,
// 当前题的下标
questionList
:
[],
// 所有试题
cacheAnswerTime
:
null
,
// 缓存题计时器
countDownTime
:
null
,
// 倒计时计时器
duration
:
0
,
// 答题所用时间
examTimeText
:
''
}
},
computed
:
{
...
...
@@ -79,10 +83,53 @@ export default {
}
}
},
beforeDestroy
()
{
clearInterval
(
this
.
cacheAnswerTime
)
// 停止缓存
clearInterval
(
this
.
countDownTime
)
// 停止倒计时
},
mounted
()
{
// 缓存答题
this
.
cacheAnswerTime
=
setInterval
(()
=>
{
this
.
submitExam
(
0
)
},
3000
)
// 答题倒计时
this
.
countDown
(
this
.
data
.
remaining_times
)
this
.
duration
=
this
.
data
.
duration
||
0
console
.
log
(
this
.
questionList
)
},
methods
:
{
// 倒计时
countDown
(
time
)
{
let
sec
=
parseInt
(
time
)
clearInterval
(
this
.
countDownTime
)
this
.
countDownTime
=
setInterval
(()
=>
{
sec
--
if
(
sec
===
0
)
{
clearInterval
(
this
.
time
.
clearTime
)
this
.
$alert
(
'考试时间结束,自动提交试卷'
,
''
,
{
confirmButtonText
:
'确定'
,
callback
:
action
=>
{
this
.
submitExam
()
}
})
return
false
}
this
.
examTimeText
=
this
.
secondToDate
(
sec
)
this
.
duration
++
},
1000
)
},
secondToDate
(
result
)
{
const
h
=
Math
.
floor
(
result
/
3600
)
<
10
?
'0'
+
Math
.
floor
(
result
/
3600
)
:
Math
.
floor
(
result
/
3600
)
const
m
=
Math
.
floor
((
result
/
60
)
%
60
)
<
10
?
'0'
+
Math
.
floor
((
result
/
60
)
%
60
)
:
Math
.
floor
((
result
/
60
)
%
60
)
const
s
=
Math
.
floor
(
result
%
60
)
<
10
?
'0'
+
Math
.
floor
(
result
%
60
)
:
Math
.
floor
(
result
%
60
)
if
(
h
===
0
)
{
result
=
m
+
':'
+
s
}
else
{
result
=
h
+
':'
+
m
+
':'
+
s
}
return
result
},
// 下一题
nextQuestion
()
{
const
totalNumber
=
this
.
data
.
questions
.
total_question_count
...
...
@@ -110,12 +157,10 @@ export default {
const
item
=
this
.
questionList
[
this
.
index
].
question_list
[
0
]
item
.
sign
?
(
item
.
sign
=
false
)
:
(
item
.
sign
=
true
)
this
.
$forceUpdate
()
console
.
log
(
item
)
},
// 提交
考试
submitExam
()
{
// 提交
、缓存考试 isCache:0缓存,1提交
submitExam
(
isCache
=
1
)
{
const
id
=
this
.
data
.
id
console
.
log
(
this
.
questionList
,
id
)
const
answer
=
{}
this
.
questionList
.
forEach
(
item
=>
{
if
(
!
answer
[
item
.
question_item_id
])
answer
[
item
.
question_item_id
]
=
{}
...
...
@@ -128,25 +173,35 @@ export default {
})
const
param
=
{
sheet_id
:
id
,
status
:
1
,
// 0缓存,1提交
status
:
isCache
,
// 0缓存,1提交
answers
:
JSON
.
stringify
(
answer
),
duration
:
10
duration
:
this
.
duration
}
api
.
setCache
(
param
).
then
(
response
=>
{
this
.
$router
.
replace
({
path
:
'/testExam/result'
})
if
(
isCache
)
{
this
.
$router
.
replace
({
path
:
'/testExam/result'
})
}
})
},
// 组装试题数据
genQuestions
(
data
)
{
const
{
questions
=
[],
answers
}
=
data
let
orderNum
=
1
console
.
log
(
answers
)
if
(
!
questions
)
return
[]
this
.
questionList
=
questions
.
question_items
.
reduce
((
result
,
question
)
=>
{
question
.
question_list
.
forEach
(
list
=>
{
list
=
list
.
map
(
item
=>
{
return
{
...
item
,
user_answer
:
[]
}
let
answerData
=
{}
if
(
answers
!==
null
&&
answers
[
question
.
question_item_id
])
{
answerData
=
answers
[
question
.
question_item_id
][
item
.
id
]
}
item
.
sign
=
answerData
.
sign
||
false
item
.
qOrder
=
orderNum
++
return
{
...
item
,
user_answer
:
answerData
.
answer
||
[]
}
// return { ...item, user_answer: [] }
})
result
.
push
(
Object
.
assign
({},
question
,
{
question_list
:
list
}))
})
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论