소스 검색

四舍五入

Michael Wang 3 년 전
부모
커밋
672622f470

+ 1 - 1
src/directives/numberToPercent.ts

@@ -4,7 +4,7 @@ export default {
     // console.log(el, binding, vnode, prevVnode);
     const ft = parseFloat(el.innerText);
     if (typeof ft === "number") {
-      el.innerText = (Math.round(ft * 100) / 100) * 100 + "%";
+      el.innerText = (Math.round(ft * 10000) / 10000) * 100 + "%";
     }
   }, // new
   beforeMount() {},

+ 9 - 1
src/features/allAnalysis/AllAnalysis2.vue

@@ -90,7 +90,15 @@ watch(() => [pageNo, pageSize], fetchData);
 async function fetchData() {
   const res = await getSasPaperList({ projectId, courseId, pageNo, pageSize });
   // console.log(res);
-  data = res.data.content;
+  data = res.data.content.map((v) => {
+    v.avgScore = Math.round(v.avgScore * 100) / 100;
+    v.stdev = Math.round(v.stdev * 100) / 100;
+    v.coefficient = Math.round(v.coefficient * 100) / 100;
+    v.reliability1 = Math.round(v.reliability1 * 100) / 100;
+    v.reliability2 = Math.round(v.reliability2 * 100) / 100;
+    v.difficulty = Math.round(v.difficulty * 100) / 100;
+    return v;
+  });
   pageNo = res.data.pageNo;
   pageSize = res.data.pageSize;
   totalElements = res.data.totalElements;

+ 4 - 4
src/features/allAnalysis/ScoreRate.vue

@@ -34,9 +34,9 @@
               <tr v-for="(seg, index) in course.segements" :key="index">
                 <td>{{ seg[0] }}-</td>
                 <td>{{ seg[1] }}</td>
-                <td>{{ Math.round(seg[2] * 100) }}%</td>
+                <td v-number-to-percent>{{ seg[2] }}%</td>
                 <td>{{ seg[3] }}</td>
-                <td>{{ Math.round(seg[4] * 100) }}%</td>
+                <td v-number-to-percent>{{ seg[4] }}%</td>
               </tr>
             </table>
 
@@ -66,9 +66,9 @@
               <tr v-for="(seg, index) in course.rangeSegements" :key="index">
                 <td>{{ seg[0] }}-</td>
                 <td>{{ seg[1] }}</td>
-                <td>{{ Math.round(seg[2] * 100) }}%</td>
+                <td v-number-to-percent>{{ seg[2] }}%</td>
                 <td>{{ seg[3] }}</td>
-                <td>{{ Math.round(seg[4] * 100) }}%</td>
+                <td v-number-to-percent>{{ seg[4] }}%</td>
               </tr>
             </table>
 

+ 4 - 4
src/features/paperAnalysis/DifficultyDistriTable.vue

@@ -30,7 +30,7 @@
       <td>
         {{ item2.totalScore }}
       </td>
-      <td>
+      <td v-round-number>
         {{ item2.difficulty }}
       </td>
       <td>
@@ -39,7 +39,7 @@
       <td>
         {{ item2.difficulityLevel.high.fullScore }}
       </td>
-      <td>
+      <td v-number-to-percent>
         {{ item2.difficulityLevel.high.percent }}
       </td>
       <td>
@@ -48,7 +48,7 @@
       <td>
         {{ item2.difficulityLevel.middle.fullScore }}
       </td>
-      <td>
+      <td v-number-to-percent>
         {{ item2.difficulityLevel.middle.percent }}
       </td>
       <td>
@@ -57,7 +57,7 @@
       <td>
         {{ item2.difficulityLevel.low.fullScore }}
       </td>
-      <td>
+      <td v-number-to-percent>
         {{ item2.difficulityLevel.low.percent }}
       </td>
     </tr>

+ 20 - 11
src/features/paperAnalysis/DiscriminationDistriTable.vue

@@ -34,35 +34,44 @@
       <td>
         {{ item2.totalScore }}
       </td>
-      <td>
+      <td v-round-number>
         {{ item2.coefficient }}
       </td>
       <td>
-        {{ item2.difficulityLevel.high.questionCount }}
+        {{ item2.discriminationLevel.excellent.questionCount }}
       </td>
       <td>
-        {{ item2.difficulityLevel.high.fullScore }}
+        {{ item2.discriminationLevel.excellent.fullScore }}
       </td>
-      <td>
-        {{ item2.difficulityLevel.high.percent }}
+      <td v-number-to-percent>
+        {{ item2.discriminationLevel.excellent.percent }}
       </td>
       <td>
-        {{ item2.difficulityLevel.middle.questionCount }}
+        {{ item2.discriminationLevel.good.questionCount }}
       </td>
       <td>
-        {{ item2.difficulityLevel.middle.fullScore }}
+        {{ item2.discriminationLevel.good.fullScore }}
+      </td>
+      <td v-number-to-percent>
+        {{ item2.discriminationLevel.good.percent }}
       </td>
       <td>
-        {{ item2.difficulityLevel.middle.percent }}
+        {{ item2.discriminationLevel.general.questionCount }}
       </td>
       <td>
-        {{ item2.difficulityLevel.low.questionCount }}
+        {{ item2.discriminationLevel.general.fullScore }}
+      </td>
+      <td v-number-to-percent>
+        {{ item2.discriminationLevel.general.percent }}
       </td>
       <td>
-        {{ item2.difficulityLevel.low.fullScore }}
+        {{ item2.discriminationLevel.bad.questionCount }}
       </td>
       <td>
-        {{ item2.difficulityLevel.low.percent }}
+        {{ item2.discriminationLevel.bad.fullScore }}
+      </td>
+      <td v-number-to-percent>
+        {{ item2.discriminationLevel.bad.percent }}
       </td>
     </tr>
   </table>

+ 6 - 1
src/features/paperAnalysis/PaperAnalysis.vue

@@ -123,6 +123,11 @@ async function fetchData() {
   res2.data = res2.data.map((q) => {
     q.difficulityLevel = JSON.parse(q.difficulityLevel || "[]");
     q.difficulityGroupLevel = JSON.parse(q.difficulityGroupLevel || "[]");
+    q.avgScore = Math.round(q.avgScore * 100) / 100;
+    q.stdev = Math.round(q.stdev * 100) / 100;
+    q.coefficient = Math.round(q.coefficient * 100) / 100;
+    q.difficulty = Math.round(q.difficulty * 100) / 100;
+    q.discrimination = Math.round(q.discrimination * 100) / 100;
     return q;
   });
   paperQuestions = res2.data;
@@ -132,7 +137,7 @@ async function fetchData() {
   res4.data.discriminationLevel = JSON.parse(
     res4.data.discriminationLevel || "[]"
   );
-  console.log(res4.data);
+  // console.log(res4.data);
   sasPaper = res4.data;
 
   const res3 = await getPaperQuestionGroups(projectId, paperId);

+ 1 - 1
src/features/paperAnalysis/QuestionBianPai.vue

@@ -7,7 +7,7 @@
       :pagination="{ pageSize: 200, hideOnSinglePage: true }"
     ></a-table>
 
-    <div class="tw-flex tw-gap-4">
+    <div class="tw-flex tw-gap-4 tw-pt-4">
       <div style="width: 400px; height: 300px">
         <v-chart class="chart" :option="chartOption(props.questions)" />
       </div>

+ 10 - 2
src/features/paperAnalysis/QuestionDifficultyGroup.vue

@@ -19,7 +19,11 @@
         <tr v-for="(item, index) in props.questions" :key="index">
           <td>{{ item.mainNumber }}</td>
           <td>{{ item.subNumber }}</td>
-          <td v-for="(item, index) in item.difficulityLevel" :key="index">
+          <td
+            v-for="(item, index) in item.difficulityLevel"
+            :key="index"
+            v-round-number
+          >
             {{ item }}
           </td>
         </tr>
@@ -49,7 +53,11 @@
         <tr v-for="(item, index) in props.questions" :key="index">
           <td>{{ item.mainNumber }}</td>
           <td>{{ item.subNumber }}</td>
-          <td v-for="(item, index) in item.difficulityGroupLevel" :key="index">
+          <td
+            v-for="(item, index) in item.difficulityGroupLevel"
+            :key="index"
+            v-round-number
+          >
             {{ item }}
           </td>
         </tr>