matching.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { optionTypeList, stemTypeList, scoreTypeList, questionNumberTypeList, switchOption } from './common';
  2. import { getRandomNumber } from '@/utils/index';
  3. // 连线类型列表
  4. export const columnNumberList = [
  5. { value: 2, label: '2列' },
  6. { value: 3, label: '3列' },
  7. ];
  8. export function getOption(content = '') {
  9. return { content, mark: getRandomNumber() };
  10. }
  11. /**
  12. * 获取连线题数据模板
  13. * 因为 option_list 和 answer.column_list 中的数据是一一对应的,所以需要函数生成来保持一致
  14. */
  15. export function getMatchingDataTemplate() {
  16. let option_list = Array.from({ length: 3 }, () =>
  17. Array.from({ length: columnNumberList[0].value }, () => getOption()),
  18. );
  19. let column_list = option_list.map((item) => item.map(({ mark }) => mark));
  20. return {
  21. type: 'matching', // 题型
  22. stem: '', // 题干
  23. option_number_show_mode: optionTypeList[0].value, // 选项类型
  24. description: '', // 描述
  25. option_list, // 选项
  26. answer: { column_list, score: 0, score_type: scoreTypeList[0].value }, // 答案
  27. // 题型属性
  28. property: {
  29. stem_type: stemTypeList[0].value, // 题干类型
  30. question_number: '1', // 题号
  31. column_number: columnNumberList[0].value, // 列数
  32. is_enable_description: switchOption[1].value, // 描述
  33. score: 1, // 分值
  34. score_type: scoreTypeList[0].value, // 分值类型
  35. },
  36. // 其他属性
  37. other: {
  38. question_number_type: questionNumberTypeList[0].value, // 题号类型
  39. },
  40. };
  41. }