Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
self-support
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李俊赕
self-support
Commits
9e03467d
Commit
9e03467d
authored
May 26, 2021
by
linwenqing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:考试bug修复
parent
d98f46a0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
201 additions
and
256 deletions
+201
-256
learn.js
src/common/api/learn.js
+5
-1
learn.vue
src/pages/index/learn.vue
+43
-44
answer.vue
src/pages/learn/answer.vue
+128
-185
assessment.vue
src/pages/learn/assessment.vue
+25
-26
No files found.
src/common/api/learn.js
View file @
9e03467d
...
...
@@ -18,8 +18,12 @@ let learnApiFun = function(vm){
/* 获取考试结果 */
let
getExamResult
=
async
(
examId
,
params
=
{})
=>
await
vm
.
$u
.
post
(
sysApiUrl
+
'/wxh-worker-rest/rest/exam/serviceRule/userExamInfo/'
+
vm
.
vuex_token
+
'?examId='
+
examId
,
params
);
/* 申请考试 */
let
applyExam
=
async
(
examId
,
params
=
{})
=>
await
vm
.
$u
.
post
(
sysApiUrl
+
'/wxh-worker-rest/rest/exam/serviceRule/'
+
vm
.
vuex_token
+
'?examId='
+
examId
,
params
);
/* 获取下一题 */
let
getNextQuestion
=
async
(
userExamId
,
questionId
,
userAnswerIds
,
params
=
{})
=>
await
vm
.
$u
.
post
(
sysApiUrl
+
'/wxh-worker-rest/rest/exam/serviceRule/next/'
+
vm
.
vuex_token
+
'?userExamId='
+
userExamId
+
'&questionId='
+
questionId
+
'&userAnswerIds='
+
(
userAnswerIds
||
"9999"
),
params
);
const
learnApi
=
{
getTrainingNoticeList
,
CourseList
,
ChapterDetails
,
CourseSection
,
updateLearnCourses
,
getExamResult
getTrainingNoticeList
,
CourseList
,
ChapterDetails
,
CourseSection
,
updateLearnCourses
,
getExamResult
,
applyExam
,
getNextQuestion
}
return
learnApi
}
...
...
src/pages/index/learn.vue
View file @
9e03467d
...
...
@@ -695,55 +695,54 @@ export default {
let
length
=
this
.
examList
.
length
;
for
(
let
i
=
0
;
i
<
length
;
i
++
)
{
let
examId
=
this
.
examList
[
i
].
id
;
this
.
$u
.
api
.
getExamResult
(
examId
)
.
then
((
res
)
=>
{
if
(
res
.
code
!=
200
)
{
console
.
log
(
"getUserExamInfo 200 err"
);
uni
.
showToast
({
icon
:
"none"
,
title
:
"获取考试信息失败"
,
});
}
this
.
examList
[
i
].
examId
=
res
.
data
.
id
;
this
.
examList
[
i
].
examStatus
=
res
.
data
.
examStatus
;
//i;//
this
.
examList
[
i
].
questionTime
=
res
.
data
.
questionTime
;
let
examResult
=
res
.
data
.
examLevelResult
;
this
.
examList
[
i
].
status
=
examResult
!=
""
?
examResult
:
"未通过"
;
//动态获取条件
let
ruleDisc
=
res
.
data
.
ruleDisc
;
let
targetIndex
=
ruleDisc
.
indexOf
(
"("
);
if
(
targetIndex
)
{
this
.
examList
[
i
].
condition
=
ruleDisc
.
substr
(
targetIndex
+
1
)
.
replace
(
")"
,
""
);
}
// examStatus 用户考试状态 0考试中 1考试完成 2未参与
that
.
exam
=
res
.
data
;
if
(
res
.
data
.
examStatus
==
2
)
{
return
;
}
if
(
res
.
data
.
examStatus
==
1
)
{
that
.
examList
[
i
].
isComplete
=
this
.
examList
[
i
].
status
==
"已通过"
;
that
.
examScore
=
res
.
data
.
examScore
;
return
;
}
if
(
res
.
data
.
examStatus
==
0
)
{
that
.
userExamId
=
res
.
data
.
id
;
}
})
.
catch
((
err
)
=>
{
uni
.
hideLoading
();
this
.
$u
.
api
.
getExamResult
(
examId
)
.
then
((
res
)
=>
{
if
(
res
.
code
!=
200
)
{
console
.
log
(
"getUserExamInfo 200 err"
);
uni
.
showToast
({
icon
:
"none"
,
title
:
"获取考试信息失败"
,
});
}
this
.
examList
[
i
].
examId
=
res
.
data
.
id
;
this
.
examList
[
i
].
examStatus
=
res
.
data
.
examStatus
;
//i;//
this
.
examList
[
i
].
questionTime
=
res
.
data
.
questionTime
;
let
examResult
=
res
.
data
.
examLevelResult
;
this
.
examList
[
i
].
status
=
examResult
!=
""
?
examResult
:
"未通过"
;
//动态获取条件
let
ruleDisc
=
res
.
data
.
ruleDisc
;
let
targetIndex
=
ruleDisc
.
indexOf
(
"("
);
if
(
targetIndex
)
{
this
.
examList
[
i
].
condition
=
ruleDisc
.
substr
(
targetIndex
+
1
)
.
replace
(
")"
,
""
);
}
// examStatus 用户考试状态 0考试中 1考试完成 2未参与
that
.
exam
=
res
.
data
;
if
(
res
.
data
.
examStatus
==
2
)
{
return
;
}
if
(
res
.
data
.
examStatus
==
1
)
{
that
.
examList
[
i
].
isComplete
=
this
.
examList
[
i
].
status
==
"已通过"
;
that
.
examScore
=
res
.
data
.
examScore
;
return
;
}
if
(
res
.
data
.
examStatus
==
0
)
{
that
.
userExamId
=
res
.
data
.
id
;
}
})
.
catch
((
err
)
=>
{
uni
.
hideLoading
();
uni
.
showToast
({
icon
:
"none"
,
title
:
"获取考试信息失败"
,
});
});
}
},
//跳转到assessment页面
...
...
src/pages/learn/answer.vue
View file @
9e03467d
...
...
@@ -95,7 +95,8 @@ export default {
timer
:
null
,
isComplete
:
false
,
// 是否已经考试完成判定
examInfo
:
null
,
isLoadQuestion
:
true
isLoadQuestion
:
true
,
isOnLoad
:
true
};
},
computed
:
{
...
...
@@ -116,9 +117,8 @@ export default {
getApp
().
trackPage
(
'学习考试答题页'
)
this
.
examId
=
e
.
examId
;
this
.
userExamId
=
e
.
userExamId
;
this
.
getNext
();
// this.applyExam();
// this.getUserExamInfo();
this
.
getUserExamInfo
();
// this.getNext();
},
onUnload
()
{
clearTimeout
(
this
.
timer
);
...
...
@@ -176,14 +176,6 @@ export default {
const
result
=
txt
.
replace
(
reg
,
""
);
return
result
;
},
//开始考试 点击
startClick
:
function
()
{
this
.
isStart
=
true
;
//this.getData()
//this.applyExam()
this
.
getUserExamInfo
();
},
gotoLogin
()
{
uni
.
navigateTo
({
url
:
"/pages/login/wxlogin"
,
...
...
@@ -197,64 +189,60 @@ export default {
});
let
that
=
this
;
uni
.
request
({
url
:
systemApiUrl
+
"/wxh-worker-rest/rest/exam"
+
"/serviceRule/userExamInfo/"
+
that
.
vuex_token
+
"?examId="
+
this
.
examId
,
method
:
"POST"
,
data
:
{
//examId:this.examId,
},
header
:
{
"Content-Type"
:
"application/x-www-form-urlencoded"
,
},
success
:
(
res
)
=>
{
uni
.
hideLoading
();
if
(
!
res
.
data
)
{
let
examId
=
that
.
examId
;
this
.
$u
.
api
.
getExamResult
(
examId
)
.
then
((
res
)
=>
{
uni
.
hideLoading
();
if
(
!
res
.
data
)
{
return
;
}
if
(
res
.
code
==
200
)
{
//examStatus 用户考试状态 0考试中 1考试完成 2未参与
if
(
res
.
data
.
examStatus
==
2
)
{
that
.
applyExam
();
return
;
}
if
(
res
.
data
.
code
==
401
||
res
.
data
.
code
==
403
)
{
//提示 提交结果失败 请再次提交
uni
.
showToast
({
icon
:
"none"
,
title
:
"获取考试结果失败,请再次尝试提交"
,
});
return
}
if
(
res
.
data
.
code
==
200
)
{
//examStatus 用户考试状态 0考试中 1考试完成 2未参与
if
(
res
.
data
.
data
.
examStatus
==
2
)
{
if
(
res
.
data
.
examStatus
==
1
)
{
if
(
that
.
isOnLoad
){
that
.
applyExam
();
that
.
isOnLoad
=
false
;
return
;
}
if
(
res
.
data
.
data
.
examStatus
==
1
)
{
that
.
isComplete
=
true
;
that
.
examScore
=
res
.
data
.
data
.
examScore
;
return
;
}
if
(
res
.
data
.
data
.
examStatus
==
0
)
{
that
.
userExamId
=
res
.
data
.
data
.
id
;
that
.
getNext
();
that
.
isComplete
=
true
;
that
.
examScore
=
res
.
data
.
examScore
;
return
;
}
if
(
res
.
data
.
examStatus
==
0
)
{
that
.
userExamId
=
res
.
data
.
id
;
let
key
=
'exma-'
+
this
.
examId
;
let
limitTime
=
uni
.
getStorageSync
(
key
);
if
(
limitTime
<
0
){
let
time
=
parseInt
(
this
.
timeDefine
[
"time-id-"
+
this
.
examId
]
);
this
.
endTime
=
time
;
this
.
currentTime
=
parseInt
(
time
*
1000
);
}
else
{
this
.
endTime
=
parseInt
(
limitTime
);
this
.
currentTime
=
parseInt
(
limitTime
*
1000
);
}
}
else
{
uni
.
showToast
({
icon
:
"none"
,
title
:
res
.
data
.
message
,
});
that
.
getNext
();
}
},
fail
:
(
e
)
=>
{
uni
.
hideLoading
();
}
else
{
uni
.
showToast
({
icon
:
"none"
,
title
:
"获取考试信息失败"
,
title
:
res
.
data
.
message
,
});
},
});
}
})
// .catch((err) => {
// uni.hideLoading();
// uni.showToast({
// icon: "none",
// title: err,
// });
// });
},
//申请考试
...
...
@@ -264,57 +252,38 @@ export default {
});
let
that
=
this
;
uni
.
request
({
url
:
systemApiUrl
+
"/wxh-worker-rest/rest/exam"
+
"/serviceRule/"
+
that
.
vuex_token
+
"?examId="
+
this
.
examId
,
method
:
"POST"
,
data
:
{
//examId:this.examId,
},
header
:
{
"Content-Type"
:
"application/x-www-form-urlencoded"
,
},
success
:
(
res
)
=>
{
uni
.
hideLoading
();
if
(
res
.
statusCode
==
401
)
{
this
.
gotoLogin
();
return
}
if
(
res
.
data
.
code
==
200
)
{
if
(
res
.
data
.
data
.
userExamId
)
{
that
.
userExamId
=
res
.
data
.
data
.
userExamId
;
//申请完考试设置倒计时总时间
let
time
=
parseInt
(
this
.
timeDefine
[
"time-id-"
+
this
.
examId
]
);
this
.
endTime
=
time
;
// let timestamp = new Date().getTime();
// this.endTime = timestamp + time * 1000;
this
.
currentTime
=
parseInt
(
time
*
1000
);
//this.formatTimeToMini(timestamp);//endTime-currentTime再格式化时间显示
that
.
getNext
();
}
}
else
{
uni
.
showToast
({
icon
:
"none"
,
title
:
res
.
data
.
message
,
});
let
examId
=
this
.
examId
;
this
.
$u
.
api
.
applyExam
(
examId
)
.
then
((
res
)
=>
{
uni
.
hideLoading
();
if
(
res
.
code
==
200
)
{
if
(
res
.
data
.
userExamId
)
{
that
.
userExamId
=
res
.
data
.
userExamId
;
//申请完考试设置倒计时总时间
let
time
=
parseInt
(
this
.
timeDefine
[
"time-id-"
+
this
.
examId
]
);
this
.
endTime
=
time
;
// let timestamp = new Date().getTime();
// this.endTime = timestamp + time * 1000;
this
.
currentTime
=
parseInt
(
time
*
1000
);
//this.formatTimeToMini(timestamp);//endTime-currentTime再格式化时间显示
that
.
getNext
();
}
},
fail
:
(
e
)
=>
{
uni
.
hideLoading
();
}
else
{
uni
.
showToast
({
icon
:
"none"
,
title
:
"申请考试 失败"
,
title
:
res
.
data
.
message
,
});
},
});
}
})
// .catch((err) => {
// uni.hideLoading();
// uni.showToast({
// icon: "none",
// title: "获取考试信息失败",
// });
// });
},
//获取下一题
...
...
@@ -333,90 +302,64 @@ export default {
});
let
that
=
this
;
uni
.
request
({
url
:
systemApiUrl
+
"/wxh-worker-rest/rest/exam"
+
"/serviceRule/next/"
+
that
.
vuex_token
+
"?userExamId="
+
this
.
userExamId
+
"&questionId="
+
questionId
+
"&userAnswerIds="
+
(
this
.
userAnswerIds
||
"9999"
)
+
","
,
// 9999超时自动下一题
method
:
"POST"
,
header
:
{
"Content-Type"
:
"application/x-www-form-urlencoded"
,
},
success
:
(
res
)
=>
{
uni
.
hideLoading
();
if
(
res
.
statusCode
==
401
)
{
this
.
gotoLogin
()
return
;
}
if
(
res
.
statusCode
==
403
){
uni
.
showToast
({
icon
:
"none"
,
title
:
"获取考试结果失败,请再次尝试提交"
,
});
return
this
.
$u
.
api
.
getNextQuestion
(
this
.
userExamId
,
questionId
,
this
.
userAnswerIds
)
.
then
((
res
)
=>
{
uni
.
hideLoading
();
if
(
res
.
code
==
200
)
{
that
.
currentItem
=
res
.
data
;
that
.
progress
=
res
.
data
.
progress
;
// if(this.isLoadQuestion){
// this.isLoadQuestion = false;
// if(!res.data.isQuestion){
// this.applyExam()
// return
// }
// let key = 'exma-' + this.examId;
// let limitTime = uni.getStorageSync(key);
// console.log(limitTime);
// // let limitTime = this.getLimitTime(that.progress);
// // console.log(limitTime);
// this.endTime = parseInt(limitTime);
// this.currentTime = parseInt(limitTime * 1000);
// }
if
(
res
.
data
.
isQuestion
)
{
let
str
=
res
.
data
.
question
.
content
;
var
wz
=
str
.
indexOf
(
"."
);
let
str1
=
str
.
substring
(
wz
+
1
);
that
.
currentItem
.
question
.
content
=
str1
.
replace
(
'*'
,
''
);
}
if
(
res
.
data
.
code
==
200
)
{
that
.
currentItem
=
res
.
data
.
data
;
that
.
progress
=
res
.
data
.
data
.
progress
;
if
(
this
.
isLoadQuestion
){
this
.
isLoadQuestion
=
false
;
if
(
!
res
.
data
.
data
.
isQuestion
){
this
.
applyExam
()
return
}
let
key
=
'exma-'
+
this
.
examId
;
let
limitTime
=
uni
.
getStorageSync
(
key
);
console
.
log
(
limitTime
);
// let limitTime = this.getLimitTime(that.progress);
// console.log(limitTime);
this
.
endTime
=
parseInt
(
limitTime
);
this
.
currentTime
=
parseInt
(
limitTime
*
1000
);
}
if
(
res
.
data
.
data
.
isQuestion
)
{
let
str
=
res
.
data
.
data
.
question
.
content
;
var
wz
=
str
.
indexOf
(
"."
);
let
str1
=
str
.
substring
(
wz
+
1
);
that
.
currentItem
.
question
.
content
=
str1
.
replace
(
'*'
,
''
);
}
if
(
res
.
data
.
data
.
answerList
)
{
that
.
handleData
();
// that.currentTime = 100
this
.
everyTime
=
getApp
().
globalData
.
questionTime
;
//每道题100s
that
.
isSelect
=
false
;
clearTimeout
(
this
.
timer
);
that
.
startCounting
();
}
else
{
that
.
isSelect
=
true
;
that
.
getUserExamInfo
();
clearTimeout
(
this
.
timer
);
this
.
isComplete
=
true
;
//用来考完试判断跳转
this
.
examInfo
=
that
.
currentItem
;
// that.bottomTitle = '完成考试,现在签约'
}
if
(
res
.
data
.
answerList
)
{
that
.
handleData
();
// that.currentTime = 100
this
.
everyTime
=
getApp
().
globalData
.
questionTime
;
//每道题100s
that
.
isSelect
=
false
;
clearTimeout
(
this
.
timer
);
that
.
startCounting
();
}
else
{
uni
.
showToast
({
icon
:
"none"
,
title
:
res
.
data
.
message
,
});
that
.
isSelect
=
true
;
that
.
getUserExamInfo
();
clearTimeout
(
this
.
timer
);
this
.
isComplete
=
true
;
//用来考完试判断跳转
this
.
examInfo
=
that
.
currentItem
;
// that.bottomTitle = '完成考试,现在签约'
}
},
fail
:
(
e
)
=>
{
uni
.
hideLoading
();
// debugger
}
else
{
uni
.
showToast
({
icon
:
"none"
,
title
:
"获取下一题 失败"
,
title
:
res
.
data
.
message
,
});
},
});
}
})
// .catch((err) => {
// uni.hideLoading();
// uni.showToast({
// icon: "none",
// title: "获取考试信息失败",
// });
// });
},
getLimitTime
(
progress
){
let
arr
=
progress
.
split
(
'/'
);
...
...
src/pages/learn/assessment.vue
View file @
9e03467d
...
...
@@ -39,9 +39,11 @@ export default {
onLoad
(
param
)
{
getApp
().
trackPage
(
'学习开始考试页'
)
this
.
examId
=
param
.
examId
;
this
.
getExamResult
();
// this.getUserExamInfo();
},
onShow
()
{
this
.
getExamResult
();
},
onUnload
()
{
uni
.
switchTab
({
url
:
'/pages/index/learn'
...
...
@@ -67,32 +69,29 @@ export default {
});
},
getExamResult
()
{
uni
.
request
({
url
:
process
.
uniEnv
.
systemUrl
.
apiUrl
+
"/wxh-worker-rest/rest/exam/serviceRule/userExamInfo/"
+
this
.
vuex_token
+
"?examId="
+
this
.
examId
,
method
:
"POST"
,
header
:
{
"Content-Type"
:
"application/x-www-from-urlencoded"
,
},
success
:
(
res
)
=>
{
uni
.
hideLoading
();
if
(
res
.
data
.
code
==
200
)
{
if
(
res
.
data
.
data
.
ruleDisc
)
{
var
str
=
res
.
data
.
data
.
ruleDisc
;
this
.
userExamId
=
res
.
data
.
data
.
id
;
let
strArr
=
str
.
split
(
"("
)[
0
].
split
(
","
);
this
.
title
=
strArr
[
0
];
this
.
score
=
strArr
[
1
];
this
.
time
=
strArr
[
2
];
this
.
ruleDisc
=
strArr
[
3
];
}
let
examId
=
this
.
examId
;
this
.
$u
.
api
.
getExamResult
(
examId
)
.
then
((
res
)
=>
{
uni
.
hideLoading
();
if
(
res
.
code
==
200
)
{
if
(
res
.
data
.
ruleDisc
)
{
var
str
=
res
.
data
.
ruleDisc
;
this
.
userExamId
=
res
.
data
.
id
;
let
strArr
=
str
.
split
(
"("
)[
0
].
split
(
","
);
this
.
title
=
strArr
[
0
];
this
.
score
=
strArr
[
1
];
this
.
time
=
strArr
[
2
];
this
.
ruleDisc
=
strArr
[
3
];
}
},
}
})
.
catch
((
err
)
=>
{
uni
.
hideLoading
();
uni
.
showToast
({
icon
:
"none"
,
title
:
"获取考试信息失败"
,
});
});
},
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment