修复练习答题,开发课程记录页,创建学习记录页

This commit is contained in:
田岩
2025-08-26 15:20:39 +08:00
parent 346f318515
commit 0d3c87d0eb
16 changed files with 721 additions and 219 deletions
+98 -60
View File
@@ -61,11 +61,13 @@
<view class="fixed-box font_pf" :style="{ marginBottom: popup_input_bottom }">
<view class="touch-btn-div" :class="{ show: showTouchBtn }">
<TouchBtn
ref="touchBtnRef"
class="talk-btns"
@submit="touchBtnSubmit"
loadingText="问题回答中,请在问题回答结束后重试!"
disabledText="只能进行一条回答"
:isLoading="!answerIsOver"
:isDisabled="topicList[questionNumber]?.isPreview"
:isDisabled="touchIsDisabled"
/>
</view>
</view>
@@ -92,7 +94,7 @@
const answerIsOver = ref(true);
const feedbackRef = ref(null);
const dialogRef = ref(null);
const popupRef = ref(null);
const touchBtnRef = ref(null);
const mode = ref('practice'); // 考试 examination 练习practice
const paperData = reactive({
@@ -105,11 +107,22 @@
const popup_input_bottom = ref('0px');
const questionNumber = ref(0); // 题号
const systemInfo = uni.getSystemInfoSync();
const topic = computed({
get: () => topicList[questionNumber.value],
set: (val) => topicList[questionNumber.value] = val
});
const showTouchBtn = computed(() => {
return topicList[questionNumber.value]['qnsTyp'] === 'ES';
return topic.value?.qnsTyp === 'ES';
});
const progress = computed(() => {
// 下面语音组件的禁用状态判断
const touchIsDisabled = computed(() => {
return topic.value?.es_status !== '' && topic.value?.es_status !== undefined
})
const progress = computed(() => {
// 计算进度百分比(保留两位小数)
const total = storageTopicList.value.length;
if (total === 0) return 0;
@@ -141,33 +154,39 @@
if (['JD', 'SN'].includes(params.qnsTyp)) {
submitProblem({ anserResult: params.answer.join(',') });
}
} else if (type === 'complete') {
// 问答题点击完成
} else if (type === 'again') {
// 问答题点击重答
// const topic = topicList[questionNumber.value];
topic.value.isPreview = false;
topic.value.es_status = ''; // 取消转圈
}
};
// 单题回答(没有问答题)
const submitProblem = (answer) => {
const topic = topicList[questionNumber.value];
console.log('答题内容', answer);
console.log('答单题', topic);
common.loading('答题中');
practiceAnswer({
exrId: paperData.exrId,
ossKey: '',
qnsId: topic.qnsId,
qnsId: topic.value.qnsId,
...answer
})
.then((res) => {
common.hideLoading();
const body = res.body;
console.log('body', body);
topic.isPreview = true; // 不能在点击了,打开预览模式
topic.clearResult = false; // 不清除正确答案了
topic.value.isPreview = true; // 不能在点击了,打开预览模式
topic.value.clearResult = false; // 不清除正确答案了
const traQnsInfoVo = body.traQnsInfoVo;
topic.analyContent = traQnsInfoVo.analyContent; // 答案解析
topic.value.analyContent = traQnsInfoVo.analyContent; // 答案解析
console.log('答题结果', traQnsInfoVo);
// 更新选项正确项目
topic.itemVos = traQnsInfoVo.itemVos; // 答案选项(todo应该不这样替换)
topic.anserResult = traQnsInfoVo.anserResult; // 正确答案字符串分割
topic.value.itemVos = traQnsInfoVo.itemVos; // 答案选项(todo应该不这样替换)
topic.value.anserResult = traQnsInfoVo.anserResult; // 正确答案字符串分割
const judgeResultStatus = traQnsInfoVo.judgeResult === 'P'; // P为正确U为错误
if (!addProblem()) {
// 返回false说明到了最后一题
@@ -179,13 +198,16 @@
// ['JD', 'SN', 'MU'].includes(topic.qnsTyp) && // 条件2.单选多选判断(这里改成了单选多选判断专属,所有不用判断这一条了)
topicList.length < storageTopicList.value.length // 条件3.不是最后一题(暂定这样判断)
) {
questionNumber.value++;
} else {
console.log('为什么没自动跳转', judgeResultStatus);
console.log('22', topicList.length < storageTopicList.value.length, topicList.length , storageTopicList.value.length);
console.log(
'22',
topicList.length < storageTopicList.value.length,
topicList.length,
storageTopicList.value.length
);
}
})
.catch(() => {
common.hideLoading();
@@ -197,10 +219,10 @@
if (maxRetries <= 0) {
return Promise.reject(new Error('超过最大重试次数,查询失败'));
}
return queryCrsPracticeAnswerResult({ execLogId }).then((resl) => {
const isWait = resl.body.isWait;
if (isWait === 'Y') {
if (isWait === 'N') {
// 如果是Y,延迟2秒后重试,重试次数减1
return new Promise((resolve) => {
setTimeout(() => {
@@ -217,7 +239,9 @@
// 单题回答(问答题专属)
const submitProblemEssayQuestion = (answer) => {
const topic = topicList[questionNumber.value];
const old_text = touchBtnRef.value?.clearinputText(); // 清除发送框数据
console.log('答题内容', answer);
console.log('答单题问答题专属', topic);
practiceAnswer({
exrId: paperData.exrId,
@@ -227,6 +251,8 @@
})
.then((res) => {
topic.isPreview = true; // 不能在点击了,打开预览模式
// touchBtnRef.value.clearinputText()
// topic.clearResult = false; // 不清除正确答案了
// 使用方式
queryWithRetry(res.body.execLogId)
@@ -234,31 +260,31 @@
console.log('查询成功', result);
const body = result.body;
const traQnsInfoVo = body.traQnsInfoVo;
topic.analyContent = traQnsInfoVo.analyContent; // 答案解析
topic.anserResult = traQnsInfoVo.anserResult // 正确答案文字内容
const judgeResultStatus = traQnsInfoVo.judgeResult === 'P'; // P为正确U为错误
topic.analyContent = traQnsInfoVo?.analyContent || ''; // 答案解析
topic.anserResult = traQnsInfoVo?.anserResult || answer.anserResult; // 正确答案文字内容
const judgeResultStatus = traQnsInfoVo?.judgeResult === 'P'; // P为正确U为错误
// 判断是语音回答还是文字回答, 通过是否存在语音地址判断 // todo 后续可能改成ossid判断
if (answer.voicePath) {
topic.es_status = '02'
} else { // 纯文字
topic.es_status = '01'
topic.es_status = '02';
} else {
// 纯文字
topic.es_status = '01';
}
// 处理成功结果
})
.catch((error) => {
console.log('查询失败', error);
topic.isPreview = false
topic.es_status = ''
topic.isPreview = false;
topic.es_status = ''; // 取消转圈
touchBtnRef.value?.clearinputText(old_text); // 清除发送框数据
// 处理失败情况
});
// const traQnsInfoVo = body.traQnsInfoVo;
// topic.analyContent = traQnsInfoVo.analyContent; // 答案解析
// console.log('答题结果', traQnsInfoVo);
// const judgeResultStatus = traQnsInfoVo.judgeResult === 'P'; // P为正确U为错误
// if (!addProblem()) {
@@ -268,44 +294,55 @@
})
.catch(() => {
topic.es_status = ''; // 取消转圈
});
};
// 录音按钮提交
// 录音组件提交
const touchBtnSubmit = (type, submitObj) => {
const topic = topicList[questionNumber.value];
topic.es_status = '00'; // 00转圈
const old_text = touchBtnRef.value?.clearinputText(); // 清除发送框数据
if (type === 'voice') {
uploadRecordNow(submitObj);
topic.value.es_status = '00'; // 00转圈
const voicePath = submitObj;
commonUploadVoiceFile(voicePath, '/traask/traAskchat/voiceTrans', {})
.then((res) => {
let _res = JSON.parse(res.data);
console.log('res小行星', _res);
if (_res.rtnCode === '0000') {
topic.value.es_status = '02'
topic.value.my_answer = {
anserResult: _res.body.transContent,
ossKey: _res.body.fileId,
ossAddr: _res.body.ossFileAddr,
voicePath: voicePath
}
// {
// "chatId":"CHAT025018122068202508232000590000000000000000000000000000000060",
// "fileId":"S3F0250181220722025082320005900000676612",
// "ossFileAddr":"http://25.18.122.66::9786/traoss/show//S3F0250181220722025082320005900000676612",
// "transContent":"一二三四。"
// }
// submitProblemEssayQuestion({
// anserResult: _res.body.transContent,
// ossKey: _res.body.fileId,
// ossAddr: _res.body.ossFileAddr,
// voicePath: voicePath
// });
}
})
.catch((err) => {
topic.value.es_status = ''; // 取消转圈
// 失败了再把发送框数据还原回去
touchBtnRef.value?.clearinputText(old_text); // 清除发送框数据
common.msg('系统异常,请联系管理员');
});
} else if (type === 'text') {
submitProblemEssayQuestion({ anserResult: submitObj });
topic.value.es_status = '01';
topic.value.anserResult = submitObj; // 正确答案文字内容
// submitProblemEssayQuestion({ anserResult: submitObj });
}
};
// 发送语音
const uploadRecordNow = (voicePath) => {
//发送语音的时候就应该拿出转圈
commonUploadVoiceFile(voicePath, '/traask/traAskchat/voiceTrans', {})
.then((res) => {
let _res = JSON.parse(res.data);
if (_res.rtnCode === '0000') {
// {
// "chatId":"CHAT025018122068202508232000590000000000000000000000000000000060",
// "fileId":"S3F0250181220722025082320005900000676612",
// "ossFileAddr":"http://25.18.122.66::9786/traoss/show//S3F0250181220722025082320005900000676612",
// "transContent":"一二三四。"
// }
submitProblemEssayQuestion({
anserResult: _res.body.transContent,
ossKey: _res.body.fileId,
ossAddr: _res.body.ossFileAddr,
voicePath: voicePath
});
}
})
.catch((err) => {
topic.es_status = ''; // 取消转圈
common.msg('系统异常,请联系管理员');
});
};
// 发送文本
const submitAnswerNow = (val, cb = null) => {};
@@ -314,6 +351,7 @@
const addProblem = () => {
if (topicList.length >= storageTopicList.value.length) return false;
topicList.push(storageTopicList.value[topicList.length]);
console.log('topicList', topicList);
return true;
};
// 初始化时检查
@@ -330,7 +368,7 @@
...res,
isPreview: false,
clearResult: true,
es_status: '', // 预设一下问答题的结果'' 空为没有 00 转圈 01 播放,其他暂定
es_status: '', // 预设一下问答题的状态'' 空为没有 00 转圈 01 播放,其他暂定
my_answer: []
}));
addProblem();