Forráskód Böngészése

新增考试成绩提交

wyling 3 éve
szülő
commit
a21d72e8e6

BIN
public/img/考试不合格.png


+ 0 - 4
src/api/modules/home.ts

@@ -1,5 +1 @@
 import request from "../request";
-
-export function apitest(){
-    return {}
-}

+ 2 - 3
src/api/modules/test.ts

@@ -15,7 +15,6 @@ interface topicQuery {
  * @returns
  */
 export async function getTopicList(params: any) {
-
   const getUserAnswer = (type: string) => {
     switch (type) {
       case "判断题":
@@ -40,7 +39,7 @@ export async function getTopicList(params: any) {
   };
 
   let res = await request({
-    url: "/qustion/info/list",
+    url: "/student/qustion/info/list",
     params,
   });
 
@@ -70,7 +69,7 @@ export async function getTopicList(params: any) {
  */
 export async function getTopicClass(path: string, params: any) {
   return request({
-    url: `/qustion/info/${path}`,
+    url: `/student/qustion/info/${path}`,
     params,
   });
 }

+ 27 - 9
src/api/modules/testScores.ts

@@ -2,11 +2,11 @@ import request from "../request";
 
 /**
  * 查询模拟考成绩列表
- * @returns 
+ * @returns
  */
 export const getTestScoresList = async () => {
   let res = await request({
-    url: "/score/info/list",
+    url: "/student/score/info/list",
   });
 
   return res.data;
@@ -14,12 +14,30 @@ export const getTestScoresList = async () => {
 
 /**
  * 获取最大成绩,平均成绩,预测成绩
- * @returns 
+ * @returns
  */
 export const getTestScoresInfo = async () => {
-    let res = await request({
-      url: "/score/info/getScoreInfoAll",
-    });
-  
-    return res.data;
-  };
+  let res = await request({
+    url: "/student/score/info/getScoreInfoAll",
+  });
+
+  return res.data;
+};
+
+interface TestScores {
+  kskm: string;
+  score: number;
+  type: string;
+}
+/**
+ * 新增考试成绩
+ * @param data
+ */
+export const createTestScores = async (data: TestScores) => {
+  const res = await request({
+    url: "/student/score/info",
+    method: "POST",
+    data,
+  });
+  return res.data;
+};

+ 48 - 8
src/views/home/children/test/index.vue

@@ -44,11 +44,21 @@ const carTypeList = ref([
     sujectList: [
       {
         name: "科目一",
-        query: { name: "科目一", cert: "轿车C1/C2/C3", subject1: 1 },
+        query: {
+          name: "科目一",
+          cert: "C1/C2/C3",
+          vehicle: "轿车",
+          subject1: 1,
+        },
       },
       {
         name: "科目四",
-        query: { name: "科目四", cert: "轿车C1/C2/C3", subject4: 1 },
+        query: {
+          name: "科目四",
+          cert: "C1/C2/C3",
+          vehicle: "轿车",
+          subject4: 1,
+        },
       },
     ],
   },
@@ -60,11 +70,21 @@ const carTypeList = ref([
     sujectList: [
       {
         name: "科目一",
-        query: { name: "科目一", cert: "客车A1/A3/B1", subject1: 1 },
+        query: {
+          name: "科目一",
+          cert: "A1/A3/B1",
+          vehicle: "客车",
+          subject1: 1,
+        },
       },
       {
         name: "科目四",
-        query: { name: "科目四", cert: "客车A1/A3/B1", subject4: 1 },
+        query: {
+          name: "科目四",
+          cert: "A1/A3/B1",
+          vehicle: "客车",
+          subject4: 1,
+        },
       },
     ],
   },
@@ -76,11 +96,21 @@ const carTypeList = ref([
     sujectList: [
       {
         name: "科目一",
-        query: { name: "科目一", cert: "货车A2/B2", subject1: 1 },
+        query: {
+          name: "科目一",
+          cert: "A2/B2",
+          vehicle: "货车",
+          subject1: 1,
+        },
       },
       {
         name: "科目四",
-        query: { name: "科目四", cert: "货车A2/B2", subject4: 1 },
+        query: {
+          name: "科目四",
+          cert: "A2/B2",
+          vehicle: "货车",
+          subject4: 1,
+        },
       },
     ],
   },
@@ -92,11 +122,21 @@ const carTypeList = ref([
     sujectList: [
       {
         name: "科目一",
-        query: { name: "科目一", cert: "摩托车D/E/F", subject1: 1 },
+        query: {
+          name: "科目一",
+          cert: "D/E/F",
+          vehicle: "摩托车",
+          subject1: 1,
+        },
       },
       {
         name: "科目四",
-        query: { name: "科目四", cert: "摩托车D/E/F", subject4: 1 },
+        query: {
+          name: "科目四",
+          cert: "D/E/F",
+          vehicle: "摩托车",
+          subject4: 1,
+        },
       },
     ],
   },

+ 1 - 1
src/views/mockTest/components/initMockTest.vue

@@ -14,7 +14,7 @@
     </div>
     <div class="class">
       <span>考试题库</span>
-      <span>{{ query.cert }}</span>
+      <span>{{ query.vehicle }}{{ query.cert }}</span>
     </div>
     <div class="class">
       <span>考试时间</span>

+ 64 - 28
src/views/mockTest/components/mockTestEnd.vue

@@ -1,28 +1,64 @@
 <template>
   <m-nav-bar title="考试结果" />
-  <div class="result-box">
+  <div class="result-box" v-if="testResult">
     <img class="img" src="/img/考试合格.png" />
     <span class="text">恭喜你,测试通过~</span>
-    <div class="fraction-box"><span class="fraction">98</span>分</div>
+    <div class="fraction-box">
+      <span class="fraction">{{ props.userTestData.testScores }}</span
+      >分
+    </div>
     <span class="hint">(满分:100;合格:90)</span>
-    <span class="time">用时:0分2秒</span>
+    <span class="time">用时:{{ useTime }}</span>
     <span class="evaluation"
       >天赋异禀、骨骼惊奇,想来是百年难得一见的考试奇才。</span
     >
-    <div class="btn-box">
-      <m-button class="btn1" text="错题重做" />
-      <m-button class="btn2" text="重新测试" />
+  </div>
+  <div class="result-box" v-else>
+    <img class="img" src="/img/考试不合格.png" />
+    <span class="text">抱歉,测试未通过~</span>
+    <div class="fraction-box">
+      <span class="fraction">{{ props.userTestData.testScores }}</span
+      >分
     </div>
+    <span class="hint">(满分:100;合格:90)</span>
+    <span class="time">用时:{{ useTime }}</span>
+    <span class="evaluation"
+      >学车之路,任重而道远!路漫漫其修远兮,吾将上下而求索。</span
+    >
+  </div>
+  <div class="btn-box">
+    <m-button class="btn1" text="错题重做" />
+    <m-button class="btn2" text="重新测试" />
   </div>
 </template>
 
 <script setup lang="ts">
-import { defineEmits } from "vue";
+import { defineEmits, defineProps, computed } from "vue";
+import dayjs from "dayjs";
+import { createTestScores } from "@/api";
+import { useRoute } from "vue-router";
+
+const props = defineProps(["userTestData"]);
+
+//是否通过考试
+const testResult = computed(() => {
+  return props.userTestData.testScores >= 90;
+});
+//用时多久
+const useTime = computed(() => {
+  return dayjs(props.userTestData.useTime).format("mm分ss秒");
+});
 
-const emits = defineEmits(["next"]);
-const gotoTest = () => {
-  emits("next");
-};
+const { query } = useRoute();
+
+//提交考试成绩
+createTestScores({
+  type: query.vehicle as string,
+  kskm: query.name as string,
+  score: props.userTestData.testScores,
+}).then((res) => {
+  console.log(res);
+});
 </script>
 
 <style lang="scss" scoped>
@@ -79,23 +115,23 @@ const gotoTest = () => {
     color: #5c6066;
     line-height: 23px;
   }
-  .btn-box {
-    margin-top: 45px;
-    width: 230px;
-    display: flex;
-    justify-content: space-between;
-    align-items: center;
-    color: #ffffff;
-    font-size: 15px;
-    font-family: PingFang SC;
-    font-weight: 400;
-    line-height: 23px;
-    .btn1 {
-      background-color: #498ef5;
-    }
-    .btn2 {
-      background-color: #01c18d;
-    }
+}
+.btn-box {
+  margin: 45px auto;
+  width: 230px;
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+  color: #ffffff;
+  font-size: 15px;
+  font-family: PingFang SC;
+  font-weight: 400;
+  line-height: 23px;
+  .btn1 {
+    background-color: #498ef5;
+  }
+  .btn2 {
+    background-color: #01c18d;
   }
 }
 </style>

+ 17 - 14
src/views/mockTest/components/startTest.vue

@@ -1,12 +1,6 @@
 <template>
   <!-- 导航栏 -->
-  <van-nav-bar
-    title="标题"
-    left-arrow
-    @click-left="onClickLeft"
-    fixed
-    placeholder
-  >
+  <van-nav-bar title="标题" left-arrow @click-left="back" fixed placeholder>
     <template #right>
       <m-icon type="shezhi" @click="setShow = true" />
     </template>
@@ -14,7 +8,11 @@
   <!-- 导航栏end -->
   <!-- 考试倒计时 -->
   <div class="dowm-box">
-    <van-count-down :time="45 * 60 * 1000" format="剩余答题时间: mm分ss秒" />
+    <van-count-down
+      :time="45 * 60 * 1000"
+      format="剩余答题时间: mm分ss秒"
+      @change="useTimeChange"
+    />
   </div>
   <!-- 考试倒计时end -->
   <!-- 分割线 -->
@@ -199,14 +197,19 @@ import { useRoute, useRouter } from "vue-router";
 import { ref, defineEmits } from "vue";
 import { Dialog } from "vant";
 import { useSubjectShowLogic, useTopicMode, useAudioSet } from "./hooks";
-const router = useRouter();
-const route = useRoute();
-const onClickLeft = () => {
-  router.back();
-};
+const { back } = useRouter();
 
 //父级传参
-const emits = defineEmits(["next"]);
+const props = defineProps(["userTestData"]);
+const emits = defineEmits(["next", "update:userTestData"]);
+
+const useTimeChange = (e: any) => {
+  emits("update:userTestData", {
+    ...props.userTestData,
+    useTime: 45 * 60 * 1000 - e.total,
+  });
+};
+
 const gotoTest = () => {
   Dialog.confirm({
     message: "确认交卷吗?",

+ 12 - 3
src/views/mockTest/index.vue

@@ -1,14 +1,23 @@
 <template>
-  <component :is="currentComponent" @next="next"></component>
+  <component
+    :is="currentComponent"
+    @next="next"
+    v-model:userTestData="userTestData"
+  ></component>
 </template>
 
 <script lang="ts" setup>
 import initMockTest from "./components/initMockTest.vue";
 import mockTestEnd from "./components/mockTestEnd.vue";
 import startTest from "./components/startTest.vue";
-console.log({startTest});
+console.log({ startTest });
 
-import { defineComponent, ref } from "vue";
+import { defineComponent, ref, reactive } from "vue";
+
+const userTestData = reactive({
+  testScores: 0,
+  useTime: 0,
+});
 
 const currentComponent = ref(initMockTest);
 const comIndex = ref(0);