Commit 2276fc43 authored by 黄奎's avatar 黄奎

新增页面

parent 5135b89c
......@@ -136,10 +136,14 @@
<q-item-label>发布考试</q-item-label>
</q-item-section>
</q-item>
<q-item clickable v-close-popup @click="showPaperInfo(scope.row)">
<q-item-section>
<q-item-label>详情</q-item-label>
</q-item-section>
</q-item>
</q-list>
</q-btn-dropdown>
</template>
</template>
</el-table-column>
</el-table>
......@@ -241,6 +245,16 @@
this.OpenNewUrl('/exam/paperPublish', {
PaperId: PaperId
})
},
//试卷详情
showPaperInfo(item) {
let PaperId = 0;
if (item) {
PaperId = item.PaperId
}
this.OpenNewUrl('/exam/paperInfo', {
PaperId: PaperId
})
}
}
}
......
<style>
.examPaper_Top {
width: 100%;
height: 83px;
border-bottom: 1px solid #d9d9d9;
display: flex;
align-items: center;
justify-content: space-between;
}
.Exam-main {
width: 100%;
height: auto !important;
overflow: hidden;
margin-top: 20px;
}
.Exam-left {
width: 29%;
border-right: 1px solid #d9d9d9;
border-bottom: 1px solid #d9d9d9;
border-radius: 3px;
border-top: 1px solid #d9d9d9;
background: #f0f0f0;
padding-top: 20px;
padding-bottom: 0px;
}
.f1 {
float: left;
}
.Exam-right {
width: 65%;
min-height: 795px;
background: #fff;
border-radius: 3px;
overflow-y: auto;
border: 1px solid #d9d9d9;
margin-left: 20px;
}
.Left-ptitel {
font-size: 14px;
color: #777;
padding-left: 18px;
}
.Left-ptitel span {
font-size: 14px;
color: #333;
}
.Left-ptitel i {
color: #c90000;
font-style: normal;
}
.Left-list {
width: 100%;
border-top: 1px solid #d9d9d9;
}
.List-ul {
margin: 0;
padding: 0;
}
.List-ul li {
height: 33px;
border-bottom: 1px solid #f3f3f3;
list-style-type: none;
}
.List-ul-li-checked {
background: #a6a6a6;
color: #333;
width: 328px;
}
.List-ul li {
display: block;
padding-left: 25px;
line-height: 33px;
font-size: 12px;
height: 33px;
border-bottom: 1px solid #f3f3f3;
color: #555;
text-decoration: none;
display: flex;
}
.List-ul-li-checked b {
color: #000;
}
.Showbtn {
display: block;
width: 90px;
float: right;
padding-top: 8px;
z-index: 1000;
}
.Left-btn {
height: 58px;
padding: 20px 0 20px 20px;
width: 100%;
border-bottom: 1px solid #d9d9d9;
display: flex;
justify-content: space-between;
align-items: center;
}
.List-bt {
width: 100%;
height: 27px;
margin-left: 1px;
background: #fdfdfd;
font-size: 14px;
line-height: 27px;
padding-left: 10px;
}
.List-bt i {
position: relative;
top: 1px;
left: 5px;
}
.List-bt i:hover {
color: #2961fe;
cursor: pointer;
}
.List-ul li:hover {
background: #a6a6a6;
color: #333;
}
.checkUl {
background: #a6a6a6;
color: #333;
}
.List-ul li:hover .exam_ListSHow {
display: block;
}
.left-btn-list {
padding: 5px 10px;
display: inline-block;
color: #555;
border-radius: 3px;
font-size: 14px;
border: 1px solid #999;
margin-right: 10px;
cursor: pointer;
}
#btn1 {
background: #26a69a !important;
}
.difficulty_Degree {
display: inline-block;
width: 80px;
text-align: right;
line-height: 56px;
}
.Left-list::-webkit-scrollbar {
width: 3px;
height: 3px;
background-color: #F5F5F5;
}
/*!*定义滚动条轨道 内阴影+圆角*!*/
.Left-list::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
border-radius: 10px;
background-color: #F5F5F5;
}
/*!*定义滑块 内阴影+圆角*!*/
.Left-list::-webkit-scrollbar-thumb {
border-radius: 10px;
-webkit-box-shadow: -webkit-gradient(linear, 0 0, 0 100%, color-stop(.5, rgba(255, 255, 255, .2)), color-stop(.5, transparent), to(transparent));
background-color: #0ae;
}
.commonDalei {
display: flex;
align-content: center;
margin-bottom: 20px;
}
.examPaper .edui-editor {
z-index: 99 !important;
}
.List-bt input {
outline: none;
height: 25px;
}
.exam_DetailList {
width: 80%;
display: inline-block;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
margin-left: 5px;
}
.exam_ListSHow {
display: none;
}
.exam_ListSHow i:hover {
color: #2961fe;
}
</style>
<template>
<div class="examPaper page-body">
<div class="examPaper_Top">
<div style="width:80%;display:flex;">
<div style="width:36%;margin-right:20px;">
<q-input filled label="标题" v-model="DataObj.PaperName" />
</div>
<div style="width:24%;">
<q-select filled option-value="Id" option-label="Name" :options="questionDifficultyTypeList" emit-value
map-options label="难度" use-input clearable v-model="DataObj.DifficultyType" />
</div>
</div>
<div style="width:20%;text-align:right;">
<q-btn color="accent" size="sm" class="q-mr-md" label="预览" />
<q-btn color="accent" size="sm" class="q-mr-md" label="保存并返回" @click="SavePaper()" />
</div>
</div>
<div class="Exam-main">
<div class="Exam-left f1">
<p class="Left-ptitel">
<span>题量:<i>{{examNum}}</i></span>
<span>  总分:<i>{{examScore}}</i></span>
</p>
<div class="Left-list" style="height:740px;overflow:auto;">
<template v-if="DataObj&&DataObj.GroupList&&DataObj.GroupList.length>0">
<div class="List-con1" v-for="(gItem,gIndex) in DataObj.GroupList" :key="gIndex">
<div class="List-bt">
<strong class="f1">
<template v-if="!gItem.isShowEdit">{{gIndex+1}}&nbsp;{{gItem.GroupName}}</template>
<template v-else>
<input style="width:160px;margin-right:10px;" v-model="gItem.GroupName" />
<input style="width:40px;" filled v-model="gItem.GScore" @change="changeGroupScore(gItem)" />
</template>
</strong>
<i class="iconfont icon-edit" title="编辑" style="font-size:18px;margin-right:5px;"
@click="getNameEdit(DataObj.GroupList,gIndex)"></i>
<i class="iconfont icon-ico_commodity_defaul" v-if="gItem.isShowEdit" title="保存"
style="top:0;margin-right:5px;" @click="saveExamName(DataObj.GroupList)"></i>
<i class="iconfont icon-shangyi2" style="margin-right:5px;" @click.stop="MoveFatherItem(gIndex,0)"
v-if="gIndex!=0"></i>
<i class="iconfont icon-xiayi" @click.stop="MoveFatherItem(gIndex,1)"
v-if="gIndex!=DataObj.GroupList.length-1"></i>
<i class="iconfont icon-shanchu2" style="margin-left:5px;" @click.stop="removeFather(gItem,gIndex)"></i>
</div>
<ul class="List-ul" v-if="gItem.DetailsList&&gItem.DetailsList.length>0">
<li class="" style="cursor:pointer;" :class="{'checkUl':dIndex==ComCheckIndex&&gIndex==ComOneIndex}"
v-for="(dItem,dIndex) in gItem.DetailsList" :key="dIndex" @click="ClickItem(dItem,gIndex,dIndex)">
({{dIndex+1}}) <span class="exam_DetailList" v-html="dItem.ShowTitle"></span>
<span class="exam_ListSHow">
<i class="iconfont icon-shangyi2" @click.stop="MoveChildItem(gIndex,dIndex,0)"
style="margin-right:5px;" v-if="dIndex!=0"></i>
<i class="iconfont icon-xiayi" @click.stop="MoveChildItem(gIndex,dIndex,1)"
v-if="dIndex!=gItem.DetailsList.length-1"></i>
<i class="iconfont icon-shanchu2" @click.stop="delExam(gItem.DetailsList,dItem,dIndex)"
style="margin-left:5px;font-size:17px;"></i>
</span>
</li>
</ul>
</div>
</template>
</div>
</div>
<div class="Exam-right f1">
<div class="Left-btn">
 <div>
