|
@@ -1,6 +1,6 @@
|
|
|
<template>
|
|
|
<div class="ev-container">
|
|
|
- <h1>新建习题</h1>
|
|
|
+ <h1>{{isEdit?'编辑习题':'新建习题'}}</h1>
|
|
|
<Divider />
|
|
|
<div class="exersices-attr display-flex">
|
|
|
<div class="exersices-attr-type my-radio-style">
|
|
@@ -25,11 +25,11 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
- <BaseSingle v-if="exersicesType=='single'" ref="single"></BaseSingle>
|
|
|
- <BaseMultiple v-else-if="exersicesType=='multiple'" ref="multiple"></BaseMultiple>
|
|
|
- <BaseJudge v-else-if="exersicesType=='judge'" ref="judge"></BaseJudge>
|
|
|
- <BaseCompletion v-else-if="exersicesType=='complete'" ref="complete"></BaseCompletion>
|
|
|
- <BaseSubjective v-else-if="exersicesType=='subjective'" ref="subjective"></BaseSubjective>
|
|
|
+ <BaseSingle v-if="exersicesType=='single'" ref="single" :editInfo="editInfo"></BaseSingle>
|
|
|
+ <BaseMultiple v-else-if="exersicesType=='multiple'" ref="multiple" :editInfo="editInfo"></BaseMultiple>
|
|
|
+ <BaseJudge v-else-if="exersicesType=='judge'" ref="judge" :editInfo="editInfo"></BaseJudge>
|
|
|
+ <BaseCompletion v-else-if="exersicesType=='complete'" ref="complete" :editInfo="editInfo"></BaseCompletion>
|
|
|
+ <BaseSubjective v-else-if="exersicesType=='subjective'" ref="subjective" :editInfo="editInfo"></BaseSubjective>
|
|
|
|
|
|
<div class="exersices-analysis">
|
|
|
<IconText :text="'解析'" :color="'#2892DD'" :icon="'md-list'" style="margin-bottom:15px;"></IconText>
|
|
@@ -47,7 +47,7 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
<script>
|
|
|
- import "videojs-contrib-hls.js/src/videojs.hlsjs"
|
|
|
+import "videojs-contrib-hls.js/src/videojs.hlsjs"
|
|
|
import IconText from '@/components/evaluation/IconText.vue'
|
|
|
import BaseSingle from '@/view/evaluation/types/BaseSingle.vue'
|
|
|
import BaseMultiple from '@/view/evaluation/types/BaseMultiple.vue'
|
|
@@ -57,19 +57,21 @@
|
|
|
import E from 'wangeditor'
|
|
|
//默认创建题目模板
|
|
|
const defaultExercise = {
|
|
|
- question: "",
|
|
|
- options: [],
|
|
|
- difficulty:"",
|
|
|
- answer: [],
|
|
|
- explain: "",
|
|
|
- type:""
|
|
|
- }
|
|
|
+ question: "",
|
|
|
+ options: [],
|
|
|
+ difficulty: "",
|
|
|
+ answer: [],
|
|
|
+ explain: "",
|
|
|
+ type: ""
|
|
|
+ }
|
|
|
export default {
|
|
|
components: {
|
|
|
- IconText, BaseSingle,BaseJudge,BaseMultiple,BaseCompletion,BaseSubjective
|
|
|
+ IconText, BaseSingle, BaseJudge, BaseMultiple, BaseCompletion, BaseSubjective
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
+ isEdit: false,
|
|
|
+ editInfo: {},
|
|
|
exersicesType: 'single',
|
|
|
exersicesDiff: "0",
|
|
|
analysisContent: "",
|
|
@@ -97,7 +99,10 @@
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
-
|
|
|
+ let editItem = this.$route.params.item; //编辑题目
|
|
|
+ if (editItem) {
|
|
|
+ this.editInfo = editItem;
|
|
|
+ }
|
|
|
},
|
|
|
methods: {
|
|
|
getContent: function (type) {
|
|
@@ -109,7 +114,7 @@
|
|
|
exerciseItem.type = this.exersicesType;
|
|
|
exerciseItem.difficulty = this.exersicesDiff;
|
|
|
exerciseItem.explain = this.analysisContent;
|
|
|
- exerciseItem.answer = [String.fromCharCode(64 + parseInt(this.$refs.single._data.trueIndex+1))];
|
|
|
+ exerciseItem.answer = [String.fromCharCode(64 + parseInt(this.$refs.single._data.trueIndex + 1))];
|
|
|
break;
|
|
|
case "multiple":
|
|
|
exerciseItem.question = this.$refs.multiple._data.stemContent;
|
|
@@ -149,30 +154,33 @@
|
|
|
if (this.checkContent(exerciseItem) && this.getSimpleText(exerciseItem.question) && this.getSimpleText(exerciseItem.explain)) {
|
|
|
this.$router.push({
|
|
|
name: 'exercisesList',
|
|
|
- params:{
|
|
|
+ params: {
|
|
|
exerciseItem: exerciseItem,
|
|
|
}
|
|
|
})
|
|
|
- console.log(exerciseItem);
|
|
|
- console.log(exerciseItem.question);
|
|
|
} else {
|
|
|
this.$Message.warning("请将题目填写完整!");
|
|
|
}
|
|
|
+
|
|
|
+ console.log(exerciseItem);
|
|
|
+
|
|
|
},
|
|
|
|
|
|
//题目类型转换
|
|
|
typeChange(val) {
|
|
|
this.exersicesType = val;
|
|
|
- this.analysisEditor.txt.clear();
|
|
|
+ if (!isEdit) {
|
|
|
+ this.analysisEditor.txt.clear();
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
//难度与背景颜色切换
|
|
|
diffChange(e, type) {
|
|
|
this.exersicesDiff = type;
|
|
|
e.preventDefault();
|
|
|
- let colorArr = ['#32CF74', '#E8BE15', '#F19300','#EB5E00', '#D30000'];
|
|
|
+ let colorArr = ['#32CF74', '#E8BE15', '#F19300', '#EB5E00', '#D30000'];
|
|
|
let ac = document.getElementsByClassName('exersices-attr-diff')[0].children[1].children;
|
|
|
- for (let i = 0; i < ac.length;i++) {
|
|
|
+ for (let i = 0; i < ac.length; i++) {
|
|
|
ac[i].style.background = "#fff";
|
|
|
ac[i].style.color = "#515a6e";
|
|
|
}
|
|
@@ -181,7 +189,7 @@
|
|
|
},
|
|
|
|
|
|
//提取富文本内容中的文本
|
|
|
- getSimpleText(html){
|
|
|
+ getSimpleText(html) {
|
|
|
var msg = html.replace(/<(?!img|video).*?>/g, '');//执行替换成空字符
|
|
|
return msg.replace(/ /ig, "");
|
|
|
},
|
|
@@ -189,11 +197,11 @@
|
|
|
checkContent(Obj) {
|
|
|
let flag = true;
|
|
|
for (let key in Obj) {
|
|
|
- if(!Obj[key]) {
|
|
|
- flag = false;
|
|
|
- }
|
|
|
- }
|
|
|
- return flag;
|
|
|
+ if (!Obj[key]) {
|
|
|
+ flag = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return flag;
|
|
|
},
|
|
|
|
|
|
//重置编辑器
|
|
@@ -202,13 +210,13 @@
|
|
|
this.analysisContent = "";
|
|
|
},
|
|
|
|
|
|
- insertAfter( newElement, targetElement ){ // newElement是要追加的元素 targetElement 是指定元素的位置
|
|
|
- var parent = targetElement.parentNode; // 找到指定元素的父节点
|
|
|
- if( parent.lastChild == targetElement ){ // 判断指定元素的是否是节点中的最后一个位置 如果是的话就直接使用appendChild方法
|
|
|
- parent.appendChild( newElement, targetElement );
|
|
|
- }else{
|
|
|
- parent.insertBefore( newElement, targetElement.nextSibling );
|
|
|
- };
|
|
|
+ insertAfter(newElement, targetElement) { // newElement是要追加的元素 targetElement 是指定元素的位置
|
|
|
+ var parent = targetElement.parentNode; // 找到指定元素的父节点
|
|
|
+ if (parent.lastChild == targetElement) { // 判断指定元素的是否是节点中的最后一个位置 如果是的话就直接使用appendChild方法
|
|
|
+ parent.appendChild(newElement, targetElement);
|
|
|
+ } else {
|
|
|
+ parent.insertBefore(newElement, targetElement.nextSibling);
|
|
|
+ };
|
|
|
},
|
|
|
|
|
|
//文件上传成功回调
|
|
@@ -231,9 +239,20 @@
|
|
|
analysisEditor.create();
|
|
|
this.analysisEditor = analysisEditor;
|
|
|
|
|
|
- //let parm = "<div class='w-e-menu' style='z-index:10001;'><i class='w-e-icon-strikethrough'></i></div>";
|
|
|
- //let bar = document.getElementsByClassName('w-e-toolbar')[5]
|
|
|
- //this.insertAfter(parm, bar);
|
|
|
+ let editItem = this.$route.params.item; //编辑题目
|
|
|
+ if (editItem) {
|
|
|
+ this.isEdit = true;
|
|
|
+ this.editInfo = editItem;
|
|
|
+ this.exersicesDiff = editItem.difficulty;
|
|
|
+ this.exersicesType = editItem.type;
|
|
|
+ this.stemContent = editItem.question;
|
|
|
+ this.optionsContent = editItem.options;
|
|
|
+ this.analysisContent = editItem.explain;
|
|
|
+ this.analysisEditor.txt.html(editItem.explain);
|
|
|
+
|
|
|
+ }
|
|
|
+ console.log(this.analysisEditor);
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
</script>
|