|
|
|
@ -3,6 +3,8 @@
|
|
|
|
|
<!-- 动态渲染题目 -->
|
|
|
|
|
<view :key="question.uuid" class="question">
|
|
|
|
|
<view >
|
|
|
|
|
<text class="time-wb" v-if="dati_able===true">{{ moment.utc(totaltime * 1000).format('mm:ss') }}</text>
|
|
|
|
|
<text class="time-wb" v-if="dati_able===false">{{ tijiao_type }}</text>
|
|
|
|
|
<image :src="question.pic" mode="aspectFit" class="question-image" />
|
|
|
|
|
<!-- 单选题刘东阳 -->
|
|
|
|
|
<view v-if="question.tx==='单选题'">
|
|
|
|
@ -35,30 +37,40 @@
|
|
|
|
|
</view>
|
|
|
|
|
<view v-if="question.tx==='判断题'">
|
|
|
|
|
<view class="grid-container-pd" >
|
|
|
|
|
<view :key="index" class="grid-item">
|
|
|
|
|
<view key="2" class="grid-item">
|
|
|
|
|
<button
|
|
|
|
|
|
|
|
|
|
:style="{backgroundColor:dx===item?'blue':''}"
|
|
|
|
|
:style="{backgroundColor:pdt==='对'?'blue':''}"
|
|
|
|
|
class="choose-button"
|
|
|
|
|
@click="dx_one(item)"
|
|
|
|
|
@click="pdt_one('对')"
|
|
|
|
|
>
|
|
|
|
|
√
|
|
|
|
|
</button>
|
|
|
|
|
</view>
|
|
|
|
|
<view :key="index" class="grid-item">
|
|
|
|
|
<view key="index" class="grid-item">
|
|
|
|
|
|
|
|
|
|
</view>
|
|
|
|
|
<view :key="index" class="grid-item">
|
|
|
|
|
<view key="index+1" class="grid-item">
|
|
|
|
|
<button
|
|
|
|
|
|
|
|
|
|
:style="{backgroundColor:dx===item?'blue':''}"
|
|
|
|
|
:style="{backgroundColor:pdt==='错'?'blue':''}"
|
|
|
|
|
class="choose-button"
|
|
|
|
|
@click="dx_one(item)"
|
|
|
|
|
@click="pdt_one('错')"
|
|
|
|
|
>
|
|
|
|
|
×
|
|
|
|
|
</button>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
</view>
|
|
|
|
|
<view v-if="question.tx==='填空题'">
|
|
|
|
|
<view v-for="(tkxone,index_tkx) in question.tk" :key="index_tkx" >
|
|
|
|
|
<view class="xuhao">
|
|
|
|
|
<h3 class="xuhao_wb">{{index_tkx+1}}</h3>
|
|
|
|
|
</view>
|
|
|
|
|
<input :value="tkt[index_tkx]" @input="val=>{tkt_one_get(val.detail.value,index_tkx);}" type="text" class="tkt-input" :disabled="dati_able===false"/>
|
|
|
|
|
<text class="print-wb">{{tkxone.print}}分</text>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<!-- 填空题 -->
|
|
|
|
|
<input v-if="question.type === 'fill'" v-model="userAnswers[question.id]" placeholder="请输入答案" />
|
|
|
|
@ -98,10 +110,16 @@
|
|
|
|
|
|
|
|
|
|
<!-- 控制按钮 -->
|
|
|
|
|
<view class="controls">
|
|
|
|
|
<button @click="prevQuestion">上一题</button>
|
|
|
|
|
<button @click="nextQuestion">下一题</button>
|
|
|
|
|
|
|
|
|
|
<view v-if="tijiao_type==='正常做答'">
|
|
|
|
|
<button @click="submitAnswers" type="primary">提交答案</button>
|
|
|
|
|
<button @click="resetQuiz">重新答题</button>
|
|
|
|
|
</view>
|
|
|
|
|
<view v-if="tijiao_type==='已结束'">
|
|
|
|
|
<button type="primary">已结束</button>
|
|
|
|
|
</view>
|
|
|
|
|
<view v-if="tijiao_type==='已提交'">
|
|
|
|
|
<button type="primary">已提交</button>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
<!-- 答案反馈 -->
|
|
|
|
@ -114,10 +132,19 @@
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
import { ref } from 'vue'
|
|
|
|
|
import {onMounted, onUnmounted, ref} from 'vue'
|
|
|
|
|
import {onLoad} from "@dcloudio/uni-app";
|
|
|
|
|
import moment from "moment";
|
|
|
|
|
const zm=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
|
|
|
|
|
const dx=ref('0');
|
|
|
|
|
const moredx=ref([])
|
|
|
|
|
const pdt=ref("none")
|
|
|
|
|
const tkt=ref([])
|
|
|
|
|
const dati_able=ref(true)
|
|
|
|
|
const intervalId = ref<number | null>(null); // 修改了此处的类型定义
|
|
|
|
|
const endtime=ref('')
|
|
|
|
|
const totaltime=ref(12)
|
|
|
|
|
const tijiao_type=ref('正常做答')//已结束,已提交
|
|
|
|
|
const question=ref({
|
|
|
|
|
uuid: "e87ed72f-cecc-4ebd-9f08-34e24730797f",
|
|
|
|
|
px: 7,
|
|
|
|
@ -145,17 +172,77 @@ const question=ref({
|
|
|
|
|
zitimu: [
|
|
|
|
|
|
|
|
|
|
],
|
|
|
|
|
tx: "判断题"
|
|
|
|
|
tx: "填空题"
|
|
|
|
|
})
|
|
|
|
|
// 题目数据(模拟从接口获取)
|
|
|
|
|
function dx_one(xx:string){
|
|
|
|
|
dx.value = xx
|
|
|
|
|
if(dati_able) {
|
|
|
|
|
dx.value = xx
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
function tkt_one_get(xx:string,index:number){
|
|
|
|
|
if(dati_able) {
|
|
|
|
|
tkt.value[index] = xx;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
onLoad((options) => {
|
|
|
|
|
console.log('load', options)
|
|
|
|
|
if(options) {
|
|
|
|
|
|
|
|
|
|
console.log('options:', options.uuid)
|
|
|
|
|
uni.request({
|
|
|
|
|
url: 'http://localhost:3400/apistu/getinclassactive',
|
|
|
|
|
method: 'GET',
|
|
|
|
|
data: { // 注意:GET 请求的参数需放在 `data` 而非 `params` 字段:ml-citation{ref="8" data="citationList"}
|
|
|
|
|
uuid: options.uuid
|
|
|
|
|
},
|
|
|
|
|
success: (res) => { /* ... */
|
|
|
|
|
console.log(res.data)
|
|
|
|
|
let infor = JSON.parse(res.data.infor)
|
|
|
|
|
console.log("题目",infor)
|
|
|
|
|
console.log(infor.endtime)
|
|
|
|
|
endtime.value = infor.endtime
|
|
|
|
|
question.value=infor.tm
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if(question.value.tx==="填空题") {
|
|
|
|
|
tkt.value = new Array(question.value.tk.length).fill('');
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
function moredx_one(xx:string){
|
|
|
|
|
if(moredx.value.includes(xx)){
|
|
|
|
|
moredx.value = moredx.value.filter(x=>x.value!==xx)
|
|
|
|
|
}else {
|
|
|
|
|
moredx.value.push(xx)
|
|
|
|
|
if(dati_able) {
|
|
|
|
|
if (moredx.value.includes(xx)) {
|
|
|
|
|
moredx.value = moredx.value.filter(x => x.value !== xx)
|
|
|
|
|
} else {
|
|
|
|
|
moredx.value.push(xx)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const startTimer = () => {
|
|
|
|
|
intervalId.value = setInterval(() => {
|
|
|
|
|
if (totaltime.value >0) {
|
|
|
|
|
|
|
|
|
|
totaltime.value=moment(endtime.value).diff(moment(),'seconds')
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
stopTimer();
|
|
|
|
|
dati_able.value=false
|
|
|
|
|
tijiao_type.value='已结束'
|
|
|
|
|
}
|
|
|
|
|
}, 1000);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 停止倒计时
|
|
|
|
|
const stopTimer = () => {
|
|
|
|
|
if (intervalId.value !== null) {
|
|
|
|
|
clearInterval(intervalId.value);
|
|
|
|
|
intervalId.value = null;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
function pdt_one(xx:string){
|
|
|
|
|
if(dati_able) {
|
|
|
|
|
pdt.value = xx
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const quizData = [
|
|
|
|
@ -228,31 +315,121 @@ function resetQuiz() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function submitAnswers() {
|
|
|
|
|
const answers = quizData.map((question) => {
|
|
|
|
|
const userAnswer = userAnswers.value[question.id]
|
|
|
|
|
const correctAnswer = question.answer
|
|
|
|
|
|
|
|
|
|
// 根据题型进行比较
|
|
|
|
|
if (question.type === 'fill') {
|
|
|
|
|
return userAnswer === correctAnswer
|
|
|
|
|
} else if (question.type === 'single') {
|
|
|
|
|
return userAnswer === correctAnswer
|
|
|
|
|
} else if (question.type === 'multiple') {
|
|
|
|
|
return (
|
|
|
|
|
Array.isArray(userAnswer) &&
|
|
|
|
|
Array.isArray(correctAnswer) &&
|
|
|
|
|
userAnswer.sort().join(',') === correctAnswer.sort().join(',')
|
|
|
|
|
)
|
|
|
|
|
} else if (question.type === 'true-false') {
|
|
|
|
|
return String(userAnswer) === String(correctAnswer)
|
|
|
|
|
let resulttm={};
|
|
|
|
|
if(question.value.tx==='填空题'){
|
|
|
|
|
let result=[];
|
|
|
|
|
let print_all=0;
|
|
|
|
|
let print_stu=0;
|
|
|
|
|
console.log()
|
|
|
|
|
question.value.tk.map((tkone,indextk)=>{
|
|
|
|
|
let resultone={};
|
|
|
|
|
resultone.studaan=tkt.value[indextk];
|
|
|
|
|
resultone.stddaan=tkone.daan
|
|
|
|
|
if(tkone.daan===tkt.value[indextk]){
|
|
|
|
|
resultone.stuprint=tkone.print;
|
|
|
|
|
resultone.stdprint=tkone.print
|
|
|
|
|
print_stu+=tkone.print
|
|
|
|
|
print_all+=tkone.print
|
|
|
|
|
}else {
|
|
|
|
|
resultone.stuprint=0;
|
|
|
|
|
resultone.stdprint=tkone.print
|
|
|
|
|
print_stu+=0
|
|
|
|
|
print_all+=tkone.print
|
|
|
|
|
}
|
|
|
|
|
result.push(resultone)
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
resulttm={stu:print_stu,all:print_all,tx:question.value.tx,tkt:result}
|
|
|
|
|
console.log(resulttm)
|
|
|
|
|
}else if(question.value.tx==='多选题'){
|
|
|
|
|
|
|
|
|
|
let zq=true;
|
|
|
|
|
question.value.morechoose.map((choose_one)=>{
|
|
|
|
|
if(!moredx.value.includes(choose_one)){
|
|
|
|
|
zq=false;
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
if(question.value.morechoose.length===moredx.value.length){
|
|
|
|
|
zq=false;
|
|
|
|
|
}
|
|
|
|
|
let dxt={stu:moredx.value,all:question.value.morechoose}
|
|
|
|
|
if(zq){
|
|
|
|
|
resulttm.stu=question.value.print
|
|
|
|
|
resulttm.all=question.value.print
|
|
|
|
|
resulttm.dxt=dxt
|
|
|
|
|
}else{
|
|
|
|
|
resulttm.stu=0
|
|
|
|
|
resulttm.all=question.value.print
|
|
|
|
|
resulttm.dxt=dxt
|
|
|
|
|
}
|
|
|
|
|
console.log(resulttm)
|
|
|
|
|
}else if(question.value.tx==='单选题'){
|
|
|
|
|
|
|
|
|
|
let zq=true;
|
|
|
|
|
if(dx.value!==question.value.onechoose)zq=false;
|
|
|
|
|
let dxt={stu:dx.value,all:question.value.onechoose}
|
|
|
|
|
if(zq){
|
|
|
|
|
resulttm.stu=question.value.print
|
|
|
|
|
resulttm.all=question.value.print
|
|
|
|
|
resulttm.dxt=dxt
|
|
|
|
|
}else{
|
|
|
|
|
resulttm.stu=0
|
|
|
|
|
resulttm.all=question.value.print
|
|
|
|
|
resulttm.dxt=dxt
|
|
|
|
|
}
|
|
|
|
|
console.log(resulttm)
|
|
|
|
|
}else if(question.value.tx==='判断题'){
|
|
|
|
|
|
|
|
|
|
let zq=true;
|
|
|
|
|
let pd_work="no"
|
|
|
|
|
if(pdt.value==="对")
|
|
|
|
|
pd_work="√"
|
|
|
|
|
else if (pdt.value==="错")
|
|
|
|
|
pd_work="×"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(pd_work!==question.value.onechoose)zq=false;
|
|
|
|
|
let dxt={stu:dx.value,all:question.value.onechoose}
|
|
|
|
|
if(zq){
|
|
|
|
|
resulttm.stu=question.value.print
|
|
|
|
|
resulttm.all=question.value.print
|
|
|
|
|
resulttm.dxt=dxt
|
|
|
|
|
}else{
|
|
|
|
|
resulttm.stu=0
|
|
|
|
|
resulttm.all=question.value.print
|
|
|
|
|
resulttm.dxt=dxt
|
|
|
|
|
}
|
|
|
|
|
console.log(resulttm)
|
|
|
|
|
}
|
|
|
|
|
uni.request({
|
|
|
|
|
url: 'http://localhost:3400/apistu/addinactivestu_qiangda',
|
|
|
|
|
method: 'POST',
|
|
|
|
|
data: { // 注意:GET 请求的参数需放在 `data` 而非 `params` 字段:ml-citation{ref="8" data="citationList"}
|
|
|
|
|
uuid: uid.value,
|
|
|
|
|
kch:'202413501',
|
|
|
|
|
kctime:'n8z1A1',
|
|
|
|
|
xuehao: '202413501063',
|
|
|
|
|
time:moment().format('YYYY-MM-DD HH:mm:ss'),
|
|
|
|
|
starttime:starttime.value,
|
|
|
|
|
name:"刘东阳A",
|
|
|
|
|
touxiangcolor:"red"
|
|
|
|
|
},
|
|
|
|
|
success: (res) => { /* ... */
|
|
|
|
|
console.log(res.data)
|
|
|
|
|
|
|
|
|
|
return false
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
results.value = answers
|
|
|
|
|
showResult.value = true
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
dati_able.value=false
|
|
|
|
|
tijiao_type.value="已提交"
|
|
|
|
|
}
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
startTimer();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 页面卸载时停止倒计时
|
|
|
|
|
onUnmounted(() => {
|
|
|
|
|
stopTimer();
|
|
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
@ -300,6 +477,7 @@ function submitAnswers() {
|
|
|
|
|
{
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-wrap: wrap;
|
|
|
|
|
margin-left: 60px;
|
|
|
|
|
}
|
|
|
|
|
.grid-container {
|
|
|
|
|
display: flex;
|
|
|
|
@ -326,4 +504,37 @@ function submitAnswers() {
|
|
|
|
|
align-items: center; /* 垂直居中 */
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
}
|
|
|
|
|
.tkt-input {
|
|
|
|
|
border: 1rpx solid black;
|
|
|
|
|
border-radius: 8rpx;
|
|
|
|
|
padding: 10rpx 20rpx;
|
|
|
|
|
margin: 20rpx 0;
|
|
|
|
|
width: 60vw;
|
|
|
|
|
color: #00f0ff;
|
|
|
|
|
display: inline-block;
|
|
|
|
|
position: relative;
|
|
|
|
|
top: 24px;
|
|
|
|
|
left: 10px;
|
|
|
|
|
}
|
|
|
|
|
.xuhao{
|
|
|
|
|
width: 35px;
|
|
|
|
|
height: 35px;
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
background-color: #4a90e2;
|
|
|
|
|
display: inline-block;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
.xuhao_wb{
|
|
|
|
|
display: inline-block;
|
|
|
|
|
font-size:25px;
|
|
|
|
|
margin-left: 6px;
|
|
|
|
|
}
|
|
|
|
|
.print-wb{
|
|
|
|
|
display: inline-block;
|
|
|
|
|
margin-left: 20px;
|
|
|
|
|
}
|
|
|
|
|
.time-wb{
|
|
|
|
|
font-size: 40px;
|
|
|
|
|
margin-left: 30vw;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|