MatchingPreview.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  1. <!-- eslint-disable vue/no-v-html -->
  2. <template>
  3. <div class="matching-preview" :style="[getAreaStyle(), getComponentStyle()]">
  4. <SerialNumberPosition v-if="isEnable(data.property.sn_display_mode)" :property="data.property" />
  5. <div class="main">
  6. <ul ref="list" class="option-list">
  7. <li v-for="(item, i) in data.option_list" :key="i" class="list-item">
  8. <template v-for="({ content, mark, multilingual, paragraph_list, rich_text_list }, j) in item">
  9. <div
  10. v-if="content"
  11. :key="mark"
  12. :class="['item-wrapper', `item-${mark}`, computedAnswerClass(mark, i, j), { isMobile: isMobile }]"
  13. :style="{
  14. cursor: disabled ? 'default' : 'pointer',
  15. flex: isMobile ? '0 1 auto' : '',
  16. width: isMobile ? 'calc(50% - 8px)' : '',
  17. overflow: isMobile ? 'auto' : '',
  18. }"
  19. @mousedown="mousedown($event, i, j, mark)"
  20. @mouseup="mouseup($event, i, j, mark)"
  21. @click="handleClickConnection($event, i, j, mark)"
  22. >
  23. <PinyinText
  24. v-if="isEnable(data.property.view_pinyin)"
  25. class="content"
  26. :paragraph-list="paragraph_list"
  27. :rich-text-list="rich_text_list"
  28. :pinyin-position="data.property.pinyin_position"
  29. :is-preview="true"
  30. />
  31. <span v-else class="content rich-text" v-html="convertText(sanitizeHTML(content))"></span>
  32. <div v-if="showLang" class="lang">
  33. {{ multilingual.find((item) => item.type === getLang())?.translation }}
  34. </div>
  35. </div>
  36. <div v-else :key="mark" style="width: calc(50% - 36px); padding: 12px 24px"></div>
  37. </template>
  38. </li>
  39. </ul>
  40. </div>
  41. <PreviewOperation @showAnswerAnalysis="showAnswerAnalysis" @judgeCorrect="judgeCorrect" @retry="retry" />
  42. <AnswerCorrect
  43. :answer-correct="data?.answer_correct"
  44. :visible.sync="visibleAnswerCorrect"
  45. :is-check-correct="isCheckCorrect"
  46. @closeAnswerCorrect="closeAnswerCorrect"
  47. />
  48. <AnswerAnalysis
  49. :visible.sync="visibleAnswerAnalysis"
  50. :answer-list="data.answer_list"
  51. :analysis-list="data.analysis_list"
  52. @closeAnswerAnalysis="closeAnswerAnalysis"
  53. >
  54. <div slot="right-answer" class="right-answer">
  55. <ul ref="answerList" class="option-list">
  56. <li v-for="(item, i) in data.option_list" :key="i" class="list-item">
  57. <div v-for="{ content, mark } in item" :key="mark" :class="['item-wrapper', `answer-item-${mark}`]">
  58. <span class="content rich-text" v-html="convertText(sanitizeHTML(content))"></span>
  59. </div>
  60. </li>
  61. </ul>
  62. </div>
  63. </AnswerAnalysis>
  64. </div>
  65. </template>
  66. <script>
  67. import { getMatchingData, svgNS } from '@/views/book/courseware/data/matching';
  68. import { arraysIntersect } from '@/utils/validate';
  69. import PreviewMixin from '../common/PreviewMixin';
  70. export default {
  71. name: 'MatchingPreview',
  72. mixins: [PreviewMixin],
  73. data() {
  74. return {
  75. data: getMatchingData(),
  76. answerList: [], // 答案列表
  77. curConnectionPoint: { i: -1, j: -1, mark: '' }, // 当前连线点
  78. // 拖拽相关
  79. drag: false,
  80. mouseEvent: {
  81. clientX: 0,
  82. clientY: 0,
  83. },
  84. };
  85. },
  86. watch: {
  87. 'data.option_list': {
  88. handler(val) {
  89. this.clearLine();
  90. if (!val) return;
  91. let list = val.map((item) => {
  92. return item.map(({ mark }) => {
  93. return { mark, preMark: [], nextMark: [] };
  94. });
  95. });
  96. this.$set(this, 'answerList', list);
  97. },
  98. immediate: true,
  99. },
  100. answerList: {
  101. handler(list) {
  102. let arr = [];
  103. list.forEach((item) => {
  104. let markArr = [];
  105. item.forEach(({ mark, nextMark }, j) => {
  106. if (j === 0) {
  107. markArr.push(mark);
  108. markArr.push([...nextMark]);
  109. } else if (item.length === 3 && j === 1) {
  110. markArr.push([...nextMark]);
  111. }
  112. });
  113. arr.push(markArr);
  114. });
  115. // 答案数组为 第一个值为固定字符串,后面为连接的值数组,如:['A', ['B', 'C'], ['1', '2']],根据此结构来判断对错、绘制连线
  116. this.answer.answer_list = arr;
  117. },
  118. deep: true,
  119. },
  120. isShowRightAnswer(cur) {
  121. if (cur) {
  122. this.$nextTick(() => {
  123. this.circulateAnswerList();
  124. });
  125. }
  126. },
  127. },
  128. created() {
  129. document.addEventListener('click', this.handleEventConnection);
  130. document.addEventListener('mousemove', this.documentMousemouse);
  131. document.addEventListener('mouseup', this.documentMouseup);
  132. },
  133. beforeDestroy() {
  134. document.removeEventListener('click', this.handleEventConnection);
  135. document.removeEventListener('mousemove', this.documentMousemouse);
  136. document.removeEventListener('mouseup', this.documentMouseup);
  137. },
  138. methods: {
  139. /* 用 mouse 事件模拟拖拽 开始*/
  140. documentMousemouse(e) {
  141. if (!this.drag) return;
  142. // 使用 svg 绘制跟随鼠标移动的连接线
  143. let svg = document.querySelector('.move-connection');
  144. let list = this.$refs.list.getBoundingClientRect(); // 列表的位置
  145. let { clientX, clientY } = e;
  146. let isLeft = clientX < this.mouseEvent.clientX; // 鼠标是否向左移动
  147. // 计算 svg 的宽度,宽度不能超过列表的宽度
  148. let width = Math.min(list.width, isLeft ? list.width - clientX + list.left - 1 : clientX - list.left - 1);
  149. if (svg) {
  150. svg.setAttribute(
  151. 'style',
  152. `position: absolute; ${isLeft ? 'right: 0;' : 'left: 0;'} width: ${width}px; height: 100%;`,
  153. );
  154. } else {
  155. svg = document.createElementNS(svgNS, 'svg');
  156. svg.classList.add('move-connection');
  157. svg.setAttribute('style', `position: absolute; width: ${width}px; height: 100%;`);
  158. let path = document.createElementNS(svgNS, 'path');
  159. this.setPathAttr(path);
  160. svg.appendChild(path);
  161. this.$refs.list.appendChild(svg);
  162. }
  163. let top = this.mouseEvent.clientY - list.top;
  164. let left = isLeft
  165. ? this.mouseEvent.clientX - list.left - Math.abs(width - list.width)
  166. : this.mouseEvent.clientX - list.left;
  167. let mouseX = isLeft ? clientX - list.left - Math.abs(width - list.width) : clientX - list.left;
  168. let mouseY = clientY - list.top;
  169. let path = svg.querySelector('path');
  170. path.setAttribute('d', `M ${left} ${top} L ${mouseX} ${mouseY}`);
  171. },
  172. documentMouseup() {
  173. if (!this.drag) return;
  174. this.drag = false;
  175. document.querySelector('.move-connection')?.remove();
  176. document.body.style.userSelect = 'auto'; // 允许选中文本
  177. this.mousePointer = { i: -1, j: -1, mark: '' };
  178. this.mouseEvent = { clientX: 0, clientY: 0 };
  179. },
  180. /**
  181. * 鼠标按下事件,设置当前连线点
  182. * @param {PointerEvent} e 事件对象
  183. * @param {number} i 选项列表索引
  184. * @param {number} j 选项索引
  185. * @param {string} mark 选项标识
  186. */
  187. mousedown(e, i, j, mark) {
  188. if (this.disabled) return;
  189. this.drag = true;
  190. document.body.style.userSelect = 'none'; // 禁止选中文本
  191. this.mouseEvent = { clientX: e.clientX, clientY: e.clientY };
  192. this.mousePointer = { i, j, mark };
  193. },
  194. /**
  195. * 鼠标抬起事件,如果是一个合适的连接点,则创建连接线
  196. * @param {PointerEvent} e 事件对象
  197. * @param {Number} i 选项列表索引
  198. * @param {Number} j 选项索引
  199. * @param {String} mark 选项标识
  200. */
  201. mouseup(e, i, j, mark) {
  202. if (this.disabled || !this.drag) return;
  203. let { i: curI, j: curJ, mark: curMark } = this.mousePointer;
  204. if (curI === -1 && curJ === -1) return;
  205. if (Math.abs(curJ - j) > 1 || mark === curMark) return;
  206. this.changeConnectionList(mark, j, true);
  207. this.createLine(mark, true);
  208. },
  209. /* 用 mouse 事件模拟拖拽 结束 */
  210. // 重置当前连线点
  211. resetCurConnectionPoint() {
  212. this.curConnectionPoint = { i: -1, j: -1, mark: '' };
  213. },
  214. /**
  215. * 当点击的不是连线点时,清除所有连线点的选中状态
  216. * @param {PointerEvent} e
  217. */
  218. handleEventConnection(e) {
  219. let currentNode = e.target;
  220. while (currentNode !== null) {
  221. if (currentNode.classList && currentNode.classList.contains('item-wrapper')) {
  222. break;
  223. }
  224. currentNode = currentNode.parentNode;
  225. }
  226. if (currentNode) return;
  227. Array.from(document.getElementsByClassName('item-wrapper')).forEach((item) => {
  228. item.classList.remove('focus');
  229. });
  230. this.resetCurConnectionPoint();
  231. },
  232. /**
  233. * 处理点击连线
  234. * @param {PointerEvent} e 事件对象
  235. * @param {Number} i 选项列表索引
  236. * @param {Number} j 选项索引
  237. * @param {String} mark 选项标识
  238. */
  239. handleClickConnection(e, i, j, mark) {
  240. if (this.disabled) return;
  241. let { i: curI, j: curJ, mark: curMark } = this.curConnectionPoint;
  242. // 获取 item-wrapper 元素
  243. let currentNode = e.target;
  244. while (currentNode !== null) {
  245. if (currentNode.classList && currentNode.classList.contains('item-wrapper')) {
  246. break;
  247. }
  248. currentNode = currentNode.parentNode;
  249. }
  250. // 如果当前连线点不存在或就是当前连线点,则设置当前连线点
  251. if ((curI === -1 && curJ === -1) || mark === curMark) {
  252. this.curConnectionPoint = { i, j, mark };
  253. currentNode.classList.add('focus');
  254. return;
  255. }
  256. // 如果当前连线点存在,清除所有连线点的选中状态
  257. Array.from(this.$refs.list.getElementsByClassName('item-wrapper')).forEach((item) => {
  258. item.classList.remove('focus');
  259. });
  260. // 如果当前连线点与上一个连线点不在相邻的位置,则设置点击的连接点为当前连线点
  261. if (Math.abs(curJ - j) > 1 || mark === curMark || (curJ === j && curI !== i)) {
  262. this.curConnectionPoint = { i, j, mark };
  263. currentNode.classList.add('focus');
  264. return;
  265. }
  266. this.changeConnectionList(mark, j);
  267. // 如果当前连线点与上一个连线点在相邻的位置,则创建连接线
  268. this.createLine(mark);
  269. },
  270. /**
  271. * @description 循环答案列表
  272. */
  273. circulateAnswerList() {
  274. this.data.answer.answer_list.forEach((item, index) => {
  275. let preMark = ''; // 上一个连线点标识
  276. item.forEach(({ mark }, j) => {
  277. if (j === 0) {
  278. preMark = mark;
  279. return;
  280. }
  281. if (mark.length <= 0) return;
  282. if (j === 2) {
  283. preMark = this.data.option_list[index][j - 1].mark;
  284. }
  285. let cur = { i: -1, j: -1, mark: '' }; // 当前连线点
  286. // 根据 preMark 查找当前连线点的位置
  287. this.data.option_list.find((list, i) => {
  288. return list.find((li, idx) => {
  289. if (li.mark === preMark) {
  290. cur = { i, j: idx };
  291. return true;
  292. }
  293. });
  294. });
  295. // 循环 mark 数组,创建连接线
  296. mark.forEach((m) => {
  297. this.curConnectionPoint = { i: cur.i, j: cur.j, mark: preMark };
  298. this.createLine(m, false, true);
  299. });
  300. });
  301. });
  302. },
  303. /**
  304. * 创建连接线
  305. * @param {String} mark 选项标识
  306. * @param {Boolean} isDrag 是否是拖拽
  307. * @param {Boolean} isShowRightAnswer 是否是显示正确答案
  308. */
  309. createLine(mark, isDrag = false, isShowRightAnswer = false) {
  310. const { offsetWidth, offsetLeft, offsetTop, offsetHeight } = document.getElementsByClassName(
  311. `${isShowRightAnswer ? 'answer-' : ''}item-${mark}`,
  312. )[0];
  313. const { curOffsetWidth, curOffsetLeft, curOffsetTop, curOffsetHeight, curMark } = this.computedCurConnectionPoint(
  314. isDrag,
  315. isShowRightAnswer,
  316. );
  317. let top = Math.min(offsetTop + offsetHeight / 2, curOffsetTop + curOffsetHeight / 2);
  318. // 判断是否是同一行
  319. const isSameRow = Math.abs(offsetTop + offsetHeight / 2 - (curOffsetTop + curOffsetHeight / 2)) <= 2;
  320. let left = Math.min(offsetLeft + offsetWidth, curOffsetLeft + curOffsetWidth);
  321. let width = Math.abs(
  322. offsetLeft > curOffsetLeft
  323. ? curOffsetLeft - offsetLeft + offsetWidth
  324. : offsetLeft - curOffsetLeft + curOffsetWidth,
  325. );
  326. let height = 0;
  327. if (!isSameRow) {
  328. height =
  329. curOffsetTop > offsetTop
  330. ? Math.abs(offsetTop + offsetHeight / 2 - (curOffsetTop + curOffsetHeight / 2))
  331. : Math.abs(offsetTop - curOffsetTop + offsetHeight / 2 - curOffsetHeight / 2);
  332. }
  333. let size = offsetLeft > curOffsetLeft ? offsetTop > curOffsetTop : offsetTop < curOffsetTop; // 判断是左上还是右下
  334. // 创建一个空的SVG元素
  335. let svg = document.createElementNS(svgNS, 'svg');
  336. svg.setAttribute(
  337. 'style',
  338. `position:absolute; width: 122px; height: ${Math.max(8, height)}px; top: ${top}px; left: ${left}px;overflow: visible;`,
  339. );
  340. svg.classList.add('connection-line', `svg-${mark}-${curMark}`); // 添加类名
  341. // 向SVG元素添加 path 元素
  342. let path = document.createElementNS(svgNS, 'path');
  343. path.setAttribute('d', `M ${size ? 0 : width} 0 L ${size ? width : 0} ${height}`); // 设置路径数据
  344. this.setPathAttr(path);
  345. svg.appendChild(path);
  346. // 在 svg 元素中的 path 元素上两端添加圆形标记
  347. let circleStart = document.createElementNS(svgNS, 'circle');
  348. circleStart.setAttribute('cx', size ? '0' : width); // 设置圆心的 x 坐标
  349. circleStart.setAttribute('cy', '0'); // 设置圆心的 y 坐标
  350. circleStart.setAttribute('r', '4'); // 设置半径
  351. const assistColor = this.data?.unified_attrib?.topic_color || '#306eff';
  352. circleStart.setAttribute('fill', assistColor); // 设置填充颜色
  353. svg.appendChild(circleStart);
  354. let circleEnd = document.createElementNS(svgNS, 'circle');
  355. circleEnd.setAttribute('cx', size ? width : '0'); // 设置圆心的 x 坐标
  356. circleEnd.setAttribute('cy', height); // 设置圆心的 y 坐标
  357. circleEnd.setAttribute('r', '4'); // 设置半径
  358. circleEnd.setAttribute('fill', assistColor); // 设置填充颜色
  359. svg.appendChild(circleEnd);
  360. this.$refs[isShowRightAnswer ? 'answerList' : 'list'].appendChild(svg); // 将SVG元素插入到文档中
  361. // 清除当前连线点
  362. this.resetCurConnectionPoint();
  363. },
  364. // 设置 path 公用属性
  365. setPathAttr(path) {
  366. path.setAttribute('stroke-width', '2'); // 设置线条宽度
  367. path.setAttribute('stroke-linecap', 'round'); // 设置线段的两端样式
  368. const assistColor = this.data?.unified_attrib?.topic_color || '#306eff';
  369. path.setAttribute('stroke', assistColor); // 设置填充颜色
  370. },
  371. /**
  372. * 计算当前连线点的位置
  373. * @param {Boolean} isDrag 是否是拖拽
  374. * @param {Boolean} isShowRightAnswer 是否是显示正确答案
  375. */
  376. computedCurConnectionPoint(isDrag = false, isShowRightAnswer = false) {
  377. let { mark } = isDrag ? this.mousePointer : this.curConnectionPoint;
  378. let type = Object.prototype.toString.call(mark);
  379. if (type === '[object String]') {
  380. type = 'string';
  381. } else if (type === '[object Object]') {
  382. type = 'object';
  383. }
  384. if (type === 'object') {
  385. mark = mark.mark;
  386. }
  387. const dom = document.getElementsByClassName(`${isShowRightAnswer ? 'answer-' : ''}item-${mark}`)[0];
  388. return {
  389. curOffsetWidth: dom.offsetWidth,
  390. curOffsetLeft: dom.offsetLeft,
  391. curOffsetTop: dom.offsetTop,
  392. curOffsetHeight: dom.offsetHeight,
  393. curMark: mark,
  394. };
  395. },
  396. // 清除所有连接线
  397. clearLine() {
  398. document.querySelectorAll('svg.connection-line').forEach((item) => {
  399. item.remove();
  400. });
  401. },
  402. /**
  403. * 修改连接列表
  404. * @param {String} mark 选项标识
  405. * @param {Number} j 当前选项索引
  406. * @param {Boolean} isDrag 是否是拖拽
  407. */
  408. changeConnectionList(mark, j, isDrag = false) {
  409. const { mark: curMark, j: curJ } = isDrag ? this.mousePointer : this.curConnectionPoint;
  410. this.changeAnswerList(curMark, mark, curJ < j);
  411. this.changeAnswerList(mark, curMark, curJ > j);
  412. },
  413. /**
  414. * 改变答案列表
  415. * @param {String} curMark 当前选项标识
  416. * @param {String} mark 选项标识
  417. */
  418. changeAnswerList(curMark, mark, isPre) {
  419. this.answerList.find((item) =>
  420. item.find((li) => {
  421. if (li.mark === curMark) {
  422. if (isPre && !li.preMark.includes(mark)) {
  423. li.nextMark.push(mark);
  424. } else if (!isPre && !li.nextMark.includes(mark)) {
  425. li.preMark.push(mark);
  426. }
  427. return true;
  428. }
  429. }),
  430. );
  431. },
  432. /**
  433. * 根据 mark 查找 nextMark 或 preMark
  434. * @param {Array} list 答案列表
  435. * @param {String} mark 标记
  436. * @param {'pre'|'next'} type 类型
  437. * @returns {String} 返回 nextMark 或 preMark
  438. */
  439. findMark(list, mark, type) {
  440. let fMark = '';
  441. list.find((item) => {
  442. return item.find((li) => {
  443. if (mark === li.mark) {
  444. fMark = type === 'pre' ? li.preMark : li.nextMark;
  445. return true;
  446. }
  447. });
  448. });
  449. return fMark;
  450. },
  451. /**
  452. * 计算答题对错选项class
  453. * @param {string} mark 选项标识
  454. * @param {number} i 选项列表索引
  455. * @param {number} j 选项索引
  456. * @returns {string} 返回 class 名称
  457. */
  458. computedAnswerClass(mark, i, j) {
  459. if (!this.isJudgingRightWrong) return '';
  460. if (j === 0) {
  461. return this.judgeFirstAnswerRightWrong(i);
  462. }
  463. let answer = this.data.answer.answer_list.find((item) => {
  464. return item.some((li) => Array.isArray(li.mark) && li.mark.includes(mark));
  465. }); // 正确答案列
  466. let userAnswer = this.answer.answer_list.find((item) => {
  467. return item.some((li) => Array.isArray(li) && li.includes(mark));
  468. }); // 选项对应的用户答案列
  469. if (answer === undefined || userAnswer === undefined) return 'wrong';
  470. if (answer.length === 0 && userAnswer.length === 0) return '';
  471. if (answer.length === 0 || userAnswer.length === 0) return 'wrong';
  472. let isRight = true;
  473. if (j === 1) {
  474. // 判断第二行答案对错,answer[0].mark 和 userAnswer[0] 是否相等
  475. isRight = answer[0].mark === userAnswer[0];
  476. } else if (j === 2) {
  477. // 判断第三行答案对错,answer[1].mark 和 userAnswer[1] 是否相交
  478. isRight = arraysIntersect(answer[1].mark, userAnswer[1]);
  479. }
  480. return isRight ? 'right' : 'wrong';
  481. },
  482. /**
  483. * 判断第一列答案对错,是否有个一个选项连接正确
  484. * @param {number} i 选项列表索引
  485. */
  486. judgeFirstAnswerRightWrong(i) {
  487. let answer = this.data.answer.answer_list[i]; // 正确答案列
  488. let userAnswer = this.answer.answer_list[i]; // 选项对应的用户答案列
  489. if (answer === undefined || userAnswer === undefined) return 'wrong';
  490. if (answer.length === 0 && userAnswer.length === 0) return '';
  491. if (answer.length === 0 || userAnswer.length === 0) return 'wrong';
  492. let isRight = true;
  493. // 判断 answer[1].mark 和 userAnswer[1] 是否相交
  494. const answerSet = new Set(answer[1].mark);
  495. isRight = userAnswer[1].some((x) => answerSet.has(x));
  496. return isRight ? 'right' : 'wrong';
  497. },
  498. retry() {
  499. this.isJudgingRightWrong = false;
  500. this.isShowRightAnswer = false;
  501. this.clearLine();
  502. this.$set(
  503. this,
  504. 'answerList',
  505. this.answerList.map((item) => item.map(({ mark }) => ({ mark, preMark: [], nextMark: [] }))),
  506. );
  507. this.$set(this, 'answer', { answer_list: [], is_right: false });
  508. },
  509. /**
  510. * 获取无文本内容的数据结构,用于保存为个人模板时的样式模板
  511. */
  512. getNoTextContentData() {
  513. let noTextContentData = JSON.parse(JSON.stringify(this.data));
  514. const resetFieldMap = {
  515. analysis_list: [],
  516. answer_list: [],
  517. };
  518. Object.assign(noTextContentData, resetFieldMap);
  519. noTextContentData.option_list.forEach((list) => {
  520. list.forEach((item) => {
  521. item.content = '';
  522. item.multilingual = [];
  523. item.paragraph_list = [];
  524. item.paragraph_list_parameter = {
  525. text: '',
  526. pinyin_proofread_word_list: [],
  527. };
  528. });
  529. });
  530. if (noTextContentData.answer) {
  531. noTextContentData.answer.answer_list = [];
  532. noTextContentData.answer.reference_answer = '';
  533. }
  534. return noTextContentData;
  535. },
  536. },
  537. };
  538. </script>
  539. <style lang="scss" scoped>
  540. @use '@/styles/mixin.scss' as *;
  541. .matching-preview {
  542. @include preview-base;
  543. overflow: auto;
  544. .option-list {
  545. position: relative;
  546. display: flex;
  547. flex-direction: column;
  548. row-gap: 16px;
  549. .list-item {
  550. display: flex;
  551. column-gap: 120px;
  552. align-items: stretch;
  553. padding: 1px;
  554. .item-wrapper {
  555. position: relative;
  556. display: flex;
  557. flex-wrap: wrap;
  558. column-gap: 24px;
  559. align-items: center;
  560. width: calc(50% - 36px);
  561. min-height: 48px;
  562. padding: 12px 24px;
  563. background-color: $content-color;
  564. border-radius: 4px;
  565. &.focus {
  566. background-color: #dcdbdd;
  567. }
  568. &.right {
  569. background-color: $right-bc-color;
  570. }
  571. &.wrong {
  572. box-shadow: 0 0 0 1px $error-color;
  573. }
  574. .content {
  575. flex: 1;
  576. }
  577. .lang {
  578. width: 100%;
  579. }
  580. }
  581. }
  582. }
  583. .right-answer {
  584. .title {
  585. margin: 24px 0;
  586. }
  587. }
  588. }
  589. </style>