123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240 |
- <template>
- <div class="auto-create-container">
- <p class="auto-create-title">设置自动出题条件</p>
- <div class="auto-filter-wrap">
- <div class="filter-wrap-item">
- <span class="filter-title">题目来源 : </span>
- <div class="filter-content">
- <CheckboxGroup v-model="filterOrigin">
- <Checkbox label="private" v-if="!isSchoolPaper" :disabled="filterOrigin.length === 1 && filterOrigin[0] === 'private'">个人题库</Checkbox>
- <Checkbox label="school" :disabled="filterOrigin.length === 1 && filterOrigin[0] === 'school'">校本题库</Checkbox>
- </CheckboxGroup>
- </div>
- </div>
- <div class="filter-wrap-item animated fadeIn" v-if="includeSchool">
- <span class="filter-title">校本占比 : </span>
- <div class="filter-content">
- <InputNumber :max="100" :min="0" :step="10" v-model="schoolRate"></InputNumber>
- <span style="margin-left: 10px;"> %</span>
- </div>
- </div>
- <div class="filter-wrap-item animated fadeIn" v-if="includeSchool">
- <span class="filter-title">选择学段 : </span>
- <div class="filter-content">
- <Select v-model="periodCode" >
- <Option v-for="item in periodList" :value="item.id" :key="item.id">{{ item.name }}</Option>
- </Select>
- </div>
- </div>
- <div class="filter-wrap-item animated fadeIn" v-if="includeSchool">
- <span class="filter-title">选择科目 : </span>
- <div class="filter-content">
- <Select v-model="subjectCode">
- <Option v-for="item in subjectList" :value="item.id" :key="item.id">{{ item.name }}</Option>
- </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">
- <span class="filter-content-text">难度 </span>
- <Select v-model="item.policy">
- <Option v-for="item in diffList" :value="item.level" :key="item.level">{{ item.label }}</Option>
- </Select>
- <span class="filter-content-text">共 </span>
- <InputNumber :max="10" :min="0" v-model="item.count"></InputNumber>
- <span class="filter-content-text"> 道题 </span>
- </div>
- </div>
- </div>
- <div class="auto-btn-wrap">
- <Button type="info" :loading="isLoading" @click="doAutoCreate">开始组题</Button>
- </div>
- </div>
- </template>
- <script>
- export default{
- name:'AutoCreate',
- data(){
- return {
- isLoading:false,
- filterOrigin:['private'],
- periodList:[],
- periodCode:'',
- subjectList:[],
- subjectCode:'',
- schoolRate:50,
- quInfos:[{
- type:'single',
- label:'单选题',
- count:0,
- policy:'random'
- },{
- type:'multiple',
- label:'多选题',
- count:0,
- policy:'random'
- },{
- type:'judge',
- label:'判断题',
- count:0,
- policy:'random'
- },{
- type:'complete',
- label:'填空题',
- count:0,
- policy:'random'
- },{
- type:'subjective',
- label:'问答题',
- count:0,
- policy:'random'
- },{
- type:'compose',
- label:'综合题',
- count:0,
- policy:'random'
- }],
- diffList:[
- {
- level: 'random',
- label: '随机',
- value: -1
- },
- {
- level: 'average',
- label: '平均分配',
- value: 0
- },
- {
- level: 'relativeEasy',
- label: '较易',
- value: 1
- },
- {
- level: 'easy',
- label: '容易',
- value: 2
- },
- {
- level: 'common',
- label: '一般',
- value: 3
- },
- {
- level: 'difficulty',
- label: '困难',
- value: 4
- },
- {
- level: 'relativeDifficulty',
- label: '较难',
- value: 5
- }
- ]
- }
- },
- created() {
- this.getSchoolBaseInfo().then(res => {
- if (!res) return
- if(res.period.length){
- this.periodList = res.period
- this.periodCode = res.period[0].id
- this.subjectList = res.period[0].subjects
- this.subjectCode = this.subjectList.length ? this.subjectList[0].id : ''
- }
- })
- },
- methods:{
-
- /** 获取当前学校基础数据 */
- getSchoolBaseInfo() {
- return new Promise((r, j) => {
- this.$store.dispatch("user/getSchoolProfile").then((res) => {
- let schoolBaseInfo = res.school_base;
- if (schoolBaseInfo) {
- r(schoolBaseInfo)
- } else {
- r(null)
- }
- });
- })
- },
-
- /* 开始组题 */
- doAutoCreate(){
- console.log(this.quInfos)
- console.log(this.filterOrigin)
- this.isLoading = true
- let params = []
- let copyInfos = 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: '',
- points:[],
- quInfos: copyInfos.map(i => {
- i.count = (i.count - Math.round(i.count * this.schoolRate * 0.01))
- return i
- })
- })
- }else{
- params.push({
- code:'Item-' + this.$store.state.userInfo.schoolCode,
- scope: scope,
- period: '',
- points:[],
- quInfos: this.quInfos.map(i => {
- i.count = Math.round(i.count * this.schoolRate * 0.01)
- return i
- })
- })
- }
- })
- // 访问API获取随机题目
- this.$api.learnActivity.Automatic(params).then(
- res => {
- if (res.length > 0) {
- console.log('组题成功', res)
- this.isLoading = false
- } else {
- this.$Message.error('未能匹配满足条件的题目!')
- setTimeout(() => {
- this.isLoading = false
- }, 1000)
- }
- },
- err => {
- this.$Message.error('API ERROR!')
- setTimeout(() => {
- this.isLoading = false
- }, 1000)
- }
- )
-
- console.log(params)
- }
- },
- mounted() {
- if(this.isSchoolPaper){
- this.filterOrigin = ['school']
- this.schoolRate = 100
- }
- },
- computed:{
- includeSchool(){
- return this.filterOrigin.indexOf('school') > -1
- },
- isSchoolPaper(){
- return this.$route.name === 'newSchoolPaper'
- }
- }
- }
- </script>
- <style lang="less">
- @import "./AutoCreateNew.less";
- </style>
|