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