|
@@ -35,9 +35,63 @@ export function getSubdivisionOption(number = 2, index) {
|
|
|
* @returns object
|
|
|
*/
|
|
|
export function analysisRecognitionSelectData(arr) {
|
|
|
- return {
|
|
|
- 'data.option_list': arr.map(getOption),
|
|
|
- };
|
|
|
+ let data = {};
|
|
|
+ if (/^小题干[::]/.test(arr[0])) {
|
|
|
+ const outputArray = [];
|
|
|
+ let currentStem = null;
|
|
|
+ let currentOptions = [];
|
|
|
+
|
|
|
+ // 遍历输入数组
|
|
|
+ arr.forEach((item) => {
|
|
|
+ // 去除前后空格
|
|
|
+ const trimmedItem = item.trim();
|
|
|
+
|
|
|
+ // 检查是否为题干
|
|
|
+ if (trimmedItem.startsWith('小题干:')) {
|
|
|
+ // 如果当前题干不为空,保存之前的题干和选项
|
|
|
+ if (currentStem !== null) {
|
|
|
+ outputArray.push({
|
|
|
+ stem: currentStem,
|
|
|
+ option: currentOptions,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 更新当前题干和选项
|
|
|
+ currentStem = trimmedItem.replace('小题干:', '');
|
|
|
+ currentOptions = [];
|
|
|
+ } else {
|
|
|
+ // 如果是选项,添加到当前选项数组
|
|
|
+ currentOptions.push(trimmedItem);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 添加最后一组题干和选项
|
|
|
+ if (currentStem !== null) {
|
|
|
+ outputArray.push({
|
|
|
+ stem: currentStem,
|
|
|
+ option: currentOptions,
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ let option_list = outputArray.map(({ stem, option }, i) => {
|
|
|
+ return {
|
|
|
+ stem,
|
|
|
+ custom_number: (i + 1).toString(),
|
|
|
+ mark: getRandomNumber('', false),
|
|
|
+ data_list: option.map((data) => getOption(data)),
|
|
|
+ };
|
|
|
+ });
|
|
|
+ data = {
|
|
|
+ 'data.property.option_number': outputArray[0].option.length,
|
|
|
+ 'data.option_list': option_list,
|
|
|
+ 'data.property.is_option_subdivision': 'true',
|
|
|
+ };
|
|
|
+ } else {
|
|
|
+ data = {
|
|
|
+ 'data.property.is_option_subdivision': 'false',
|
|
|
+ 'data.option_list': arr.map(getOption),
|
|
|
+ };
|
|
|
+ }
|
|
|
+ return data;
|
|
|
}
|
|
|
|
|
|
/**
|