|
@@ -2,22 +2,37 @@
|
|
|
<div class="auto-create-container">
|
|
|
<p class="auto-create-title">{{$t('evaluation.createPaper.setAutoConditions')}}</p>
|
|
|
<div class="auto-filter-wrap">
|
|
|
+ <div class="filter-wrap-item">
|
|
|
+ <span class="filter-title">{{ $t('cusMgt.typeLabel') }} : </span>
|
|
|
+ <div class="filter-content">
|
|
|
+ <RadioGroup v-model="originType" border @on-change="onFilterOriginChange" style="display: inline-block">
|
|
|
+ <Radio label="bank">{{ $t('utils.bank') }}</Radio>
|
|
|
+ <Radio label="syllabus">{{ $t('auth.syllabus') }}</Radio>
|
|
|
+ </RadioGroup>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
<div class="filter-wrap-item" v-if="!isSchoolPaper">
|
|
|
<span class="filter-title">{{$t('evaluation.createPaper.origin')}} : </span>
|
|
|
<div class="filter-content">
|
|
|
<CheckboxGroup v-model="filterOrigin" @on-change="onFilterOriginChange">
|
|
|
- <Checkbox label="private" v-if="!isSchoolPaper" :disabled="filterOrigin.length === 1 && filterOrigin[0] === 'private'">{{$t('evaluation.filter.privateBank')}}</Checkbox>
|
|
|
- <Checkbox label="school" :disabled="onlySchool" v-if="hasSchool">{{$t('evaluation.filter.schoolBank')}}</Checkbox>
|
|
|
+ <Checkbox label="private" v-if="!isSchoolPaper" :disabled="filterOrigin.length === 1 && filterOrigin[0] === 'private'">
|
|
|
+ {{ originType === 'bank' ? $t('evaluation.filter.privateBank') : $t('courseManage.syllabus.personalSyllabus') }}
|
|
|
+ </Checkbox>
|
|
|
+ <Checkbox label="school" :disabled="onlySchool" v-if="hasSchool">
|
|
|
+ {{ originType === 'bank' ? $t('evaluation.filter.schoolBank') : $t('courseManage.syllabus.schoolSyllabus') }}
|
|
|
+ </Checkbox>
|
|
|
</CheckboxGroup>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div class="filter-wrap-item" v-if="includeSchool && filterOrigin.length > 1">
|
|
|
- <span class="filter-title">{{$t('evaluation.createPaper.schoolRate')}} : </span>
|
|
|
- <div class="filter-content">
|
|
|
- <InputNumber :max="100" :min="0" :step="10" v-model="schoolRate"></InputNumber>
|
|
|
- <span style="margin-left: 10px;min-width: 300px;color: #d1d1d1;"> % ( {{$t('evaluation.createPaper.rateTip')}} )</span>
|
|
|
+ <template v-if="originType === 'bank'">
|
|
|
+ <div class="filter-wrap-item" v-if="includeSchool && filterOrigin.length > 1">
|
|
|
+ <span class="filter-title">{{$t('evaluation.createPaper.schoolRate')}} : </span>
|
|
|
+ <div class="filter-content">
|
|
|
+ <InputNumber :max="100" :min="0" :step="10" v-model="schoolRate"></InputNumber>
|
|
|
+ <span style="margin-left: 10px;min-width: 300px;color: #d1d1d1;"> % ( {{$t('evaluation.createPaper.rateTip')}} )</span>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- </div>
|
|
|
+ </template>
|
|
|
<div class="filter-wrap-item" v-if="includeSchool && !isSchoolPaper">
|
|
|
<span class="filter-title">{{$t('evaluation.newExercise.choosePeriod')}} : </span>
|
|
|
<div class="filter-content">
|
|
@@ -34,29 +49,95 @@
|
|
|
</Select>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div class="filter-wrap-item" v-for="(item,index) in quInfos" :key="index">
|
|
|
- <span class="filter-title">{{ item.label }} :</span>
|
|
|
- <div class="filter-content light-iview-select light-iview-input-number">
|
|
|
- <span class="filter-content-text">{{$t('evaluation.filter.diff')}} </span>
|
|
|
- <Select v-model="item.policy" @on-change="onSelectDiff(item,index)">
|
|
|
- <Option v-for="(diff,index) in diffList" :value="diff.level" :key="diff.level" :label="diff.label">
|
|
|
- <span>{{ diff.label }}</span>
|
|
|
- <span style="margin-left: 10px;color: red;">({{ countResult.length ? countResult.find(i => i.type === item.type).counts[index] : 0 }})</span>
|
|
|
- </Option>
|
|
|
- </Select>
|
|
|
- <span class="filter-content-text">{{$t('evaluation.createPaper.total')}} </span>
|
|
|
- <InputNumber :max="canUseArr[index]" :min="0" v-model="item.count"></InputNumber>
|
|
|
- <span class="filter-content-text" style="margin:0 10px"> {{$t('evaluation.createPaper.nums')}} </span>
|
|
|
+ <template v-if="originType === 'bank'">
|
|
|
+ <div class="filter-wrap-item" v-for="(item,index) in quInfos" :key="index">
|
|
|
+ <span class="filter-title">{{ item.label }} :</span>
|
|
|
+ <div class="filter-content light-iview-select light-iview-input-number">
|
|
|
+ <span class="filter-content-text">{{$t('evaluation.filter.diff')}} </span>
|
|
|
+ <Select v-model="item.policy" @on-change="onSelectDiff(item,index)">
|
|
|
+ <Option v-for="(diff,index) in diffList" :value="diff.level" :key="diff.level" :label="diff.label">
|
|
|
+ <span>{{ diff.label }}</span>
|
|
|
+ <span style="margin-left: 10px;color: red;">({{ countResult.length ? countResult.find(i => i.type === item.type).counts[index] : 0 }})</span>
|
|
|
+ </Option>
|
|
|
+ </Select>
|
|
|
+ <span class="filter-content-text">{{$t('evaluation.createPaper.total')}} </span>
|
|
|
+ <InputNumber :max="canUseArr[index]" :min="0" v-model="item.count"></InputNumber>
|
|
|
+ <span class="filter-content-text" style="margin:0 10px"> {{$t('evaluation.createPaper.nums')}} </span>
|
|
|
+ </div>
|
|
|
+ <span v-if="filterOrigin.length === 1">( <span style="color: #2c99c7;">{{ canUseArr[index] }}</span> {{ $t('evaluation.canChoose') }} )</span>
|
|
|
</div>
|
|
|
- <span v-if="filterOrigin.length === 1">( <span style="color: #2c99c7;">{{ canUseArr[index] }}</span> {{ $t('evaluation.canChoose') }} )</span>
|
|
|
- </div>
|
|
|
- <div class="filter-wrap-item">
|
|
|
- <span class="filter-title">{{$t('evaluation.newExercise.knowledge')}} : </span>
|
|
|
- <div class="filter-content">
|
|
|
- <Tag v-for="(item,index) in relatePoints" color="success" :key="index" :name="item" closable @on-close="onClosePoint(index)">{{ item }}</Tag>
|
|
|
- <Icon type="md-add-circle" @click="onSelectPoint" size="18" style="cursor: pointer;" />
|
|
|
+ <div class="filter-wrap-item">
|
|
|
+ <span class="filter-title">{{$t('evaluation.newExercise.knowledge')}} : </span>
|
|
|
+ <div class="filter-content">
|
|
|
+ <Tag v-for="(item,index) in relatePoints" color="success" :key="index" :name="item" closable @on-close="onClosePoint(index)">{{ item }}</Tag>
|
|
|
+ <Icon type="md-add-circle" @click="onSelectPoint" size="18" style="cursor: pointer;" />
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- </div>
|
|
|
+ </template>
|
|
|
+ <template v-else>
|
|
|
+ <!-- <div class="filter-wrap-item" v-if="!isSchoolPaper">
|
|
|
+ <span class="filter-title">{{$t('evaluation.createPaper.origin')}} : </span>
|
|
|
+ <div class="filter-content">
|
|
|
+ <CheckboxGroup v-model="filterOrigin" @on-change="onFilterOriginChange" border style="display: inline-block">
|
|
|
+ <Checkbox label="private" v-if="!isSchoolPaper" :disabled="filterOrigin.length === 1 && filterOrigin[0] === 'private'">{{ $t('courseManage.syllabus.personalSyllabus') }}</Checkbox>
|
|
|
+ <Checkbox label="school" :disabled="onlySchool" v-if="hasSchool">{{ $t('courseManage.syllabus.schoolSyllabus') }}</Checkbox>
|
|
|
+ </CheckboxGroup>
|
|
|
+ </div>
|
|
|
+ </div> -->
|
|
|
+ <div class="filter-wrap-item">
|
|
|
+ <span class="filter-title">{{ $t('auth.select') }}{{ $t('selflearn.choose.book') }} : </span>
|
|
|
+ <div class="filter-content" style="max-width: 85%;">
|
|
|
+ <template v-if="volumeList.length">
|
|
|
+ <RadioGroup v-model="volumeFilter" @on-change="getTreeByVolumeId(volumeList[volumeFilter - 1])" border style="display: inline-block; margin-bottom: 10px;">
|
|
|
+ <Radio v-for="(item, index) in volumeList" :key="index" :label="index + 1">
|
|
|
+ {{ item.name }}
|
|
|
+ <span style="color: #2db7f5;">({{ item.scope === 'school' ? $t('cusMgt.school') : $t('cusMgt.private') }})</span>
|
|
|
+ </Radio>
|
|
|
+ </RadioGroup>
|
|
|
+ </template>
|
|
|
+ <span v-else>{{ $t('assessment.no') }}</span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <template v-if="volumeList.length">
|
|
|
+ <div>
|
|
|
+ <el-tree ref="tree" :data="treeList" :props="defaultProps" class="tree" node-key="id" show-checkbox check-on-click-node accordion highlight-current @node-click="onNodeClick" :expand-on-click-node="false">
|
|
|
+ <div class="custom-tree-node" slot-scope="{ node, data }">
|
|
|
+ <span class="tree-node-lable">
|
|
|
+ <span class="text-cut" style="width: 60%;display: inline-block;vertical-align: bottom;" :title="data.title">
|
|
|
+ {{ data.title }}
|
|
|
+ </span>
|
|
|
+ </span>
|
|
|
+ <span class="ques-num">
|
|
|
+ <!-- <span class="filter-content-text">{{$t('evaluation.createPaper.total')}} </span>
|
|
|
+ {{ data.count }}
|
|
|
+ <span class="filter-content-text" style="margin:0 10px"> {{$t('evaluation.createPaper.nums')}} </span> -->
|
|
|
+ {{ $t('evaluation.index.item') }}:{{ data.quesList.length }}/{{ data.count }}
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ </el-tree>
|
|
|
+ </div>
|
|
|
+ <div class="filter-wrap-item">
|
|
|
+ <span class="filter-title">{{ $t('evaluation.createPaper.totalQues') }} : </span>
|
|
|
+ <InputNumber :max="quesTotal" :min="0" v-model="quesCount" style="width: 100px;"></InputNumber>
|
|
|
+ <span style="margin-left: 10px;"><Icon type="ios-alert" color="#e14040" />{{ $t('evaluation.createPaper.volumeTips1') }}{{ quesTotal }}{{ $t('evaluation.createPaper.volumeTips2') }}</span>
|
|
|
+ </div>
|
|
|
+ <div class="filter-wrap-item">
|
|
|
+ <span class="filter-title">{{ $t('evaluation.createPaper.questype') }} : </span>
|
|
|
+ <div class="filter-content light-iview-select light-iview-input-number">
|
|
|
+ <CheckboxGroup v-model="syllabusType">
|
|
|
+ <Checkbox v-for="(item, index) in syllQuInfos" :key="index" :label="item.type" :disabled="!item.count">
|
|
|
+ <span>{{ item.label }}</span>
|
|
|
+ (<span>{{ item.count }}</span>{{ $t('evaluation.paperPickTip2') }})
|
|
|
+ </Checkbox>
|
|
|
+ </CheckboxGroup>
|
|
|
+ </div>
|
|
|
+ <!-- <p style="color: #e14040;">
|
|
|
+ <Icon type="ios-alert" />
|
|
|
+ 未选择题型,将默认随机分配题型
|
|
|
+ </p> -->
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </template>
|
|
|
</div>
|
|
|
<div class="auto-btn-wrap">
|
|
|
<Button type="info" :loading="isLoading" @click="doAutoCreate">{{$t('evaluation.createPaper.doAutoCreate')}}</Button>
|
|
@@ -174,8 +255,63 @@ export default {
|
|
|
],
|
|
|
itemConds: [],
|
|
|
countResult: [],
|
|
|
- canUseArr: new Array(8).fill(0)
|
|
|
-
|
|
|
+ canUseArr: new Array(8).fill(0),
|
|
|
+ originType: 'bank',
|
|
|
+ volumeList: [],
|
|
|
+ treeList: [],
|
|
|
+ volumeFilter: 1,
|
|
|
+ defaultProps: {
|
|
|
+ children: 'children',
|
|
|
+ label: 'title'
|
|
|
+ },
|
|
|
+ quesCount: 0,
|
|
|
+ quesTotal: 0,
|
|
|
+ syllabusType: [],
|
|
|
+ syllQuInfos: [
|
|
|
+ {
|
|
|
+ type: 'single',
|
|
|
+ label: this.$t('evaluation.single'),
|
|
|
+ count: 0,
|
|
|
+ ids: [],
|
|
|
+ }, {
|
|
|
+ type: 'multiple',
|
|
|
+ label: this.$t('evaluation.multiple'),
|
|
|
+ count: 0,
|
|
|
+ ids: [],
|
|
|
+ }, {
|
|
|
+ type: 'judge',
|
|
|
+ label: this.$t('evaluation.judge'),
|
|
|
+ count: 0,
|
|
|
+ ids: [],
|
|
|
+ }, {
|
|
|
+ type: 'complete',
|
|
|
+ label: this.$t('evaluation.complete'),
|
|
|
+ count: 0,
|
|
|
+ ids: [],
|
|
|
+ }, {
|
|
|
+ type: 'subjective',
|
|
|
+ label: this.$t('evaluation.subjective'),
|
|
|
+ count: 0,
|
|
|
+ ids: [],
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: 'connector',
|
|
|
+ label: this.$t('evaluation.connector'),
|
|
|
+ count: 0,
|
|
|
+ ids: [],
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: 'correct',
|
|
|
+ label: this.$t('evaluation.correct'),
|
|
|
+ count: 0,
|
|
|
+ ids: [],
|
|
|
+ }, {
|
|
|
+ type: 'compose',
|
|
|
+ label: this.$t('evaluation.compose'),
|
|
|
+ count: 0,
|
|
|
+ ids: [],
|
|
|
+ }
|
|
|
+ ],
|
|
|
}
|
|
|
},
|
|
|
|
|
@@ -211,125 +347,347 @@ export default {
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
+ getVolumeList(scope) {
|
|
|
+ let findParams = {
|
|
|
+ "scope": scope,
|
|
|
+ "code": scope === 'school' ? this.$store.state.userInfo.schoolCode : this.$store.state.userInfo.TEAMModelId,
|
|
|
+ "periodId": scope === "school" ? this.periodCode : '',
|
|
|
+ "subjectId": scope === "school" ? this.subjectCode : '',
|
|
|
+ // gradeIds: this.manualFilter.gradeIds,
|
|
|
+ "status": 1,
|
|
|
+ }
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ this.$api.syllabus.FindVolumes(findParams).then(res => {
|
|
|
+ if(!res.error) {
|
|
|
+ if(!this.isSchoolPaper) res.volumes.forEach(item => item.name = `${item.name}(${scope === 'school' ? '学校' : '个人'})`)
|
|
|
+ resolve(res.volumes)
|
|
|
+ }
|
|
|
+ }).catch((e) => {
|
|
|
+ reject(e);
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 根据册别查询对应课纲树形结构 */
|
|
|
+ getTreeByVolumeId(volume) {
|
|
|
+ this.$api.syllabus.GetTreeByVolume({
|
|
|
+ volumeId: volume.id,
|
|
|
+ volumeCode: volume.code,
|
|
|
+ scope: volume.scope
|
|
|
+ }).then(res => {
|
|
|
+ if (!res.error) {
|
|
|
+ this.treeList = res.tree.map(i =>{
|
|
|
+ return i.trees[0]
|
|
|
+ })
|
|
|
+ this.getQuesNum(this.treeList)
|
|
|
+ } else {
|
|
|
+ this.$Message.warning(res.error);
|
|
|
+ this.treeList = []
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ this.treeList = []
|
|
|
+ }).finally(() => {
|
|
|
+ this.isLoading = false
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ /* 处理树中题目数量 */
|
|
|
+ /* getQuesNum(arr, obj) {
|
|
|
+ arr.forEach(item => {
|
|
|
+ item.quesList = item.rnodes.filter(nodes => nodes.type === 'item') || []
|
|
|
+ if(item.children.length) {
|
|
|
+ this.getQuesNum(item.children, item)
|
|
|
+ }
|
|
|
+ item.count = item.quesList.length
|
|
|
+ if(obj) {
|
|
|
+ obj.count += item.quesList.length
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }, */
|
|
|
+ /* 处理树中题目数量 */
|
|
|
+ getQuesNum(arr) {
|
|
|
+ let quesCount = 0
|
|
|
+ arr.forEach(item => {
|
|
|
+ item.quesList = item.rnodes.filter(nodes => nodes.type === 'item') || []
|
|
|
+ item.quesList.forEach(ques => {
|
|
|
+ let info = this.syllQuInfos.find(syll => syll.type === ques.subType)
|
|
|
+ if(info && !info.ids.includes(ques.id)) {
|
|
|
+ info.count++
|
|
|
+ info.ids.push(ques.id)
|
|
|
+ this.quesTotal ++
|
|
|
+ }
|
|
|
+ })
|
|
|
+ item.count = item.quesList.length
|
|
|
+ if(item.children.length) {
|
|
|
+ item.count += this.getQuesNum(item.children)
|
|
|
+ }
|
|
|
+ quesCount += item.count
|
|
|
+ })
|
|
|
+ return quesCount
|
|
|
+ },
|
|
|
|
|
|
/* 学段切换 */
|
|
|
onPeriodChange(val) {
|
|
|
let curPeriod = this.periodList.filter(i => i.id === val)[0]
|
|
|
this.subjectList = curPeriod.subjects
|
|
|
this.subjectCode = this.subjectList.length ? this.subjectList[0].id : ''
|
|
|
- if (this.onlySchool) {
|
|
|
- this.periodCode = val
|
|
|
- this.onCondChange()
|
|
|
+ if(this.originType === 'bank') {
|
|
|
+ if (this.onlySchool) {
|
|
|
+ this.periodCode = val
|
|
|
+ this.onCondChange()
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.onFilterOriginChange()
|
|
|
}
|
|
|
},
|
|
|
|
|
|
onSubjectChange() {
|
|
|
- this.onlySchool && this.onCondChange()
|
|
|
+ if(this.originType === 'bank') {
|
|
|
+ this.onlySchool && this.onCondChange()
|
|
|
+ } else {
|
|
|
+ this.onFilterOriginChange()
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
- /* 开始组题 */
|
|
|
+ /* 开始组题(课纲由前端来生成题目) */
|
|
|
doAutoCreate() {
|
|
|
- if (this.quInfos.map(i => i.count).filter(j => j === null).length) {
|
|
|
- this.$Message.warning(this.$t('evaluation.createPaper.noItemTip'))
|
|
|
- return
|
|
|
- }
|
|
|
- this.isLoading = true
|
|
|
- let params = []
|
|
|
- let copyInfos = JSON.parse(JSON.stringify(this.quInfos))
|
|
|
- let copyInfos2 = JSON.parse(JSON.stringify(this.quInfos))
|
|
|
- this.filterOrigin.forEach(scope => {
|
|
|
- if (scope === 'private') {
|
|
|
- params.push({
|
|
|
- code: 'Item-' + this.$store.state.userInfo.TEAMModelId,
|
|
|
- scope: scope,
|
|
|
- period: '',
|
|
|
- subject: '',
|
|
|
- points: this.relatePoints,
|
|
|
- quInfos: this.filterOrigin.length === 1 ? copyInfos : copyInfos.map(i => {
|
|
|
- i.count = (i.count - Math.round(i.count * this.schoolRate * 0.01))
|
|
|
- return i
|
|
|
- })
|
|
|
- })
|
|
|
+ if(this.originType === 'syllabus') {
|
|
|
+ if(!this.volumeList.length) return
|
|
|
+ let syllabusTree = this.$refs.tree.getCheckedNodes(false, true)
|
|
|
+ let quesList = [
|
|
|
+ {
|
|
|
+ type: 'single',
|
|
|
+ question: [],
|
|
|
+ }, {
|
|
|
+ type: 'multiple',
|
|
|
+ question: [],
|
|
|
+ }, {
|
|
|
+ type: 'judge',
|
|
|
+ question: [],
|
|
|
+ }, {
|
|
|
+ type: 'complete',
|
|
|
+ question: [],
|
|
|
+ }, {
|
|
|
+ type: 'subjective',
|
|
|
+ question: [],
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: 'connector',
|
|
|
+ question: [],
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: 'correct',
|
|
|
+ question: [],
|
|
|
+ }, {
|
|
|
+ type: 'compose',
|
|
|
+ question: [],
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ if(!this.quesCount) {
|
|
|
+ this.$Message.warning(this.$t('evaluation.createPaper.tips14'))
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if(!this.syllabusType.length) {
|
|
|
+ this.$Message.warning(this.$t('evaluation.createPaper.tips15'))
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if(!syllabusTree.length) {
|
|
|
+ this.$Message.warning(this.$t('evaluation.createPaper.tips16'))
|
|
|
+ return
|
|
|
} else {
|
|
|
- params.push({
|
|
|
- code: 'Item-' + this.$store.state.userInfo.schoolCode,
|
|
|
- scope: scope,
|
|
|
- period: this.periodCode,
|
|
|
- subject: this.subjectCode,
|
|
|
- points: this.relatePoints,
|
|
|
- quInfos: this.filterOrigin.length === 1 ? copyInfos2 : copyInfos2.map((i, index) => {
|
|
|
- i.count = Math.round(i.count * this.schoolRate * 0.01)
|
|
|
- return i
|
|
|
+ // let syllQues = syllabusTree.map(item => item.quesList).flat()
|
|
|
+ let syllQues = []
|
|
|
+ syllabusTree.forEach(item => {
|
|
|
+ item.quesList.forEach(ques => {
|
|
|
+ ques.nodeId = item.id
|
|
|
+ ques.blob = ques.link
|
|
|
+ syllQues.push(ques)
|
|
|
})
|
|
|
})
|
|
|
+ syllQues.forEach(item => {
|
|
|
+ let info = quesList.find(ques => ques.type === item.subType)
|
|
|
+ if(info && !info.question.find(infos => infos.id === item.id)) {
|
|
|
+ info.question.push(item)
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
- })
|
|
|
+ this.isLoading = true
|
|
|
+ let syllAutoQues = [] //组成题目集合
|
|
|
+ let excessNum = this.quesCount //排除一道题目的类型后,剩余题目数量
|
|
|
+ let excessQues = [] //有多道题目的类型
|
|
|
+ this.syllabusType.forEach(item => {
|
|
|
+ let info = quesList.find(ques => ques.type === item)
|
|
|
+ if(info && info.question.length) {
|
|
|
+ if(info.question.length > 1) {
|
|
|
+ excessQues.push({type: info.type, num: 0})
|
|
|
+ } else {
|
|
|
+ excessNum--
|
|
|
+ info.question[0].blob = info.question[0].link
|
|
|
+ syllAutoQues.push(info.question[0])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ if(excessQues.length) {
|
|
|
+ if(excessQues.length === 1) {
|
|
|
+ excessQues[0].num = excessNum
|
|
|
+ } else { //多个题型有多个题目时,随机分配数量 >= 1
|
|
|
+ excessQues = this.setTypeNum(excessQues, excessNum, quesList)
|
|
|
+ }
|
|
|
+ excessQues.forEach(item => {
|
|
|
+ let info = quesList.find(ques => ques.type === item.type)
|
|
|
+ if(info) {
|
|
|
+ const array = []
|
|
|
+ for (let i = 0; i < info.question.length; i++) {
|
|
|
+ array.push(i)
|
|
|
+ }
|
|
|
+ const indexArr = []
|
|
|
+ while (indexArr.length < item.num) {
|
|
|
+ const index = Math.floor(Math.random() * array.length)
|
|
|
+ indexArr.push(array[index])
|
|
|
+ array.splice(index, 1)
|
|
|
+ }
|
|
|
+ for (let i = 0; i < indexArr.length; i++) {
|
|
|
+ info.question[indexArr[i]].blob = info.question[indexArr[i]].link
|
|
|
+ info.question[indexArr[i]].blob = info.question[indexArr[i]].link
|
|
|
+ syllAutoQues.push(info.question[indexArr[i]])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ // 根据选出来的题目id 获取blob信息
|
|
|
+ this.$emit('autoQuestions', syllAutoQues, true)
|
|
|
+ this.isLoading = false
|
|
|
|
|
|
- // 针对自定义难度的参数进行调整
|
|
|
- params.forEach(i => {
|
|
|
- i.quInfos.forEach(j => {
|
|
|
- if (j.policy === 'random' || j.policy === 'average') {
|
|
|
- j.custom = []
|
|
|
+ } else {
|
|
|
+ if (this.quInfos.map(i => i.count).filter(j => j === null).length) {
|
|
|
+ this.$Message.warning(this.$t('evaluation.createPaper.noItemTip'))
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.isLoading = true
|
|
|
+ let params = []
|
|
|
+ let copyInfos = JSON.parse(JSON.stringify(this.quInfos))
|
|
|
+ let copyInfos2 = JSON.parse(JSON.stringify(this.quInfos))
|
|
|
+ this.filterOrigin.forEach(scope => {
|
|
|
+ if (scope === 'private') {
|
|
|
+ params.push({
|
|
|
+ code: 'Item-' + this.$store.state.userInfo.TEAMModelId,
|
|
|
+ scope: scope,
|
|
|
+ period: '',
|
|
|
+ subject: '',
|
|
|
+ points: this.relatePoints,
|
|
|
+ quInfos: this.filterOrigin.length === 1 ? copyInfos : copyInfos.map(i => {
|
|
|
+ i.count = (i.count - Math.round(i.count * this.schoolRate * 0.01))
|
|
|
+ return i
|
|
|
+ })
|
|
|
+ })
|
|
|
} else {
|
|
|
- j.custom = [{
|
|
|
- level: this.diffList.find(k => k.level === j.policy).value,
|
|
|
- count: j.count
|
|
|
- }]
|
|
|
- j.policy = 'custom'
|
|
|
+ params.push({
|
|
|
+ code: 'Item-' + this.$store.state.userInfo.schoolCode,
|
|
|
+ scope: scope,
|
|
|
+ period: this.periodCode,
|
|
|
+ subject: this.subjectCode,
|
|
|
+ points: this.relatePoints,
|
|
|
+ quInfos: this.filterOrigin.length === 1 ? copyInfos2 : copyInfos2.map((i, index) => {
|
|
|
+ i.count = Math.round(i.count * this.schoolRate * 0.01)
|
|
|
+ return i
|
|
|
+ })
|
|
|
+ })
|
|
|
}
|
|
|
})
|
|
|
- })
|
|
|
|
|
|
- // 访问API获取随机题目
|
|
|
- this.$api.learnActivity.Automatic(params).then(
|
|
|
- res => {
|
|
|
- if (res.length > 0) {
|
|
|
- let needCount = params.reduce((a, b) => a + b.quInfos.reduce((c, d) => c + d.count, 0), 0)
|
|
|
- let getCount = res.reduce((a, b) => a + b.count, 0)
|
|
|
- if (needCount > getCount) {
|
|
|
- console.log(needCount, getCount);
|
|
|
- this.$Modal.confirm({
|
|
|
- title: this.$t('settings.modalTip4'),
|
|
|
- content: this.$t('evaluation.createPaper.tip10'),
|
|
|
- onOk: () => {
|
|
|
- let result = []
|
|
|
- res.forEach(i => {
|
|
|
- result = result.concat(i.item)
|
|
|
- })
|
|
|
- console.log('组题成功', result)
|
|
|
- this.$emit('autoQuestions', result)
|
|
|
- this.isLoading = false
|
|
|
- },
|
|
|
- onCancel: () => {
|
|
|
- this.isLoading = false
|
|
|
- }
|
|
|
- })
|
|
|
+ // 针对自定义难度的参数进行调整
|
|
|
+ params.forEach(i => {
|
|
|
+ i.quInfos.forEach(j => {
|
|
|
+ if (j.policy === 'random' || j.policy === 'average') {
|
|
|
+ j.custom = []
|
|
|
} else {
|
|
|
- let result = []
|
|
|
- res.forEach(i => {
|
|
|
- result = result.concat(i.item)
|
|
|
- })
|
|
|
- console.log('组题成功', result)
|
|
|
- this.$emit('autoQuestions', result)
|
|
|
- this.isLoading = false
|
|
|
+ j.custom = [{
|
|
|
+ level: this.diffList.find(k => k.level === j.policy).value,
|
|
|
+ count: j.count
|
|
|
+ }]
|
|
|
+ j.policy = 'custom'
|
|
|
}
|
|
|
+ })
|
|
|
+ })
|
|
|
|
|
|
- } else {
|
|
|
- this.$Message.error(this.$t('evaluation.createPaper.noResultTip'))
|
|
|
+ // 访问API获取随机题目
|
|
|
+ this.$api.learnActivity.Automatic(params).then(
|
|
|
+ res => {
|
|
|
+ if (res.length > 0) {
|
|
|
+ let needCount = params.reduce((a, b) => a + b.quInfos.reduce((c, d) => c + d.count, 0), 0)
|
|
|
+ let getCount = res.reduce((a, b) => a + b.count, 0)
|
|
|
+ if (needCount > getCount) {
|
|
|
+ console.log(needCount, getCount);
|
|
|
+ this.$Modal.confirm({
|
|
|
+ title: this.$t('settings.modalTip4'),
|
|
|
+ content: this.$t('evaluation.createPaper.tip10'),
|
|
|
+ onOk: () => {
|
|
|
+ let result = []
|
|
|
+ res.forEach(i => {
|
|
|
+ result = result.concat(i.item)
|
|
|
+ })
|
|
|
+ console.log('组题成功', result)
|
|
|
+ this.$emit('autoQuestions', result)
|
|
|
+ this.isLoading = false
|
|
|
+ },
|
|
|
+ onCancel: () => {
|
|
|
+ this.isLoading = false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ let result = []
|
|
|
+ res.forEach(i => {
|
|
|
+ result = result.concat(i.item)
|
|
|
+ })
|
|
|
+ console.log('组题成功', result)
|
|
|
+ this.$emit('autoQuestions', result)
|
|
|
+ this.isLoading = false
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ this.$Message.error(this.$t('evaluation.createPaper.noResultTip'))
|
|
|
+ setTimeout(() => {
|
|
|
+ this.isLoading = false
|
|
|
+ }, 1000)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ err => {
|
|
|
+ this.$Message.error('API ERROR!')
|
|
|
setTimeout(() => {
|
|
|
this.isLoading = false
|
|
|
}, 1000)
|
|
|
}
|
|
|
- },
|
|
|
- err => {
|
|
|
- this.$Message.error('API ERROR!')
|
|
|
- setTimeout(() => {
|
|
|
- this.isLoading = false
|
|
|
- }, 1000)
|
|
|
- }
|
|
|
- )
|
|
|
+ )
|
|
|
|
|
|
- console.log(params)
|
|
|
+ console.log(params)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 为题型随机分配数量
|
|
|
+ setTypeNum(arr, total, quesList) {
|
|
|
+ let partSum = total / arr.length
|
|
|
+ arr.forEach((item, index) => {
|
|
|
+ // 题目数量不能超过题型本身数量
|
|
|
+ let info = quesList.find(ques => ques.type === item.type)
|
|
|
+ let num = index === arr.length - 1 ?
|
|
|
+ ((info.question.length - item.num) > total ? total : (info.question.length - item.num)) :
|
|
|
+ (Math.floor(Math.random() * (info ? ((info.question.length - item.num) > (partSum - 1) ? (partSum - 1) : (info.question.length - item.num)) : (partSum - 1))) + 1)
|
|
|
+ item.num += num
|
|
|
+ item.noRemain = info.question.length === item.num ? true : false
|
|
|
+ total -= num
|
|
|
+ })
|
|
|
+ // 筛出未分配完题目的题型,再继续分配数量,直至 total = 0
|
|
|
+ if(total) {
|
|
|
+ let autoArr = arr.filter(item => !item.noRemain)
|
|
|
+ if(autoArr.length) {
|
|
|
+ autoArr = this.setTypeNum(autoArr, total, quesList)
|
|
|
+ autoArr.forEach(item => {
|
|
|
+ let info = arr.find(ques => ques.type === item.type)
|
|
|
+ let quesinfo = quesList.find(ques => ques.type === item.type)
|
|
|
+ // info.num = info.num + item.num
|
|
|
+ info.noRemain = quesinfo.question.length === info.num ? true : false
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return arr
|
|
|
},
|
|
|
|
|
|
onClosePoint(index) {
|
|
@@ -351,15 +709,39 @@ export default {
|
|
|
},
|
|
|
|
|
|
/* 来源选择 */
|
|
|
- onFilterOriginChange() {
|
|
|
- if (this.filterOrigin.length === 1) {
|
|
|
- this.getFilterCount(this.filterOrigin[0]).then(res => {
|
|
|
- this.itemConds = res
|
|
|
- this.onCondChange()
|
|
|
- })
|
|
|
+ async onFilterOriginChange() {
|
|
|
+ if(this.originType === 'bank') {
|
|
|
+ if (this.filterOrigin.length === 1) {
|
|
|
+ this.getFilterCount(this.filterOrigin[0]).then(res => {
|
|
|
+ this.itemConds = res
|
|
|
+ this.onCondChange()
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ let resultList = []
|
|
|
+ for (let i = 0; i < this.filterOrigin.length; i++) {
|
|
|
+ try {
|
|
|
+ let data = []
|
|
|
+ data = await this.getVolumeList(this.filterOrigin[i]);
|
|
|
+ resultList = resultList.concat(data);
|
|
|
+ } catch (e) {
|
|
|
+ console.log(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.treeList = []
|
|
|
+ this.volumeList = resultList
|
|
|
+ this.volumeFilter = 1
|
|
|
+ if(this.volumeList.length) {
|
|
|
+ this.getTreeByVolumeId(this.volumeList[0])
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
|
|
|
+ /* 点击某个节点 */
|
|
|
+ async onNodeClick(data) {
|
|
|
+ console.log('111111111111', data);
|
|
|
+ },
|
|
|
+
|
|
|
/* 题目数量发生变化 */
|
|
|
async onCondChange() {
|
|
|
// if(!this.isSchoolPaper) return
|