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

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
@@ -1,8 +1,85 @@
<template>
<view class="scroll_div">
<scroll-view scroll-y="true" class="scroll-Y" @scrolltolower="scrolltolower" :show-scrollbar="false">
<itemVue :item="item" v-for="(item, index) in data_list" ></itemVue>
<list-no-data v-if="total == 0 && status == 'nomore'"></list-no-data>
<uv-load-more v-if="total != 0" :status="status" loadmore-text="轻轻上拉加载" :height="30"></uv-load-more>
</scroll-view>
</view>
</template>
<script setup>
import itemVue from './item.vue';
<script>
import { setPageCache } from '@/common/common';
import common from '@/common/common';
import { ref, reactive, onMounted, nextTick } from 'vue';
import { queryPracticeRecordPaging, queryPracticeHis, queryCrsExamRecordPaging } from '@/api/courseRecord.js';
import { studyDurationIcon, studyTimeIcon } from '@/common/imgSvg';
const status = ref('loading'); // loadmore - 加载前,loading - 加载中,nomore - 没有数据
const limit = 15;
const total = ref(-1);
const page = ref(0);
const data_list = reactive([]);
const props = defineProps({});
const getData = (from = '', searchText = '') => {
if (from == 'first') {
if (total.value !== -1) {
return;
}
status.value = 'loading';
total.value = -1;
page.value = 1;
data_list.length = 0;
} else {
if (status.value !== 'loadmore' && status.value !== '') return;
status.value = 'loading';
page.value++;
}
setTimeout(() => {
queryCrsExamRecordPaging({
page: page.value,
limit: limit
})
.then((res) => {
total.value = res.total;
data_list.push(...res.body);
})
.finally(() => {
if (data_list.length >= total.value) {
status.value = 'nomore';
} else {
status.value = 'loadmore';
}
});
}, 200);
};
const getStatusClass = (isFinish) => {
// 00进行中、01已完成、02已超时
if (isFinish === '00') return 'in_progress';
if (isFinish === '01') return 'completed';
return 'expired';
};
const scrolltolower = (item) => {
getData();
};
const search = (value) => {
total.value = -1;
getData('first', value);
};
defineExpose({
getData,
search
});
</script>
<style>
</style>
<style scoped lang="scss">
.scroll_div {
background-color: #f1f5fa;
}
.scroll-Y {
height: calc(100vh - var(--status-bar-height) - 88rpx - 88rpx - 30rpx);
}
</style>
+290
View File
@@ -0,0 +1,290 @@
<template>
<view class="item" @click="click_item(item)">
<view class="details_div">
<view class="img_div" v-if="props.mode === 'testingHall'">
<image-preview class="img" :src="item.ossAddr" mode="scaleToFill"></image-preview>
</view>
<view class="right_div">
<view class="title ellipsis-text">
{{ item.examName }}
</view>
<view class="prompt_div">
<view class="prompt_div_left">
<view class="top">{{ item.highestGrade || 0 }}</view>
<view class="bottom">历史最高分</view>
</view>
<view class="prompt_div_line"></view>
<view class="prompt_div_right" @click="show_list_click">
<view class="click_text">
{{ item.examCnt || 0 }}
<uv-icon
class="click_text_icon"
:name="show_list_state ? 'arrow-down' : 'arrow-right'"
color="#0066FF"
size="12"
:bold="true"
></uv-icon>
</view>
<view class="bottom">考试次数</view>
</view>
</view>
</view>
</view>
<view class="list_div" :class="{ loaded: isLoaded }" :style="{ height: list_div_height }">
<view class="list_item" v-for="item_list in data_list">
<view class="list_content">
<view class="list_small_item">
<image src="@/static/images/courseRecord/time.png" class="icon_img"></image>
<view class="prompt">考试时间{{ item_list.examStartTm }}</view>
</view>
<view class="list_small_item">
<image src="@/static/images/courseRecord/duration.png" class="icon_img"></image>
<view class="prompt">考试得分{{ item_list.examGrade }}</view>
</view>
</view>
<view class="fl1"></view>
<uv-icon name="arrow-right" color="#979797" size="17" :bold="true"></uv-icon>
</view>
<uv-load-more
v-if="status === 'loading'"
:status="status"
loadmore-text="轻轻上拉加载"
:height="30"
></uv-load-more>
</view>
</view>
</template>
<script setup>
import { computed, ref, reactive, nextTick } from 'vue';
import { setPageCache } from '@/common/common';
import common from '@/common/common';
const status = ref('loadmore'); // loadmore - 加载前,loading - 加载中,nomore - 没有数据
const props = defineProps({
item: {
type: Object,
default: () => {}
},
mode: {
type: String,
default: 'testingHall',
validator: (value) => {
// 考试: examination
// 练习: practice
// 错题本: mistake
// 学习: study
// 考试结算页 settlement
// 考试中心 testingHall
return ['examination', 'practice', 'mistake', 'study', 'settlement', 'testingHall'].includes(value);
}
}
});
import { queryCrsExamHisByExamId } from '@/api/courseRecord.js';
const item = computed(() => props.item);
const data_list = reactive([]);
const isLoaded = ref(false);
const total = ref(-1);
const show_list_state = ref(false);
const list_div_height = computed(() => {
if (!show_list_state.value) {
return '0';
} else if (status.value === 'loading') {
return '100rpx';
} else {
return data_list.length * 136 + 'rpx';
}
});
// 点击获取考试详情
const show_list_click = () => {
show_list_state.value = !show_list_state.value;
if (total.value === -1) {
//加载数据
status.value = 'loading';
data_list.length = 0;
queryCrsExamHisByExamId({ examId: item.value.examId }).then((res) => {
console.log('queryCrsExamHisByExamId', res);
data_list.push(...res.body);
total.value = data_list.length;
status.value = 'loadmore';
// // 数据更新后触发动画
// // 使用$nextTick确保DOM已更新
nextTick(() => {
// isLoaded.value = true;
});
});
}
};
// 跳转到详情
const click_item = () => {};
</script>
<style scoped lang="scss">
.icon_img {
width: 24rpx;
height: 24rpx;
}
.list_div {
overflow: hidden; /* 确保内容不会溢出容器 */
transition: height 0.2s ease-out; /* 高度动画 */
.list_item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 18rpx 32rpx 18rpx 28rpx;
background-color: #f9fbff;
border-radius: 8rpx;
margin: 20rpx 0 0 0;
.list_content {
.list_small_item {
display: flex;
align-items: center;
font-weight: 400;
font-size: 24rpx;
color: #666666;
line-height: 40rpx;
text-align: left;
font-style: normal;
.prompt {
margin-left: 16rpx;
}
}
}
}
}
.item {
margin: 17rpx 20rpx;
background-color: #fff;
border-radius: 16rpx;
padding: 32rpx 22rpx;
.details_div {
display: flex;
.img_div {
position: relative;
width: 226rpx;
height: 168rpx;
overflow: hidden;
border-radius: 22rpx;
.img {
width: 226rpx;
height: 168rpx;
}
.subscript {
position: absolute;
right: 0;
top: 0;
width: 92rpx;
height: 46rpx;
border-radius: 0px 0px 0px 22rpx;
font-family: PingFangSC;
font-weight: 400;
font-size: 22rpx;
line-height: 32px;
display: flex;
align-items: center;
justify-content: center;
}
}
.right_div {
flex: 1;
overflow: hidden;
margin-left: 24rpx;
display: flex;
flex-direction: column;
.title {
font-family: PingFangSC;
color: #333333;
text-align: left;
font-style: normal;
font-weight: 600;
font-size: 28rpx; /* 字体大小30rpx */
overflow: hidden; /* 超出部分隐藏 */
margin-bottom: 8rpx;
min-height: 40rpx;
}
.prompt_div {
font-family: PingFangSC;
font-weight: 400;
font-size: 22rpx;
color: #666;
line-height: 34rpx;
display: flex;
align-items: center;
overflow: hidden;
height: 116rpx;
background-color: #f9fbff;
border-radius: 8rpx;
justify-content: space-around;
.prompt_div_line {
width: 4rpx;
height: 30rpx;
background: linear-gradient(
to bottom,
RGBA(242, 244, 248, 1) 0%,
RGBA(230, 232, 238, 1) 30%,
/* 中间开始 */ RGBA(230, 232, 238, 1) 70%,
/* 中间结束 */ RGBA(242, 244, 248, 1) 100%
);
}
.prompt_div_left,
.prompt_div_right {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
.top,
.click_text {
font-family: Arial;
font-weight: 700;
font-size: 30rpx;
color: #333333;
line-height: 34rpx;
text-align: center;
font-style: normal;
}
.bottom {
}
.click_text {
position: relative;
.click_text_icon {
position: absolute;
margin-left: 18rpx;
top: calc(50% - 12rpx);
right: -220%;
}
}
}
}
.people_progress_div {
display: flex;
font-family: PingFangSC;
font-weight: 400;
font-size: 23rpx;
color: #666;
margin-bottom: 23rpx;
line-height: 23rpx;
flex-wrap: nowrap;
height: 23rpx;
overflow: hidden;
}
}
}
}
</style>
@@ -17,7 +17,7 @@
}}阿斯顿萨达萨达阿斯顿萨达萨达萨达萨达萨达萨达
</view>
<view class="prompt_div">
<image :src="studyDurationIcon()" class="img"></image>
<image src="@/static/images/courseRecord/time.png" class="img"></image>
<view class="prompt">答题正确率30</view>
</view>
<view class="prompt_div">
@@ -40,11 +40,11 @@
import { setPageCache } from '@/common/common';
import common from '@/common/common';
import { ref, reactive, onMounted, nextTick } from 'vue';
import { queryPracticeRecordPaging, queryPracticeHis } from '@/api/courseRecord.js';
import { queryPracticeRecordPaging, queryPracticeHis, queryCrsExamRecordPaging } from '@/api/courseRecord.js';
import { studyDurationIcon, studyTimeIcon } from '@/common/imgSvg';
const props = defineProps({});
const getData = (from = '', searchText = '') => {
if (from == 'first') {
if (total.value !== -1) {
@@ -0,0 +1,8 @@
<template>
</template>
<script>
</script>
<style>
</style>
+2 -3
View File
@@ -49,7 +49,7 @@
import common from '@/common/common.js';
const listItemRefs = ref([]);
const taskRef = ref(null);
const tabAct = ref(1);
const tabAct = ref(2);
const tabList = ref([
{
name: '学习记录'
@@ -103,12 +103,11 @@
/*
状态栏 var(--status-bar-height)
标题高度88rpx
搜索栏高度80rpx
tab切换栏高度88rpx
下方滑动区域上下边距各10共20rpx
**/
height: calc(100vh - var(--status-bar-height) - 88rpx - 80rpx - 88rpx - 20rpx);
height: calc(100vh - var(--status-bar-height) - 88rpx - 88rpx - 30rpx);
}
.swiper-item {
+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();