replaceAnswer.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import { stemTypeList, scoreTypeList, questionNumberTypeList, switchOption, fontSizeList } from './common';
  2. import { getRandomNumber } from '@/utils/index';
  3. export function getOption(content = '') {
  4. return [
  5. { content, mark: getRandomNumber() },
  6. { content, mark: getRandomNumber() },
  7. { content, mark: getRandomNumber() },
  8. { content, mark: getRandomNumber() },
  9. ];
  10. }
  11. /**
  12. * 解析智能识别数据
  13. * @param {array} arr 智能识别数据
  14. * @returns object
  15. */
  16. export function analysisRecognitionReplaceAnswerData(arr) {
  17. let option_list = [];
  18. let column_count = 0;
  19. arr.forEach((item) => {
  20. let item_arr = item.split(' ');
  21. if (item_arr.length > column_count) {
  22. column_count = item_arr.length;
  23. }
  24. });
  25. for (let i = 0; i < arr.length; i++) {
  26. let table_item = [];
  27. let item_arr = arr[i].split(' ');
  28. for (let j = 0; j < column_count; j++) {
  29. table_item.push({ content: item_arr[j] ? item_arr[j] : '', mark: getRandomNumber() });
  30. }
  31. option_list.push(table_item);
  32. }
  33. return {
  34. 'data.option_list': option_list,
  35. 'data.property.row_count': arr.length,
  36. 'data.property.column_count': column_count,
  37. };
  38. }
  39. // 替换练习数据模板
  40. export const replaceAnswerData = {
  41. type: 'replace_answer', // 题型
  42. stem: '', // 题干
  43. description: '', // 描述
  44. analysis: '', // 解析,富文本
  45. option_list: [getOption(), getOption(), getOption(), getOption()], // 选项
  46. file_id_list: [], // 文件 id 列表
  47. answer: { score: 1, score_type: scoreTypeList[0].value }, // 答案
  48. reference_answer: '', // 参考答案
  49. // 题型属性
  50. property: {
  51. stem_type: stemTypeList[1].value, // 题干类型
  52. question_number: '1', // 题号
  53. stem_question_number_font_size: fontSizeList[6], // 题干题号
  54. is_enable_description: switchOption[1].value, // 描述
  55. is_enable_reference_answer: switchOption[0].value, // 是否开启参考答案
  56. is_enable_analysis: switchOption[1].value, // 是否开启解析
  57. score: 1, // 分值
  58. score_type: scoreTypeList[0].value, // 分值类型
  59. row_count: 4,
  60. column_count: 4,
  61. },
  62. // 其他属性
  63. other: {
  64. question_number_type: questionNumberTypeList[1].value, // 题号类型
  65. },
  66. };