jichoi / lms_front star
woals 2024-08-14
240814 권민수 객관식 문제 가져오는 기능 구현(이게 진짜)
@9b55cd76dd38f0b32718dea89c45c9180602f95f
client/views/layout/Side.vue
--- client/views/layout/Side.vue
+++ client/views/layout/Side.vue
@@ -28,7 +28,7 @@
           v-for="historyItem in studentInfo.history"
           :key="historyItem.unitId"
         >
-          {{ historyItem.bookName }} {{ historyItem.unitName }}
+          [{{ historyItem.bookName }}] {{ historyItem.unitName }}
         </li>
       </ul>
     </div>
client/views/pages/main/Chapter/Chapter3_3.vue
--- client/views/pages/main/Chapter/Chapter3_3.vue
+++ client/views/pages/main/Chapter/Chapter3_3.vue
@@ -6,7 +6,7 @@
       </router-link>
     </div>
     <div class="title-box mb25 flex align-center mt40">
-      <span class="title mr40">1. Hello WORLD</span>
+      <span class="title mr40">{{ unitData.unit_nm || '(단원 이름 데이터 없음)' }}</span>
       <span class="subtitle">my name is dd</span>
     </div>
     <div class="flex justify-between align-center">
@@ -14,7 +14,7 @@
       <div class="content title-box">
         <p class="title mt25 title-bg">step3.</p>
         <div class="flex align-center mb30">
-          <p class="subtitle2 mr20">주어진 단어 중 <em class="yellow-bg">명사</em>인 것을 고르세요.</p>
+          <p class="subtitle2 mr20">{{ dataList.prblmExpln }}</p>
         </div>
 
         <div class="text-ct">
@@ -30,24 +30,16 @@
               </div>
          </div>
           <div class="pickGroup mt60 flex align-center justify-center" style="gap: 100px; margin-top: 7%;">
-            <article style="gap: 60px; bottom: 159px;
-    left: 242px;">
+
+            <article v-for="(detail, index) in problemDetail" :key="index" style="gap: 60px;">
               <div class="flex align-center">
                 <button><img src="../../../../resources/img/img136_71s.png" alt="">
-                  <p>1</p>
+                  <p>{{ index + 1 }}</p>
                 </button>
-                <p>a</p>
+                <p>{{ detail.prblmDtlExpln }}</p>
               </div>
             </article>
-            <article style="gap: 60px; bottom: 159px;
-    right: 559px;">
-             <div class="flex align-center">
-                <button><img src="../../../../resources/img/img136_71s.png" alt="">
-                  <p>2</p>
-                </button>
-                <p>b</p>
-             </div>
-            </article>
+
           </div>
         </div>
       </div>
@@ -57,16 +49,25 @@
 </template>
 
 <script>
+import axios from "axios";
+
 export default {
   data() {
     return {
-      timer: '00'
+      timer: '00',
+      prblmId: "",
+      problemDetail: [],
+      dataList: [],
+      prblmExpln: null,
+      unitData: {}, // 단원 정보 데이터
     }
   },
   methods: {
+
     goToPage(page) {
       this.$router.push({ name: page });
     },
+
     startTimer() {
       if (this.intervalId) {
         clearInterval(this.intervalId);
@@ -79,7 +80,55 @@
           clearInterval(this.intervalId);
         }
       }, 1000);
-    }
+    },
+
+    // 단원 정보를 불러오는 API 호출
+    fetchUnitDetail(unitId) {
+        console.log("테스트", this.dataList);
+        axios.post('/unit/unitDetail.json', {
+            unitId: unitId
+        })
+        .then(response => {
+            console.log(response.data[0]);
+            if (response.data.length > 0) {
+                this.unitData = response.data[0];
+            }
+        })
+        .catch(error => {
+            console.error('단원 정보를 불러오는 중 오류 발생:', error);
+        })
+    },
+
+    problemSearch() {
+        const vm = this;
+        vm.prblmId = JSON.parse(sessionStorage.getItem("prblmId"));
+        axios({
+            url: "problem/problemInfo.json",
+            method: "post",
+            headers: {
+                "Content-Type": "application/json; charset=UTF-8",
+            },
+            data: {
+                prblmId: vm.prblmId,
+            },
+        })
+            .then(function (res) {
+                console.log("problem - response : ", res.data);
+                vm.dataList = res.data.problem;
+                vm.problemDetail = res.data.problemDetail;
+
+                // 문제 정보가 성공적으로 받아와진 후, unitId를 이용해 단원 정보를 가져옴
+                if (vm.dataList.unitId) {
+                  vm.fetchUnitDetail(vm.dataList.unitId);
+                } else {
+                  console.error("단원 ID가 없습니다.");
+                }
+            })
+            .catch(function (error) {
+                console.log("problem - error : ", error);
+            });
+    },
+
   },
   watch: {
 
@@ -90,7 +139,7 @@
   components: {
   },
   mounted() {
-
+    this.problemSearch();
   }
 }
 </script>
Add a comment
List