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.
410 lines
15 KiB
410 lines
15 KiB
"use strict";
|
|
const common_vendor = require("../../../common/vendor.js");
|
|
const common_assets = require("../../../common/assets.js");
|
|
const utils_utils = require("../../../utils/utils.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_u_icon2 = common_vendor.resolveComponent("u-icon");
|
|
const _easycom_up_icon2 = common_vendor.resolveComponent("up-icon");
|
|
const _easycom_up_count_down2 = common_vendor.resolveComponent("up-count-down");
|
|
const _easycom_u_popup2 = common_vendor.resolveComponent("u-popup");
|
|
(_easycom_u_icon2 + _easycom_up_icon2 + _easycom_up_count_down2 + _easycom_u_popup2)();
|
|
}
|
|
const _easycom_u_icon = () => "../../../uni_modules/uview-plus/components/u-icon/u-icon.js";
|
|
const _easycom_up_icon = () => "../../../uni_modules/uview-plus/components/u-icon/u-icon.js";
|
|
const _easycom_up_count_down = () => "../../../uni_modules/uview-plus/components/u-count-down/u-count-down.js";
|
|
const _easycom_u_popup = () => "../../../uni_modules/uview-plus/components/u-popup/u-popup.js";
|
|
if (!Math) {
|
|
(_easycom_u_icon + _easycom_up_icon + _easycom_up_count_down + _easycom_u_popup)();
|
|
}
|
|
const _sfc_main = {
|
|
__name: "exam",
|
|
setup(__props) {
|
|
var _a;
|
|
let usecarStore = store_modules_car.carStore();
|
|
let randomNumber = "";
|
|
common_vendor.onLoad((options) => {
|
|
randomNumber = options.randomNumber;
|
|
});
|
|
const types = common_vendor.ref([
|
|
"单选题",
|
|
"多选题",
|
|
"判断题"
|
|
]);
|
|
let phone = (_a = common_vendor.index.getStorageSync("loginInfo")) == null ? void 0 : _a.phone;
|
|
const showCommit = common_vendor.ref(false);
|
|
const showNoPass = common_vendor.ref(false);
|
|
const showWrong = common_vendor.ref(false);
|
|
const show = common_vendor.ref(false);
|
|
common_vendor.onMounted(() => {
|
|
utils_utils.detectOrient("#brushQuestions");
|
|
});
|
|
function previewImg() {
|
|
show.value = true;
|
|
}
|
|
function goBack() {
|
|
common_vendor.index.navigateBack();
|
|
}
|
|
const questionBank = common_vendor.ref({});
|
|
const questionBankList = common_vendor.ref([]);
|
|
let ansCard = 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,
|
|
examType: 2
|
|
};
|
|
const { data: res } = await config_api.startExam(obj);
|
|
common_vendor.index.hideLoading();
|
|
questionBank.value = res.questionBank[0];
|
|
questionBankList.value = res.questionBank;
|
|
let size = usecarStore.carInfo.stepType == 1 ? 10 : 5;
|
|
ansCard.value = chunk(questionBankList.value, size);
|
|
initOptionArr();
|
|
examInfo.value = res;
|
|
} catch (e) {
|
|
common_vendor.index.hideLoading();
|
|
}
|
|
}
|
|
startQuestionFn();
|
|
function chunk(arr, size) {
|
|
if (arr.length == 0)
|
|
return [];
|
|
let result = [];
|
|
let tmp = [];
|
|
arr.forEach((item, index) => {
|
|
if (tmp.length == 0) {
|
|
result.push(tmp);
|
|
}
|
|
item.index = index;
|
|
tmp.push(item);
|
|
if (tmp.length == size) {
|
|
tmp = [];
|
|
}
|
|
});
|
|
return result;
|
|
}
|
|
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);
|
|
}
|
|
});
|
|
}
|
|
const curOption = common_vendor.ref({});
|
|
async function chooseOption(item) {
|
|
if (questionBank.value.answerMy)
|
|
return;
|
|
console.log(item);
|
|
if (questionBank.value.types != 2) {
|
|
item.answer = item.key;
|
|
curOption.value = item;
|
|
} else if (questionBank.value.types == 2) {
|
|
if (!curOption.value.answer)
|
|
curOption.value.answer = "";
|
|
if (curOption.value.answer.includes(item.key)) {
|
|
curOption.value.answer = curOption.value.answer.replace(item.key, "");
|
|
return;
|
|
}
|
|
curOption.value.answer = (curOption.value.answer + item.key).split("").sort().join("");
|
|
}
|
|
}
|
|
async function nextQuestion(num) {
|
|
if (curOption.value.answer) {
|
|
questionBank.value.answerMy = curOption.value.answer;
|
|
if (questionBank.value.types == 3)
|
|
questionBank.value.answerMy = curOption.value.answer == "A" ? "true" : "false";
|
|
}
|
|
if (questionBank.value.answerMy && questionBank.value.answer != questionBank.value.answerMy && curOption.value.isNext != "next") {
|
|
curOption.value.isNext = "next";
|
|
showWrong.value = true;
|
|
if (countDownRef.value) {
|
|
countDownRef.value.pause();
|
|
}
|
|
return false;
|
|
}
|
|
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 = "";
|
|
if (questionBank.value.answerMy)
|
|
curOption.value.answer = questionBank.value.answerMy;
|
|
initOptionArr();
|
|
}
|
|
function ansCardClick(item) {
|
|
currentIndex.value = item.index;
|
|
getQuestionFn();
|
|
}
|
|
let grade = common_vendor.ref(0);
|
|
async function submitBtnFn() {
|
|
if (curOption.value.answer)
|
|
questionBank.value.answerMy = curOption.value.answer;
|
|
let wrongArr = questionBankList.value.filter((item) => item.answer != item.answerMy);
|
|
let worngId = wrongArr.map((item) => item.id).join(",");
|
|
grade.value = info.value.funllScore / questionBankList.value.length * (questionBankList.value.length - wrongArr.length);
|
|
let obj = {
|
|
"answer": null,
|
|
"carType": usecarStore.carInfo.carType,
|
|
"examId": examInfo.value.id,
|
|
"examType": 2,
|
|
"grade": grade.value,
|
|
"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);
|
|
if (showCommit.value)
|
|
showCommit.value = false;
|
|
if (grade.value < info.value.score) {
|
|
showNoPass.value = true;
|
|
} else {
|
|
setTimeout(() => {
|
|
common_vendor.index.navigateBack();
|
|
}, 1500);
|
|
}
|
|
}
|
|
function finishFn() {
|
|
common_vendor.index.$u.toast("考试时间已到,准备自动为您交卷");
|
|
setTimeout(() => {
|
|
submitBtnFn();
|
|
}, 1500);
|
|
}
|
|
const countDownRef = common_vendor.ref(null);
|
|
const yesNum = common_vendor.ref(0);
|
|
const noNum = common_vendor.ref(0);
|
|
function handApaper() {
|
|
if (curOption.value.answer)
|
|
questionBank.value.answerMy = curOption.value.answer;
|
|
yesNum.value = questionBankList.value.filter((item) => item.answer == item.answerMy).length;
|
|
noNum.value = questionBankList.value.filter((item) => item.answerMy == void 0).length;
|
|
console.log(questionBankList.value);
|
|
if (noNum) {
|
|
showCommit.value = true;
|
|
if (countDownRef.value) {
|
|
countDownRef.value.pause();
|
|
}
|
|
} else {
|
|
submitBtnFn();
|
|
}
|
|
}
|
|
function closeCommitPopup() {
|
|
showCommit.value = false;
|
|
if (countDownRef.value) {
|
|
countDownRef.value.start();
|
|
}
|
|
}
|
|
function showWrongClose() {
|
|
showWrong.value = false;
|
|
if (countDownRef.value) {
|
|
countDownRef.value.start();
|
|
}
|
|
curOption.value = {};
|
|
currentIndex.value = currentIndex.value + 1;
|
|
getQuestionFn();
|
|
}
|
|
let info = common_vendor.ref({});
|
|
async function questionExamFn() {
|
|
const { data: res } = await config_api.questionExam({ stepType: usecarStore.carInfo.stepType, carType: usecarStore.carInfo.carType });
|
|
info.value = res;
|
|
}
|
|
questionExamFn();
|
|
return (_ctx, _cache) => {
|
|
return common_vendor.e({
|
|
a: common_vendor.t(common_vendor.unref(randomNumber)),
|
|
b: common_vendor.p({
|
|
name: "arrow-left",
|
|
size: "16"
|
|
}),
|
|
c: common_vendor.o(goBack),
|
|
d: common_assets._imports_0$4,
|
|
e: common_vendor.t(common_vendor.unref(phone)),
|
|
f: common_vendor.t(common_vendor.unref(usecarStore).carInfo.carTypeName),
|
|
g: common_vendor.t(common_vendor.unref(usecarStore).carInfo.stepType == 1 ? "一" : "四"),
|
|
h: common_vendor.t(common_vendor.unref(currentIndex) + 1),
|
|
i: common_vendor.t(questionBank.value.title),
|
|
j: common_vendor.f(questionBank.value.optionArr, (item, index, i0) => {
|
|
return {
|
|
a: common_vendor.t(item.key),
|
|
b: common_vendor.t(item.text)
|
|
};
|
|
}),
|
|
k: questionBank.value.types == 3
|
|
}, questionBank.value.types == 3 ? {
|
|
l: common_vendor.t(curOption.value.answer == "true" ? "A" : "B")
|
|
} : {
|
|
m: common_vendor.t(curOption.value.answer)
|
|
}, {
|
|
n: common_vendor.f(questionBank.value.optionArr, (item, index, i0) => {
|
|
var _a2;
|
|
return {
|
|
a: common_vendor.t(item.key),
|
|
b: ((_a2 = curOption.value.answer) == null ? void 0 : _a2.includes(item.key)) ? 1 : "",
|
|
c: common_vendor.o(($event) => chooseOption(item))
|
|
};
|
|
}),
|
|
o: common_vendor.unref(ansCard).length
|
|
}, common_vendor.unref(ansCard).length ? {
|
|
p: common_vendor.f(common_vendor.unref(usecarStore).carInfo.stepType == 1 ? 10 : 5, (item, index, i0) => {
|
|
return {
|
|
a: common_vendor.t(index + 1)
|
|
};
|
|
}),
|
|
q: common_vendor.f(common_vendor.unref(ansCard), (item, index, i0) => {
|
|
return {
|
|
a: common_vendor.t(index + 1),
|
|
b: common_vendor.f(item, (item2, index2, i1) => {
|
|
return common_vendor.e({
|
|
a: item2.types == 3 && item2.answerMy
|
|
}, item2.types == 3 && item2.answerMy ? common_vendor.e({
|
|
b: item2.answer == item2.answerMy
|
|
}, item2.answer == item2.answerMy ? {
|
|
c: "4d3e765a-1-" + i0 + "-" + i1,
|
|
d: common_vendor.p({
|
|
name: "checkmark",
|
|
color: "#55ff7f",
|
|
size: "18"
|
|
})
|
|
} : {
|
|
e: "4d3e765a-2-" + i0 + "-" + i1,
|
|
f: common_vendor.p({
|
|
name: "close",
|
|
color: "#ff0000",
|
|
size: "18"
|
|
})
|
|
}) : {
|
|
g: common_vendor.t(item2.answerMy)
|
|
}, {
|
|
h: item2.answer == item2.answerMy ? 1 : "",
|
|
i: common_vendor.o(($event) => ansCardClick(item2))
|
|
});
|
|
})
|
|
};
|
|
})
|
|
} : {}, {
|
|
r: common_vendor.sr(countDownRef, "4d3e765a-3", {
|
|
"k": "countDownRef"
|
|
}),
|
|
s: common_vendor.o(finishFn),
|
|
t: common_vendor.p({
|
|
time: common_vendor.unref(info).totalExamTime * 60 * 1e3,
|
|
format: "mm:ss"
|
|
}),
|
|
v: common_vendor.t(types.value[questionBank.value.types - 1]),
|
|
w: common_vendor.t(questionBank.value.types == 2 ? "多" : "一"),
|
|
x: common_vendor.o(($event) => common_vendor.unref(uni_modules_uviewPlus_libs_function_debounce.debounce)(nextQuestion(-1), 500)),
|
|
y: common_vendor.unref(currentIndex) == 0 ? 1 : "",
|
|
z: common_vendor.unref(currentIndex) == 0,
|
|
A: common_vendor.o(($event) => common_vendor.unref(uni_modules_uviewPlus_libs_function_debounce.debounce)(nextQuestion(1), 500)),
|
|
B: common_vendor.unref(currentIndex) >= questionBankList.value.length - 1 ? 1 : "",
|
|
C: common_vendor.unref(currentIndex) >= questionBankList.value.length - 1,
|
|
D: common_vendor.o(handApaper),
|
|
E: questionBank.value.img
|
|
}, questionBank.value.img ? {
|
|
F: questionBank.value.img,
|
|
G: common_vendor.o(previewImg)
|
|
} : {}, {
|
|
H: questionBank.value.img,
|
|
I: common_vendor.o(($event) => show.value = false),
|
|
J: common_vendor.p({
|
|
show: show.value,
|
|
mode: "center",
|
|
closeable: true,
|
|
bgColor: "transparent"
|
|
}),
|
|
K: common_vendor.t(yesNum.value),
|
|
L: common_vendor.t(questionBankList.value.length - yesNum.value - noNum.value),
|
|
M: common_vendor.t(noNum.value),
|
|
N: common_vendor.o(submitBtnFn),
|
|
O: common_vendor.o(closeCommitPopup),
|
|
P: common_vendor.o(closeCommitPopup),
|
|
Q: common_vendor.p({
|
|
show: showCommit.value,
|
|
mode: "center",
|
|
closeable: true,
|
|
round: "10"
|
|
}),
|
|
R: common_vendor.t(common_vendor.unref(grade)),
|
|
S: common_vendor.o(goBack),
|
|
T: common_vendor.o(goBack),
|
|
U: common_vendor.p({
|
|
time: 4 * 1e3,
|
|
format: "ss"
|
|
}),
|
|
V: common_vendor.o(($event) => showNoPass.value = false),
|
|
W: common_vendor.p({
|
|
show: showNoPass.value,
|
|
mode: "center",
|
|
closeable: true,
|
|
round: "10"
|
|
}),
|
|
X: common_vendor.t(questionBank.value.title),
|
|
Y: common_vendor.f(questionBank.value.optionArr, (item, index, i0) => {
|
|
return {
|
|
a: common_vendor.t(item.key),
|
|
b: common_vendor.t(item.text)
|
|
};
|
|
}),
|
|
Z: questionBank.value.types == 3
|
|
}, questionBank.value.types == 3 ? {
|
|
aa: common_vendor.t(questionBank.value.answer == "true" ? "A" : "B")
|
|
} : {
|
|
ab: common_vendor.t(questionBank.value.answer)
|
|
}, {
|
|
ac: questionBank.value.types == 3
|
|
}, questionBank.value.types == 3 ? {
|
|
ad: common_vendor.t(questionBank.value.answerMy == "true" ? "A" : "B")
|
|
} : {
|
|
ae: common_vendor.t(questionBank.value.answerMy)
|
|
}, {
|
|
af: common_vendor.o(showWrongClose),
|
|
ag: common_vendor.o(showWrongClose),
|
|
ah: common_vendor.p({
|
|
time: 6 * 1e3,
|
|
format: "ss"
|
|
}),
|
|
ai: common_vendor.o(showWrongClose),
|
|
aj: common_vendor.p({
|
|
show: showWrong.value,
|
|
mode: "center",
|
|
closeable: true,
|
|
round: "10"
|
|
})
|
|
});
|
|
};
|
|
}
|
|
};
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-4d3e765a"]]);
|
|
wx.createPage(MiniProgramPage);
|