liushengqiang 2 anni fa
parent
commit
f81f238fec

+ 5 - 1
src/page-orchestra/api.ts

@@ -22,7 +22,11 @@ export const sysMusicScoreAccompanimentQueryPage = (sysMusicScoreId: string) =>
 export const musicPracticeRecordSave = (data: any) => {
 	return request.post("/musicPracticeRecord/save", {requestType: 'json', data });
 };
-/** 记录训练时长 */
+/** 记录课后练习时长 */
+export const studentLessonTrainingLessonTrainingRecord = (data: any) => {
+	return request.post("/studentLessonTraining/lessonTrainingRecord", {requestType: 'json', data });
+};
+/** 获取学习会员信息 */
 export const studentMember = () => {
 	return request.get("/student/member");
 };

+ 50 - 26
src/page-orchestra/custom-plugins/recording-time/index.tsx

@@ -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>;
 	},
 });

+ 3 - 0
src/page-orchestra/evaluat-model/index.tsx

@@ -25,6 +25,7 @@ import { Vue3Lottie } from "vue3-lottie";
 import startData from "./data/start.json";
 import startingData from "./data/starting.json";
 import iconEvaluat from "./icons/evaluating.json";
+import { getQuery } from "/src/utils/queryString";
 
 // frequency 频率, amplitude 振幅, decibels 分贝
 type TCriteria = "frequency" | "amplitude" | "decibels";
@@ -134,6 +135,7 @@ export default defineComponent({
 		};
 		/** 连接websocket */
 		const handleConnect = async () => {
+			const query = getQuery()
 			const behaviorId = localStorage.getItem("behaviorId") || undefined;
 			const rate = state.speed / state.originSpeed;
 			const content = {
@@ -151,6 +153,7 @@ export default defineComponent({
 				speed: state.speed,
 				heardLevel: state.setting.evaluationDifficulty,
 				beatLength: Math.round((state.fixtime * 1000) / rate),
+				practiceSource: query.unitId ? 'UNIT_TEST' : 'PRACTICE',
 				// evaluationCriteria: getEvaluationCriteria(),
 			};
 			await connectWebsocket(content);