|
|
@ -121,7 +121,7 @@ import Util from '@/libs/util' |
|
|
|
import QuesConst from '@/const/ques' |
|
|
|
import QuesConst from '@/const/ques' |
|
|
|
import TestPaperConst from '@/const/testPaper' |
|
|
|
import TestPaperConst from '@/const/testPaper' |
|
|
|
import _ from 'lodash' |
|
|
|
import _ from 'lodash' |
|
|
|
// import Decimal from 'decimal.js' |
|
|
|
import Decimal from 'decimal.js' |
|
|
|
export default { |
|
|
|
export default { |
|
|
|
props: ['visible'], |
|
|
|
props: ['visible'], |
|
|
|
data () { |
|
|
|
data () { |
|
|
@ -221,7 +221,7 @@ export default { |
|
|
|
const ques = this.checked.find(e => e.quesBank.id === checkQues.id) |
|
|
|
const ques = this.checked.find(e => e.quesBank.id === checkQues.id) |
|
|
|
// 已选中的题库数组里有该题库,则往该题库的知识点数组里 |
|
|
|
// 已选中的题库数组里有该题库,则往该题库的知识点数组里 |
|
|
|
if (ques) { |
|
|
|
if (ques) { |
|
|
|
const i = ques.knowledges.findIndex(e => e === data.id) |
|
|
|
const i = ques.knowledges.findIndex(e => e.id === data.id) |
|
|
|
if (checked && i === -1) { |
|
|
|
if (checked && i === -1) { |
|
|
|
ques.knowledges.push(data) |
|
|
|
ques.knowledges.push(data) |
|
|
|
} else if (!checked && i >= 0) { |
|
|
|
} else if (!checked && i >= 0) { |
|
|
@ -250,14 +250,22 @@ export default { |
|
|
|
closeOnClickModal: false, |
|
|
|
closeOnClickModal: false, |
|
|
|
}) |
|
|
|
}) |
|
|
|
this.checked = [] |
|
|
|
this.checked = [] |
|
|
|
|
|
|
|
// this.$nextTick(() => { |
|
|
|
|
|
|
|
// this.$refs.knowledge.setCheckedKeys([]) |
|
|
|
|
|
|
|
// }) |
|
|
|
} catch (e) { } |
|
|
|
} catch (e) { } |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 删除题库 |
|
|
|
// 删除题库 |
|
|
|
delQuesBank (i) { |
|
|
|
delQuesBank (i) { |
|
|
|
this.checked.splice(i, 1) |
|
|
|
const k = this.$refs.knowledge |
|
|
|
|
|
|
|
this.checked[i].knowledges.map(e => { |
|
|
|
|
|
|
|
k.setChecked(e.id, false, true) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
// this.checked.splice(i, 1) |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 删除知识点 |
|
|
|
// 删除知识点 |
|
|
|
delKnowledge (i, j, item) { |
|
|
|
delKnowledge (i, j, item) { |
|
|
|
|
|
|
|
this.$refs.knowledge.setChecked(item.knowledges[j].id, false) |
|
|
|
item.knowledges.splice(j, 1) |
|
|
|
item.knowledges.splice(j, 1) |
|
|
|
item.knowledges.length || this.checked.splice(i, 1) // 知识点清空了则把该题库删除 |
|
|
|
item.knowledges.length || this.checked.splice(i, 1) // 知识点清空了则把该题库删除 |
|
|
|
}, |
|
|
|
}, |
|
|
@ -282,33 +290,23 @@ export default { |
|
|
|
// 遍历题型数组 |
|
|
|
// 遍历题型数组 |
|
|
|
list.forEach(e => { |
|
|
|
list.forEach(e => { |
|
|
|
const total = e.questionNum |
|
|
|
const total = e.questionNum |
|
|
|
const nums = { |
|
|
|
|
|
|
|
basicDifficulty: 0, |
|
|
|
|
|
|
|
normalDifficulty: 0, |
|
|
|
|
|
|
|
hardDifficulty: 0, |
|
|
|
|
|
|
|
veryHardDifficulty: 0, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 初始化题目数量 |
|
|
|
|
|
|
|
for (let i = 0; i < 4; i++) { |
|
|
|
|
|
|
|
nums[names[i]] = 0 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 初始分配题目数量 |
|
|
|
// 初始分配题目数量 |
|
|
|
let totalWeight = total * target |
|
|
|
let totalWeight = Decimal(total).mul(Decimal(target)).toNumber() |
|
|
|
const maxCount = Math.ceil(total / 4) |
|
|
|
const maxCount = Math.ceil(total / 4) |
|
|
|
for (let i = 0; i < 4; i++) { |
|
|
|
for (let i = 0; i < 4; i++) { |
|
|
|
console.log("🚀 ~ calculateQuestionNumbers ~ totalWeight:", totalWeight) |
|
|
|
|
|
|
|
if (totalWeight > 0) { |
|
|
|
if (totalWeight > 0) { |
|
|
|
const random = Math.floor(Math.random() * (maxCount)) + 1 |
|
|
|
const random = Math.floor(Math.random() * maxCount) + 1 |
|
|
|
const weight = difficultyWeights[i] |
|
|
|
const weight = difficultyWeights[i] |
|
|
|
totalWeight -= weight * random |
|
|
|
totalWeight = Decimal(totalWeight).sub(Decimal(weight * random)).toNumber() |
|
|
|
e[names[i]] = totalWeight > 0 ? random : 0 |
|
|
|
this.$set(e, names[i], totalWeight > 0 ? random : 0) |
|
|
|
|
|
|
|
// e[names[i]] = totalWeight > 0 ? random : 0 |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// e.nums = nums |
|
|
|
console.log("🚀 ~ calculateQuestionNumbers ~ totalWeight:", totalWeight) |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
return list |
|
|
|
return list |
|
|
|
}, |
|
|
|
}, |
|
|
@ -365,7 +363,6 @@ export default { |
|
|
|
let invalid = 0 |
|
|
|
let invalid = 0 |
|
|
|
let hasQues = 0 |
|
|
|
let hasQues = 0 |
|
|
|
list.map((e, i) => { |
|
|
|
list.map((e, i) => { |
|
|
|
console.log("🚀 ~ submit ~ e:", e) |
|
|
|
|
|
|
|
if (e.questionNum !== res.list[i].questions.length) invalid = 1 |
|
|
|
if (e.questionNum !== res.list[i].questions.length) invalid = 1 |
|
|
|
if (e.examQuestions.length) hasQues = 1 |
|
|
|
if (e.examQuestions.length) hasQues = 1 |
|
|
|
}) |
|
|
|
}) |
|
|
|