wordDictation.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import {
  2. stemTypeList,
  3. scoreTypeList,
  4. questionNumberTypeList,
  5. optionTypeList,
  6. switchOption,
  7. fontSizeList,
  8. } from './common';
  9. import { getRandomNumber } from '@/utils/index';
  10. import { handleSplitPy } from './chinese';
  11. export function getOption(content = '') {
  12. return {
  13. content,
  14. mark: getRandomNumber(),
  15. audio_file_id: '',
  16. pinyin: '',
  17. pinyin_item_list: [],
  18. hz_strokes_list: [],
  19. };
  20. }
  21. // 音频生成方式类型
  22. export const audioGenerationMethodList = [
  23. {
  24. value: 'upload',
  25. label: '上传',
  26. },
  27. {
  28. value: 'auto',
  29. label: '自动生成',
  30. },
  31. {
  32. value: 'record',
  33. label: '录音',
  34. },
  35. ];
  36. /**
  37. * 解析智能识别数据
  38. * @param {array} arr 智能识别数据
  39. * @returns object
  40. */
  41. export function analysisRecognitionWordDictationData(arr) {
  42. let option_list = [];
  43. arr.map((content, index) => {
  44. let content_item = content.split('/');
  45. option_list.push({
  46. content: content_item[0] ? content_item[0] : '',
  47. mark: getRandomNumber(),
  48. audio_file_id: '',
  49. pinyin: content_item[1] ? content_item[1] : '',
  50. pinyin_item_list: [],
  51. hz_strokes_list: [],
  52. });
  53. handleSplitPy(option_list[index]);
  54. });
  55. return {
  56. 'data.option_list': option_list,
  57. };
  58. }
  59. // 听写题数据模板
  60. export const wordDictationData = {
  61. type: 'word_dictation', // 题型
  62. stem: '', // 题干
  63. description: '', // 描述
  64. option_number_show_mode: optionTypeList[1].value, // 选项类型
  65. answer: { score: 1, score_type: scoreTypeList[0].value }, // 答案
  66. option_list: [getOption(), getOption(), getOption()], // 选项
  67. file_id_list: [],
  68. // 题型属性
  69. property: {
  70. stem_type: stemTypeList[1].value, // 题干类型
  71. question_number: '1', // 题号
  72. stem_question_number_font_size: fontSizeList[6], // 题干题号
  73. is_enable_description: switchOption[1].value, // 描述
  74. score: 1, // 分值
  75. score_type: scoreTypeList[0].value, // 分值类型
  76. },
  77. // 其他属性
  78. other: {
  79. question_number_type: questionNumberTypeList[1].value, // 题号类型
  80. audio_generation_method: audioGenerationMethodList[0].value, // 音频生成方式
  81. },
  82. };