试卷自动分配

master
yujialong 4 months ago
parent 9ded1da513
commit 88781b9d98
  1. 5
      package-lock.json
  2. 1
      package.json
  3. 2
      src/pages/quesBank/index.vue
  4. 41
      src/pages/testPaper/detail/auto.vue
  5. 28
      src/pages/testPaper/detail/index.vue

5
package-lock.json generated

@ -4217,6 +4217,11 @@
"resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz",
"integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA="
},
"decimal.js": {
"version": "10.4.3",
"resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.4.3.tgz",
"integrity": "sha512-VBBaLc1MgL5XpzgIP7ny5Z6Nx3UrRkIViUkPUdtl9aya5amy3De1gsUUSB1g3+3sExYNjCAsAznmukyxCb1GRA=="
},
"decode-uri-component": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz",

@ -13,6 +13,7 @@
"axios": "^0.18.0",
"babel-polyfill": "^6.26.0",
"dayjs": "^1.11.12",
"decimal.js": "^10.4.3",
"echarts": "^4.8.0",
"element-theme": "^2.0.1",
"element-ui": "^2.13.0",

@ -232,7 +232,7 @@ export default {
},
//
sortChange (column) {
if (column.prop === 'questionNumOrderBy') this.filter.questionNumOrderBy = column.order ? column.order === 'ascending' ? 'asc' : 'desc' : ''
if (column.prop === 'questionsNum') this.filter.questionNumOrderBy = column.order ? column.order === 'ascending' ? 'asc' : 'desc' : ''
if (column.prop === 'createTime') this.filter.timeOrderBy = column.order ? column.order === 'ascending' ? 'asc' : 'desc' : ''
this.getList()
},

@ -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
})

@ -120,11 +120,18 @@
<div v-html="ques.stem"></div>
<p><el-input class="score" placeholder="请输入" v-model="ques.score" /></p>
</div>
<!-- <div v-for="(opt, j) in ques.examQuestions" :key="j" class="opts">
<div v-html=""></div>
</div> -->
<!-- 单选多选判断的选项 -->
<template
v-if="ques.questionType !== 'fill_blank' && ques.questionType !== 'essay' && ques.questionAnswerVersionsList">
<div v-for="(opt, j) in ques.questionAnswerVersionsList" :key="j" class="opt">
<span>{{ numToLetter(j) }}.&nbsp;</span>
<div v-html="opt.optionText"></div>
</div>
</template>
<div class="bottom-line">
<div class="correct">正确答案A</div>
<div class="correct">正确答案A</div>
<div class="actions">
<div class="sort">
<span>排序</span>
@ -183,6 +190,7 @@ export default {
difficults: TestPaperConst.difficults,
paperTypes: TestPaperConst.paperTypes,
arabicToChinese: Util.arabicToChinese,
numToLetter: Util.numToLetter,
paperId: this.$route.query.paperId,
libraryId: this.$route.query.libraryId,
headers: {
@ -590,6 +598,7 @@ export default {
.top-line {
display: flex;
align-items: center;
margin-bottom: 10px;
}
.label {
@ -612,6 +621,16 @@ export default {
}
}
.opt {
display: flex;
flex-wrap: wrap;
padding-left: 10px;
margin-bottom: 5px;
font-size: 14px;
color: #707070;
line-height: 1.6;
}
.bottom-line {
display: flex;
justify-content: space-between;
@ -620,6 +639,7 @@ export default {
.correct {
font-size: 13px;
color: #333;
}
.actions {

Loading…
Cancel
Save