Browse Source

提交答案接口签名

Michael Wang 3 năm trước cách đây
mục cha
commit
bb01837996

+ 17 - 2
src/features/OnlineExam/Examing/setups/useAnswerQuestions.ts

@@ -1,6 +1,9 @@
 import { httpApp } from "@/plugins/axiosApp";
 import { store } from "@/store/store";
 import { AudioPlayTime } from "@/types/student-client";
+import { doEnc } from "@/utils/encDec";
+import { MD5 } from "@/utils/md5";
+import { getKey } from "@/utils/utils";
 
 function resetExamQuestionDirty() {
   store.exam.examQuestionList = store.exam.examQuestionList.map((eq) => {
@@ -34,10 +37,22 @@ export async function answerAllQuestions(
       ) as Answer;
     });
   if (answers.length > 0) {
+    const timestamp = Date.now();
+    const rawStr = MD5(JSON.stringify(answers));
+
+    const key = getKey(timestamp);
+
+    const sign = doEnc(rawStr, key);
+
     try {
       await httpApp.post(
-        "/api/ecs_oe_student/examQuestion/submitQuestionAnswer",
-        answers
+        "/api/ecs_oe_student/examControl/submitQuestionAnswer",
+        { answers: JSON.stringify(answers), sign },
+        {
+          "axios-retry": { retries: 4 },
+          noErrorMessage: true,
+          headers: { timestamp },
+        }
       );
       resetExamQuestionDirty();
     } catch (error) {

+ 0 - 1
src/features/OnlineExam/StartExamModal.vue

@@ -235,7 +235,6 @@ async function enterExam() {
     });
 
     const key = getKey(timestamp);
-    console.log({ rawStr, key });
 
     let encryptParams = "";
     encryptParams = doEnc(rawStr, key);