|
@@ -550,6 +550,7 @@
|
|
|
|
|
|
/** 按照题型配分 */
|
|
|
onConfirmTypeScore() {
|
|
|
+ let step = 0.5
|
|
|
/** 重新计算剩余分配分数 */
|
|
|
this.surPlusScore = this.paperInfo.score - this.groupTypeList.reduce((p, e) => parseInt(p) + parseInt(e
|
|
|
.score), 0)
|
|
@@ -558,34 +559,37 @@
|
|
|
} else {
|
|
|
/* 按照题型配分后平均分配给每个子题 */
|
|
|
this.groupTypeList.forEach(item => {
|
|
|
+ let averageArr = this.$tools.doAverage(item.score,item.list.length,step)
|
|
|
item.list.forEach((exercise, exerciseIndex) => {
|
|
|
- // 先找到原始列表里面的当前题目
|
|
|
+ exercise.score = averageArr[exerciseIndex]
|
|
|
let listItem = this.exerciseList.filter(item => item.id === exercise.id)[0]
|
|
|
- // 先判断是否总分除以题目数量能否除尽
|
|
|
- let remainder = item.score % item.list.length
|
|
|
- // 如果可以整除 则直接计算
|
|
|
- if (remainder === 0) {
|
|
|
- exercise.score = item.score / item.list.length
|
|
|
- } else {
|
|
|
- // 如果不能整除 则前面所有取整 最后一题加上余数 即可完成配分
|
|
|
- let integerScore = parseInt(item.score / item.list.length)
|
|
|
- // let lastItem = exerciseIndex === item.list.length - 1
|
|
|
- // exercise.score = lastItem ? integerScore + remainder : integerScore
|
|
|
- exercise.score = exerciseIndex + 1 > remainder ? integerScore :
|
|
|
- integerScore + 1
|
|
|
- }
|
|
|
listItem.score = exercise.score
|
|
|
-
|
|
|
- if (exercise.type === 'compose' && exercise.children && exercise.children
|
|
|
- .length) {
|
|
|
+ // 先找到原始列表里面的当前题目
|
|
|
+ // // 先判断是否总分除以题目数量能否除尽
|
|
|
+ // let remainder = item.score % item.list.length
|
|
|
+ // // 如果可以整除 则直接计算
|
|
|
+ // if (remainder === 0) {
|
|
|
+ // exercise.score = item.score /
|
|
|
+ // } else {
|
|
|
+ // // 如果不能整除 则前面所有取整 最后一题加上余数 即可完成配分
|
|
|
+ // let integerScore = parseInt(item.score / item.list.length)
|
|
|
+ // // let lastItem = exerciseIndex === item.list.length - 1
|
|
|
+ // // exercise.score = lastItem ? integerScore + remainder : integerScore
|
|
|
+ // exercise.score = exerciseIndex + 1 > remainder ? integerScore :
|
|
|
+ // integerScore + 1
|
|
|
+ // }
|
|
|
+
|
|
|
+ if (exercise.type === 'compose' && exercise.children && exercise.children.length) {
|
|
|
+ let childrenScoreArr = this.$tools.doAverage(exercise.score,exercise.children.length,step)
|
|
|
exercise.children.forEach((child, childIndex) => {
|
|
|
- let remainder = exercise.score % exercise.children.length
|
|
|
- let integerScore = parseInt(exercise.score / exercise.children
|
|
|
- .length)
|
|
|
- // let lastItem = childIndex === exercise.children.length - 1
|
|
|
- // child.score = lastItem ? integerScore + remainder : integerScore
|
|
|
- child.score = childIndex + 1 > remainder ? integerScore :
|
|
|
- integerScore + 1
|
|
|
+ child.score =childrenScoreArr[childIndex]
|
|
|
+ // let remainder = exercise.score % exercise.children.length
|
|
|
+ // let integerScore = parseInt(exercise.score / exercise.children
|
|
|
+ // .length)
|
|
|
+ // // let lastItem = childIndex === exercise.children.length - 1
|
|
|
+ // // child.score = lastItem ? integerScore + remainder : integerScore
|
|
|
+ // child.score = childIndex + 1 > remainder ? integerScore :
|
|
|
+ // integerScore + 1
|
|
|
})
|
|
|
}
|
|
|
|
|
@@ -696,6 +700,59 @@
|
|
|
console.log(list)
|
|
|
console.log(this.noAnswerList)
|
|
|
})
|
|
|
+
|
|
|
+ this.$EventBus.$off('getNewPaper')
|
|
|
+ this.$EventBus.$on('getNewPaper', newPaper => {
|
|
|
+ console.log(newPaper)
|
|
|
+ let isSave = Number(sessionStorage.getItem('isSave'))
|
|
|
+ console.log(isSave)
|
|
|
+ if (newPaper && !isSave) {
|
|
|
+ let that = this
|
|
|
+ this.groupList = [] // 题型排序的数据
|
|
|
+ this.orderList = [] //顺序排列的数据
|
|
|
+ this.exerciseList = []
|
|
|
+ this.paperInfo = newPaper
|
|
|
+ this.multipleRule = newPaper.multipleRule || 1 // 配分规则
|
|
|
+ if (newPaper.item.length) {
|
|
|
+ newPaper.item.forEach(i => {
|
|
|
+ if (!i.score) i.score = 0
|
|
|
+ // 如果有综合题 则将小题的分数进行累加作为综合题的分数
|
|
|
+ if(i.type === 'compose' && i.children.length){
|
|
|
+ i.score = i.children.reduce((a,b) => a + b.score , 0)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // 给顺序题目排序
|
|
|
+ this.orderList.push({
|
|
|
+ list: newPaper.item
|
|
|
+ })
|
|
|
+ /* 处理试卷内题目按照题型排序 */
|
|
|
+ this.typeList.forEach(item => {
|
|
|
+ this._.mapKeys(this._.groupBy(newPaper.item, 'type'), function(value, key) {
|
|
|
+ if (key === item) {
|
|
|
+ /* 按照题型排序,并且计算每种题型的总分 */
|
|
|
+ that.groupList.push({
|
|
|
+ type: key,
|
|
|
+ list: value,
|
|
|
+ score: value.reduce((p, e) => parseInt(p) + parseInt(e
|
|
|
+ .score), 0)
|
|
|
+ })
|
|
|
+ that.exerciseList = that.exerciseList.concat(value)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 重新赋值
|
|
|
+ this.originData = this.exerciseList
|
|
|
+ this.groupTypeList = this.groupList
|
|
|
+ this.totalNum = newPaper.item.length
|
|
|
+ console.log('groupType', this.groupTypeList);
|
|
|
+ // 剩余可分配分数 更新
|
|
|
+ this.surPlusScore = newPaper.score - newPaper.item.reduce((p, e) => Number(p) + Number(e.score),
|
|
|
+ 0);
|
|
|
+ this.$emit('scoreUpdate', this.surPlusScore)
|
|
|
+ this.pageScrollTo(0)
|
|
|
+ }
|
|
|
+ })
|
|
|
},
|
|
|
computed: {
|
|
|
listData() {
|
|
@@ -730,55 +787,11 @@
|
|
|
watch: {
|
|
|
paper: {
|
|
|
handler(newPaper) {
|
|
|
- if (newPaper) {
|
|
|
- console.log('C-BaseExerciseList-Paper', newPaper)
|
|
|
- let that = this
|
|
|
- this.groupList = [] // 题型排序的数据
|
|
|
- this.orderList = [] //顺序排列的数据
|
|
|
- this.exerciseList = []
|
|
|
- this.paperInfo = newPaper
|
|
|
- this.multipleRule = newPaper.multipleRule || 1 // 配分规则
|
|
|
- if (newPaper.item.length) {
|
|
|
- newPaper.item.forEach(i => {
|
|
|
- if (!i.score) i.score = 0
|
|
|
- // 如果有综合题 则将小题的分数进行累加作为综合题的分数
|
|
|
- // if(i.type === 'compose' && i.children.length){
|
|
|
- // i.score = i.children.reduce((a,b) => a + b.score , 0)
|
|
|
- // }
|
|
|
- })
|
|
|
- // 给顺序题目排序
|
|
|
- this.orderList.push({
|
|
|
- list: newPaper.item
|
|
|
- })
|
|
|
- /* 处理试卷内题目按照题型排序 */
|
|
|
- this.typeList.forEach(item => {
|
|
|
- this._.mapKeys(this._.groupBy(newPaper.item, 'type'), function(value, key) {
|
|
|
- if (key === item) {
|
|
|
- /* 按照题型排序,并且计算每种题型的总分 */
|
|
|
- that.groupList.push({
|
|
|
- type: key,
|
|
|
- list: value,
|
|
|
- score: value.reduce((p, e) => parseInt(p) + parseInt(e
|
|
|
- .score), 0)
|
|
|
- })
|
|
|
- that.exerciseList = that.exerciseList.concat(value)
|
|
|
- }
|
|
|
- })
|
|
|
- });
|
|
|
- }
|
|
|
- // 重新赋值
|
|
|
- this.originData = this.exerciseList
|
|
|
- this.groupTypeList = this.groupList
|
|
|
- this.totalNum = newPaper.item.length
|
|
|
- console.log('groupType', this.groupTypeList);
|
|
|
- // 剩余可分配分数 更新
|
|
|
- this.surPlusScore = newPaper.score - newPaper.item.reduce((p, e) => Number(p) + Number(e.score),
|
|
|
- 0);
|
|
|
- this.$emit('scoreUpdate', this.surPlusScore)
|
|
|
- this.pageScrollTo(0)
|
|
|
- }
|
|
|
+ console.log('C-BaseExerciseList-Paper', newPaper)
|
|
|
+
|
|
|
},
|
|
|
- deep: true
|
|
|
+ immediate:true
|
|
|
+ // deep: true
|
|
|
},
|
|
|
viewModel: {
|
|
|
handler(newValue) {
|