客观题页面
parent
a98e0ae083
commit
4d55468ca9
@ -0,0 +1,39 @@
|
||||
import request from '@/utils/request'
|
||||
let baseUrl = '/pc/course/'
|
||||
export function getList(query) {
|
||||
return request({
|
||||
url: baseUrl+'list',
|
||||
method: 'post',
|
||||
data: query
|
||||
})
|
||||
}
|
||||
export function add(cat) {
|
||||
return request({
|
||||
url: baseUrl+"add",
|
||||
method: 'post',
|
||||
data: cat
|
||||
})
|
||||
}
|
||||
|
||||
export function update(cat) {
|
||||
return request({
|
||||
url: baseUrl+"update",
|
||||
method: 'post',
|
||||
data: cat
|
||||
})
|
||||
}
|
||||
|
||||
export function del(cat) {
|
||||
return request({
|
||||
url: baseUrl+"delete",
|
||||
method: 'post',
|
||||
data: cat
|
||||
})
|
||||
}
|
||||
export function get(cat) {
|
||||
return request({
|
||||
url: baseUrl+"get",
|
||||
method: 'post',
|
||||
data: cat
|
||||
})
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
import request from '@/utils/request'
|
||||
let baseUrl = '/pc/system/level/'
|
||||
export function getList() {
|
||||
return request({
|
||||
url: baseUrl+'list',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
export function add(cat) {
|
||||
return request({
|
||||
url: baseUrl+"add",
|
||||
method: 'post',
|
||||
data: cat
|
||||
})
|
||||
}
|
||||
|
||||
export function update(cat) {
|
||||
return request({
|
||||
url: baseUrl+"update",
|
||||
method: 'post',
|
||||
data: cat
|
||||
})
|
||||
}
|
||||
|
||||
export function del(cat) {
|
||||
return request({
|
||||
url: baseUrl+"delete",
|
||||
method: 'post',
|
||||
data: cat
|
||||
})
|
||||
}
|
||||
export function get(cat) {
|
||||
return request({
|
||||
url: baseUrl+"get",
|
||||
method: 'post',
|
||||
data: cat
|
||||
})
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
import request from '@/utils/request'
|
||||
let baseUrl = '/pc/question/'
|
||||
export function getList(query) {
|
||||
return request({
|
||||
url: baseUrl+'list',
|
||||
method: 'post',
|
||||
data: query
|
||||
})
|
||||
}
|
||||
export function add(cat) {
|
||||
return request({
|
||||
url: baseUrl+"add",
|
||||
method: 'post',
|
||||
data: cat
|
||||
})
|
||||
}
|
||||
|
||||
export function update(cat) {
|
||||
return request({
|
||||
url: baseUrl+"update",
|
||||
method: 'post',
|
||||
data: cat
|
||||
})
|
||||
}
|
||||
|
||||
export function del(cat) {
|
||||
return request({
|
||||
url: baseUrl+"delete",
|
||||
method: 'post',
|
||||
data: cat
|
||||
})
|
||||
}
|
||||
export function get(cat) {
|
||||
return request({
|
||||
url: baseUrl+"get",
|
||||
method: 'post',
|
||||
data: cat
|
||||
})
|
||||
}
|
||||
export function batch(data){
|
||||
return request({
|
||||
url: baseUrl+"batchupdate",
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1 @@
|
||||
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1645446191066" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2770" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M568.263111 96.028444c25.429333 0 49.834667 10.069333 67.868445 28.103112l199.736888 199.736888c18.033778 18.033778 28.16 42.439111 28.16 67.868445v408.234667a128 128 0 0 1-128 128H287.914667a128 128 0 0 1-128-128V224.028444a128 128 0 0 1 128-128H568.32z m0.398222 71.964445H287.971556a55.978667 55.978667 0 0 0-55.978667 55.068444v576.967111c0 30.606222 24.576 55.466667 55.068444 55.978667h448.910223a55.978667 55.978667 0 0 0 56.035555-55.068444V391.736889a24.007111 24.007111 0 0 0-6.712889-16.611556l-200.078222-200.078222a24.007111 24.007111 0 0 0-16.497778-7.054222z m-28.728889 500.053333a36.010667 36.010667 0 0 1 0 71.964445H355.953778a36.010667 36.010667 0 1 1 0-72.021334H539.875556z m39.480889-331.036444a36.010667 36.010667 0 0 1 0 50.915555l-190.407111 190.407111a1.991111 1.991111 0 0 1-1.251555 0.568889l-48.696889 3.356445a1.991111 1.991111 0 0 1-2.161778-1.877334v-0.170666l0.682667-51.427556c0-0.568889 0.227556-1.024 0.568889-1.422222L528.497778 337.009778a36.010667 36.010667 0 0 1 50.915555 0z" p-id="2771" fill="#d81e06"></path></svg>
|
After Width: | Height: | Size: 1.4 KiB |
@ -0,0 +1 @@
|
||||
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1645446491415" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1317" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M898.3 960.1H280.2c-34.1 0-61.8-27.7-61.8-61.8V280.2c0-34.1 27.7-61.8 61.8-61.8h618.1c34.1 0 61.8 27.7 61.8 61.8v618.1c0 34.2-27.6 61.8-61.8 61.8z m0-649c0-8.2-3.3-16.1-9.1-21.9-5.8-5.8-13.7-9.1-21.9-9.1H311.1c-17.1 0-30.9 13.8-30.9 30.9v556.3c0 8.2 3.3 16.1 9.1 21.9 5.8 5.8 13.7 9.1 21.9 9.1h556.3c8.2 0 16.1-3.3 21.9-9.1 5.8-5.8 9.1-13.7 9.1-21.9V311.1h-0.2z m-170 278.2H620.2v108.2c0 4.1-1.6 8-4.5 10.9-2.9 2.9-6.8 4.5-10.9 4.5h-30.9c-4.1 0-8-1.6-10.9-4.5-2.9-2.9-4.5-6.8-4.5-10.9V589.3H450.2c-8.5 0-15.5-6.9-15.5-15.5v-30.9c0-8.5 6.9-15.5 15.5-15.5h108.2V419.3c0-4.1 1.6-8 4.5-10.9 2.9-2.9 6.8-4.5 10.9-4.5h30.9c4.1 0 8 1.6 10.9 4.5 2.9 2.9 4.5 6.8 4.5 10.9v108.2h108.2c8.5 0 15.5 6.9 15.5 15.5v30.9c0 8.4-6.9 15.4-15.5 15.4z m46.4-401.8c-17.1 0-30.9-13.8-30.9-30.9 0-8.2-3.3-16.1-9.1-21.9-5.8-5.8-13.7-9.1-21.9-9.1H156.6c-8.2 0-16.1 3.3-21.9 9.1-5.8 5.8-9.1 13.7-9.1 21.9v556.3c0 8.2 3.3 16.1 9.1 21.9 5.8 5.8 13.7 9.1 21.9 9.1 17.1 0 30.9 13.8 30.9 30.9 0 17.1-13.8 30.9-30.9 30.9h-30.9c-34.1 0-61.8-27.7-61.8-61.8V125.7c0-34.1 27.7-61.8 61.8-61.8h618.1c34.1 0 61.8 27.7 61.8 61.8v30.9c0 8.2-3.3 16.1-9.1 21.9-5.7 5.7-13.6 9-21.8 9z" p-id="1318" fill="#f4ea2a"></path></svg>
|
After Width: | Height: | Size: 1.5 KiB |
@ -0,0 +1 @@
|
||||
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1645445980496" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2619" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M956.48 1012.032H73.408V10.048h624.704l258.368 254.08v747.904zM702.016 113.344v161.792h161.792l-161.792-161.792zM584.064 205.44H203.2v65.216h380.864V205.44z m243.84 185.408H202.112v65.152h625.792V390.848z" fill="#2F63AE" p-id="2620"></path><path d="M688.064 622.976c-14.912 0-27.2 1.856-36.736 5.76s-17.28 9.28-23.04 16.128-10.176 14.976-12.992 24.256a162.816 162.816 0 0 0-6.08 30.016l-59.584-12.544c2.048-18.496 6.592-35.328 13.44-50.368s16.128-27.968 27.712-38.592c11.712-10.56 25.536-18.752 41.664-24.384s34.624-8.512 55.552-8.512c17.856 0 34.752 2.56 50.624 7.616 15.808 5.056 29.568 12.544 41.216 22.4a108.8 108.8 0 0 1 27.84 36.032c6.784 14.208 10.24 30.208 10.24 48.192 0 15.168-2.56 28.16-7.808 38.912s-11.648 20.544-19.264 29.568-16 17.6-25.152 25.984c-9.088 8.384-17.408 17.6-25.088 27.776s-14.08 21.888-19.264 35.2a132.736 132.736 0 0 0-7.872 48.576h-60.928c0-14.848 1.024-28.544 2.944-40.96a145.28 145.28 0 0 1 9.6-34.304c6.592-11.904 14.848-22.848 24.896-32.896s19.648-20.096 28.864-30.272 17.216-20.608 23.744-31.36 9.856-22.848 9.856-36.224c0-9.856-1.6-18.368-4.928-25.536s-7.744-12.992-13.44-17.472a55.808 55.808 0 0 0-20.352-9.792 95.872 95.872 0 0 0-25.664-3.2z m-0.96 280.896c5.696 0 11.072 1.152 16.128 3.392a43.52 43.52 0 0 1 26.048 39.232 42.88 42.88 0 0 1-26.048 38.784 41.92 41.92 0 0 1-46.592-9.216 41.216 41.216 0 0 1-12.16-29.568 43.456 43.456 0 0 1 12.16-30.08 43.904 43.904 0 0 1 30.464-12.544z" fill="#FFFFFF" p-id="2621"></path></svg>
|
After Width: | Height: | Size: 1.8 KiB |
@ -0,0 +1 @@
|
||||
batch
|
@ -0,0 +1,261 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<div class="filter-container">
|
||||
<el-button @click="$router.back()">
|
||||
取消
|
||||
</el-button>
|
||||
<el-button type="primary" @click="add">
|
||||
确认
|
||||
</el-button>
|
||||
</div>
|
||||
<el-form ref="dataForm" :rules="rules" :model="temp" label-position="left" label-width="100px" style="margin-left:50px;">
|
||||
<div class="tz-flex">
|
||||
<el-form-item label="归属课程" >
|
||||
<el-select v-model="temp.courseId" class="filter-item" placeholder="请选择">
|
||||
<el-option v-for="item in courseOptions" :key="item.id" :label="item.name" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="题目层次">
|
||||
<el-select v-model="temp.levelId" class="filter-item" placeholder="请选择">
|
||||
<el-option v-for="item in levelOptions" :key="item.id" :label="item.name" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="题型" prop="timestamp">
|
||||
<el-select @change="typeChange" v-model="temp.questionType" class="filter-item" placeholder="请选择">
|
||||
<el-option v-for="item in typeOptions" :key="item.id" :label="item.name" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="分值" prop="timestamp">
|
||||
<el-input-number v-model="temp.score" :min="1" />
|
||||
</el-form-item>
|
||||
</div>
|
||||
<el-form-item label="题干">
|
||||
<el-input type="textarea" v-model="temp.stem" prop="stem" />
|
||||
<el-checkbox v-model="checkGroup.stem" label="图" />
|
||||
<upload-image v-if="checkGroup.stem" v-model="temp.stemImg" :url.sync="temp.stemImg" />
|
||||
</el-form-item>
|
||||
<el-form-item label="选项">
|
||||
<div v-for="item in temp.answerList" :key="item.id" class="opt">
|
||||
<div class="line">
|
||||
<span class="correct" @dblclick="cancel(item)" @click="confirm(item)" :style="item.correct?'background-color:red; color:white':''" >{{ indexToWord(item.id) }}</span> <el-input v-model="item.title" /><el-checkbox v-if="temp.questionType<3" v-model="item.check" label="图" />
|
||||
</div>
|
||||
<div class="line">
|
||||
<upload-image v-if="!!item.img" :url.sync="item.img" />
|
||||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="答案">
|
||||
<div style="display:flex">
|
||||
<span class="correct" style="background-color:red; color:white" v-for="item in temp.answerId" :key="item">{{ indexToWord(item) }}</span>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="解析">
|
||||
<el-input type="textarea" v-model="temp.analysis" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import * as course from '@/api/course'
|
||||
import * as level from '@/api/level'
|
||||
import * as question from '@/api/question'
|
||||
import uploadImage from '@/components/Upload/SingleImage2.vue'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
'upload-image': uploadImage
|
||||
},
|
||||
filters: {
|
||||
statusFilter(status) {
|
||||
const statusMap = {
|
||||
published: 'success',
|
||||
draft: 'info',
|
||||
deleted: 'danger'
|
||||
}
|
||||
return statusMap[status]
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
list: null,
|
||||
listLoading: true,
|
||||
listQuery: {
|
||||
pageNo: 0
|
||||
},
|
||||
total: 0,
|
||||
limit: 20,
|
||||
textMap: {
|
||||
update: 'Edit',
|
||||
create: 'Create'
|
||||
},
|
||||
checkGroup:{
|
||||
stem: false
|
||||
},
|
||||
dialogFormVisible: false,
|
||||
courseOptions: [],
|
||||
levelOptions: [],
|
||||
typeOptions:[
|
||||
{
|
||||
id: 1,
|
||||
name: '单选'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: '多选'
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: '判断'
|
||||
}
|
||||
],
|
||||
dialogStatus: 'Edit',
|
||||
statusOptions: ['published', 'draft', 'deleted'],
|
||||
temp: {
|
||||
score: 1,
|
||||
courseId: 0,
|
||||
courseName: '',
|
||||
levelId: 1,
|
||||
levelName: '',
|
||||
questionType: 1,
|
||||
stem: '',
|
||||
stemImg: '',
|
||||
answerList:[],
|
||||
answerId: [],
|
||||
analysis: ''
|
||||
},
|
||||
rules: {
|
||||
stem: [{ required: true, message: '题干为必填项', trigger: 'blur' }]
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
if(this.$route.query){
|
||||
if(this.$route.query.id){
|
||||
question.get({id: this.$route.query.id}).then(res=>{
|
||||
this.temp= res.data
|
||||
this.checkGroup.stem = !!this.temp.stemImg
|
||||
this.temp.answerId.forEach(i=>this.temp.answerList.find( (t)=> t.id == i ).correct=true)
|
||||
this.temp.answerId.forEach(i=>this.temp.answerList.find( (t)=> t.id == i ).check=!!this.temp.answerList.find( (t)=> t.id == i ).img)
|
||||
})
|
||||
}
|
||||
}
|
||||
this.fetchData()
|
||||
},
|
||||
methods: {
|
||||
fetchData() {
|
||||
this.listLoading = true
|
||||
course.getList({pageNo: 0, pageSize: 1000}).then(res=>{
|
||||
if(res.code==200){
|
||||
this.courseOptions = res.data.page.content
|
||||
}
|
||||
this.listLoading = false
|
||||
})
|
||||
level.getList().then(res=>{
|
||||
if(res.code==200){
|
||||
this.levelOptions = res.data.list
|
||||
}
|
||||
})
|
||||
},
|
||||
handleUpdate(row) {
|
||||
this.temp = Object.assign({}, row) // copy obj
|
||||
this.temp.timestamp = new Date(this.temp.timestamp)
|
||||
this.dialogStatus = 'update'
|
||||
this.dialogFormVisible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs['dataForm'].clearValidate()
|
||||
})
|
||||
},
|
||||
add(){
|
||||
question.add(this.temp).then(response=>{
|
||||
if(response.code === 200){
|
||||
this.$notify({
|
||||
title: '操作成功',
|
||||
message: "success",
|
||||
type: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
changeUrl(val){
|
||||
this.temp.thumbnail = val
|
||||
},
|
||||
typeChange(val){
|
||||
this.temp.answerList=[]
|
||||
this.temp.answerId=[]
|
||||
if(val == 1||val == 2){
|
||||
this.temp.answerList.push({ id: 1, title: '', img: '', check: false, correct: false });
|
||||
this.temp.answerList.push({ id: 2, title: '', img: '', check: false, correct: false });
|
||||
this.temp.answerList.push({ id: 3, title: '', img: '', check: false, correct: false });
|
||||
this.temp.answerList.push({ id: 4, title: '', img: '', check: false, correct: false });
|
||||
}else{
|
||||
this.temp.answerList.push({ id: 1, title: '正确', img: '', correct: false});
|
||||
this.temp.answerList.push({ id: 2, title: '错误', img: '', correct: false});
|
||||
}
|
||||
},
|
||||
indexToWord(index){
|
||||
return String.fromCharCode(64+index)
|
||||
},
|
||||
cancel(item){
|
||||
item.correct = false
|
||||
const i = this.temp.answerId.indexOf(item.id)
|
||||
this.temp.answerId.splice(i,1)
|
||||
},
|
||||
confirm(item){
|
||||
if(this.temp.questionType !=2){
|
||||
this.temp.answerList.forEach(i =>{ i.correct = false})
|
||||
this.temp.answerId = []
|
||||
}
|
||||
item.correct = true
|
||||
if(this.temp.answerId.includes(item.id) == false){
|
||||
this.temp.answerId.push(item.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
.tz-line{
|
||||
display: flex;
|
||||
width: 100%;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.tz-line button{
|
||||
margin-left: 10px;
|
||||
width: 100px;
|
||||
}
|
||||
.tz-flex{
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.tz-flex .el-form-item,.el-select{
|
||||
width: 50%;
|
||||
}
|
||||
.opt{
|
||||
margin-bottom: 5px;
|
||||
margin-right: 5px;
|
||||
}
|
||||
.correct{
|
||||
display: flex;
|
||||
width: 50px;
|
||||
background-color: rgb(209, 208, 205);
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-right:5px;
|
||||
border-radius: 5px;
|
||||
color:white;
|
||||
}
|
||||
.opt .el-input{
|
||||
margin-left: 5px;
|
||||
margin-right: 5px;
|
||||
}
|
||||
.opt .el-checkbox{
|
||||
margin-left: 5px;
|
||||
}
|
||||
.opt div{
|
||||
display: flex;
|
||||
width: 100%;
|
||||
margin-top: 5px;
|
||||
}
|
||||
</style>
|
@ -0,0 +1,259 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<div class="filter-container">
|
||||
<el-button @click="$router.back()">
|
||||
取消
|
||||
</el-button>
|
||||
<el-button type="primary" @click="add">
|
||||
确认
|
||||
</el-button>
|
||||
</div>
|
||||
<el-form ref="dataForm" :rules="rules" :model="temp" label-position="left" label-width="100px" style="margin-left:50px;">
|
||||
<div class="tz-flex">
|
||||
<el-form-item label="归属课程" prop="name">
|
||||
<el-select v-model="temp.courseId" class="filter-item" placeholder="请选择">
|
||||
<el-option v-for="item in courseOptions" :key="item.id" :label="item.name" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="题目层次">
|
||||
<el-select v-model="temp.levelId" class="filter-item" placeholder="请选择">
|
||||
<el-option v-for="item in levelOptions" :key="item.id" :label="item.name" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="题型" prop="timestamp">
|
||||
<el-select @change="typeChange" v-model="temp.questionType" class="filter-item" placeholder="请选择">
|
||||
<el-option v-for="item in typeOptions" :key="item.id" :label="item.name" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="分值" prop="timestamp">
|
||||
<el-input-number v-model="temp.score" :min="1" />
|
||||
</el-form-item>
|
||||
</div>
|
||||
<el-form-item label="题干">
|
||||
<el-input type="textarea" v-model="temp.stem" />
|
||||
<el-checkbox v-model="checkGroup.stem" label="图" />
|
||||
<upload-image v-if="checkGroup.stem" v-model="temp.stemImg" :url.sync="temp.stemImg" />
|
||||
</el-form-item>
|
||||
<el-form-item label="选项">
|
||||
<div v-for="item in temp.answerList" :key="item.id" class="opt">
|
||||
<div class="line">
|
||||
<span class="correct" @dblclick="cancel(item)" @click="confirm(item)" :style="item.correct?'background-color:red; color:white':''" >{{ indexToWord(item.id) }}</span> <el-input v-model="item.title" /><el-checkbox v-if="temp.questionType<3" v-model="item.check" label="图" />
|
||||
</div>
|
||||
<div class="line">
|
||||
<upload-image v-if="item.check" :url.sync="item.img" />
|
||||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="答案">
|
||||
<div style="display:flex">
|
||||
<span class="correct" style="background-color:red; color:white" v-for="item in temp.answerId" :key="item">{{ indexToWord(item) }}</span>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="解析">
|
||||
<el-input type="textarea" v-model="temp.analysis" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import * as course from '@/api/course'
|
||||
import * as level from '@/api/level'
|
||||
import * as question from '@/api/question'
|
||||
import uploadImage from '@/components/Upload/SingleImage2.vue'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
'upload-image': uploadImage
|
||||
},
|
||||
filters: {
|
||||
statusFilter(status) {
|
||||
const statusMap = {
|
||||
published: 'success',
|
||||
draft: 'info',
|
||||
deleted: 'danger'
|
||||
}
|
||||
return statusMap[status]
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
list: null,
|
||||
listLoading: true,
|
||||
listQuery: {
|
||||
pageNo: 0
|
||||
},
|
||||
total: 0,
|
||||
limit: 20,
|
||||
textMap: {
|
||||
update: 'Edit',
|
||||
create: 'Create'
|
||||
},
|
||||
checkGroup:{
|
||||
stem: false
|
||||
},
|
||||
dialogFormVisible: false,
|
||||
courseOptions: [],
|
||||
levelOptions: [],
|
||||
typeOptions:[
|
||||
{
|
||||
id: 1,
|
||||
name: '单选'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: '多选'
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: '判断'
|
||||
}
|
||||
],
|
||||
dialogStatus: 'Edit',
|
||||
statusOptions: ['published', 'draft', 'deleted'],
|
||||
temp: {
|
||||
score: 1,
|
||||
courseId: 0,
|
||||
courseName: '',
|
||||
levelId: 1,
|
||||
levelName: '',
|
||||
questionType: 1,
|
||||
stem: '',
|
||||
stemImg: '',
|
||||
answerList:[],
|
||||
answerId: [],
|
||||
analysis: ''
|
||||
},
|
||||
rules: {
|
||||
name: [{ required: true, message: '课程名为必填项', trigger: 'blur' }]
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
if(this.$route.query){
|
||||
if(this.$route.query.id){
|
||||
course.get({id: this.$route.query.id}).then(res=>{
|
||||
this.temp= res.data
|
||||
})
|
||||
}
|
||||
}
|
||||
this.fetchData()
|
||||
this.typeChange(1)
|
||||
},
|
||||
methods: {
|
||||
fetchData() {
|
||||
this.listLoading = true
|
||||
course.getList({pageNo: 0, pageSize: 1000}).then(res=>{
|
||||
if(res.code==200){
|
||||
this.courseOptions = res.data.page.content
|
||||
}
|
||||
this.listLoading = false
|
||||
})
|
||||
level.getList().then(res=>{
|
||||
if(res.code==200){
|
||||
this.levelOptions = res.data.list
|
||||
}
|
||||
})
|
||||
},
|
||||
handleUpdate(row) {
|
||||
this.temp = Object.assign({}, row) // copy obj
|
||||
this.temp.timestamp = new Date(this.temp.timestamp)
|
||||
this.dialogStatus = 'update'
|
||||
this.dialogFormVisible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs['dataForm'].clearValidate()
|
||||
})
|
||||
},
|
||||
add(){
|
||||
question.add(this.temp).then(response=>{
|
||||
if(response.code === 200){
|
||||
this.$notify({
|
||||
title: '操作成功',
|
||||
message: "success",
|
||||
type: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
changeUrl(val){
|
||||
this.temp.thumbnail = val
|
||||
},
|
||||
typeChange(val){
|
||||
this.temp.answerList=[]
|
||||
this.temp.answerId=[]
|
||||
if(val == 1||val == 2){
|
||||
this.temp.answerList.push({ id: 1, title: '', img: '', check: false, correct: false });
|
||||
this.temp.answerList.push({ id: 2, title: '', img: '', check: false, correct: false });
|
||||
this.temp.answerList.push({ id: 3, title: '', img: '', check: false, correct: false });
|
||||
this.temp.answerList.push({ id: 4, title: '', img: '', check: false, correct: false });
|
||||
}else{
|
||||
this.temp.answerList.push({ id: 1, title: '正确', img: '', correct: false});
|
||||
this.temp.answerList.push({ id: 2, title: '错误', img: '', correct: false});
|
||||
}
|
||||
},
|
||||
indexToWord(index){
|
||||
return String.fromCharCode(64+index)
|
||||
},
|
||||
cancel(item){
|
||||
item.correct = false
|
||||
const i = this.temp.answerId.indexOf(item.id)
|
||||
this.temp.answerId.splice(i,1)
|
||||
},
|
||||
confirm(item){
|
||||
if(this.temp.questionType !=2){
|
||||
this.temp.answerList.forEach(i =>{ i.correct = false})
|
||||
this.temp.answerId = []
|
||||
}
|
||||
item.correct = true
|
||||
if(this.temp.answerId.includes(item.id) == false){
|
||||
this.temp.answerId.push(item.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
.tz-line{
|
||||
display: flex;
|
||||
width: 100%;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.tz-line button{
|
||||
margin-left: 10px;
|
||||
width: 100px;
|
||||
}
|
||||
.tz-flex{
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.tz-flex .el-form-item,.el-select{
|
||||
width: 50%;
|
||||
}
|
||||
.opt{
|
||||
margin-bottom: 5px;
|
||||
margin-right: 5px;
|
||||
}
|
||||
.correct{
|
||||
display: flex;
|
||||
width: 50px;
|
||||
background-color: rgb(209, 208, 205);
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-right:5px;
|
||||
border-radius: 5px;
|
||||
color:white;
|
||||
}
|
||||
.opt .el-input{
|
||||
margin-left: 5px;
|
||||
margin-right: 5px;
|
||||
}
|
||||
.opt .el-checkbox{
|
||||
margin-left: 5px;
|
||||
}
|
||||
.opt div{
|
||||
display: flex;
|
||||
width: 100%;
|
||||
margin-top: 5px;
|
||||
}
|
||||
</style>
|
@ -0,0 +1,95 @@
|
||||
package com.tz.platform.pc.biz;
|
||||
|
||||
import com.tz.platform.common.core.base.Result;
|
||||
import com.tz.platform.entity.Question;
|
||||
import com.tz.platform.pc.dto.PageQuestionDTO;
|
||||
import com.tz.platform.pc.dto.QuestionDTO;
|
||||
import com.tz.platform.pc.vo.BatchQuestionVO;
|
||||
import com.tz.platform.pc.vo.PageQuestionVO;
|
||||
import com.tz.platform.pc.vo.QuestionVO;
|
||||
import com.tz.platform.repository.QuestionDao;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@Component
|
||||
public class PCQuestionBiz {
|
||||
@Autowired
|
||||
private QuestionDao questionDao;
|
||||
|
||||
public Result<PageQuestionDTO> list(PageQuestionVO questionVO){
|
||||
PageQuestionDTO questionDTO = new PageQuestionDTO();
|
||||
Pageable pageable = PageRequest.of(questionVO.getPageNo(),20);
|
||||
Page<Question> questions =null;
|
||||
if((questionVO.getCourseId() == null|| questionVO.getCourseId() == 0) && StringUtils.isEmpty(questionVO.getStem())){
|
||||
questions = questionDao.findAll(pageable);
|
||||
}else if(questionVO.getCourseId()>0&&StringUtils.hasText(questionVO.getStem())){
|
||||
questions = questionDao.findAllByCourseIdAndStem(questionVO.getCourseId(),questionVO.getStem(),pageable);
|
||||
}else if(questionVO.getCourseId()>0){
|
||||
questions = questionDao.findAllByCourseId(questionVO.getCourseId(),pageable);
|
||||
}else {
|
||||
questions = questionDao.findAllByStem(questionVO.getStem(),pageable);
|
||||
}
|
||||
return Result.success(questionDTO.setPage(questions));
|
||||
}
|
||||
|
||||
public Result<Long> add(QuestionVO questionVo){
|
||||
Result<Long> v = valid(questionVo);
|
||||
if(v.getCode()!=200){
|
||||
return v;
|
||||
}
|
||||
Question question = new Question();
|
||||
BeanUtils.copyProperties(questionVo,question);
|
||||
question = questionDao.save(question);
|
||||
return Result.success(question.getId());
|
||||
}
|
||||
public Result<String> update(QuestionVO questionVO){
|
||||
Result<Long> v = valid(questionVO);
|
||||
if(v.getCode()!=200){
|
||||
return Result.error(v.getMsg());
|
||||
}
|
||||
Question question = new Question();
|
||||
BeanUtils.copyProperties(questionVO,question);
|
||||
questionDao.save(question);
|
||||
return Result.success("success");
|
||||
}
|
||||
|
||||
private Result<Long> valid(QuestionVO questionVO){
|
||||
if(!StringUtils.hasText(questionVO.getStem())){
|
||||
return Result.error("题干不能为空");
|
||||
}
|
||||
if(!StringUtils.hasText(questionVO.getAnalysis())){
|
||||
return Result.error("解析不能为空");
|
||||
}
|
||||
|
||||
// if(!StringUtils.hasText(questionVO.getCourseName())){
|
||||
// return Result.error("课程名不能为空");
|
||||
// }
|
||||
return Result.success(0L);
|
||||
}
|
||||
|
||||
public Result<String> delete(QuestionVO questionVO){
|
||||
questionDao.deleteById(questionVO.getId());
|
||||
return Result.success("success");
|
||||
}
|
||||
|
||||
|
||||
public Result<QuestionDTO> get(QuestionVO questionVO){
|
||||
Question question = questionDao.getById(questionVO.getId());
|
||||
if(question == null){
|
||||
return Result.error("没有数据");
|
||||
}
|
||||
QuestionDTO questionDTO = new QuestionDTO();
|
||||
BeanUtils.copyProperties(question,questionDTO);
|
||||
return Result.success(questionDTO);
|
||||
}
|
||||
|
||||
public Result<String> batch(BatchQuestionVO vo){
|
||||
questionDao.batchUpdate(vo.getStatus(),vo.getIds());
|
||||
return Result.success("success");
|
||||
}
|
||||
}
|
Binary file not shown.
Loading…
Reference in New Issue