浏览代码

Merge branch 'master' of http://gcls-git.helxsoft.cn/GCLS/eep_page

zq 9 小时之前
父节点
当前提交
2757f70b45

+ 1 - 1
src/router/modules/project.js

@@ -161,7 +161,7 @@ const projectPage = {
     // 机构管理员 -> 项目管理 -> 已上架教材
     {
       path: 'org/book',
-      name: 'ProjectManageBook',
+      name: 'OrgProjectManageBook',
       component: () => import('@/views/project_manage/org/book/index.vue'),
     },
     // 机构管理员 -> 项目管理 -> 已上架教材 -> 预览教材

+ 0 - 2
src/utils/mathjax.js

@@ -18,9 +18,7 @@ window.MathJax = {
     displayAlign: 'center', // 左对齐
     displayIndent: '0', // 不缩进
     scale: 1, // 缩放比例
-    minScaleAdjust: 50, // 最小缩放比例
     exFactor: 2, // 行高因子
-    linebreaks: true, // 自动换行
   },
   startup: {
     ready() {

+ 14 - 28
src/views/book/courseware/create/components/question/sort/Sort.vue

@@ -8,25 +8,24 @@
             class="sort-rich"
             :style="{
               gridArea: `rich-${i}`,
-              ...getRichStyle(i),
             }"
           >
-            <RichText v-model="item.content" :inline="true" placeholder="" />
+            <RichText v-model="item.content" :inline="true" placeholder="输入内容" />
           </div>
           <div
             :key="item.mark"
             class="custom-serial-number"
             :style="{
               gridArea: `number-${i}`,
-              ...getNumberStyle(i),
             }"
           >
             <el-input
               v-model="item.custom_serial_number"
-              v-numeric-only
               :class="{
                 'text-center': data.property.arrange_direction === arrangeTypeList[0].value,
               }"
+              placeholder="输入序号"
+              @input="handleCustomSerialNumber(item)"
             />
           </div>
         </template>
@@ -90,7 +89,7 @@ export default {
         gridTemplateRows = '1fr 42px';
       } else {
         gridTemplateAreas = this.data.option_list.map((_, i) => `'number-${i} rich-${i}'`).join(' ');
-        gridTemplateColumns = '48px 1fr';
+        gridTemplateColumns = '75px 1fr';
       }
 
       return {
@@ -99,29 +98,14 @@ export default {
         gridTemplateRows,
       };
     },
-    getRichStyle(i) {
-      let isVertical = this.data.property.arrange_direction === arrangeTypeList[1].value; // 是否竖排
-      let isLast = i !== this.data.option_list.length - 1; // 是否最后一个
-
-      let borderBottom = !isVertical || (isVertical && isLast) ? 'none' : '1px solid #ccc';
-      let borderRight = !isVertical && isLast ? 'none' : '1px solid #ccc';
-
-      return {
-        borderBottom,
-        borderRight,
-      };
-    },
-    getNumberStyle(i) {
-      let isVertical = this.data.property.arrange_direction === arrangeTypeList[1].value; // 是否竖排
-      let isLast = i !== this.data.option_list.length - 1; // 是否最后一个
-
-      let borderRight = (!isVertical && isLast) || isVertical ? 'none' : '1px solid #ccc';
-      let borderBottom = isVertical && isLast ? 'none' : '1px solid #ccc';
-
-      return {
-        borderRight,
-        borderBottom,
-      };
+    /**
+     * 处理自定义序号输入
+     * @param {Object} item - 当前选项对象
+     * @param {string} item.custom_serial_number - 自定义序号
+     * @description 只允许输入数字和 /
+     */
+    handleCustomSerialNumber(item) {
+      item.custom_serial_number = item.custom_serial_number.replace(/[^0-9/]/g, '');
     },
   },
 };
