提交 d2bbcdbc 编写于 作者: yi.li's avatar yi.li

Merge branch 'dev-question-bank-0916' of...

Merge branch 'dev-question-bank-0916' of 192.168.110.53:com.pica.cloud.education.frontend/pica-professional-exam into dev-question-bank-0916
......@@ -25,7 +25,7 @@
</article>
<article class="title-wrapper">
<span class="type" :class="{'multi': currentQuestion.typeId == 2}">
<span>{{currentQuestion.typeId == 1 ? "单选题" : "多选题"}}</span>
<span>{{currentQuestion.typeId != 2 ? "单选题" : "多选题"}}</span>
</span>
<span class="content" v-html="currentQuestion.question"></span>
<!-- <img src="https://files.yunqueyi.com/image/png/protal/project/20200702161856970.png" /> -->
......@@ -92,6 +92,8 @@ export default {
...mapGetters([
"questionList",
"currentQuestion",
"commonConfig",
"titleConfig"
])
},
data() {
......@@ -124,7 +126,7 @@ export default {
myAnswer = myAnswer.split('').join(',');
this.currentQuestion.myAnswer = myAnswer;
} else {
// 单选题直接设置commitFlag
// 单选题或者判断题直接设置commitFlag
if(this.currentQuestion.options[index].isCorrect) {
this.currentQuestion.commitFlag = 1;
} else {
......@@ -136,18 +138,43 @@ export default {
this.$forceUpdate();
console.log("in commit", this.currentQuestion.myAnswer);
},
commitAnswer() {
// 提交答案
commitAnswer(isMulti) {
let params = {
commitKind: 1, // 答题来源 1:错题集 2:收藏 3:题库
directoryId: 0, // 题库ID
myAnswer: this.currentQuestion.myAnswer, // 我的答案,单选时单个答案,如A;多选答案,按照顺序使用
paperId: 1, // 试卷ID
paperIndex: 1, // 试卷索引(随机试卷的第n套)
resultId: 1, // 刷题库轮次ID,刷收藏和错题集时为0
rightFlag: 1, // 答题对错:1对 2错
titleId: 1, // 题目ID
commitKind: this.commonConfig.commitKind, // 答题来源 1:错题集 2:收藏 3:题库
directoryId: this.currentQuestion.directoryId, // 题库ID
myAnswer: this.currentQuestion.myAnswer, // 我的答案,单选时单个答案,如A;多选答案,按照顺序使用
paperId: this.currentQuestion.paperId, // 试卷ID
paperIndex: this.currentQuestion.paperIndex, // 试卷索引(随机试卷的第n套)
resultId: this.titleConfig.resultId, // 刷题库轮次ID,刷收藏和错题集时为0
// rightFlag: 1, // 答题对错:1对 2错
titleId: this.currentQuestion.titleId, // 题目ID
titleNo: this.currentQuestion.titleNo, // 题目ID
};
this.currentQuestion.commitFlag = 1;
// 计算是否答对了题目(只有多选题,才做相应处理)
if(isMulti) {
let cList = this.currentQuestion, option = {}, isRight = true;
for(let i = 0; i < cList.length; i ++) {
option = cList[i];
if(option.isCorrect && !option.isSelected) {
isRight = false;
return;
}
}
if(isRight) {
this.currentQuestion.commitFlag = 1;
} else {
this.currentQuestion.commitFlag = 2;
}
}
this.POST(`onlineexam/practise/commit`, params).then(({ data }) => {
// this.currentTitleNo = data.currentTitleNo;
// this.handlerQuestionList(data);
// this.handlerPractiseData(data.practiseTitleModelList);
console.log("onlineexam/practise/commit", data);
});
}
}
};
......
......@@ -112,7 +112,7 @@ export default {
operateType: favorFlag == 1 ? 2 : 1, // 操作类型:1:收藏 2:取消收藏
paperId: currentQuestion.paperId,
paperIndex: currentQuestion.paperIndex,
token: this.userInfo.userToken || this.token || '998E10CD98ED4BCF91A28223270FE8CE',
token: this.userInfo.userToken || this.token || '93521BDB92774134B2CC18633F2B6D3A',
setEntry: true
// userId: 0
};
......
......@@ -97,7 +97,7 @@ const question = {
// async getQuestionList({ commit, state }, params) {
// // let param = {
// // ...params,
// // token: '998E10CD98ED4BCF91A28223270FE8CE',
// // token: '93521BDB92774134B2CC18633F2B6D3A',
// // setEntry: true
// // };
// // this.GET(`portal/titleTest/practise/titles`, param).then(({ data }) => {
......
......@@ -2,7 +2,7 @@
// import { getBaseUrl } from '@/utils/index'
// import { setCookie, getCookie, delCookie } from '@/utils/index';
// import { envConfig } from '@/utils/env-config';
import { findQuestionIndexNo, getOrderText } from "@/utils";
import { findQuestionIndexNo, getOrderText, concatArray } from "@/utils";
const question = {
state: {
......@@ -59,11 +59,11 @@ const question = {
secondSubjectId: 0,
cardType: 3,
goodsType: 3,
commitKind: 1, // 答题来源 1:错题集 2:收藏 3:题库
commitKind: 3, // 答题来源 1:错题集 2:收藏 3:题库
},
titleConfig: {
bindStatus: 0, // 绑卡状态:0未绑卡 1已绑卡
commitKind: 1, // 答题来源 1:错题集 2:收藏 3:题库
commitKind: 3, // 答题来源 1:错题集 2:收藏 3:题库
currentTitleNo: 0, // 定位答题题目id
resultId: 0, // 刷题库轮次ID
totalCount: 0, // 题目总数
......@@ -97,7 +97,7 @@ const question = {
// 处理返回的数据
handlerQuestionList({ commit, state }, rezultData) {
// debugger
let questionList = rezultData.practiseTitleModelList;
let questionList = rezultData.practiseTitleModelList || [];
let handlerList = [], question, option, optionList = [], myAnswer = "", answer = "";
questionList.forEach( (item, index) => {
......@@ -123,16 +123,16 @@ const question = {
});
console.log('in handlerList', handlerList);
let cIndex = findQuestionIndexNo(handlerList, 'titleNo', rezultData.currentTitleNo || 1);
commit("SET_CURRENT_QUESTION", handlerList[cIndex]);
commit("SET_QUESTION_LIST", handlerList);
let newList = concatArray(state.questionList, handlerList, 'titleNo');
let titleConfig = {
bindStatus: rezultData.bindStatus, // 绑卡状态:0未绑卡 1已绑卡
commitKind: rezultData.commitKind, // 答题来源 1:错题集 2:收藏 3:题库
currentTitleNo: rezultData.currentTitleNo, // 定位答题题目id
resultId: rezultData.resultId, // 刷题库轮次ID
currentTitleNo: rezultData.currentTitleNo, // 定位答题题目id
resultId: rezultData.resultId, // 刷题库轮次ID
totalCount: rezultData.totalCount, // 题目总数
}
commit("SET_CURRENT_QUESTION", newList[cIndex] || {titleNo: 1});
commit("SET_QUESTION_LIST", newList);
commit("SET_TITLE_CONIFG", titleConfig);
},
......
......@@ -14,9 +14,9 @@ service.interceptors.request.use(config => {
if (config.data && config.data.setEntry) {
config.headers['sysCode'] = config.data.sysCode || 10
if (config.data.token) {
config.headers['token'] = config.data.token || '998E10CD98ED4BCF91A28223270FE8CE'
config.headers['token'] = config.data.token || '93521BDB92774134B2CC18633F2B6D3A'
if (process.env.BUILD_ENV == "development") { // 本地开发环境
config.headers['token'] = config.data.token || '998E10CD98ED4BCF91A28223270FE8CE';
config.headers['token'] = config.data.token || '93521BDB92774134B2CC18633F2B6D3A';
}
}
delete config.data.setEntry;
......
......@@ -301,6 +301,7 @@ export function getOrderText(index) {
return orderVac[index];
}
// 从数组中查找某个key对应值所在的位置(序号:0开始的)
export function findQuestionIndexNo(oList, key, keyValue) {
let index = oList.findIndex( item => {
return item[key] == keyValue;
......@@ -308,3 +309,28 @@ export function findQuestionIndexNo(oList, key, keyValue) {
return index;
}
// 对两个数组中的元素进行排序
export function concatArray(firstArr = [], secondArr = [], key) {
if(firstArr.length == 0) return secondArr;
if(secondArr.length == 0) return [];
let all = [], newArr = [], deleteIndex;
if(firstArr[0][key] == secondArr[0][key]) {
return firstArr;
}else if(firstArr[0][key] < secondArr[0][key]) {
all = firstArr.concat(secondArr);
} else {
all = secondArr.concat(firstArr);
}
// 从all中去重
for(let i = 0; i < all.length; i ++) {
deleteIndex = findQuestionIndexNo(all.slice(i + 1), key, all[i][key]);
if(deleteIndex >= 0) {
all.splice(deleteIndex, 1);
i --;
}
}
console.log("in contactArray", all);
return all;
}
......@@ -110,7 +110,7 @@ module.exports = {
// 通用GET请求
GET(api, para, callback, str) {
// debugger
let token = para.token || this.token || this.$store.state.user.token || '998E10CD98ED4BCF91A28223270FE8CE';
let token = para.token || this.token || this.$store.state.user.token || '93521BDB92774134B2CC18633F2B6D3A';
para.token = token;
delete para.token;
delete para.setEntry;
......@@ -148,8 +148,10 @@ module.exports = {
// 通用POST请求
POST(api, para, callback) {
let token = para.token || this.token || this.$store.state.user.token || '';
let token = para.token || this.token || this.$store.state.user.token || '93521BDB92774134B2CC18633F2B6D3A';
para.token = token;
delete para.token;
delete para.setEntry;
return fetch({
url: getBaseUrl(api),
method: 'post',
......
此差异已折叠。
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册