题目管理

This commit is contained in:
18571350067 2021-11-07 17:16:36 +08:00
parent 612846b052
commit 249ebff4ed
9 changed files with 612 additions and 38 deletions

View File

@ -1,7 +1,7 @@
import request from '@/utils/request'
const questionApi = {
// add: 'sys/menu/add',
add: 'courseManagement/question/addOrUpdate',
get: '/courseManagement/question/details',
// update: 'sys/menu/update',
// del: 'courseManagement/course/delete',
@ -12,13 +12,15 @@ const questionApi = {
}
// export function menuAdd (params) {
// return request({
// url: menuApi.add,
// method: 'post',
// data: params
// })
// }
// 题目新增
export function questionAdd (params) {
return request({
url: questionApi.add,
method: 'post',
data: params
})
}
// export function menuGet (params) {
// return request({
// url: menuApi.get,

View File

@ -1,6 +1,9 @@
<template>
<a-card :bordered="false" title="系統新增">
<a-form-model :model="form">
<div style="width: 100%; height: 40px; margin-bottom: 8px; margin-left: 80%">
<a-button type="primary" @click="goback">返回</a-button>
</div>
<a-row>
<!-- 课程名称 -->
<a-col :span="18" :offset="3">
@ -19,7 +22,7 @@
</a-form-model-item>
</a-col>
<!-- -->
<!-- 件大小 -->
<a-col :span="9">
<a-form-item label="课时" :label-col="{ span: 4 }" :wrapper-col="{ span: 10 }">
<a-input-number id="hour" v-model="dataValue" :min="1" :max="1000" @change="onChange" :style="{ display: 'ln', width: '100%' }" />
@ -93,9 +96,9 @@
</a-form-model-item>
</a-col>
</a-row>
<a-row :span="18" :offset="3">
<a-button @click="save">保存</a-button>
</a-row>
<div style="width: 100%; height: 40px; margin-bottom: 8px; margin-left: 50%">
<a-button type="primary" @click="save">保存</a-button>
</div>
</a-form-model>
</a-card>
</template>
@ -118,10 +121,12 @@ export default {
{ id: '2', name: '人员类别2' },
{ id: '3', name: '人员类别3' },
],
previewVisible: false,
fileList: []
fileList: [],
previewImage :[
]
}
},
@ -164,6 +169,11 @@ export default {
})
},
//
goback(){
this.$router.push({path:"/course/CourseList",query:{} })
},
getToken() {
let hreader = {};
hreader[ACCESS_TOKEN] = storage.get(ACCESS_TOKEN);
@ -188,5 +198,18 @@ export default {
},
},
}
// Base64
function getBase64(file) {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = () => resolve(reader.result);
reader.onerror = error => reject(error);
});
}
</script>

View File

@ -1,5 +1,4 @@
<template>
<page-header-wrapper :title="false">
<a-card :bordered="false" title="课程列表">
<div class="table-page-search-wrapper">
<SearchCom :form="queryParam" :list="queryOptions" @search="handleRefresh" @reset="() => {queryParam = {}, handleRefresh()}" ></SearchCom>
@ -23,7 +22,6 @@
</template>
</s-table>
</a-card>
</page-header-wrapper>
</template>
<script>

View File

