select.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import {
  2. optionTypeList,
  3. stemTypeList,
  4. selectTypeList,
  5. scoreTypeList,
  6. questionNumberTypeList,
  7. switchOption,
  8. fontSizeList,
  9. } from './common';
  10. import { getRandomNumber } from '@/utils/index';
  11. export function getOption(content = '') {
  12. return { content, mark: getRandomNumber() };
  13. }
  14. /**
  15. * 获取选项细分数据项
  16. * @param {number} number 选项数
  17. */
  18. export function getSubdivisionOption(number = 2) {
  19. return {
  20. mark: getRandomNumber(),
  21. data_list: Array.from({ length: number }, () => getOption()),
  22. };
  23. }
  24. /**
  25. * 获取选择题数据模板(防止 mark 重复)
  26. */
  27. export function getSelectData() {
  28. return {
  29. type: 'select', // 题型
  30. stem: '', // 题干
  31. option_number_show_mode: optionTypeList[0].value, // 选项类型
  32. description: '', // 描述
  33. option_list: [
  34. { content: '', mark: getRandomNumber() },
  35. { content: '', mark: getRandomNumber() },
  36. { content: '', mark: getRandomNumber() },
  37. ], // 选项
  38. file_id_list: [], // 文件 id 列表
  39. answer: { answer_list: [], score: 1, score_type: scoreTypeList[0].value }, // 答案
  40. // 题型属性
  41. property: {
  42. stem_type: stemTypeList[1].value, // 题干类型
  43. question_number: '1', // 题号
  44. stem_question_number_font_size: fontSizeList[6], // 题干题号
  45. option_question_number_font_size: fontSizeList[5], // 选项题号
  46. is_enable_description: switchOption[1].value, // 描述
  47. select_type: selectTypeList[0].value, // 选择类型
  48. is_option_subdivision: switchOption[1].value, // 选项细分
  49. option_number: 2, // 选项数
  50. score: 1, // 分值
  51. score_type: scoreTypeList[0].value, // 分值类型
  52. },
  53. // 其他属性
  54. other: {
  55. question_number_type: questionNumberTypeList[1].value, // 题号类型
  56. },
  57. };
  58. }