You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

433 lines
17 KiB

"use strict";
const common_vendor = require("../../../common/vendor.js");
const common_assets = require("../../../common/assets.js");
const config_api = require("../../../config/api.js");
require("../../../uni_modules/uview-plus/index.js");
const store_modules_car = require("../../../store/modules/car.js");
const uni_modules_uviewPlus_libs_function_debounce = require("../../../uni_modules/uview-plus/libs/function/debounce.js");
if (!Array) {
const _easycom_up_count_down2 = common_vendor.resolveComponent("up-count-down");
const _easycom_up_navbar2 = common_vendor.resolveComponent("up-navbar");
const _easycom_up_icon2 = common_vendor.resolveComponent("up-icon");
const _easycom_up_popup2 = common_vendor.resolveComponent("up-popup");
const _easycom_up_textarea2 = common_vendor.resolveComponent("up-textarea");
const _easycom_up_button2 = common_vendor.resolveComponent("up-button");
(_easycom_up_count_down2 + _easycom_up_navbar2 + _easycom_up_icon2 + _easycom_up_popup2 + _easycom_up_textarea2 + _easycom_up_button2)();
}
const _easycom_up_count_down = () => "../../../uni_modules/uview-plus/components/u-count-down/u-count-down.js";
const _easycom_up_navbar = () => "../../../uni_modules/uview-plus/components/u-navbar/u-navbar.js";
const _easycom_up_icon = () => "../../../uni_modules/uview-plus/components/u-icon/u-icon.js";
const _easycom_up_popup = () => "../../../uni_modules/uview-plus/components/u-popup/u-popup.js";
const _easycom_up_textarea = () => "../../../uni_modules/uview-plus/components/u-textarea/u-textarea.js";
const _easycom_up_button = () => "../../../uni_modules/uview-plus/components/u-button/u-button.js";
if (!Math) {
(_easycom_up_count_down + _easycom_up_navbar + _easycom_up_icon + _easycom_up_popup + _easycom_up_textarea + _easycom_up_button)();
}
const _sfc_main = {
__name: "examQuestions",
setup(__props) {
function speak(text) {
const speech = new SpeechSynthesisUtterance(text);
window.speechSynthesis.speak(speech);
}
const currentNav = common_vendor.ref("1");
const types = common_vendor.ref([
"单选题",
"多选题",
"判断题"
]);
const yesNum = common_vendor.ref(0);
const noNum = common_vendor.ref(0);
let showCommit = common_vendor.ref(false);
let usecarStore = store_modules_car.carStore();
let totalExamTime = common_vendor.ref(45);
let passScore = common_vendor.ref(90);
common_vendor.onLoad((options) => {
totalExamTime.value = options.totalExamTime;
passScore.value = options.score;
});
const show = common_vendor.ref(false);
function closePopup() {
show.value = false;
}
function openPopup() {
show.value = true;
}
let showCommt = common_vendor.ref(false);
let contentStr = common_vendor.ref("");
function showCommtClose() {
showCommt.value = false;
contentStr.value = "";
}
const questionBank = common_vendor.ref({});
const questionBankList = common_vendor.ref([]);
let examInfo = common_vendor.ref([]);
let currentIndex = common_vendor.ref(0);
async function startQuestionFn() {
try {
common_vendor.index.showLoading({
title: "正在加载..."
});
let obj = {
carType: usecarStore.carInfo.carType,
stepType: usecarStore.carInfo.stepType,
city: usecarStore.carInfo.city,
examType: 1
};
const { data: res } = await config_api.startExam(obj);
common_vendor.index.hideLoading();
questionBank.value = res.questionBank[0];
questionBankList.value = res.questionBank;
initOptionArr();
examInfo.value = res;
} catch (e) {
common_vendor.index.hideLoading();
}
}
startQuestionFn();
common_vendor.watch(() => questionBankList, (newVal, oldVal) => {
yesNum.value = oldVal.value.filter((item) => item.yes).length;
noNum.value = oldVal.value.filter((item) => item.yes == 0).length;
}, { deep: true });
function initOptionArr() {
questionBank.value.optionArr = [];
let abcd = [
"a",
"b",
"c",
"d",
"e",
"f"
];
abcd.forEach((k, i) => {
let option = "option" + k;
if (questionBank.value[option]) {
let obj = {
key: k.toLocaleUpperCase(),
text: questionBank.value[option],
index: i + 1
};
questionBank.value.optionArr.push(obj);
}
});
if (questionBank.value.types == 3) {
questionBank.value.optionArr[0].key = "true";
questionBank.value.optionArr[1].key = "false";
}
}
async function nextQuestion(num) {
if (questionBank.value.types == 2 && curOption.value.ans) {
if (!curOption.value.answer) {
curOption.value.answer = curOption.value.ans;
}
if (questionBank.value.answer != curOption.value.ans && curOption.value.isNext != "next") {
curOption.value.isNext = "next";
questionBank.value.yes = 0;
return false;
} else if (questionBank.value.answer == curOption.value.ans) {
questionBank.value.yes = 1;
}
}
curOption.value = {};
currentIndex.value = currentIndex.value + num;
getQuestionFn();
}
async function getQuestionFn() {
console.log(currentIndex.value);
questionBank.value = questionBankList.value[currentIndex.value];
curOption.value = {};
curOption.value.isNext = "";
initOptionArr();
}
async function quesIdListClick(id, index) {
curOption.value = {};
currentIndex.value = index;
getQuestionFn();
show.value = false;
}
async function questionWrongColleFn() {
let isAdd = questionBank.value.isCollect == 1 ? "0" : "1";
const obj = {
"carType": usecarStore.carInfo.carType,
"isAdd": isAdd,
"questionId": questionBank.value.id,
"stepType": usecarStore.carInfo.stepType
};
await config_api.questionWrongColle(obj);
questionBank.value.isCollect = isAdd;
console.log(questionBank.value.isCollect);
}
const curOption = common_vendor.ref({});
async function chooseOption(item) {
console.log(item);
if (curOption.value.answer)
return;
if (questionBank.value.types != 2) {
if (questionBank.value.answer == item.key) {
questionBank.value.yes = 1;
currentIndex.value = currentIndex.value + 1;
curOption.value = item;
setTimeout(() => {
getQuestionFn();
}, 500);
} else {
item.answer = item.key;
curOption.value = item;
questionBank.value.yes = 0;
}
} else if (questionBank.value.types == 2) {
if (!curOption.value.ans)
curOption.value.ans = "";
if (curOption.value.ans.includes(item.key)) {
curOption.value.ans = curOption.value.ans.replace(item.key, "");
return;
}
curOption.value.ans = (curOption.value.ans + item.key).split("").sort().join("");
}
}
let remaining = common_vendor.ref(0);
let countDownRef = common_vendor.ref(null);
function handApaper() {
let arr = questionBankList.value.filter((item) => item.yes == void 0);
if (arr.length || passScore.value * 1 > yesNum.value) {
remaining.value = arr.length;
showCommit.value = true;
if (countDownRef.value) {
countDownRef.value.pause();
}
} else {
submitBtnFn();
}
}
function closeCommitPopup() {
showCommit.value = false;
if (countDownRef.value) {
countDownRef.value.start();
}
}
async function submitBtnFn() {
let wrongArr = questionBankList.value.filter((item) => item.yes != 1);
let worngId = wrongArr.map((item) => item.id).join(",");
let obj = {
"answer": null,
"carType": usecarStore.carInfo.carType,
"examId": examInfo.value.id,
"examType": 1,
"grade": questionBankList.value.length - wrongArr.length,
"isEnd": 1,
"pass": 1,
"sort": examInfo.value.sort,
"stepType": usecarStore.carInfo.stepType,
"userId": examInfo.value.userId,
"wrongQuestionIds": worngId
};
const res = await config_api.startExamDo(obj);
console.log(res);
common_vendor.index.$u.toast("已交卷");
setTimeout(() => {
common_vendor.index.navigateBack();
}, 1500);
}
function finishFn() {
common_vendor.index.$u.toast("考试时间已到,准备自动为您交卷");
setTimeout(() => {
submitBtnFn();
}, 1500);
}
function goBack() {
common_vendor.index.navigateBack();
}
return (_ctx, _cache) => {
return common_vendor.e({
a: common_vendor.sr(countDownRef, "7aaaebcc-1,7aaaebcc-0", {
"k": "countDownRef"
}),
b: common_vendor.o(finishFn),
c: common_vendor.p({
time: common_vendor.unref(totalExamTime) * 60 * 1e3,
format: "mm:ss"
}),
d: common_vendor.p({
leftText: " ",
title: "",
safeAreaInsetTop: false,
autoBack: true
}),
e: common_vendor.p({
name: "checkmark-circle-fill",
color: "#55ff7f",
size: "20"
}),
f: common_vendor.t(yesNum.value),
g: common_vendor.p({
name: "close-circle-fill",
color: "#ff0000",
size: "20"
}),
h: common_vendor.t(noNum.value),
i: common_vendor.t(common_vendor.unref(currentIndex) + 1),
j: common_vendor.t(questionBankList.value.length),
k: common_vendor.t(types.value[questionBank.value.types - 1]),
l: questionBank.value.types == 2 ? 1 : "",
m: questionBank.value.types == 3 ? 1 : "",
n: common_vendor.t(questionBank.value.title),
o: common_vendor.o(($event) => speak(questionBank.value.title)),
p: questionBank.value.img
}, questionBank.value.img ? {
q: questionBank.value.img
} : {}, {
r: common_vendor.f(questionBank.value.optionArr, (item, index, i0) => {
var _a, _b;
return common_vendor.e(questionBank.value.types == 2 && (!curOption.value.answer || curOption.value.answer == questionBank.value.answer) ? common_vendor.e({
a: (_a = curOption.value.ans) == null ? void 0 : _a.includes(item.key)
}, ((_b = curOption.value.ans) == null ? void 0 : _b.includes(item.key)) ? {
b: "7aaaebcc-4-" + i0,
c: common_vendor.p({
name: "checkmark-circle-fill",
color: "#55ff7f",
size: "20"
})
} : {}, {
d: common_vendor.t(item.key),
e: common_vendor.t(item.text)
}) : common_vendor.e({
f: !curOption.value.key && questionBank.value.types != 2
}, !curOption.value.key && questionBank.value.types != 2 ? {} : questionBank.value.answer.includes(item.key) ? {
h: "7aaaebcc-5-" + i0,
i: common_vendor.p({
name: "checkmark-circle-fill",
color: "#55ff7f",
size: "20"
})
} : {
j: "7aaaebcc-6-" + i0,
k: common_vendor.p({
name: "close-circle-fill",
color: "#ff0000",
size: "20"
})
}, {
g: questionBank.value.answer.includes(item.key),
l: questionBank.value.types != 3
}, questionBank.value.types != 3 ? {
m: common_vendor.t(item.key)
} : {}, {
n: common_vendor.t(item.text)
}), {
o: common_vendor.o(($event) => chooseOption(item))
});
}),
s: questionBank.value.types == 2 && (!curOption.value.answer || curOption.value.answer == questionBank.value.answer),
t: curOption.value.answer && questionBank.value.answer != curOption.value.answer
}, curOption.value.answer && questionBank.value.answer != curOption.value.answer ? common_vendor.e({
v: questionBank.value.types == 3
}, questionBank.value.types == 3 ? {
w: common_vendor.t(questionBank.value.answer == "false" ? "错误" : "正确")
} : {
x: common_vendor.t(questionBank.value.answer)
}, {
y: questionBank.value.types == 3
}, questionBank.value.types == 3 ? {
z: common_vendor.t(curOption.value.answer == "false" ? "错误" : "正确")
} : {
A: common_vendor.t(curOption.value.answer)
}) : {}, {
B: common_vendor.o(($event) => common_vendor.unref(uni_modules_uviewPlus_libs_function_debounce.debounce)(nextQuestion(-1), 500)),
C: common_vendor.unref(currentIndex) == 0 ? 1 : "",
D: common_vendor.unref(currentIndex) == 0,
E: common_vendor.o(($event) => common_vendor.unref(uni_modules_uviewPlus_libs_function_debounce.debounce)(nextQuestion(1), 500)),
F: common_vendor.unref(currentIndex) >= questionBankList.value.length - 1 ? 1 : "",
G: common_vendor.unref(currentIndex) >= questionBankList.value.length - 1,
H: currentNav.value == 2 || curOption.value.answer && curOption.value.answer != questionBank.value.answer
}, currentNav.value == 2 || curOption.value.answer && curOption.value.answer != questionBank.value.answer ? {
I: common_vendor.t(questionBank.value.resolving)
} : {}, {
J: common_assets._imports_0$3,
K: common_vendor.o(($event) => common_vendor.isRef(showCommt) ? showCommt.value = true : showCommt = true),
L: common_assets._imports_1$1,
M: common_vendor.o(openPopup),
N: questionBank.value.isCollect == "1"
}, questionBank.value.isCollect == "1" ? {
O: common_assets._imports_2$1
} : {
P: common_assets._imports_3$1
}, {
Q: common_vendor.o(questionWrongColleFn),
R: common_vendor.o(handApaper),
S: common_vendor.t(yesNum.value),
T: common_vendor.t(noNum.value),
U: common_vendor.t(common_vendor.unref(currentIndex) + 1),
V: common_vendor.t(questionBankList.value.length),
W: common_vendor.f(questionBankList.value, (item, index, i0) => {
return common_vendor.e({
a: common_vendor.t(index + 1),
b: index == common_vendor.unref(currentIndex)
}, index == common_vendor.unref(currentIndex) ? {} : {}, {
c: item.yes == 1 ? 1 : "",
d: item.yes == 0 ? 1 : "",
e: index,
f: common_vendor.o(($event) => quesIdListClick(item, index), index)
});
}),
X: common_vendor.o(closePopup),
Y: common_vendor.o(openPopup),
Z: common_vendor.p({
show: show.value,
mode: "bottom",
round: "20",
closeable: true
}),
aa: common_vendor.o(common_vendor.m(($event) => common_vendor.isRef(contentStr) ? contentStr.value = $event : contentStr = $event, {
trim: true
}, true)),
ab: common_vendor.p({
placeholder: "请输入反馈内容",
maxlength: "300",
modelValue: common_vendor.unref(contentStr)
}),
ac: common_vendor.o(_ctx.submitClick),
ad: common_vendor.p({
text: "提 交",
type: "primary"
}),
ae: common_vendor.o(showCommtClose),
af: common_vendor.p({
show: common_vendor.unref(showCommt),
mode: "bottom",
round: "20rpx",
closeable: true
}),
ag: common_vendor.unref(remaining)
}, common_vendor.unref(remaining) ? {} : common_vendor.unref(passScore).value * 1 > yesNum.value.value ? {} : {}, {
ah: common_vendor.unref(passScore).value * 1 > yesNum.value.value,
ai: common_vendor.t(common_vendor.unref(remaining)),
aj: common_vendor.t(questionBankList.value.length - common_vendor.unref(remaining)),
ak: common_vendor.sr(countDownRef, "7aaaebcc-12,7aaaebcc-11", {
"k": "countDownRef"
}),
al: common_vendor.p({
time: common_vendor.unref(totalExamTime) * 60 * 60 * 1e3,
format: "HH:mm"
}),
am: common_assets._imports_4$1,
an: common_vendor.unref(remaining)
}, common_vendor.unref(remaining) ? {
ao: common_vendor.o(goBack),
ap: common_vendor.o(closeCommitPopup)
} : {
aq: common_vendor.o(closeCommitPopup),
ar: common_vendor.o(submitBtnFn)
}, {
as: common_vendor.o(closeCommitPopup),
at: common_vendor.p({
show: common_vendor.unref(showCommit),
mode: "center",
round: "20rpx",
closeable: true
})
});
};
}
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-7aaaebcc"]]);
wx.createPage(MiniProgramPage);