Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
center-exam-show
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
center-exam-show
Commits
26b4b778
提交
26b4b778
authored
7月 23, 2021
作者:
lihuihui
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 新增解答题
上级
9d79903a
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
96 行增加
和
38 行删除
+96
-38
base_api.js
src/api/base_api.js
+10
-11
answerCard.vue
src/components/exam/answerCard.vue
+1
-0
question.vue
src/components/exam/question.vue
+47
-1
examAnswer.vue
src/pages/exam/examAnswer.vue
+38
-26
没有找到文件。
src/api/base_api.js
浏览文件 @
26b4b778
...
...
@@ -2,7 +2,7 @@ import axios from 'axios'
import
_
from
'lodash'
export
default
class
API
{
constructor
(
config
)
{
constructor
(
config
)
{
/* 创建一个 自定义配置axios实例 */
// 让ajax携带cookie
axios
.
defaults
.
withCredentials
=
true
...
...
@@ -22,12 +22,12 @@ export default class API {
}
/* 获取当前Vue创建实例 */
getVueInstance
()
{
getVueInstance
()
{
return
window
.
G
.
$instance_vue
}
/* 重新封装 请求时的执行函数 */
_request
(
_config
=
{})
{
_request
(
_config
=
{})
{
/* 具体执行请求成功后业务逻辑前,先执行该方法 */
const
beforeSuccess
=
_config
.
beforeSuccess
?
_config
.
beforeSuccess
:
this
.
_reqSuccess
/* 具体执行请求失败后业务逻辑前,先执行该方法 */
...
...
@@ -57,8 +57,7 @@ export default class API {
_config
.
data
=
fr
}
/* 创建并根据参数发起请求 */
return
this
.
_axios
(
_config
)
.
then
(
beforeSuccess
.
bind
(
this
),
beforeFail
.
bind
(
this
))
return
this
.
_axios
(
_config
).
then
(
beforeSuccess
.
bind
(
this
),
beforeFail
.
bind
(
this
))
}
/**
...
...
@@ -66,7 +65,7 @@ export default class API {
* 注意:如果不能满足需求,可在接口定义处重新实现
* @param {[object]} res 返回数据
*/
_reqSuccess
(
res
)
{
_reqSuccess
(
res
)
{
const
{
status
,
data
}
=
res
let
err
=
null
if
(
status
===
200
)
{
...
...
@@ -82,7 +81,7 @@ export default class API {
* 注意:如果不能满足需求,可在接口定义处重新实现
* @param {[object]} res 如果未到达 response 阶段,则无res.response
*/
_reqFail
(
res
)
{
_reqFail
(
res
)
{
let
err
=
null
if
(
res
.
code
===
'ECONNABORTED'
)
{
err
=
new
Error
(
'网络超时,请稍后重试'
)
...
...
@@ -111,22 +110,22 @@ export default class API {
}
/* 重新实现 get请求 */
get
(
url
,
data
,
config
)
{
get
(
url
,
data
,
config
)
{
return
this
.
_request
(
_
.
assignIn
({
url
,
method
:
'GET'
,
params
:
data
},
config
))
}
/* 重新实现 post请求 */
post
(
url
,
data
,
config
)
{
post
(
url
,
data
,
config
)
{
return
this
.
_request
(
_
.
assignIn
({
url
,
method
:
'POST'
,
data
:
data
},
config
))
}
/* 重新实现 put请求 */
put
(
url
,
data
,
config
)
{
put
(
url
,
data
,
config
)
{
return
this
.
_request
(
_
.
assignIn
({
url
,
method
:
'PUT'
,
data
:
data
},
config
))
}
/* 重新实现 delete请求 */
delete
(
url
,
data
,
config
)
{
delete
(
url
,
data
,
config
)
{
return
this
.
_request
(
_
.
assignIn
({
url
,
method
:
'DELETE'
,
params
:
data
},
config
))
}
}
src/components/exam/answerCard.vue
浏览文件 @
26b4b778
...
...
@@ -138,6 +138,7 @@ export default {
},
methods
:
{
goQuestion
(
n
)
{
this
.
$emit
(
'switchQuestion'
)
this
.
questionParams
.
questionIndex
=
n
-
1
}
}
...
...
src/components/exam/question.vue
浏览文件 @
26b4b778
...
...
@@ -30,6 +30,17 @@
</
template
>
</ul>
</template>
<!-- 问答题 -->
<
template
v-if=
"questionData.question_item_type == 3"
>
<div
class=
"title-type"
>
<div
class=
"type"
>
{{
questionData
.
question_item_title
}}
</div>
<div
class=
"num"
>
{{
questionData
.
q_order
}}
/
{{
questionParams
.
question
.
total_question_count
}}
</div>
</div>
<div
class=
"title"
>
<div
class=
"num"
>
{{
questionData
.
q_order
}}
.
</div><div
class=
"des"
v-html=
"questionData.content"
></div>
</div>
<el-input
@
input=
"QAChange(questionData.question_item_id, questionData.id)"
type=
"textarea"
placeholder=
"请输入内容"
v-model=
"questionData.textContent"
></el-input>
</
template
>
<!-- 复合题 -->
<
template
v-if=
"questionData.question_item_type == 5"
>
<div
class=
"title-type"
>
...
...
@@ -89,7 +100,8 @@ export default {
return
{
questionData
:
{},
clearTime
:
null
,
setCacheTime
:
null
setCacheTime
:
null
,
textarea
:
''
}
},
beforeDestroy
()
{
...
...
@@ -142,9 +154,38 @@ export default {
this
.
questionData
[
k
]
=
item
[
k
]
})
typeof
this
.
questionData
.
options
===
'string'
&&
(
this
.
questionData
.
options
=
JSON
.
parse
(
currentItem
.
options
))
const
pId
=
this
.
questionData
.
question_item_id
const
cId
=
this
.
questionData
.
id
console
.
log
(
this
.
questionData
.
question_item_id
,
this
.
questionData
.
id
,
'321++'
)
// 问答题答案回显
if
(
this
.
questionParams
.
answerRecord
[
pId
])
{
if
(
this
.
questionParams
.
answerRecord
[
pId
][
cId
])
{
this
.
questionData
.
textContent
=
this
.
questionParams
.
answerRecord
[
pId
][
cId
].
answer
[
0
]
return
}
}
this
.
questionData
.
textContent
=
''
}
}
})
console
.
log
(
this
.
questionData
,
'===123'
,
this
.
questionParams
)
},
// 问答题回答
QAChange
(
pId
,
cId
)
{
this
.
questionParams
.
answerRecord
[
pId
]
?
this
.
questionParams
.
answerRecord
[
pId
][
cId
]
?
this
.
questionParams
.
answerRecord
[
pId
][
cId
].
answer
=
[
this
.
questionData
.
textContent
]
:
this
.
questionParams
.
answerRecord
[
pId
][
cId
]
=
{
answer
:
[
this
.
questionData
.
textContent
],
sign
:
false
}
:
this
.
questionParams
.
answerRecord
[
pId
]
=
{
[
cId
]:
{
answer
:
[
this
.
questionData
.
textContent
],
sign
:
false
}
}
this
.
$forceUpdate
()
},
// 选项选择
changeOptions
:
_
.
debounce
(
function
(
type
,
pId
,
cId
,
optId
)
{
...
...
@@ -286,6 +327,11 @@ export default {
}
</
script
>
<
style
lang=
"scss"
scoped
>
::v-deep
{
.el-textarea__inner
{
height
:
150px
;
}
}
.title-type
{
width
:
100%
;
height
:
45px
;
...
...
src/pages/exam/examAnswer.vue
浏览文件 @
26b4b778
...
...
@@ -15,6 +15,7 @@
<div
class=
"left"
ref=
"wrapper2"
>
<div>
<question
style=
"padding-bottom: 30px"
v-if=
"Object.keys(questionParams.question).length"
:contentHeight=
"contentHeight"
:questionParams=
"questionParams"
...
...
@@ -24,7 +25,12 @@
</div>
</div>
<div
class=
"right"
ref=
"wrapper"
>
<answer-card
:questionParams=
"questionParams"
:changeTime=
"changeTime"
:info=
"sInfo.info"
></answer-card>
<answer-card
:questionParams=
"questionParams"
:changeTime=
"changeTime"
:info=
"sInfo.info"
@
switchQuestion=
"switchQuestion"
></answer-card>
</div>
<ul
class=
"flag-tips"
>
<li>
...
...
@@ -221,8 +227,7 @@ export default {
const
param
=
{
answer
:
JSON
.
stringify
(
this
.
questionParams
.
answerRecord
)
}
action
.
Exam
.
endExam
(
this
.
$route
.
params
.
examId
,
param
)
.
then
(
res
=>
{
action
.
Exam
.
endExam
(
this
.
$route
.
params
.
examId
,
param
).
then
(
res
=>
{
if
(
!
n
)
{
clearInterval
(
this
.
clearTime
)
this
.
$router
.
replace
({
...
...
@@ -232,28 +237,28 @@ export default {
// this.sendExamInfo(6)
window
.
localStorage
.
setItem
(
'showflag'
,
'true'
)
})
.
catch
(
err
=>
{
if
(
err
.
message
.
indexOf
(
'error'
)
!==
-
1
)
{
this
.
$confirm
(
'网络异常,请保持网络通畅'
,
'提示'
,
{
distinguishCancelAndClose
:
true
,
confirmButtonText
:
'退出考试'
,
cancelButtonText
:
'重新提交'
,
type
:
'warning'
})
.
then
(()
=>
{
this
.
$router
.
replace
({
path
:
`/login/
${
JSON
.
parse
(
window
.
localStorage
.
getItem
(
'examInfo'
)).
exam_id
}
`
})
})
.
catch
(
action
=>
{
action
===
'cancel'
&&
this
.
endExamRequest
()
})
}
else
{
this
.
$alert
(
err
.
message
,
{
callback
:
action
=>
{}
})
}
})
//
.catch(err => {
//
if (err.message.indexOf('error') !== -1) {
//
this.$confirm('网络异常,请保持网络通畅', '提示', {
//
distinguishCancelAndClose: true,
//
confirmButtonText: '退出考试',
//
cancelButtonText: '重新提交',
//
type: 'warning'
//
})
//
.then(() => {
//
this.$router.replace({
//
path: `/login/${JSON.parse(window.localStorage.getItem('examInfo')).exam_id}`
//
})
//
})
//
.catch(action => {
//
action === 'cancel' && this.endExamRequest()
//
})
//
} else {
//
this.$alert(err.message, {
//
callback: action => {}
//
})
//
}
//
})
},
countDown
(
time
)
{
const
lefttime
=
parseInt
(
time
/
1000
)
...
...
@@ -301,11 +306,18 @@ export default {
this
.
questionParams
.
questionIndex
+
1
!==
this
.
questionParams
.
question
.
total_question_count
&&
this
.
questionParams
.
questionIndex
++
}
this
.
refreshBscroll
()
// this.initBscroll()
},
refreshBscroll
()
{
this
.
$nextTick
(()
=>
{
this
.
domBScroll
.
refresh
()
this
.
domBScroll
.
scrollTo
(
0
,
-
10
,
0
)
})
// this.initBscroll()
},
switchQuestion
()
{
console
.
log
(
1111
)
this
.
refreshBscroll
()
},
getTopic
()
{
action
.
Exam
.
getTopic
(
this
.
$route
.
params
.
examId
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论