@@ -132,9 +116,11 @@ export default {
 
 .sort-wrapper {
   display: grid;
+  gap: 12px;
 
   .sort-rich {
     padding: 8px;
+    background-color: $content-color;
     border: 1px solid #ccc;
 
     :deep p {

+ 9 - 1
src/views/book/courseware/create/components/question/sort/SortSetting.vue

@@ -16,6 +16,13 @@
           {{ label }}
         </el-radio>
       </el-form-item>
+      <el-form-item label="顺序">
+        <el-radio-group v-model="property.order_type">
+          <el-radio v-for="{ value, label } in orderTypeList" :key="value" :label="value">
+            {{ label }}
+          </el-radio>
+        </el-radio-group>
+      </el-form-item>
     </el-form>
   </div>
 </template>
@@ -23,7 +30,7 @@
 <script>
 import SettingMixin from '@/views/book/courseware/create/components/common/SettingMixin';
 
-import { arrangeTypeList, getSortProperty } from '@/views/book/courseware/data/sort';
+import { arrangeTypeList, getSortProperty, orderTypeList } from '@/views/book/courseware/data/sort';
 
 export default {
   name: 'SortPreview',
@@ -32,6 +39,7 @@ export default {
     return {
       property: getSortProperty(),
       arrangeTypeList,
+      orderTypeList,
     };
   },
   methods: {},

+ 6 - 0
src/views/book/courseware/data/sort.js

@@ -15,6 +15,11 @@ export function getOption() {
   };
 }
 
+export const orderTypeList = [
+  { value: 'order', label: '设定显示' },
+  { value: 'random', label: '随机打乱' },
+];
+
 export function getSortProperty() {
   return {
     serial_number: 1,
@@ -23,6 +28,7 @@ export function getSortProperty() {
     sn_display_mode: displayList[0].value,
     option_count: 3,
     arrange_direction: arrangeTypeList[0].value,
+    order_type: orderTypeList[0].value,
   };
 }
 

+ 29 - 11
src/views/book/courseware/preview/components/sort/SortPreview.vue

@@ -54,7 +54,7 @@
 <script>
 import draggable from 'vuedraggable';
 
-import { getSortData, arrangeTypeList } from '@/views/book/courseware/data/sort';
+import { getSortData, arrangeTypeList, orderTypeList } from '@/views/book/courseware/data/sort';
 
 import PreviewMixin from '../common/PreviewMixin';
 
@@ -71,6 +71,7 @@ export default {
       drag: false,
       clickIndexList: [], // 点击选中的索引
       is_all_right: false, // 是否全对
+      orderTypeList,
     };
   },
   watch: {
@@ -87,12 +88,23 @@ export default {
         this.move_list = this.answer.answer_list.map((mark) =>
           this.data.option_list.find((item) => item.mark === mark),
         );
-        this.is_all_right = this.move_list.every(
-          ({ custom_serial_number }, index) => index + 1 === Number(custom_serial_number),
-        );
+        const rightAnswerNum = this.move_list.custom_serial_number.split('/').length; // 正确答案组数
+        let correctSerial = 0; // 目前是第几组是正确答案
+        for (let i = 0; i < rightAnswerNum; i++) {
+          let isRight = this.move_list.every(
+            ({ custom_serial_number }, index) => index + 1 === Number(custom_serial_number.split('/')[i]),
+          );
+          if (isRight) {
+            this.is_all_right = isRight;
+            correctSerial = i;
+            break;
+          }
+        }
 
         this.right_answer_list = this.data.option_list.toSorted(
-          (a, b) => Number(a.custom_serial_number) - Number(b.custom_serial_number),
+          (a, b) =>
+            Number(a.custom_serial_number.split('/')[correctSerial]) -
+            Number(b.custom_serial_number.split('/')[correctSerial]),
         );
       },
       immediate: true,
@@ -100,7 +112,11 @@ export default {
     'data.option_list': {
       handler(val) {
         if (!val) return;
-        this.move_list = JSON.parse(JSON.stringify(val));
+        if (this.data.property.order_type === orderTypeList[0].value) {
+          this.move_list = JSON.parse(JSON.stringify(val));
+        } else {
+          this.move_list = JSON.parse(JSON.stringify(val)).sort(() => Math.random() - 0.5);
+        }
       },
       deep: true,
       immediate: true,
@@ -120,15 +136,17 @@ export default {
      * @param {number} index 索引
      */
     computedDragItemClass(index) {
+      let judgeClass = '';
+      if (this.isJudgingRightWrong) {
+        let serialList = this.move_list[index].custom_serial_number.split('/');
+        let isRight = serialList.some((serial) => Number(serial) === index + 1);
+        judgeClass = isRight ? 'right' : 'error';
+      }
       return [
         {
           selected: this.clickIndexList.includes(index),
         },
-        this.isJudgingRightWrong
-          ? Number(this.move_list[index].custom_serial_number) === index + 1
-            ? 'right'
-            : 'error'
-          : '',
+        judgeClass,
       ];
     },
     /**