소스 검색

习题编辑

psycho 6 년 전
부모
커밋
ca32f3e7c7

+ 5 - 0
TEAMModelOS/ClientApp/router/routes.js

@@ -54,6 +54,11 @@ export const routes = [
         name:'exercisesList',
         component: resolve => require(['@/view/evaluation/index/ExercisesList.vue'], resolve), //路由懒加载
       },
+      {
+        path: '/testPaper',
+        name:'testPaper',
+        component: resolve => require(['@/view/evaluation/index/TestPaper.vue'], resolve), //路由懒加载
+      },
 
     ]
   }

+ 2 - 1
TEAMModelOS/ClientApp/view/evaluation/index/CreateExercises.css

@@ -96,10 +96,11 @@ exersices-attr-diff {
     .option-editor .w-e-text {
         overflow:hidden;
         width:auto !important;
+        line-height:40px;
     }
     .option-editor .w-e-text-container {
         border:none !important;
-        height:auto !important;
+        height:40px !important;
     }
 .option-order {
     min-height: 40px;

+ 58 - 39
TEAMModelOS/ClientApp/view/evaluation/index/CreateExercises.vue

@@ -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(/&nbsp;/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>

+ 11 - 1
TEAMModelOS/ClientApp/view/evaluation/index/ExercisesList.vue

@@ -67,7 +67,7 @@
           </div>
         </div>
         <div class="item-tools">
-          <Button type="primary">编辑题目</Button>
+          <Button type="primary" @click="handleEdit(item)">编辑题目</Button>
           <Button type="info">选题</Button>
           <span class="item-tools-bind">
             <span class="item-tools-tool"><Icon type="ios-link" />绑定知识点</span>
@@ -161,6 +161,16 @@ import { setTimeout } from 'core-js';
       pageSizeChange(val) {
         this.pageSize = val;
         this.pageChange(1);
+      },
+
+      //编辑习题
+      handleEdit(item) {
+        this.$router.push({
+            name: 'createExercises',
+            params:{
+              item: item,
+            }
+          })
       }
 
     },

+ 81 - 0
TEAMModelOS/ClientApp/view/evaluation/index/TestPaper.css

@@ -0,0 +1,81 @@
+.ev-body {
+    width:65% !important;
+}
+.paper-container {
+    user-select: none !important;
+}
+    .paper-container .paper-header {
+        background: #fff;
+    }
+    .paper-container .paper-title {
+        font-size: 20px;
+        font-weight: bold;
+        vertical-align: middle;
+    }
+    .paper-container .paper-subTitle {
+        font-size: 16px;
+        font-weight: bold;
+        margin: 15px;
+        vertical-align: middle;
+    }
+    .paper-container .paper-info {
+        font-size: 14px;
+        vertical-align: middle;
+    }
+
+    .paper-container .paper-toolbar {
+        background: #fff;
+        height:100px;
+    }
+
+.paper-content {
+    background: #fff;
+    padding:20px;
+    margin-top:10px;
+    display:flex;
+    flex-direction:row;
+}
+
+    .paper-content .paper-body {
+       width:90%;
+       padding-left:50px;
+    }
+
+    .paper-content .exercise-item {
+        font-size:14px !important;
+        margin-top:0 !important;
+        padding:5px 10px !important;
+        box-sizing:border-box;
+    }
+
+    .paper-content .paper-content-section {
+        font-size:18px;
+        font-weight:bold;
+        margin-top:20px;
+    }
+
+    .paper-content .paper-content-section span {
+        font-size:16px;
+        font-weight:500;
+        margin-left:10px;
+    }
+
+    .paper-content .content-wrap .exercise-item:hover {
+        box-shadow: none !important;
+        border: 1px solid #d2d2d2;
+    }
+
+.flex-row-center {
+    display: flex;
+    flex-direction: row;
+    justify-content: center;
+    align-items: center;
+}
+
+.flex-col-center {
+    display: flex;
+    flex-direction: column;
+    justify-content: center;
+    align-items: center;
+}
+

+ 122 - 0
TEAMModelOS/ClientApp/view/evaluation/index/TestPaper.vue

@@ -0,0 +1,122 @@
+<template>
+  <div class="paper-container">
+    <!-- 试卷编辑工具栏 -->
+    <div class="paper-toolbar">
+
+
+    </div>
+
+    <!-- 试卷内容 -->
+    <div class="paper-content">
+      <div class="paper-line">
+        <div id="pui_seal" title="点击设置&quot;装订线&quot;" style="display: block;">
+        <img alt="装订线" title="装订线" src="http://zujuan.xkw.com/resource/image/v2/peal_line.png" width="58" height="">
+        </div>
+      </div>
+      <div class="paper-body">
+        <!-- 试卷头部信息 -->
+        <div class="paper-header flex-col-center">
+          <p class="paper-title">{{paperInfo.title}}</p>
+          <p class="paper-subTitle">{{paperInfo.subTitle}}</p>
+          <p class="paper-info">考试时间:{{paperInfo.time}} 出卷人:{{paperInfo.builder}}</p>
+        </div>
+        <!-- 题目类型及列表 -->
+        <div class="paper-part" v-for="(item,order) in paperInfo.parts">
+          <div class="paper-content-section">{{numberConvertToUppercase(order)+'、'+item.name}}<span>(共6题,每题5分,共30分)</span></div>
+          <div v-if="list.length == 0">暂无数据</div>
+          <div class="content-wrap" v-else>
+            <div class="exercise-item" v-for="(question,index) of item.questions">
+              <div class="item-question">
+                <p>{{index+1}} : <span v-html="question.question"></span></p>
+              </div>
+              <div v-for="(option,optionIndex) in question.options">
+                <p>{{String.fromCharCode(64 + parseInt(optionIndex+1))}} : <span v-html="option.value"></span></p>
+              </div>
+            </div>
+          </div>
+        </div>
+      </div>
+    </div>
+  </div>
+</template>
+<script>
+  import questions from './list.json'
+  import paper from './paper.json'
+  export default {
+    data() {
+      return {
+        list: [],
+        paperInfo: {},
+        exersicesType: {
+          single: "单选",
+          multiple: "多选",
+          judge: "判断",
+          complete: "填空",
+          subjective:"问答"
+        },
+        exersicesDiff: ["容易", "较易", "一般", "较难", "困难"],
+        diffColors: ['#32CF74', '#E8BE15', '#F19300', '#EB5E00', '#D30000'],
+        filterType:"0",
+        filterDiff:"0",
+        filterSort: "0",
+        pageSize: 5,
+        pageNum: 1,
+        totalNum: 100,
+        allList: questions.list
+      }
+    },
+    created() {
+      this.list = questions.list;
+      this.paperInfo = paper;
+
+    },
+    methods: {
+      backToAdd() {
+        this.$router.push({
+            path: '/createExercises',//或者路径跳转path: '/addCreditCards',
+          })
+      },
+
+      numberConvertToUppercase(num) {
+          num = Number(num+1);
+          var upperCaseNumber = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '百', '千', '万', '亿'];
+          var length = String(num).length;
+          if (length == 1) {
+            return upperCaseNumber[num];
+          } else if (length == 2) {
+            if (num == 10) {
+              return upperCaseNumber[num];
+            } else if (num > 10 && num < 20) {
+              return '十' + upperCaseNumber[String(num).charAt(1)];
+            } else {
+              return upperCaseNumber[String(num).charAt(0)] + '十' + upperCaseNumber[String(num).charAt(1)].replace('零', '');
+            }
+          }
+      },
+
+      //切换页码
+      pageChange(page) {
+        let start = this.pageSize * (page - 1);
+        let end = this.pageSize * page;
+        let list = questions.list;
+        this.list = list.slice(start, end);
+        window.scroll(0, 0);
+      },
+
+      //切换分页Size
+      pageSizeChange(val) {
+        this.pageSize = val;
+        this.pageChange(1);
+      }
+
+    },
+    mounted() {
+     
+    }
+  }
+</script>
+<style scoped>
+  @import"../index/ExercisesList.css";
+  @import"../index/TestPaper.css";
+
+</style>

+ 5 - 2
TEAMModelOS/ClientApp/view/evaluation/index/index.vue

@@ -15,11 +15,13 @@
   import Header from '@/common/headers.vue'
   import CreateExercises from '@/view/evaluation/index/CreateExercises.vue'
   import ExercisesList from '@/view/evaluation/index/ExercisesList.vue'
+  import TestPaper from '@/view/evaluation/index/TestPaper.vue'
   export default {
     components: {
       Header,
       CreateExercises,
-      ExercisesList
+      ExercisesList,
+      TestPaper
     },
     data() {
       return {
@@ -52,10 +54,11 @@
     .ev-body .ev-slide {
       width:20%;
       height:1200px;
-      background:#d6d6d6;
+      background:#e1e1e1;
     }
 
     .ev-body .ev-content {
        width:79%;
     }
+
 </style>

+ 23 - 14
TEAMModelOS/ClientApp/view/evaluation/index/list.json

@@ -1,34 +1,43 @@
 {
   "list": [
     {
-      "answer": [ "A" ],
-      "difficulty": "0",
-      "explain": "<p>下列各句中,画线词语的古今意义相同的一项<p><br></p>",
+      "answer": [ "D" ],
+      "difficulty": "1",
+      "explain": "<p>下列各句中,画线词语的古今意义相同的一项(    )<p><br></p>",
       "options": [
         {
           "code": "A",
-          "value": "焉用亡郑以<u>陪</u>邻"
+          "value": "焉用亡郑以<u>陪</u>邻",
+          "index": 0
         },
         {
           "code": "B",
-          "value": "燕王<u>诚</u>振怖大王之威"
+          "value": "燕王<u>诚</u>振怖大王之威",
+          "index": 1
         },
         {
           "code": "C",
-          "value": "<u>籍</u>吏民,封府库"
+          "value": "<u>籍</u>吏民,封府库",
+          "index": 2
         },
         {
           "code": "D",
-          "value": "沛公起<u>如</u>厕"
+          "value": "沛公起<u>如</u>厕",
+          "index": 3
+        },
+        {
+          "code": "E",
+          "value": "沛公起<u>如</u>厕",
+          "index": 4
         }
       ],
-      "question": "<p>下列各句中,画线词语的古今意义相同的一项是(    )</p><p><br></p>",
-      "type": "single"
+      "question": "<p>解析解析解析解析解析解析解析解析解析解析</p><p><br></p>",
+      "type": "multiple"
     },
     {
       "answer": [ "A" ],
-      "difficulty": "0",
-      "explain": "<p>下列各句中,画线词语的古今意义相同的一项<p><br></p>",
+      "difficulty": "2",
+      "explain": "<p>下列各句中,画线词语的古今意义相同的一项(    )<p><br></p>",
       "options": [
         {
           "code": "A",
@@ -47,13 +56,13 @@
           "value": "沛公起<u>如</u>厕"
         }
       ],
-      "question": "<p>下列各句中,画线词语的古今意义相同的一项</p><p><br></p>",
+      "question": "<p>下列各句中,画线词语的古今意义相同的一项(    )</p><p><br></p>",
       "type": "single"
     },
     {
       "answer": [ "A" ],
       "difficulty": "0",
-      "explain": "<p>下列各句中,画线词语的古今意义相同的一项<p><br></p>",
+      "explain": "<p>下列各句中,画线词语的古今意义相同的一项(    )<p><br></p>",
       "options": [
         {
           "code": "A",
@@ -70,7 +79,7 @@
         {
           "code": "D",
           "value": "沛公起<u>如</u>厕"
-        }
+        } 
       ],
       "question": "<p>下列各句中,画线词语的古今意义相同的一项是(    )</p><p><br></p>",
       "type": "single"

+ 190 - 0
TEAMModelOS/ClientApp/view/evaluation/index/paper.json

@@ -0,0 +1,190 @@
+{
+  "title": "2018-2019东山学校六月高三模拟考试(理综)",
+  "subTitle": "试卷副标题",
+  "time": "120分钟",
+  "builder": "张纪中",
+  "parts": [
+    {
+      "name": "选择题",
+      "questions": [
+        {
+          "answer": [ "A" ],
+          "difficulty": "0",
+          "explain": "<p>下列各句中,画线词语的古今意义相同的一项(    )<p><br></p>",
+          "options": [
+            {
+              "code": "A",
+              "value": "焉用亡郑以<u>陪</u>邻"
+            },
+            {
+              "code": "B",
+              "value": "燕王<u>诚</u>振怖大王之威"
+            },
+            {
+              "code": "C",
+              "value": "<u>籍</u>吏民,封府库"
+            },
+            {
+              "code": "D",
+              "value": "沛公起<u>如</u>厕"
+            }
+          ],
+          "question": "<p>下列各句中,画线词语的古今意义相同的一项是(    )</p><p><br></p>",
+          "type": "single"
+        },
+        {
+          "answer": [ "A" ],
+          "difficulty": "0",
+          "explain": "<p>下列各句中,画线词语的古今意义相同的一项(    )<p><br></p>",
+          "options": [
+            {
+              "code": "A",
+              "value": "焉用亡郑以<u>陪</u>邻"
+            },
+            {
+              "code": "B",
+              "value": "燕王<u>诚</u>振怖大王之威"
+            },
+            {
+              "code": "C",
+              "value": "<u>籍</u>吏民,封府库"
+            },
+            {
+              "code": "D",
+              "value": "沛公起<u>如</u>厕"
+            }
+          ],
+          "question": "<p>下列各句中,画线词语的古今意义相同的一项(    )</p><p><br></p>",
+          "type": "single"
+        },
+        {
+          "answer": [ "A" ],
+          "difficulty": "0",
+          "explain": "<p>下列各句中,画线词语的古今意义相同的一项(    )<p><br></p>",
+          "options": [
+            {
+              "code": "A",
+              "value": "焉用亡郑以<u>陪</u>邻"
+            },
+            {
+              "code": "B",
+              "value": "燕王<u>诚</u>振怖大王之威"
+            },
+            {
+              "code": "C",
+              "value": "<u>籍</u>吏民,封府库"
+            },
+            {
+              "code": "D",
+              "value": "沛公起<u>如</u>厕"
+            }
+          ],
+          "question": "<p>下列各句中,画线词语的古今意义相同的一项是(    )</p><p><br></p>",
+          "type": "single"
+        },
+        {
+          "answer": [ "A" ],
+          "difficulty": "0",
+          "explain": "<p>下列各句中,画线词语的古今意义相同的一项<p><br></p>",
+          "options": [
+            {
+              "code": "A",
+              "value": "焉用亡郑以<u>陪</u>邻"
+            },
+            {
+              "code": "B",
+              "value": "燕王<u>诚</u>振怖大王之威"
+            },
+            {
+              "code": "C",
+              "value": "<u>籍</u>吏民,封府库"
+            },
+            {
+              "code": "D",
+              "value": "沛公起<u>如</u>厕"
+            }
+          ],
+          "question": "<p>下列各句中,画线词语的古今意义相同的一项是(    )</p><p><br></p>",
+          "type": "single"
+        }
+      ]
+
+    },
+    {
+      "name": "填空题",
+      "questions": [
+        {
+          "answer": [ "A" ],
+          "difficulty": "0",
+          "explain": "<p>下列各句中,画线词语的古今意义相同的一项<p><br></p>",
+          "options": [],
+          "question": "<p>《论语》中曾子认为为人处世要每天从三个方面反省自己的句子是:“&nbsp;<span class=\"complete-line\" data-index=\"0\" data-answer=\"0\" contenteditable=\"false\">①</span>&nbsp;&nbsp;&nbsp;”。<br></p>",
+          "type": "complete"
+        },
+        {
+          "answer": [ "A" ],
+          "difficulty": "0",
+          "explain": "<p>下列各句中,画线词语的古今意义相同的一项<p><br></p>",
+          "options": [],
+          "question": "<p>龚自珍《己亥杂诗》中表现既有还家的喜悦,又有离京的愤然的诗句是“&nbsp;<span class=\"complete-line\" data-index=\"0\" data-answer=\"0\" contenteditable=\"false\">①</span>&nbsp;,&nbsp;<span class=\"complete-line\" data-index=\"1\" data-answer=\"1\" contenteditable=\"false\">②</span>&nbsp;”。&nbsp;&nbsp;<br></p>",
+          "type": "complete"
+        },
+        {
+          "answer": [ "A" ],
+          "difficulty": "0",
+          "explain": "<p>下列各句中,画线词语的古今意义相同的一项<p><br></p>",
+          "options": [],
+          "question": "<p>龚自珍《己亥杂诗》中表现既有还家的喜悦,又有离京的愤然的诗句是“&nbsp;<span class=\"complete-line\" data-index=\"0\" data-answer=\"0\" contenteditable=\"false\">①</span>&nbsp;,&nbsp;<span class=\"complete-line\" data-index=\"1\" data-answer=\"1\" contenteditable=\"false\">②</span>&nbsp;”。&nbsp;&nbsp;<br></p>",
+          "type": "complete"
+        },
+        {
+          "answer": [ "A" ],
+          "difficulty": "0",
+          "explain": "<p>下列各句中,画线词语的古今意义相同的一项<p><br></p>",
+          "options": [],
+          "question": "<p>龚自珍《己亥杂诗》中表现既有还家的喜悦,又有离京的愤然的诗句是“&nbsp;<span class=\"complete-line\" data-index=\"0\" data-answer=\"0\" contenteditable=\"false\">①</span>&nbsp;,&nbsp;<span class=\"complete-line\" data-index=\"1\" data-answer=\"1\" contenteditable=\"false\">②</span>&nbsp;”。&nbsp;&nbsp;<br></p>",
+          "type": "complete"
+        }
+      ]
+
+    },
+    {
+      "name": "阅读理解",
+      "questions": [
+        {
+          "answer": [ "A" ],
+          "difficulty": "0",
+          "explain": "<p>下列各句中,画线词语的古今意义相同的一项<p><br></p>",
+          "options": [],
+          "question": "<p>《论语》中曾子认为为人处世要每天从三个方面反省自己的句子是:“&nbsp;<span class=\"complete-line\" data-index=\"0\" data-answer=\"0\" contenteditable=\"false\">①</span>&nbsp;&nbsp;&nbsp;”。<br></p>",
+          "type": "complete"
+        },
+        {
+          "answer": [ "A" ],
+          "difficulty": "0",
+          "explain": "<p>下列各句中,画线词语的古今意义相同的一项<p><br></p>",
+          "options": [],
+          "question": "<p>龚自珍《己亥杂诗》中表现既有还家的喜悦,又有离京的愤然的诗句是“&nbsp;<span class=\"complete-line\" data-index=\"0\" data-answer=\"0\" contenteditable=\"false\">①</span>&nbsp;,&nbsp;<span class=\"complete-line\" data-index=\"1\" data-answer=\"1\" contenteditable=\"false\">②</span>&nbsp;”。&nbsp;&nbsp;<br></p>",
+          "type": "complete"
+        },
+        {
+          "answer": [ "A" ],
+          "difficulty": "0",
+          "explain": "<p>下列各句中,画线词语的古今意义相同的一项<p><br></p>",
+          "options": [],
+          "question": "<p>龚自珍《己亥杂诗》中表现既有还家的喜悦,又有离京的愤然的诗句是“&nbsp;<span class=\"complete-line\" data-index=\"0\" data-answer=\"0\" contenteditable=\"false\">①</span>&nbsp;,&nbsp;<span class=\"complete-line\" data-index=\"1\" data-answer=\"1\" contenteditable=\"false\">②</span>&nbsp;”。&nbsp;&nbsp;<br></p>",
+          "type": "complete"
+        },
+        {
+          "answer": [ "A" ],
+          "difficulty": "0",
+          "explain": "<p>下列各句中,画线词语的古今意义相同的一项<p><br></p>",
+          "options": [],
+          "question": "<p>龚自珍《己亥杂诗》中表现既有还家的喜悦,又有离京的愤然的诗句是“&nbsp;<span class=\"complete-line\" data-index=\"0\" data-answer=\"0\" contenteditable=\"false\">①</span>&nbsp;,&nbsp;<span class=\"complete-line\" data-index=\"1\" data-answer=\"1\" contenteditable=\"false\">②</span>&nbsp;”。&nbsp;&nbsp;<br></p>",
+          "type": "complete"
+        }
+      ]
+
+    }
+  ]
+}

+ 26 - 2
TEAMModelOS/ClientApp/view/evaluation/types/BaseMultiple.vue

@@ -25,6 +25,7 @@
     components: {
       IconText
     },
+    props: ['editInfo'],
     data() {
       return {
         options: [...new Array(4).keys()], //默认四个选项
@@ -33,6 +34,7 @@
         trueArr: [0],
         trueIndex: [0],
         stemContent: "",
+        stemEditor:null,
         transferArr: [],
         optionsContent: [],
         defaultConfig: {
@@ -42,6 +44,11 @@
         }
       }
     },
+    created() {
+      if (Object.keys(this.editInfo).length > 0) {
+        this.options = [...new Array(this.editInfo.options.length).keys()];
+      }
+    },
     methods: {
       initEditors() {
         //Editor默认配置
@@ -72,6 +79,11 @@
             }
           }
           editor.create();
+
+        //如果是编辑状态 则将选项内容回显
+          if (Object.keys(this.editInfo).length > 0) {
+            editor.txt.html(this.editInfo.options[i].value);
+          }
         }
       },
       //设置正确答案
@@ -159,14 +171,26 @@
       },
     },
     mounted() {
-      //初始化选项编辑器
-      this.initEditors();
+
       let stemEditor = new E(this.$refs.editor);
       stemEditor.customConfig = this.defaultConfig;
       stemEditor.customConfig.onchange = (html) => {
         this.stemContent = html;
       }
       stemEditor.create();
+      this.stemEditor = stemEditor;
+
+       //判断是否为编辑状态
+      if (Object.keys(this.editInfo).length > 0) {
+        this.stemEditor.txt.html(this.editInfo.question);
+        this.stemContent = this.editInfo.question;
+        this.optionsContent = this.editInfo.options;
+        this.transferArr = this.editInfo.answer;
+        this.options = this.editInfo.options.map((item,index) => index);
+      }
+
+      //初始化选项编辑器
+      this.initEditors();
     },
     computed: {
       //选项顺序转化成字母

+ 56 - 25
TEAMModelOS/ClientApp/view/evaluation/types/BaseSingle.vue

@@ -25,12 +25,14 @@
     components: {
       IconText
     },
+    props: ['editInfo'],
     data() {
       return {
         options: [...new Array(4).keys()], //默认四个选项
         existOptions: [...new Array(4).keys()],
         initFlag: true,
         trueIndex: 0,
+        stemEditor:null,
         stemContent: "",
         optionsContent: [],
         defaultConfig: {
@@ -40,36 +42,53 @@
         }
       }
     },
+    created() {
+      if (Object.keys(this.editInfo).length > 0) {
+        this.options = [...new Array(this.editInfo.options.length).keys()];
+      }
+    },
     methods: {
       initEditors() {
         //Editor默认配置
-        for (let i of this.options) {
-          let that = this;
-          let editor = new E(that.$refs['singleOption' + i][0]);
-          editor.customConfig = this.defaultConfig;
-          editor.customConfig.onblur = function () {
-            let allToolbars = document.getElementsByClassName('option-editor');
-            for (let i = 0; i < allToolbars.length; i++) {
-              if (allToolbars[i].children.length) {
-                allToolbars[i].children[0].style.visibility = "hidden"
+        if (this.options.length > 0) {
+          this.options.forEach((item, i) => {
+            let that = this;
+            let editor = new E(that.$refs['singleOption' + i][0]);
+            editor.customConfig = this.defaultConfig;
+
+            //选项编辑器失焦隐藏工具栏
+            editor.customConfig.onblur = function () {
+              let allToolbars = document.getElementsByClassName('option-editor');
+              for (let i = 0; i < allToolbars.length; i++) {
+                if (allToolbars[i].children.length) {
+                  allToolbars[i].children[0].style.visibility = "hidden"
+                }
               }
             }
-          }
-          editor.customConfig.onchange = (html) => {
-            let key = String.fromCharCode(64 + parseInt(i + 1));
-            let codeArr = this.optionsContent.map(item => item.code);
-            //如果已经编辑过则 修改选项内容
-            if (codeArr.indexOf(key) != -1) {
-              this.optionsContent[codeArr.indexOf(key)].value = html;
-            } else { //否则创建新选项
-                let option = {
-                  code: key,
-                  value:html
-                }
-                this.optionsContent.push(option);
+
+            //选项编辑器内容发生变化时
+            editor.customConfig.onchange = (html) => {
+              let key = String.fromCharCode(64 + parseInt(i + 1));
+              let codeArr = this.optionsContent.map(item => item.code);
+              //如果已经编辑过则 修改选项内容
+              if (codeArr.indexOf(key) != -1) {
+                this.optionsContent[codeArr.indexOf(key)].value = html;
+              } else { //否则创建新选项
+                  let option = {
+                    code: key,
+                    value:html
+                  }
+                  this.optionsContent.push(option);
+              }
             }
-          }
-          editor.create();
+            editor.create();
+
+            //如果是编辑状态 则将选项内容回显
+            if (Object.keys(this.editInfo).length > 0) {
+              editor.txt.html(this.editInfo.options[i].value);
+            }
+
+          })
         }
       },
       //设置正确答案
@@ -130,6 +149,8 @@
           this.$Message.warning("至少保留两个选项!");
         }
       },
+
+      //模拟选项聚焦事件
       optionClick(index) {
         let allToolbars = document.getElementsByClassName('option-editor');
         let that = this;
@@ -143,14 +164,24 @@
       },
     },
     mounted() {
-      this.initEditors();
       let stemEditor = new E(this.$refs.singleEditor);
       stemEditor.customConfig = this.defaultConfig;
       stemEditor.customConfig.onchange = (html) => {
         this.stemContent = html;
       }
       stemEditor.create();
+      this.stemEditor = stemEditor;
 
+      //判断是否为编辑状态
+      if (Object.keys(this.editInfo).length > 0) {
+        this.stemEditor.txt.html(this.editInfo.question);
+        this.stemContent = this.editInfo.question;
+        this.optionsContent = this.editInfo.options;
+        this.trueIndex = this.editInfo.answer[0].charCodeAt() - 65;
+        this.options = this.editInfo.options.map((item,index) => index);
+      }
+
+      this.initEditors();
     }
   }
 </script>