<template v-for="(fItem,fIndex) in firstTypeList">
<q-btn :key="fIndex" color="accent" :id="commonIndex==fIndex?'btn1':''" size="sm" :label="fItem.Name"
style="margin-left:5px;" @click="onItemClick(fItem,fIndex)" />
</template>
<q-btn-dropdown color="accent" size="sm" label="更多" style="margin-left:5px;">
<q-list>
<q-item v-for="(fItem,fIndex) in secondTypeList" @click="onItemClick(fItem)" clickable v-close-popup
:key="fIndex">
<q-item-section>
<q-item-label>{{fItem.Name}}</q-item-label>
</q-item-section>
</q-item>
</q-list>
</q-btn-dropdown>
</div>
 <div>
<q-btn color="accent" size="sm" @click="isShowQuestion=true" class="q-mr-md" label="题库选题"  />
</div>
</div>
<div class="row wrap" v-if="ChooseItem" style="padding:20px;">
<div class="edit_stem">
<q-input filled stack-label maxlength="5" :dense="false" @keyup.native="checkInteger(ChooseItem,'Score')"
v-model="ChooseItem.Score" class="col-12 q-pb-lg" label="分数" />
</div>
<div class="col-12">
<template v-if="ChooseItem.QuestionTypeKey=='cloze'">
<span class="question_number">选项处用##题号##替换,如##1##</span>
</template>
<UeEditor v-if="ChooseItem.QuestionTypeKey!='sharing-choose'" v-model="ChooseItem.Title" :config="config"
ref="UE_Title"></UeEditor>
</div>
<br />
<!--单选题-->
<single v-if="ChooseItem.QuestionTypeKey=='single'||ChooseItem.QuestionTypeKey=='single-number'"
:questionData="ChooseItem.QuestionContentObj" @getChild="getChildData" :setOption="ChooseItem"></single>
<!--多选题-->
<multiple v-if="ChooseItem.QuestionTypeKey=='multiple'" :questionData="ChooseItem.QuestionContentObj"
@getChild="getChildData" :setOption="ChooseItem"></multiple>
<!--填空题-->
<fill-in v-if="ChooseItem.QuestionTypeKey=='fill-in'" :questionData="ChooseItem.QuestionContentObj"
@getChild="getChildData" :setOption="ChooseItem"></fill-in>
<!--判断题-->
<judge v-if="ChooseItem.QuestionTypeKey=='judge'" :questionData="ChooseItem.QuestionContentObj"
@getChild="getChildData" :setOption="ChooseItem"></judge>
<!--简答题、名词解释、论述题、计算题、口语题、其它-->
<short-answer v-if="ChooseItem.QuestionTypeKey=='short-answer'||ChooseItem.QuestionTypeKey=='noun-explanation'||ChooseItem.QuestionTypeKey=='essay-question'
||ChooseItem.QuestionTypeKey=='calculation' || ChooseItem.QuestionTypeKey=='spoken'|| ChooseItem.QuestionTypeKey=='other'
" :setOption="ChooseItem"> </short-answer>
<!--分录题、资料题-->
<entry-problem v-if="ChooseItem.QuestionTypeKey=='entry-problem'|| ChooseItem.Key=='data-question'"
:questionData="ChooseItem.QuestionContentObj" :setOption="ChooseItem" @getChild="getChildData">
</entry-problem>
<!--连线题-->
<matching v-if="ChooseItem.QuestionTypeKey=='matching'" :questionData="ChooseItem.QuestionContentObj"
:setOption="ChooseItem" @getChild="getChildData"></matching>
<!--排序题-->
<sorting-problem v-if="ChooseItem.QuestionTypeKey=='sorting-problem'"
:questionData="ChooseItem.QuestionContentObj" :setOption="ChooseItem" @getChild="getChildData">
</sorting-problem>
<!--完型填空-->
<cloze v-if="ChooseItem.QuestionTypeKey=='cloze'" :questionData="ChooseItem.QuestionContentObj"
:setOption="ChooseItem" @getChild="getChildData"></cloze>
<!--阅读理解、听力题-->
<reading-comprehensio
v-if="ChooseItem.QuestionTypeKey=='reading-comprehensio'||ChooseItem.QuestionTypeKey=='listening'"
:questionData="ChooseItem.QuestionContentObj" :setOption="ChooseItem" @getChild="getChildData">
</reading-comprehensio>
<!--共用选择题-->
<sharing-choose v-if="ChooseItem.QuestionTypeKey=='sharing-choose'"
:questionData="ChooseItem.QuestionContentObj" @getChild="getChildData" :setOption="ChooseItem">
</sharing-choose>
<br />
<div class="col-12">
<div style="margin:20px 0;">答案解析</div>
<UeEditor v-model="ChooseItem.AnswerParse" :config="config" ref="UE_AnswerParse"></UeEditor>
</div>
<br />
<div class="col-12 commonDalei" style="margin-top:20px;">
<span class="difficulty_Degree">难度:</span>
<q-select filled option-value="Id" size="sm" style="display:inline-block;width:300px;" option-label="Name"
v-model="ChooseItem.DifficultyType" :options="questionDifficultyTypeList" emit-value map-options />
</div>
<div class="col-12 commonDalei">
<br />
<span class="difficulty_Degree">所属大类:</span>
<q-select filled option-value="Id" size="sm" style="display:inline-block;width:300px;" option-label="Name"
v-model="ChooseItem.Category" :options="questionCategoryList" emit-value map-options />
</div>
<div class="col-12 commonDalei">
<br />
<span class="difficulty_Degree">考级程度:</span>
<q-select filled option-value="Id" size="sm" style="display:inline-block;width:300px;" option-label="Name"
v-model="ChooseItem.LevelType" :options="questionLevalTypeList" emit-value map-options />
</div>
<div class="col-12">
<span class="difficulty_Degree">知识点:</span>
<a class="addKnowledge" @click="isShowPoint=true">
<i class="iconfont icon-add" style="position:relative;top:1px;"></i>选择知识点
</a>
<span class="knowledge_List" v-for="(x, i) in choosePointArray" :key="i">
{{x.PointName}}
<i class="iconfont icon-shanchu1" @click="removePointTag(i)"></i>
</span>
</div>
</div>
</div>
<questionForm v-if="isShowQuestion" @close="closeQuestForm" @success="getQuestionList"></questionForm>
</div>
</div>
</template>
<script>
import UeEditor from '../../components/editor/UeEditor'
//知识点列表
import questionpoint from '../../components/question/questionpoint'
import single from '../../components/questiontype/single'
import multiple from '../../components/questiontype/multiple'
import fillIn from '../../components/questiontype/fill-in'
import judge from '../../components/questiontype/judge'
import shortAnswer from '../../components/questiontype/short-answer'
import entryProblem from '../../components/questiontype/entry-problem'
import matching from '../../components/questiontype/matching'
import sortingProblem from '../../components/questiontype/sorting-problem'
import cloze from '../../components/questiontype/cloze'
import readingComprehensio from '../../components/questiontype/reading-comprehensio'
import sharingChoose from '../../components/questiontype/sharing-choose'
import questionForm from '../../components/exam/question-form'
import {
GetPaper,
savePaperInfo,
} from '../../api/teacher/index';
import {
CreateQuestion, //生成问题
} from '../../api/question/questionconfig'
import {
queryQuestionTypeList,
queryDifficultyType,
queryQuestionCategory,
queryQuestionLevelType,
DeletePaperGroup,
DeletePaperDetails
} from '../../api/question/question'
export default {
components: {
UeEditor,
questionpoint, //知识点
single, //单选题
multiple, //多选题
fillIn, //填空题
judge, //判断题
shortAnswer, //简答题
entryProblem, //分录题
matching, //连线题
sortingProblem, //排序题
cloze, //完型填空
readingComprehensio, //阅读理解
sharingChoose, //共用选择题、
questionForm
},
meta: {
title: "考试"
},
watch: {
'ChooseItem.Title': {
handler(newValue) {
this.ChooseItem.ShowTitle = newValue;
},
deep: true
},
'ChooseItem.Score': {
handler(newValue) {
this.ChooseItem.Score = newValue;
this.calcPaper();
},
deep: true
},
'ChooseItem.QuestionContentObj': {
handler(newValue) {
this.ChooseItem.QuestionContentObj = newValue;
},
deep: true
}
},
data() {
return {
config: {
initialFrameWidth: null,
initialFrameHeight: 80,
},
msg: {
PaperId: 0
},
//试卷对象
DataObj: {
PaperId: 0, //试卷编号
PaperName: '', //试卷名称
QuestionBandIds: "", //关联题库编号
DifficultyType: 1, //试卷难易程度
GenerateType: 2, //组卷类型(1-智能组卷,2-手动组卷,3-智能导入)
CreateNum: 1, //生成试卷套数
PaperType: 2, //试卷类型(1-文件夹,2-试卷)
ParentId: 0, //父节点编号,
GroupList: [], //试卷答题分类
},
//点击问题对象
ChooseItem: {},
questionDifficultyTypeList: [], //难易程度列表
questionLevalTypeList: [],
questionCategoryList: [], //分类
choosePointArray: [], //选择知识点
firstTypeList: [], //第一类题型
secondTypeList: [], //第二类题型
allTypeList: [], //所有题型
isShowQuestion: false,
commonIndex: -1,
examNum: 0, //题量
examScore: 0, //总分
ComOneIndex: -1,
ComCheckIndex: -1
}
},
created() {
if (this.$route.query && this.$route.query.Id) {
this.msg.PaperId = decodeURI(this.$route.query.Id)
}
this.getQuestionType();
this.getDifficultyType();
this.getQuestionCategory();
this.getQuestionLevelType();
},
mounted() {
if (this.msg.PaperId && this.msg.PaperId > 0) {
this.GetPaperInfo()
}
},
methods: {
//大类改变分数
changeGroupScore(gItem) {
var subScore = 0;
if (gItem.GScore && gItem.GScore > 0) {
subScore = gItem.GScore;
}
if (gItem.DetailsList && gItem.DetailsList.length > 0) {
var avgScore = Number(subScore / gItem.DetailsList.length).toFixed(2);
gItem.DetailsList.forEach(sItem => {
sItem.Score = avgScore;
})
}
this.calcPaper();
},
//上移下移(IsUp:0上移,1下移)
MoveFatherItem(subIndex, IsUp) {
var currentItem = this.DataObj.GroupList[subIndex];
//上移
if (IsUp == 0) {
if (subIndex > 0) {
var upItem = this.DataObj.GroupList[subIndex - 1];
this.$set(this.DataObj.GroupList, subIndex - 1, currentItem);
this.$set(this.DataObj.GroupList, subIndex, upItem);
this.$forceUpdate();
}
} else {
//下移
if (subIndex != this.DataObj.GroupList.length - 1) {
var downItem = this.DataObj.GroupList[subIndex + 1];
this.$set(this.DataObj.GroupList, subIndex + 1, currentItem);
this.$set(this.DataObj.GroupList, subIndex, downItem);
this.$forceUpdate();
}
}
},
//移动子项
MoveChildItem(Index, subIndex, IsUp) {
var currentItem = this.DataObj.GroupList[Index].DetailsList[subIndex];
//上移
if (IsUp == 0) {
if (subIndex > 0) {
var upItem = this.DataObj.GroupList[Index].DetailsList[subIndex - 1];
this.$set(this.DataObj.GroupList[Index].DetailsList, subIndex - 1, currentItem);
this.$set(this.DataObj.GroupList[Index].DetailsList, subIndex, upItem);
this.$forceUpdate();
}
} else {
//下移
if (subIndex != this.DataObj.GroupList[Index].DetailsList.length - 1) {
var downItem = this.DataObj.GroupList[Index].DetailsList[subIndex + 1];
this.$set(this.DataObj.GroupList[Index].DetailsList, subIndex + 1, currentItem);
this.$set(this.DataObj.GroupList[Index].DetailsList, subIndex, downItem);
this.$forceUpdate();
}
}
},
//删除题目
delExam(gitem, item, index) {
if (item.Id == 0) {
gitem.splice(index, 1);
} else {
this.$q.dialog({
title: '提示信息',
message: '是否确定删除',
cancel: true,
persistent: true,
ok: "确定",
cancel: "取消",
}).onOk(() => {
let msg = {
Id: item.Id,
}
DeletePaperDetails(msg).then(res => {
if (res.Code == 1) {
this.GetPaperInfo();
}
})
}).onCancel(() => {
});
}
this.calcPaper();
},
//点击修改标题名字和分数
getNameEdit(item, index) {
item.forEach(x => {
x.isShowEdit = false;
})
item[index].isShowEdit = true;
this.$forceUpdate();
},
//鼠标移开输入框 保存数据 还有隐藏输入框
saveExamName(item) {
item.forEach(x => {
x.isShowEdit = false;
})
this.$forceUpdate();
},
//获取子组件内容
getChildData(obj) {
if (obj) {
this.ChooseItem.QuestionContent = JSON.stringify(obj);
}
},
//获取题型列表
getQuestionType() {
queryQuestionTypeList({}).then(res => {
if (res.Code == 1) {
var tempArray = res.Data;
this.allTypeList = tempArray;
if (tempArray && tempArray.length > 0) {
this.firstTypeList = tempArray.slice(0, 5);
this.secondTypeList = tempArray.slice(5);
}
}
});
},
//题型点击【添加问题】
onItemClick(item, index) {
var questionObj = this.getDetailsObj();
questionObj.QuestionTypeId = item.QId;
questionObj.QuestionTypeKey = item.Key;
questionObj.GroupName = item.Name;
var obj = CreateQuestion(item.Key);
questionObj.QuestionContentObj = obj;
if (obj) {
questionObj.QuestionContent = JSON.stringify(obj);
}
var tempArray = [];
tempArray.push(questionObj);
this.AddQuestion(tempArray);
},
//添加问题
AddQuestion(qArray) {
if (this.DataObj) {
if (!this.DataObj.GroupList) {
this.DataObj.GroupList = [];
}
if (qArray && qArray.length > 0) {
qArray.forEach(qItem => {
if (!this.checkGroupExists(qItem.QuestionTypeId)) {
this.DataObj.GroupList.push({
GId: 0, //大题分组编号
PaperId: 0, //试卷编号
GroupName: qItem.GroupName,
QuestionTypeId: qItem.QuestionTypeId,
QuestionTypeKey: qItem.QuestionTypeKey,
GSortNum: 0,
GScore: 0, //分数
DetailsList: [], //问题列表
});
}
this.DataObj.GroupList.forEach((gItem, gIndex) => {
if (gItem.QuestionTypeId == qItem.QuestionTypeId) {
if (!gItem.DetailsList) {
gItem.DetailsList = [];
}
gItem.DetailsList.push(qItem);
}
})
})
}
}
this.calcPaper();
},
//判断题库是否存在
checkGroupExists(QuestionTypeId) {
var isExistsGroup = false;
if (this.DataObj && this.DataObj.GroupList && this.DataObj.GroupList.length > 0) {
this.DataObj.GroupList.forEach(item => {
if (!isExistsGroup) {
if (item.QuestionTypeId == QuestionTypeId) {
isExistsGroup = true;
}
}
})
}
return isExistsGroup;
},
//获取试卷问题详细Obj
getDetailsObj() {
var objOption = {
Id: 0, //试卷详情编号
PaperId: 0, //试卷编号
BankId: 0, //题库编号
QuestionId: 0, //问题编号
Title: "", //问题标题
QuestionContent: "", //问题内容
DifficultyType: 1, //问题难易程度
AnswerParse: "", //答案解析
QuestionTypeId: 0, //问题类型编号
QuestionTypeKey: "", //问题类型Key
Knowledge: "", //知识点
IsUpdateJobExam: 0, //是否同步修改引用此题目的作业和考试(1-是)
SortNum: 0, //排序
Answer: '', //问题答案【JSON字符串】
QuestionContentObj: [], //问题选项
IsMutex: 1, //填空题(答案顺序打乱也判正确)
Category: 0, //问题大类,
LevelType: 1, //考级程度
Score: 0, //分数
GroupName: "", //分组名称
ShowTitle: ''
};
return objOption;
},
//获取问题大类
getQuestionCategory() {
queryQuestionCategory().then(res => {
this.questionCategoryList = res.Data;
})
},
//获取问题考级程度
getQuestionLevelType() {
queryQuestionLevelType().then(res => {
this.questionLevalTypeList = res.Data;
})
},
//获取问题难易程度列表
getDifficultyType() {
queryDifficultyType().then(res => {
if (res.Code == 1) {
this.questionDifficultyTypeList = res.Data;
}
});
},
//获取题目
GetPaperInfo() {
GetPaper(this.msg).then(res => {
var tempData = res.Data;
if (res.Code == 1) {
this.DataObj.PaperId = tempData.PaperId;
this.DataObj.PaperName = tempData.PaperName;
this.DataObj.QuestionBandIds = tempData.QuestionBandIds;
this.DataObj.DifficultyType = tempData.DifficultyType;
this.DataObj.GenerateType = tempData.GenerateType;
this.DataObj.CreateNum = tempData.CreateNum;
this.DataObj.PaperType = tempData.PaperType;
this.DataObj.ParentId = tempData.ParentId;
if (tempData.GroupList && tempData.GroupList.length > 0) {
this.DataObj.GroupList = tempData.GroupList;
}
this.calcPaper();
}
})
},
//计算试卷相关
calcPaper() {
this.examScore = 0;
this.examNum = 0;
if (this.DataObj && this.DataObj.GroupList) {
this.DataObj.GroupList.forEach(x => {
x.isShowEdit = false;
if (x.DetailsList && x.DetailsList.length > 0) {
this.examNum += x.DetailsList.length;
x.DetailsList.forEach(y => {
if (y.Score) {
this.examScore += parseInt(y.Score);
}
})
}
})
}
},
//点击问题
ClickItem(questionItem, index, index2) {
this.ChooseItem = {};
this.ComOneIndex = index;
this.ComCheckIndex = index2;
this.ChooseItem = questionItem;
this.ChooseItem.QuestionContentObj = questionItem.QuestionContentObj;
if (questionItem.QuestionTypeKey != 'sharing-choose') {
this.$refs.UE_Title.reloadNewValue();
}
this.$refs.UE_AnswerParse.reloadNewValue();
this.ChooseItem.AnswerParse = questionItem.AnswerParse;
this.$forceUpdate();
},
//保存题目
SavePaper() {
if (this.validateType()) {
savePaperInfo(this.DataObj).then(res => {
if (res.Code == 1) {
this.$q.notify({
icon: 'iconfont icon-chenggong',
color: 'accent',
timeout: 2000,
message: '操作成功!',
position: 'top'
})
this.$router.push({
path: '/exam/examPaper',
query: {}
});
} else {
this.$q.notify({
type: 'negative',
position: "top",
message: `操作失败!`
})
}
})
}
},
//验证
validateType() {
var result = true;
for (let k = 0; k < this.DataObj.GroupList.length; k++) {
//连线题
if (this.DataObj.GroupList[k].QuestionTypeKey == 'matching') {
for (let j = 0; j < this.DataObj.GroupList[k].DetailsList.length; j++) {
if (this.DataObj.GroupList[k].DetailsList[j].QuestionContentObj.length > 0) {
for (let p = 0; p < this.DataObj.GroupList[k].DetailsList[j].QuestionContentObj[0].length; p++) {
if (this.DataObj.GroupList[k].DetailsList[j].QuestionContentObj[0][p].Content == '') {
this.$q.notify({
type: 'negative',
position: "top",
message: `${this.DataObj.GroupList[k].GroupName}${j+1}题第一组第${p+1}行数据内容为空!`
})
result = false;
return;
}
}
}
}
}
//单选题
if (this.DataObj.GroupList[k].QuestionTypeKey == 'single') {
var Num = 0;
for (let i = 0; i < this.DataObj.GroupList[k].DetailsList.length; i++) {
if (this.DataObj.GroupList[k].DetailsList[i].Title == '') {
this.$q.notify({
type: 'negative',
position: "top",
message: `${this.DataObj.GroupList[k].GroupName}${i+1}题标题为空!`
})
result = false;
return;
}
for (let j = 0; j < this.DataObj.GroupList[k].DetailsList[i].QuestionContentObj.length; j++) {
if (this.DataObj.GroupList[k].DetailsList[i].QuestionContentObj[j].Content == '') {
this.$q.notify({
type: 'negative',
position: "top",
message: `请填写${this.DataObj.GroupList[k].GroupName}${i+1}题选项!`
})
result = false;
return;
}
if (this.DataObj.GroupList[k].DetailsList[i].QuestionContentObj[j].IsAnswer) {
Num++
}
}
}
if (Num == 0) {
this.$q.notify({
type: 'negative',
position: "top",
message: `请设置单选题答案选项`
})
result = false;
return;
}
}
}
return result;
},
//js 判断重复
isRepeat(Arr, type) {
var result = true;
var msg = '';
switch (type) {
case 1:
msg = '第1组数据选项不能相同'
break;
case 2:
msg = '第2组数据选项不能相同'
break;
case 3:
msg = '选项内容不能相同'
break;
case 4:
msg = '题干内容不能相同!';
break;
default:
}
let num = 0;
for (var i = 0; i < Arr.length - 1; i++) {
for (var j = i + 1; j < Arr.length; j++) {
if (Arr[i].Content === Arr[j].Content) {
this.$q.notify({
type: 'negative',
position: "top",
message: msg
})
num++;
}
}
}
if (num > 0) {
result = false;
} else {
result = true;
}
return result;
},
closeQuestForm() {
this.isShowQuestion = false;
},
//获取选择的问题列表
getQuestionList(qArray) {
var tempArray = [];
if (qArray && qArray.length > 0) {
qArray.forEach(eItem => {
var qObj = this.getDetailsObj();
qObj.QuestionId = eItem.QuestionId;
qObj.Title = eItem.SourceTitle;
qObj.ShowTitle = eItem.Title;
qObj.QuestionContent = eItem.QuestionContent;
qObj.DifficultyType = eItem.DifficultyType;
qObj.AnswerParse = eItem.AnswerParse;
qObj.QuestionTypeId = eItem.QuestionTypeId;
qObj.QuestionTypeKey = eItem.QuestionTypeKey;
qObj.Knowledge = eItem.Knowledge;
qObj.IsUpdateJobExam = eItem.IsUpdateJobExam;
qObj.SortNum = eItem.SortNum;
qObj.Answer = eItem.Answer;
qObj.IsMutex = eItem.IsMutex;
qObj.Category = eItem.Category;
qObj.LevelType = eItem.LevelType;
var tempType = this.allTypeList.find(x => x.QId == qObj.QuestionTypeId);
if (tempType) {
qObj.GroupName = tempType.Name;
}
//问题选项
if (eItem.QuestionContent) {
qObj.QuestionContentObj = JSON.parse(eItem.QuestionContent);
}
tempArray.push(qObj);
});
}
this.AddQuestion(tempArray);
this.isShowQuestion = false;
},
//删除分组及问题
removeFather(item, index) {
if (item.GId == 0) {
this.DataObj.GroupList.splice(index, 1);
} else {
this.$q.dialog({
title: '提示信息',
message: '是否确定删除',
cancel: true,
persistent: true,
ok: "确定",
cancel: "取消",
}).onOk(() => {
let msg = {
GId: item.GId,
QuestionTypeId: item.QuestionTypeId
}
DeletePaperGroup(msg).then(res => {
if (res.Code == 1) {
this.GetPaperInfo();
}
})
}).onCancel(() => {
});
}
this.calcPaper();
}
}
}
</script>
......@@ -1049,17 +1049,22 @@ const routes = [{
import("pages/exam/examlist")
},
{
path: "/exam/paperEdit", //考试编辑
path: "/exam/paperEdit", //试卷编辑
component: () =>
import("pages/exam/paperEdit")
},
{
path: "/exam/paperCreate", //考试组卷
path: "/exam/paperInfo", //试卷详情
component: () =>
import("pages/exam/paperInfo")
},
{
path: "/exam/paperCreate", //试卷组卷
component: () =>
import("pages/exam/paperCreate")
},
{
path: "/exam/paperPublish", //发布考试
path: "/exam/paperPublish", //试卷发布考试
component: () =>
import("pages/exam/paperPublish")
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment