|
@@ -1,34 +1,58 @@
|
|
|
import { defineComponent, onBeforeUnmount, onMounted, onUnmounted, reactive, ref, watch } from "vue";
|
|
|
import state from "/src/state";
|
|
|
-import { musicPracticeRecordSave } from "../../api";
|
|
|
+import { musicPracticeRecordSave, studentLessonTrainingLessonTrainingRecord } from "../../api";
|
|
|
import { browser, getBehaviorId } from "/src/utils";
|
|
|
-
|
|
|
+import { getQuery } from "/src/utils/queryString";
|
|
|
+import { storeData } from "/src/store";
|
|
|
+// 单元测试 | 自主练习 | 评测 | 课后练习
|
|
|
+type IFeature = "UNIT_TEST" | "PRACTICE" | "EVALUATION" | "LESSON_TRAINING";
|
|
|
const recordData = reactive({
|
|
|
starTime: Date.now(),
|
|
|
});
|
|
|
const handleRecord = () => {
|
|
|
// 不是评测模式不记录
|
|
|
- if (state.modeType === 'evaluating') return;
|
|
|
- let total = Date.now() - recordData.starTime;
|
|
|
+ if (state.modeType === "evaluating") return;
|
|
|
+ const query = getQuery();
|
|
|
+ let totalTime = (Date.now() - recordData.starTime) / 1000;
|
|
|
recordData.starTime = Date.now();
|
|
|
- if (total < 0) total = 0;
|
|
|
- const body = {
|
|
|
- musicSheetId: state.examSongId,
|
|
|
- sysMusicScoreId: state.examSongId,
|
|
|
- feature: "PRACTICE",
|
|
|
- practiceSource: state.modeType,
|
|
|
- playTime: total / 1000,
|
|
|
- deviceType: browser().android ? "ANDROID" : "IOS",
|
|
|
- behaviorId: getBehaviorId()
|
|
|
- };
|
|
|
- musicPracticeRecordSave(body);
|
|
|
+ if (totalTime < 0) totalTime = 0;
|
|
|
+ // 课后训练
|
|
|
+ if (query.lessonTrainingId) {
|
|
|
+ const browserInfo = browser();
|
|
|
+ studentLessonTrainingLessonTrainingRecord({
|
|
|
+ materialType: "SONG",
|
|
|
+ record: {
|
|
|
+ clientType: storeData.platformType,
|
|
|
+ practiceSource: "LESSON_TRAINING",
|
|
|
+ feature: "PRACTICE",
|
|
|
+ deviceType: browserInfo.android ? "ANDROID" : browserInfo.isApp ? "IOS" : "WEB",
|
|
|
+ behaviorId: getBehaviorId(),
|
|
|
+ playTime: totalTime,
|
|
|
+ musicSheetId: state.examSongId,
|
|
|
+ },
|
|
|
+ courseScheduleId: query.courseScheduleId,
|
|
|
+ lessonTrainingId: query.lessonTrainingId,
|
|
|
+ materialId: query.materialId,
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ const body = {
|
|
|
+ musicSheetId: state.examSongId,
|
|
|
+ sysMusicScoreId: state.examSongId,
|
|
|
+ feature: "PRACTICE",
|
|
|
+ practiceSource: "PRACTICE",
|
|
|
+ playTime: totalTime,
|
|
|
+ deviceType: browser().android ? "ANDROID" : "IOS",
|
|
|
+ behaviorId: getBehaviorId(),
|
|
|
+ };
|
|
|
+ musicPracticeRecordSave(body);
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
export const handleNoEndExit = () => {
|
|
|
- if (state.playState === 'play') {
|
|
|
- handleRecord()
|
|
|
- }
|
|
|
-}
|
|
|
+ if (state.playState === "play") {
|
|
|
+ handleRecord();
|
|
|
+ }
|
|
|
+};
|
|
|
|
|
|
/**
|
|
|
* 记录练习时长, 仅记录练习模式的时长
|
|
@@ -36,16 +60,16 @@ export const handleNoEndExit = () => {
|
|
|
export default defineComponent({
|
|
|
name: "recordingTime",
|
|
|
setup() {
|
|
|
- const timer = ref()
|
|
|
+ const timer = ref();
|
|
|
onMounted(() => {
|
|
|
- clearInterval(timer.value)
|
|
|
+ clearInterval(timer.value);
|
|
|
timer.value = setInterval(() => {
|
|
|
- handleRecord()
|
|
|
- }, 60 * 1000)
|
|
|
- })
|
|
|
+ handleRecord();
|
|
|
+ }, 60 * 1000);
|
|
|
+ });
|
|
|
onBeforeUnmount(() => {
|
|
|
- clearInterval(timer.value)
|
|
|
- })
|
|
|
+ clearInterval(timer.value);
|
|
|
+ });
|
|
|
return () => <div></div>;
|
|
|
},
|
|
|
});
|