@@ -3,10 +3,12 @@
< image src = "../../../static/images/train/bj.jpg" class = "bjImg" mode = "" > < / image >
< image src = "../../../static/images/train/bj.jpg" class = "bjImg" mode = "" > < / image >
< div class = "con-box" >
< div class = "con-box" >
< div class = "header" >
< div class = "header" >
< div > 正确率 : { { accuracyRat e} } % < / div >
< div style = "font-weight: 600;font-size: 32rpx;" > { { rows . nam e } } < / div >
< div > 用时 : { { formattedTime } } < / div >
< div class = "headerCon" >
< div class = "headBtn" v-if = "isRunning" @click="pause" > 暂停 < / div >
< div > 考试时长 : { { rows . timeLimit } } 分钟 < / div >
< div class = "headBtn" v-if = "!isRunning" @click="start" > 继续 < / div >
< div > { { formattedTime } } < / div >
< div class = "headBtn" @click ="exit()" > 退出 < / div >
< / div >
< / div >
< / div >
< div class = "problemCard" >
< div class = "problemCard" >
< div v-for = "(item,index) in problemData" :key="index" >
< div v-for = "(item,index) in problemData" :key="index" >
@@ -18,57 +20,29 @@
< span > { { item . content } } < / span >
< span > { { item . content } } < / span >
< / div >
< / div >
< div class = "options" v-if = "item.type=='single'" >
< div class = "options" v-if = "item.type=='single'" >
< div class = "opt" @click ="selected(i)" :class = "radio!==''&&i==radio ?'active':''" v-for = "(val,i) in parseOptions(item.trainChooses)" >
< div class = "opt" @click ="selected(i,index )" :class = "item.choice!==''&&i==item.choice ?'active':''" v-for = "(val,i) in parseOptions(item.trainChooses)" >
< div class = "optLab" > { { indexToLetter ( i ) } } < / div >
< div class = "optLab" > { { indexToLetter ( i ) } } < / div >
< span > { { val } } < / span >
< span > { { val } } < / span >
< / div >
< / div >
< / div >
< / div >
< div class = "options" v-if = "item.type=='multiple'" >
< div class = "options" v-if = "item.type=='multiple'" >
< div class = "opt" @click ="selected2(i)" :class = "judgment(i)?'active':''" v-for = "(val,i) in parseOptions(item.trainChooses)" >
< div class = "opt" @click ="selected2(i,index )" :class = "judgment(i,index )?'active':''" v-for = "(val,i) in parseOptions(item.trainChooses)" >
< div class = "optLab" > { { indexToLetter ( i ) } } < / div >
< div class = "optLab" > { { indexToLetter ( i ) } } < / div >
< span > { { val } } < / span >
< span > { { val } } < / span >
< / div >
< / div >
< / div >
< / div >
< div class = "options" v-if = "item.type=='judge'" >
< div class = "options" v-if = "item.type=='judge'" >
< div class = "opt" @click ="selected3('正确')" :class = "radio2 =='正确'?'active':''" >
< div class = "opt" @click ="selected3('正确',index )" :class = "item.choice =='正确'?'active':''" >
< span > 正确 < / span >
< span > 正确 < / span >
< / div >
< / div >
< div class = "opt" @click ="selected3('错误')" :class = "radio2 =='错误'?'active':''" >
< div class = "opt" @click ="selected3('错误',index )" :class = "item.choice =='错误'?'active':''" >
< span > 错误 < / span >
< span > 错误 < / span >
< / div >
< / div >
< / div >
< / div >
< div class = "analysis" v-if = "analysis" >
< div class = "analysisHead correct" v-if = "judgWhether=='正确'" >
< div > 回答正确 ! < / div >
< div > < / div >
< / div >
< div class = "analysisHead errors" v-if = "judgWhether=='错误'" >
< div > 回答错误 ! < / div >
< div > < / div >
< / div >
< div class = "analysisCon" >
< div class = "parse1" > 正确答案 : < / div >
< div class = "parse2" v-if = "item.type=='single'" style="color: #30A0FF;font-weight: bold;" > {{ String.fromCharCode ( 65 + Number ( item.answer ) ) }} . < / div >
< div class = "parse2" v-if = "item.type=='multiple'" style="color: #30A0FF;font-weight: bold;" >
< span v-for = "(val,i) in parseOptions(item.answer)" > {{ indexToLetter ( val -1 ) }} . < / span >
< / div >
< div class = "parse2" v-if = "item.type=='judge'" style="color: #30A0FF;font-weight: bold;" > {{ item.answer }} < / div >
< / div >
< div class = "analysisCon" >
< div class = "parse1" > 答案解析 : < / div >
< div class = "parse2" > { { item . answerDesc } } < / div >
< / div >
< div class = "analysisCon" >
< div class = "parse1" > 知识点 : < / div >
< div >
< el-tag style = "margin-right: 10px;" > { { item . knowledgePoint } } < / el-tag >
< / div >
< / div >
< / div >
< div class = "problemBtns" >
< div class = "problemBtns" >
< div v-if = "analysis&&judgWhether!=''&&questionIndex!=problemData.length" @click="questionIndex+=1 "> 下一题 < / div >
< div :class = "(problemData[questionIndex-1].type=='multiple'?problemData[questionIndex-1].choice.length==0:problemData[questionIndex-1].choice==='')?'events':''" @click ="submit() "> 提交答案 < / div >
< div v-else :class = "((radio===''&&radio2===''&&checkList.length==0&&isRunning)||analysis)?'events':''" @click ="submit()" > 提交答案 < / div >
< / div >
< / div >
< / template >
< / template >
< / div >
< / div >
@@ -77,25 +51,10 @@
< div class = "footerLeft" >
< div class = "footerLeft" >
< div class = "zuo" :class = "questionIndex==1?'events':''" @click ="questionIndex-=1" > < / div >
< div class = "zuo" :class = "questionIndex==1?'events':''" @click ="questionIndex-=1" > < / div >
< div class = "you" :class = "questionIndex==problemData.length?'events':''" @click ="questionIndex+=1" > < / div >
< div class = "you" :class = "questionIndex==problemData.length?'events':''" @click ="questionIndex+=1" > < / div >
< div @click ="collect(1)" style = "text-align: center;font-size: 24rpx;" v-if = "(problemData[questionIndex - 1]?.isCollect || 0)!=1" >
< image :src = "urls+'wsc.png'" mode = "" style = "width: 34rpx;height: 32rpx;" > < / image >
< div > 收藏 < / div >
< / div >
< / div >
< div @click ="collect(0 )" style = "text-align: center;font-size: 24rpx;" v-if = "(problemData[questionIndex - 1]?.isCollect || 0)==1" >
< div class = "footerBtn" @click ="complete( )" > 完成练习 < / div >
< image :src = "urls+'video-sc.png'" mode = "" style = "width: 34rpx;height: 32rpx;" > < / image >
< div > 取消 < / div >
< / div >
< / div >
< div class = "footerBtn" @click ="exit()" > 完成练习 < / div >
< div class = "footerLeft" >
< div class = "footerLeft" >
< div >
< div class = "icons" style = "background-color: #1CADF5;" > √ < / div >
< div class = "texts" style = "color: #1CADF5;" > { { correctIndex } } < / div >
< / div >
< div >
< div class = "icons" style = "background-color: #FF6668;" > × < / div >
< div class = "texts" style = "color: #FF6668;" > { { errorsIndex } } < / div >
< / div >
< div @click ="dialogVisible=true" >
< div @click ="dialogVisible=true" >
< div > < span style = "color: #1CADF5;" > { { questionIndex } } < / span > / { { problemData . length } } < / div >
< div > < span style = "color: #1CADF5;" > { { questionIndex } } < / span > / { { problemData . length } } < / div >
< div > 题号 < / div >
< div > 题号 < / div >
@@ -124,6 +83,7 @@ const { $api,urls , navTo,navBack , vacanciesTo, formatTotal, config } = inject(
import useUserStore from '@/stores/useUserStore' ;
import useUserStore from '@/stores/useUserStore' ;
import useDictStore from '@/stores/useDictStore' ;
import useDictStore from '@/stores/useDictStore' ;
const userInfo = ref ( { } ) ;
const userInfo = ref ( { } ) ;
const rows = ref ( { } ) ;
const Authorization = ref ( '' ) ;
const Authorization = ref ( '' ) ;
const radio = ref ( '' ) ;
const radio = ref ( '' ) ;
const radio2 = ref ( '' ) ;
const radio2 = ref ( '' ) ;
@@ -131,9 +91,7 @@ const checkList = ref([]);
const questionIndex = ref ( 1 ) ;
const questionIndex = ref ( 1 ) ;
const correctIndex = ref ( 0 ) ;
const correctIndex = ref ( 0 ) ;
const errorsIndex = ref ( 0 ) ;
const errorsIndex = ref ( 0 ) ;
const accuracyRate = ref ( 0 ) ;
const elapsedTime = ref ( 0 ) ;
const elapsedTime = ref ( 0 ) ;
const analysis = ref ( false ) ;
const judgWhether = ref ( '' ) ;
const judgWhether = ref ( '' ) ;
const isRunning = ref ( false ) ;
const isRunning = ref ( false ) ;
const dialogVisible = ref ( false ) ;
const dialogVisible = ref ( false ) ;
@@ -149,7 +107,6 @@ watch(questionIndex, (newVal, oldVal) => {
radio . value = ""
radio . value = ""
radio2 . value = ""
radio2 . value = ""
checkList . value = [ ]
checkList . value = [ ]
analysis . value = false
judgWhether . value = ""
judgWhether . value = ""
} ) ;
} ) ;
@@ -161,6 +118,7 @@ watch(questionIndex, (newVal, oldVal) => {
// });
// });
onLoad ( ( options ) => {
onLoad ( ( options ) => {
rows . value = options
Authorization . value = uni . getStorageSync ( 'Padmin-Token' ) || ''
Authorization . value = uni . getStorageSync ( 'Padmin-Token' ) || ''
getHeart ( ) ;
getHeart ( ) ;
} ) ;
} ) ;
@@ -201,16 +159,57 @@ function queryData(){
'Authorization' : Authorization . value ,
'Authorization' : Authorization . value ,
'Content-Type' : "application/x-www-form-urlencoded"
'Content-Type' : "application/x-www-form-urlencoded"
}
}
$api . myRequest ( '/train/public/trainPractice/getQuestions' , {
if ( rows . value . types == 1 ) {
userId : userInfo . value . userId
$api . myRequest ( '/train/public/trainExamDash/getExamTopicNoAnswer' , {
userId : userInfo . value . userId ,
examPaperId : rows . value . examPaperId
} , 'post' , 9100 , header ) . then ( ( resData ) => {
} , 'post' , 9100 , header ) . then ( ( resData ) => {
resData . forEach ( ( item , i ) => {
if ( resData && resData . code == 200 ) {
elapsedTime . value = ( rows . value . timeLimit * 60 )
resData . data . forEach ( ( item , i ) => {
if ( item . type == 'multiple' ) {
item . choice = [ ]
} else {
item . choice = ""
}
problemData . value . push ( item )
problemData . value . push ( item )
problemList . value . push ( { index : i + 1 , whether : "" } )
problemList . value . push ( { index : i + 1 , whether : "" } )
} )
} )
start ( )
start ( )
accuracyRates ( )
}
} ) ;
} ) ;
} else if ( rows . value . types == 2 ) {
$api . myRequest ( '/train/public/trainExamDash/continueExam' , {
userId : userInfo . value . userId ,
examPaperId : rows . value . examPaperId
} , 'post' , 9100 , header ) . then ( ( resData ) => {
if ( resData && resData . code == 200 ) {
elapsedTime . value = ( rows . value . timeLimit * 60 )
resData . data . forEach ( ( item , i ) => {
if ( item . type == 'multiple' ) {
if ( item . choosed ) {
item . choice = item . choosed . split ( "," ) ;
item . submitAnswers = true
} else {
item . choice = [ ]
item . submitAnswers = false
}
} else {
if ( item . choosed ) {
item . choice = item . choosed ;
item . submitAnswers = true
item . submitAnswers = false
} else {
item . choice = ""
}
}
problemData . value . push ( item )
problemList . value . push ( { index : i + 1 , whether : "" } )
} )
start ( )
}
} ) ;
}
}
}
function collect ( is ) {
function collect ( is ) {
let header = {
let header = {
@@ -225,76 +224,102 @@ function collect(is){
problemData . value [ questionIndex . value - 1 ] . isCollect = is
problemData . value [ questionIndex . value - 1 ] . isCollect = is
} ) ;
} ) ;
} ;
} ;
//正确率
function accuracyRates ( ) {
let header = {
'Authorization' : Authorization . value ,
'Content-Type' : "application/x-www-form-urlencoded"
}
$api . myRequest ( '/train/public/trainPractice/getCount' , {
userId : userInfo . value . userId ,
} , 'post' , 9100 , header ) . then ( ( resData ) => {
accuracyRate . value = resData . truePresent
} ) ;
} ;
//提交答案
//提交答案
function submit ( ) {
function submit ( ) {
let indexs = questionIndex . value - 1
let indexs = questionIndex . value - 1
let parm = {
let parm = {
examPaperId : rows . value . examPaperId ,
questionId : problemData . value [ indexs ] . questionId ,
questionId : problemData . value [ indexs ] . questionId ,
userId : userInfo . value . userId ,
userId : userInfo . value . userId ,
answer : problemData . value [ indexs ] . answer
answer : problemData . value [ indexs ] . type == 'multiple' ? problemData . value [ indexs ] . choice . join ( "," ) : problemData . value [ indexs ] . choice ,
}
examId : problemData . value [ indexs ] . examId
if ( problemData . value [ indexs ] . type == 'single' ) {
parm . submitAnswer = radio . value
} else if ( problemData . value [ indexs ] . type == 'multiple' ) {
parm . submitAnswer = checkList . value . join ( ',' )
} else if ( problemData . value [ indexs ] . type == 'judge' ) {
parm . submitAnswer = radio2 . value
}
}
let header = {
let header = {
'Authorization' : Authorization . value ,
'Authorization' : Authorization . value ,
'Content-Type' : "application/json "
'Content-Type' : "application/x-www-form-urlencoded "
}
}
$api . myRequest ( '/train/public/trainPractice /submitAnswer' , parm , 'post' , 9100 , header ) . then ( ( resData ) => {
$api . myRequest ( '/train/public/trainExamDash /submitAnswer' , parm , 'post' , 9100 , header ) . then ( ( resData ) => {
if ( resData && resData . code == 200 ) {
if ( resData && resData . code == 200 ) {
analysis . value = true
problemData . value [ indexs ] . submitAnswers = true
judgWhether . value = resData . msg
if ( problemData . value . length == questionIndex . value ) {
problemList . value [ indexs ] . whether = resData . msg
$api . msg ( '已经是最后一题了,请仔细检查后交卷!' )
if ( resData . msg == '正确' ) {
} else {
correct Index. value ++
question Index. value += 1
} else if ( resData . msg == '错误' ) {
errorsIndex . value ++
}
}
accuracyRates ( )
}
}
} ) ;
} ) ;
} ;
} ;
function selected ( i ) {
//完成练习
radio . value = i
function complete ( ) {
let arr = [ ]
problemData . value . forEach ( ( item , index ) => {
if ( ! item . submitAnswers ) {
arr . push ( index + 1 )
}
} )
wx . showModal ( {
title : '提示' ,
content : ( arr . length > 0 ? '第' + arr . join ( "," ) + '题还未作答,' : '请仔细检查试卷 , ' ) + '确认是否交卷?' ,
success ( res ) {
if ( res . confirm ) {
onpaper ( )
} else if ( res . cancel ) {
console . log ( '用户点击取消' )
}
}
} )
} ;
function onpaper ( ) {
let indexs = questionIndex . value - 1
let parm = {
examPaperId : rows . value . examPaperId ,
userId : userInfo . value . userId ,
examId : problemData . value [ indexs ] . examId ,
useTime : ( rows . value . timeLimit * 60 ) - elapsedTime . value ,
}
let header = {
'Authorization' : Authorization . value ,
'Content-Type' : "application/x-www-form-urlencoded"
}
$api . myRequest ( '/train/public/trainExamDash/submitExam' , parm , 'post' , 9100 , header ) . then ( ( resData ) => {
if ( resData && resData . code == 200 ) {
$api . msg ( '提交成功!' )
navBack ( )
}
} ) ;
} ;
function selected ( i , index ) {
problemData . value [ index ] . choice = i
problemData . value = JSON . parse ( JSON . stringify ( problemData . value ) )
} ;
} ;
//多选
//多选
function selected2 ( i ) {
function selected2 ( i , indexs ){
let arr = checkList . valu e. join ( "," )
let arr = problemData . value [ indexs ] . choic e. join ( "," )
if ( arr . indexOf ( i ) !== - 1 ) {
if ( arr . indexOf ( i ) !== - 1 ) {
const index = checkList . valu e. indexOf ( i ) ;
const index = problemData . value [ indexs ] . choic e. indexOf ( i ) ;
if ( index !== - 1 ) {
if ( index !== - 1 ) {
checkList . valu e. splice ( index , 1 ) ;
problemData . value [ indexs ] . choic e. splice ( index , 1 ) ;
}
}
} else {
} else {
checkList . valu e. push ( i )
problemData . value [ indexs ] . choic e. push ( i )
}
}
problemData . value = JSON . parse ( JSON . stringify ( problemData . value ) )
} ;
} ;
function judgment ( i ) {
function judgment ( i , indexs ){
let arr = checkList . valu e. join ( "," )
let arr = problemData . value [ indexs ] . choic e. join ( "," )
if ( arr . indexOf ( i ) !== - 1 ) {
if ( arr . indexOf ( i ) !== - 1 ) {
return true
return true
} else {
} else {
return false
return false
}
}
} ;
} ;
function selected3 ( i ) {
function selected3 ( i , index ){
radio2. value = i
// radio2.value=i
problemData . value [ index ] . choice = i
problemData . value = JSON . parse ( JSON . stringify ( problemData . value ) )
} ;
} ;
// 解析选项
// 解析选项
function parseOptions ( options ) {
function parseOptions ( options ) {
@@ -320,14 +345,16 @@ function start() {
if ( isRunning . value ) return
if ( isRunning . value ) return
isRunning . value = true
isRunning . value = true
timer = setInterval ( ( ) => {
timer = setInterval ( ( ) => {
elapsedTime . value ++
elapsedTime . value -= 1
if ( elapsedTime . value == 0 ) {
// this.$message({
// message: '考试时间已结束,系统将自动交卷',
// type: 'warning'
// });
onpaper ( )
}
} , 1000 )
} , 1000 )
} ;
} ;
function pause ( ) {
if ( ! isRunning . value ) return
clearInterval ( timer )
isRunning . value = false
} ;
function clones ( ) {
function clones ( ) {
dialogVisible . value = false
dialogVisible . value = false
} ;
} ;
@@ -336,7 +363,17 @@ function switchs(i){
dialogVisible . value = false
dialogVisible . value = false
} ;
} ;
function exit ( ) {
function exit ( ) {
wx . showModal ( {
title : '提示' ,
content : '直接退出是不计分的, 确定要退出吗?' ,
success ( res ) {
if ( res . confirm ) {
navBack ( )
navBack ( )
} else if ( res . cancel ) {
console . log ( '用户点击取消' )
}
}
} )
}
}
< / script >
< / script >
@@ -360,15 +397,16 @@ function exit(){
padding : 20 rpx 28 rpx ;
padding : 20 rpx 28 rpx ;
box - sizing : border - box ;
box - sizing : border - box ;
. header {
. header {
height : 10 0 rpx ;
height : 11 0 rpx ;
padding : 0 10 rpx ;
padding : 1 0rpx 10 rpx 0 ;
display : flex ;
align - items : center ;
justify - content : space - between ;
background : linear - gradient ( 0 deg , # 4285 EC 0 % , # 0 BBAFB 100 % ) ;
background : linear - gradient ( 0 deg , # 4285 EC 0 % , # 0 BBAFB 100 % ) ;
color : # fff ;
color : # fff ;
font - size : 26 rpx ;
font - size : 26 rpx ;
border - radius : 10 rpx
border - radius : 10 rpx
. headerCon {
display : flex ;
align - items : center ;
justify - content : space - between ;
. headBtn {
. headBtn {
background : # 499 FFF ;
background : # 499 FFF ;
border - radius : 4 px ;
border - radius : 4 px ;
@@ -378,6 +416,8 @@ function exit(){
line - height : 50 rpx ;
line - height : 50 rpx ;
}
}
}
}
}
. problemCard {
. problemCard {
margin - top : 30 rpx ;
margin - top : 30 rpx ;
. problemTitle {
. problemTitle {