@ -0,0 +1,154 @@
<template>
<a-card :bordered="false" title="添加课件">
<a-form-model :model="form">
<div style="width: 100%; height: 40px; margin-bottom: 8px; margin-left: 80%">
<a-button type="primary" @click="goback">返回</a-button>
</div>
<a-row>
<!-- 课程名称 -->
<a-col :span="18" :offset="3">
<a-form-model-item label="课件名称" :label-col="{ span: 4 }" :wrapper-col="{ span: 15 }">
<a-input v-model="form.courseName" v-decorator="['courseName', { rules: [{ required: true, message: '请填写课程名称' }] }]" />
</a-form-model-item>
</a-col>
<!-- 课件分类 -->
<a-col :span="9" :offset="3">
<a-form-model-item label="课件分类" :label-col="{ span: 8 }" :wrapper-col="{ span: 12 }">
<a-button type="primary" @click="classify">添加分类</a-button>
</a-form-model-item>
</a-col>
<!-- 课件大小 -->
<a-col :span="9">
<a-form-item label="课件大小" :label-col="{ span: 9 }" :wrapper-col="{ span: 14 }">
<div>
<a-input-number :disabled="false"/>
<div style="marginTop:15px">
<a-button type="primary" @click="toggle">
Toggle disabled
</a-button>
</div>
</div>
</a-form-item>
</a-col>
<!-- 上传课件 -->
<a-col :span="18" :offset="3">
<a-form-model-item label="上传课件" :label-col="{ span: 4 }" :wrapper-col="{ span: 15 }">
<a-upload action="/dawa/sys/oss/upload?sourceId=course" list-type="picture-card" :file-list="fileList" :headers="getToken()" @change="handleChange" @preview="handlePreview">
<div v-if="fileList.length < 1">
<a-icon type="plus" />
<div class="ant-upload-text">上传</div>
</div>
</a-upload>
<a-modal :visible="previewVisible" :footer="null" @cancel="handleCancel">
<img alt="example" style="width: 100%" :src="previewImage" />
</a-modal>
<!-- <a-upload name="file" list-type="picture-card" class="avatar-uploader" :show-upload-list="false" action="" :headers="getToken()" :change="onSuccess">
<img v-if="imageUrl" :src="imageUrl" alt="avatar" />
<div v-else>
<a-icon :type="loading ? 'loading' : 'plus'" />
<div class="ant-upload-text">封面图片</div>
</div>
</a-upload> -->
</a-form-model-item>
</a-col>
</a-row>
<div style="width: 100%; height: 40px; margin-bottom: 8px; margin-left: 50%">
<a-button type="primary" @click="save">保存</a-button>
</div>
</a-form-model>
</a-card>
</template>
<script>
import { courseAdd, getCourseDetails } from '@/api/course/course'
import storage from 'store'
import { ACCESS_TOKEN } from '@/store/mutation-types'
export default {
name: 'step1',
data() {
return {
dataValue: 1,
form: {},
personType: [
{ id: '1', name: '人员类别1' },
{ id: '2', name: '人员类别2' },
{ id: '3', name: '人员类别3' },
],
previewVisible: false,
fileList: [],
previewImage :[
]
}
},
components: {
courseAdd,
getCourseDetails
},
created() {
if (this.$route.query.id) {
getCourseDetails({ id: this.$route.query.id }).then(res => {
this.form = res.data;
this.form.courseType = this.form.courseType + '';
this.form.industryInvolved = this.form.industryInvolved + '';
this.form.isRequired = this.form.isRequired + '';
});
}
},
methods: {
//
goback(){
this.$router.push({path:"/course/CourseList",query:{} })
},
getToken() {
let hreader = {};
hreader[ACCESS_TOKEN] = storage.get(ACCESS_TOKEN);
return hreader;
},
onSuccess(file) {
console.log('1---', file);
},
handleCancel() {
this.previewVisible = false;
},
async handlePreview(file) {
if (!file.url && !file.preview) {
file.preview = await getBase64(file.originFileObj);
}
this.previewImage = file.url || file.preview;
this.previewVisible = true;
},
handleChange({ fileList }) {
this.fileList = fileList;
},
},
}
// Base64
function getBase64(file) {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = () => resolve(reader.result);
reader.onerror = error => reject(error);
});
}
</script>

View File

