|
@@ -8,15 +8,18 @@ import {
|
|
computed,
|
|
computed,
|
|
toRefs,
|
|
toRefs,
|
|
onMounted,
|
|
onMounted,
|
|
- watch
|
|
|
|
|
|
+ watch,
|
|
|
|
+ nextTick
|
|
} from "vue";
|
|
} from "vue";
|
|
import {
|
|
import {
|
|
catchError,
|
|
catchError,
|
|
toast
|
|
toast
|
|
} from "@/utils/common.js"
|
|
} from "@/utils/common.js"
|
|
import * as httpUnit from "@/api/unitTest.js"
|
|
import * as httpUnit from "@/api/unitTest.js"
|
|
-import cacheManager, {useUnitTestTishi} from "@/utils/cacheManager.js"
|
|
|
|
-
|
|
|
|
|
|
+import cacheManager, {
|
|
|
|
+ useUnitTestTishi
|
|
|
|
+} from "@/utils/cacheManager.js"
|
|
|
|
+
|
|
|
|
|
|
function useJifen() {
|
|
function useJifen() {
|
|
const data = reactive({
|
|
const data = reactive({
|
|
@@ -25,12 +28,16 @@ function useJifen() {
|
|
jifen: 0, // 积分
|
|
jifen: 0, // 积分
|
|
})
|
|
})
|
|
|
|
|
|
- function updateJifen({rightAnswer,wrongAnswer,jifen}) {
|
|
|
|
|
|
+ function updateJifen({
|
|
|
|
+ rightAnswer,
|
|
|
|
+ wrongAnswer,
|
|
|
|
+ jifen
|
|
|
|
+ }) {
|
|
data.rightAnswer = rightAnswer;
|
|
data.rightAnswer = rightAnswer;
|
|
data.wrongAnswer = wrongAnswer;
|
|
data.wrongAnswer = wrongAnswer;
|
|
data.jifen = jifen;
|
|
data.jifen = jifen;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
return {
|
|
return {
|
|
...toRefs(data),
|
|
...toRefs(data),
|
|
updateJifen
|
|
updateJifen
|
|
@@ -40,10 +47,19 @@ function useJifen() {
|
|
export function useExam() {
|
|
export function useExam() {
|
|
// 缓存
|
|
// 缓存
|
|
|
|
|
|
- const { showTishi, handleCloseTishi, handleShowTishi} = useTishiLeftRight()
|
|
|
|
- const {rightAnswer,wrongAnswer,jifen, updateJifen} = useJifen();
|
|
|
|
|
|
+ const {
|
|
|
|
+ showTishi,
|
|
|
|
+ handleCloseTishi,
|
|
|
|
+ handleShowTishi
|
|
|
|
+ } = useTishiLeftRight()
|
|
|
|
+ const {
|
|
|
|
+ rightAnswer,
|
|
|
|
+ wrongAnswer,
|
|
|
|
+ jifen,
|
|
|
|
+ updateJifen
|
|
|
|
+ } = useJifen();
|
|
|
|
+
|
|
|
|
|
|
-
|
|
|
|
const data = reactive({
|
|
const data = reactive({
|
|
count: 0, // 已答题数
|
|
count: 0, // 已答题数
|
|
total: 0, // 总题数
|
|
total: 0, // 总题数
|
|
@@ -63,29 +79,35 @@ export function useExam() {
|
|
}
|
|
}
|
|
const cacheZhangInfo = cacheManager.get('zhangInfo');
|
|
const cacheZhangInfo = cacheManager.get('zhangInfo');
|
|
let currentObject = cacheZhangInfo.jieList.find(item => item.number == options.jieNumber);
|
|
let currentObject = cacheZhangInfo.jieList.find(item => item.number == options.jieNumber);
|
|
- const { cardId,zhangId,nianji } = cacheManager.get('auth');
|
|
|
|
-
|
|
|
|
|
|
+ const {
|
|
|
|
+ cardId,
|
|
|
|
+ zhangId,
|
|
|
|
+ nianji
|
|
|
|
+ } = cacheManager.get('auth');
|
|
|
|
+
|
|
data.jieId = currentObject.jieId; // 需要路由参数 节Id
|
|
data.jieId = currentObject.jieId; // 需要路由参数 节Id
|
|
- data.zhangId = zhangId;// 需要路由参数 章Id
|
|
|
|
|
|
+ data.zhangId = zhangId; // 需要路由参数 章Id
|
|
data.nianji = nianji; // 需要年纪Id 来执行返回页面
|
|
data.nianji = nianji; // 需要年纪Id 来执行返回页面
|
|
data.xueke = cardId; // 需要年纪Id 来执行返回页面
|
|
data.xueke = cardId; // 需要年纪Id 来执行返回页面
|
|
data.haveFlag = cacheZhangInfo.haveFlag
|
|
data.haveFlag = cacheZhangInfo.haveFlag
|
|
-
|
|
|
|
|
|
+
|
|
// 初始化页面数据
|
|
// 初始化页面数据
|
|
initPage();
|
|
initPage();
|
|
})
|
|
})
|
|
-
|
|
|
|
|
|
+
|
|
watch(() => data.list, (val) => {
|
|
watch(() => data.list, (val) => {
|
|
const list = data.list.filter(item => {
|
|
const list = data.list.filter(item => {
|
|
if (item.type == 3) {
|
|
if (item.type == 3) {
|
|
// 填空题 所有试题答完
|
|
// 填空题 所有试题答完
|
|
return !item.reply.some(citem => citem.trim() == '');
|
|
return !item.reply.some(citem => citem.trim() == '');
|
|
} else {
|
|
} else {
|
|
- return item.reply!==null
|
|
|
|
|
|
+ return item.reply !== null
|
|
}
|
|
}
|
|
});
|
|
});
|
|
data.count = list.length;
|
|
data.count = list.length;
|
|
- },{deep: true})
|
|
|
|
|
|
+ }, {
|
|
|
|
+ deep: true
|
|
|
|
+ })
|
|
|
|
|
|
|
|
|
|
// 初始化页面数据
|
|
// 初始化页面数据
|
|
@@ -106,8 +128,8 @@ export function useExam() {
|
|
item.reply = null;
|
|
item.reply = null;
|
|
if (item.type == 3) {
|
|
if (item.type == 3) {
|
|
item.result = JSON.parse(item.result);
|
|
item.result = JSON.parse(item.result);
|
|
- item.placeholders = item.result.map((item,cindex) => `[bank${cindex}]`)
|
|
|
|
- item.reply = item.result.map(() => '');
|
|
|
|
|
|
+ item.placeholders = item.result.map((item, cindex) => `[bank${cindex}]`)
|
|
|
|
+ item.reply = item.result.map(() => '');
|
|
}
|
|
}
|
|
})
|
|
})
|
|
}
|
|
}
|
|
@@ -118,7 +140,7 @@ export function useExam() {
|
|
formatListToUse(cList)
|
|
formatListToUse(cList)
|
|
data.list = cList;
|
|
data.list = cList;
|
|
data.total = cList.length;
|
|
data.total = cList.length;
|
|
-
|
|
|
|
|
|
+
|
|
handleShowTishi();
|
|
handleShowTishi();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -126,22 +148,25 @@ export function useExam() {
|
|
async function handleSubmit(dom) {
|
|
async function handleSubmit(dom) {
|
|
const result = [];
|
|
const result = [];
|
|
data.list.forEach(item => {
|
|
data.list.forEach(item => {
|
|
- result.push({reply: item.reply ? JSON.stringify(item.reply):'',stId: item.stId})
|
|
|
|
|
|
+ result.push({
|
|
|
|
+ reply: item.reply ? JSON.stringify(item.reply) : '',
|
|
|
|
+ stId: item.stId
|
|
|
|
+ })
|
|
})
|
|
})
|
|
-
|
|
|
|
- const [error, cdata] =await catchError(httpUnit.getExamSubmit({
|
|
|
|
|
|
+
|
|
|
|
+ const [error, cdata] = await catchError(httpUnit.getExamSubmit({
|
|
jieId: data.jieId,
|
|
jieId: data.jieId,
|
|
shitiList: result
|
|
shitiList: result
|
|
}));
|
|
}));
|
|
|
|
|
|
if (error) {
|
|
if (error) {
|
|
toast("单元测试数据提交异常");
|
|
toast("单元测试数据提交异常");
|
|
- return ;
|
|
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
dom.showPopup({
|
|
dom.showPopup({
|
|
- right:cdata.dui,
|
|
|
|
- wrong:cdata.cuo,
|
|
|
|
- jifen:cdata.jifen
|
|
|
|
|
|
+ right: cdata.dui,
|
|
|
|
+ wrong: cdata.cuo,
|
|
|
|
+ jifen: cdata.jifen
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
@@ -163,7 +188,10 @@ export function useExam() {
|
|
|
|
|
|
// 提示信息显示隐藏
|
|
// 提示信息显示隐藏
|
|
function useTishiLeftRight() {
|
|
function useTishiLeftRight() {
|
|
- const { updateTishi, getTishi} = useUnitTestTishi();
|
|
|
|
|
|
+ const {
|
|
|
|
+ updateTishi,
|
|
|
|
+ getTishi
|
|
|
|
+ } = useUnitTestTishi();
|
|
const showTishi = ref(false);
|
|
const showTishi = ref(false);
|
|
// 大鹅关闭追加缓存 --- 单独针对当前手机的缓存提示
|
|
// 大鹅关闭追加缓存 --- 单独针对当前手机的缓存提示
|
|
function handleCloseTishi() {
|
|
function handleCloseTishi() {
|
|
@@ -175,10 +203,46 @@ function useTishiLeftRight() {
|
|
const isNotShow = Boolean(getTishi());
|
|
const isNotShow = Boolean(getTishi());
|
|
showTishi.value = !isNotShow;
|
|
showTishi.value = !isNotShow;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
return {
|
|
return {
|
|
showTishi,
|
|
showTishi,
|
|
handleCloseTishi,
|
|
handleCloseTishi,
|
|
handleShowTishi
|
|
handleShowTishi
|
|
}
|
|
}
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+export function useTiankongItem(popupRef) {
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ const index = ref(null);
|
|
|
|
+ const tiankongValue = ref(null);
|
|
|
|
+ const question = ref(null);
|
|
|
|
+
|
|
|
|
+ function refreshFn(data) {
|
|
|
|
+ index.value = +data.index;
|
|
|
|
+ tiankongValue.value = data.value;
|
|
|
|
+ question.value = data.question;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ function onBlur(dd) {
|
|
|
|
+ tiankongValue.value = dd.result;
|
|
|
|
+ uni.$emit('tiankongItemBlur', {
|
|
|
|
+ index: dd.index,
|
|
|
|
+ value: dd.result,
|
|
|
|
+ question: question.value
|
|
|
|
+ })
|
|
|
|
+ nextTick(() => {
|
|
|
|
+ tiankongValue.value = "";
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ uni.$on('tiankongItemShow', (data) => {
|
|
|
|
+ refreshFn(data);
|
|
|
|
+ popupRef.value.showPopup();
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ return {
|
|
|
|
+ index,
|
|
|
|
+ tiankongValue,
|
|
|
|
+ onBlur
|
|
|
|
+ }
|
|
}
|
|
}
|