@ -1,9 +1,10 @@
<template>
<page-header-wrapper :title="false">
<a-card :bordered="false">
<span style="font-size : 20px; margin-left :15px">课件信息</span>
<div class="button" style="width: 100%; height: 32px; margin-bottom: 8px; margin-left: 85%;">
<a-button type="primary" @click="goback">返回</a-button>
<a-card :bordered="false" title="项目档案">
<template slot="extra">
<a-button size="small" @click="goback">返回</a-button>
</template>
<div class="button" style="width: 100%; height: 32px; margin-bottom: 8px; margin-right: 10%;">
<!-- <a-button type="primary" @click="goback">返回</a-button> -->
<a-button type="primary" @click="coursewareAdd">上传课件</a-button>
</div>
<s-table ref="table" size="default" rowKey="id" :columns="columns" :data="loadData">
@ -20,13 +21,11 @@
</template>
</s-table>
</a-card>
</page-header-wrapper>
</template>
<script>
import { STable, SearchCom } from '@/components'
import { getCoursewareListByCourseId } from '@/api/course/course'
import { deleteCourseware } from '@/api/course/courseware'
import { coursewareAdd } from '@/api/course/courseware'
export default {
components: {
@ -54,7 +53,7 @@ export default {
methods: {
//
coursewareAdd(){
this.$router.push({path:"/course/courseware/coursewareAdd",query:{}})
this.$router.push({path:"/course/CoursewareAddOrUpdate",query:{}})
},
//

View File

@ -0,0 +1,392 @@
<template>
<a-card :bordered="false" title="新增习题">
<template slot="extra">
<a-button size="small" @click="close">返回</a-button>
<a-button size="small" type="primary" @click="queding">确定</a-button>
</template>
<a-tabs :animated="false" :default-active-key="tabKey" @change="callback" :headStyle="{ paddingTop: '0px' }">
<!-- 单选题 -->
<a-tab-pane key="1" tab="单选">
<a-radio-group v-model="radio.rightAnswers" style="width: 100%">
<a-card title="题目(题干内容)" :bordered="false">
<a-textarea placeholder="" :rows="6" v-model="radio.questionName" style="width: 100%" />
</a-card>
<a-card :bordered="false">
<template slot="title">
选项从选项中选择一个作为答案<br />A &nbsp;&nbsp;
<a-radio value="A">答案</a-radio>
</template>
<a-textarea placeholder="" :rows="6" v-model="radio.answerA" style="width: 100%" />
</a-card>
<a-card :bordered="false">
<template slot="title">
B &nbsp;&nbsp;
<a-radio value="B">答案</a-radio>
</template>
<a-textarea placeholder="" :rows="6" v-model="radio.answerB" style="width: 100%" />
</a-card>
<a-card :bordered="false">
<template slot="title">
C &nbsp;&nbsp;
<a-radio value="C">答案</a-radio>
</template>
<a-textarea placeholder="" :rows="6" v-model="radio.answerC" style="width: 100%" />
</a-card>
<a-card :bordered="false">
<template slot="title">
D &nbsp;&nbsp;
<a-radio value="D">答案</a-radio>
</template>
<a-textarea placeholder="" :rows="6" v-model="radio.answerD" style="width: 100%" />
</a-card>
<a-card title="答案解析" :bordered="false">
<a-textarea placeholder="" :rows="6" v-model="radio.asnwerParse" style="width: 100%" />
</a-card>
</a-radio-group>
</a-tab-pane>
<!-- 多选题 -->
<a-tab-pane key="2" tab="多选">
<a-card title="题目(题干内容)" :bordered="false">
<a-textarea placeholder="" :rows="6" v-model="multiselect.questionName" style="width: 100%" />
</a-card>
<a-card :bordered="false">
<template slot="title">
选项从选项中选择一个作为答案<br />A &nbsp;&nbsp;
<a-checkbox v-model="multiselect.a" value="A">答案</a-checkbox>
</template>
<a-textarea placeholder="" :rows="6" v-model="multiselect.answerA" style="width: 100%" />
</a-card>
<a-card :bordered="false">
<template slot="title">
B &nbsp;&nbsp;
<a-checkbox v-model="multiselect.b" value="B">答案</a-checkbox>
</template>
<a-textarea placeholder="" :rows="6" v-model="multiselect.answerB" style="width: 100%" />
</a-card>
<a-card :bordered="false">
<template slot="title">
C &nbsp;&nbsp;
<a-checkbox v-model="multiselect.c" value="C">答案</a-checkbox>
</template>
<a-textarea placeholder="" :rows="6" v-model="multiselect.answerC" style="width: 100%" />
</a-card>
<a-card :bordered="false">
<template slot="title">
D &nbsp;&nbsp;
<a-checkbox v-model="multiselect.d" value="D">答案</a-checkbox>
</template>
<a-textarea placeholder="" :rows="6" v-model="multiselect.answerD" style="width: 100%" />
</a-card>
<a-card title="答案解析" :bordered="false">
<a-textarea placeholder="" :rows="6" v-model="multiselect.asnwerParse" style="width: 100%" />
</a-card>
</a-tab-pane>
<!-- 判断题 -->
<a-tab-pane key="3" tab="判断">
<a-radio-group v-model="estimate.rightAnswers" style="width: 100%">
<a-card title="题目(题干内容)" :bordered="false">
<a-textarea placeholder="" :rows="6" v-model="estimate.questionName" style="width: 100%" />
</a-card>
<a-card :bordered="false">
<template slot="title">
选项从选项中选择一个作为答案<br />
<a-radio :value="1"> 正确 </a-radio>
<a-radio :value="2"> 错误 </a-radio>
</template>
</a-card>
<a-card title="答案解析" :bordered="false">
<a-textarea placeholder="" :rows="6" v-model="estimate.asnwerParse" style="width: 100%" />
</a-card>
</a-radio-group>
</a-tab-pane>
<!-- 简答题 -->
<a-tab-pane key="4" tab="简答">
<a-card title="题目(题干内容)" :bordered="false">
<a-textarea placeholder="" :rows="6" v-model="shortAnswer.questionName" style="width: 100%" />
</a-card>
<a-card :bordered="false">
<template slot="title"> 答案 </template>
<a-textarea placeholder="" :rows="6" v-model="shortAnswer.rightAnswers" style="width: 100%" />
</a-card>
<a-card title="答案解析" :bordered="false">
<a-textarea placeholder="" :rows="6" v-model="shortAnswer.asnwerParse" style="width: 100%" />
</a-card>
</a-tab-pane>
<!-- 填空题 -->
<a-tab-pane key="5" tab="填空">
<a-card title="题目(题干内容)" :bordered="false">
<a-textarea placeholder="" :rows="6" v-model="Completion.questionName" style="width: 100%" />
</a-card>
<a-card title="答案" :bordered="false">
<div style="text-align: center; margin-bottom: 10px">
<a-button type="primary" style="width: 40%" @click="addAnswerSize">添加一个新填空</a-button>
<a-button style="width: 40%" @click="delAnswerSize">刪除一个新填空</a-button>
</div>
<div v-for="(answer, index) in answerList" :key="index" style="margin-bottom: 10px">
<a-input :value="answerList[index]" @change="onChangeInput">
<template slot="addonBefore">
<b>填空{{ index+1 }}:</b>
</template>
</a-input>
</div>
</a-card>
<a-card title="答案解析" :bordered="false">
<a-textarea placeholder="" :rows="6" v-model="Completion.asnwerParse" style="width: 100%" />
</a-card>
</a-tab-pane>
</a-tabs>
</a-card>
</template>
<script>
import { questionAdd, getQuestionDeatil } from '@/api/course/question/question'
export default {
components: {},
data() {
return {
radio: {},
multiselect: {},
estimate: {},
shortAnswer: {},
answerList: ["111","222","333"],
Completion: { },
tabKey: this.$route.query.questionType ? this.$route.query.questionType : '1'
// tabKey,
}
},
created() {
if (this.$route.query.id) {
getQuestionDeatil({ id: this.$route.query.id }).then((res) => {
console.log(this.tabKey)
if (this.tabKey == '1') {
this.radio = res.data
} else if (this.tabKey == '2') {
this.multiselect = res.data
}
})
}
},
methods: {
close() {
this.$router.push({
path: '/course/question/QuestionList',
query: {
id: this.$route.query.courseId,
},
})
},
// getQuestionType() {
// if (!this.$route.query.questionType || this.$route.query.questionType === '') tabKey = '1'
// tabKey = this.$route.query.questionType
// },
callback(key) {
this.radio = {}
this.multiselect = {}
this.estimate = {}
this.shortAnswer = {}
this.Completion = { answerSize: 2 }
this.tabKey = key
},
onChangeInput(e) {
},
//
addAnswerSize() {
if (this.answerList.length == 10) {
this.$message.error('填空数量最多不能超过10个')
return
}
this.answerList.push('')
},
//
delAnswerSize() {
if (this.answerList.length == 1) {
this.$message.error('填空数量最少不能少于1个')
return
}
this.Completion.answerSize--
},
//
queding() {
let from
if (this.tabKey === '1') {
from = this.radioV()
if (typeof from == 'boolean' && !from) return
} else if (this.tabKey === '2') {
from = this.multiselectV()
if (typeof from == 'boolean' && !from) return
} else if (this.tabKey === '3') {
from = this.estimateV()
if (typeof from == 'boolean' && !from) return
} else if (this.tabKey === '4') {
from = this.shortAnswerV()
if (typeof from == 'boolean' && !from) return
} else if (this.tabKey === '5') {
from = this.CompletionV()
if (typeof from == 'boolean' && !from) return
console.log('5---', this.Completion)
}
console.log('a--')
from.courseId = this.$route.query.courseId
questionAdd(from).then((res) => {
this.$message.success('新增题目成功!')
this.close()
})
},
//
radioV() {
//
if (!this.radio.questionName || this.radio.questionName === '') {
this.$message.error('题目(题干内容)不能为空!')
return false
}
//
if (!this.radio.answerA || this.radio.answerA === '') {
this.$message.error('答案A不能为空!')
return false
} else if (!this.radio.answerB || this.radio.answerB === '') {
this.$message.error('答案B不能为空!')
return false
} else if (!this.radio.answerC || this.radio.answerC === '') {
this.$message.error('答案C不能为空!')
return false
} else if (!this.radio.answerD || this.radio.answerD === '') {
this.$message.error('答案D不能为空!')
return false
}
//
if (!this.radio.rightAnswers || this.radio.rightAnswers === '') {
this.$message.error('请选择正确答案!')
return false
}
let from = {}
from = this.radio
from.questionType = 1
return from
},
//
multiselectV() {
//
if (!this.multiselect.questionName || this.multiselect.questionName === '') {
this.$message.error('题目(题干内容)不能为空!')
return false
}
//
if (!this.multiselect.answerA || this.multiselect.answerA === '') {
this.$message.error('答案A不能为空')
return false
} else if (!this.multiselect.answerB || this.multiselect.answerB === '') {
this.$message.error('答案B不能为空')
return false
} else if (!this.multiselect.answerC || this.multiselect.answerC === '') {
this.$message.error('答案C不能为空')
return false
} else if (!this.multiselect.answerD || this.multiselect.answerD === '') {
this.$$message.error('答案D不能为空')
return false
}
let from = {}
from = this.multiselect
from.questionType = 2
from.rightAnswers = ''
// ,
if (this.multiselect.a && this.multiselect.a == true) from.rightAnswers += 'A'
if (this.multiselect.b && this.multiselect.b == true) from.rightAnswers += 'B'
if (this.multiselect.c && this.multiselect.c == true) from.rightAnswers += 'C'
if (this.multiselect.d && this.multiselect.d == true) from.rightAnswers += 'D'
if (from.rightAnswers.length < 1 || from.rightAnswers == '') {
this.$message.error('请选择正确答案!')
return false
}
return from
},
//
estimateV() {
console.log('rightAnswers', this.estimate.rightAnswers)
//
if (!this.estimate.questionName || this.estimate.questionName === '') {
this.$message.error('题干不能为空!')
return
}
//
if (!this.estimate.rightAnswers || this.estimate === '') {
this.$message.error('请选择题目的正确答案!')
return
}
let from = this.estimate
from.questionType = 3
return from
},
//
shortAnswerV() {
//
if (!this.shortAnswer.questionName || this.shortAnswer.questionName === '') {
this.$message.error('题干不能为空!')
return false
}
if (!this.shortAnswer.rightAnswers || this.shortAnswer.rightAnswers === '') {
this.$message.error('正确答案不能为空!')
return false
}
let from = this.shortAnswer
from.questionType = 4
return from
},
//
CompletionV() {
if (!this.Completion.questionName || this.Completion.questionName === '') {
this.$message.error('题干不能为空!')
return false
}
console.log(this.Completion.conten)
// if (!this.Completion.rightAnswers || this.Completion.rightAnswers === '') {
// this.$message.error('')
// return false
// }
// let answer =[];
// for(i in answerSize) {
// let daan ={};
// }
let tiank = this.Completion
console.log('tiank ', tiank)
let from = this.Completion
from.questionType = 5
return from
},
},
}
</script>

View File

@ -8,17 +8,21 @@
</div>
<h1 class="questionNumber">题序</h1>
<!-- 题目序号 -->
<div v-for="(item, index) in quesitonList" :key="item" class="questionLeftItem" @click="quesionId(item)">{{ index+1 }}</div>
<div v-for="(item, index) in quesitonList" :key="item" class="questionLeftItem" @click="quesionId(item)">
{{ index+1 }}
</div>
</div>
<div class="questionDetail">
<br />
<a-button type="primary" class="create-button" style="font-size: 15px; margin:0px 10px 10px 0px" @click="questionBatch" > 批量导入 </a-button>
<b><h1 class="questionContent">课程题目库预览</h1></b>
<a-divider :style="{ backgroundColor: '#000' }" />
<div class="question">
<h1 class="questionName">
{{ questionDetail.questionType }}{{questionDetail.questionName}}
<span class="edit" @click="edit(i)">编辑</span>
<span class="edit" @click="edit(questionDetail.id)">编辑</span>
<span class="edit" @click="del(questionDetail.id)">删除</span>
</h1>
<div class="answer">A. {{ questionDetail.answerA }}</div>
<div class="answer">B. {{ questionDetail.answerB }}</div>
@ -44,16 +48,15 @@ import { getQuestionDeatil } from '@/api/course/question/question'
export default {
data() {
return {
queryParam: { id: this.$route.query.id },
quesitonList: [],
questionDetail: {},
}
},
created: function () {
let parameter = {}
let parameter = {id : this.$route.query.id}
// id
getQuestionListByCourseId(Object.assign(parameter, this.queryParam)).then((res) => {
getQuestionListByCourseId(parameter).then((res) => {
this.quesitonList = res.data
if (!res.data.length) return
@ -75,18 +78,24 @@ export default {
this.$router.push({
path: '/course/CourseList',
query: {
// courseName: this.$$router.query.courseName,
// PageNum: this.$$router.query.PageNum,
// courseUserOrgId : this.$$router.query.courseUserOrgId,
},
})
},
questionSave() {
alert('還在對接中~~~')
this.$router.push({
path: '/course/question/QuestionAdd', query :{
courseId: this.$route.query.id,
}});
},
edit: function (i) {
alert('题目ID:' + i)
edit(record) {
console.log(record)
this.$router.push({ path : '/course/question/QuestionAdd', query:{ id: record , questionType:this.questionDetail.questionType ,courseId:this.$route.query.id}});
},
//
questionBatch(){
alert('批量导入')
courseId:this.$route.query.id
}
},
}
</script>

View File

@ -1,3 +0,0 @@
<h1>
hello World
</h1>