jichoi / lms_front star
홍아랑 홍아랑 2024-08-22
240822 홍아랑 문제1 버튼 내 문제들(ch2_6,7,8) api연결
@5755588d18ae233708170045abc1827ba706f961
client/views/pages/main/Chapter/Chapter2_6.vue
--- client/views/pages/main/Chapter/Chapter2_6.vue
+++ client/views/pages/main/Chapter/Chapter2_6.vue
@@ -2,83 +2,132 @@
   <div id="Chapter1_1" class="content-wrap">
     <div style="margin: 30px 0px 50px; width: 20%">
       <router-link to="/MyPlan.page">
-        <div class="logo mb25"><img src="../../../../resources/img/logo2.png" alt=""></div>
+        <div class="logo mb25">
+          <img src="../../../../resources/img/logo2.png" alt="" />
+        </div>
       </router-link>
     </div>
-    <div class="title-box mb25 flex align-center mt40" style="
-    justify-content: space-between;
-">
+    <div
+      class="title-box mb25 flex align-center mt40"
+      style="justify-content: space-between"
+    >
       <div>
         <span class="title mr40">1. Hello WORLD</span>
         <span class="subtitle">my name is dd</span>
       </div>
-      <button class="completeBtn" @click="complete"> 학습 종료 </button>
+      <button class="completeBtn" @click="complete">학습 종료</button>
     </div>
     <div class="flex justify-between align-center">
-      <div class="pre-btn" @click="goToPage('Chapter2_5')"><img src="../../../../resources/img/left.png" alt=""></div>
+      <div class="pre-btn" @click="previousProblem()">
+        <img src="../../../../resources/img/left.png" alt="" />
+      </div>
       <div class="content title-box">
-        <div style="display: flex; justify-content: space-between;">
+        <div style="display: flex; justify-content: space-between">
           <p class="title mt25 title-bg">step3 - 놀면서 배우는 영어</p>
-          <button id="returnButton" @click="returnPage" style="margin: 4rem;">
-            <img src="../../../../resources/img/btn_return_50x50.png" alt="">
+          <button id="returnButton" @click="returnPage" style="margin: 4rem">
+            <img src="../../../../resources/img/btn_return_50x50.png" alt="" />
             <p>되돌리기</p>
           </button>
         </div>
         <div class="flex align-center mb30">
-          <p class="subtitle2 mr20">앗! 퍼즐이 망가졌어! 퍼즐을 맞춰 문장을 완성해보자!</p>
+          <p class="subtitle2 mr20">
+            앗! 퍼즐이 망가졌어! 퍼즐을 맞춰 문장을 완성해보자!
+          </p>
         </div>
         <div class="text-ct">
           <div class="dropGroup">
             <div class="flex justify-center">
-              <div class="popTxt" id="drop1" @dragover.prevent @drop="handleDrop(1)">
-                <img src="../../../../resources/img/img66_38s_1.png" alt="">
-                <button v-if="showButton1"><img src="../../../../resources/img/img66_38s_1_color.png" alt="">
-                  <p>i</p>
+              <div
+                class="popTxt"
+                id="drop1"
+                @dragover.prevent
+                @drop="handleDrop(1)"
+              >
+                <img src="../../../../resources/img/img66_38s_1.png" alt="" />
+                <button v-if="showButton1">
+                  <img
+                    src="../../../../resources/img/img66_38s_1_color.png"
+                    alt=""
+                  />
+                  <p>{{ answerArr[0] }}</p>
                 </button>
               </div>
-              <div class="popTxt" id="drop2" @dragover.prevent @drop="handleDrop(2)">
-                <img src="../../../../resources/img/img66_38s_2.png" alt="">
-                <button v-if="showButton2"><img src="../../../../resources/img/img66_38s_2_color.png" alt="">
-                  <p>have</p>
+              <div
+                class="popTxt"
+                id="drop2"
+                @dragover.prevent
+                @drop="handleDrop(2)"
+              >
+                <img src="../../../../resources/img/img66_38s_2.png" alt="" />
+                <button v-if="showButton2">
+                  <img
+                    src="../../../../resources/img/img66_38s_2_color.png"
+                    alt=""
+                  />
+                  <p>{{ answerArr[1] }}</p>
                 </button>
               </div>
-              <div class="popTxt" id="drop3" @dragover.prevent @drop="handleDrop(3)">
-                <img src="../../../../resources/img/img66_38s_3.png" alt="">
-                <button v-if="showButton3"><img src="../../../../resources/img/img66_38s_3_color.png" alt="">
-                  <p>banana</p>
+              <div
+                class="popTxt"
+                id="drop3"
+                @dragover.prevent
+                @drop="handleDrop(3)"
+              >
+                <img src="../../../../resources/img/img66_38s_3.png" alt="" />
+                <button v-if="showButton3">
+                  <img
+                    src="../../../../resources/img/img66_38s_3_color.png"
+                    alt=""
+                  />
+                  <p>{{ answerArr[2] }}</p>
                 </button>
               </div>
             </div>
           </div>
           <div class="dragGroup">
-            <article style="right: 0; top: 36%;" @dragstart="handleDragStart(1)" v-show="!dragHidden1">
+            <article
+              style="right: 0; top: 36%"
+              @dragstart="handleDragStart(1)"
+              v-show="!dragHidden1"
+            >
               <button id="drag1" draggable="true">
-                <img src="../../../../resources/img/img67_38s.png" alt="">
-                <p>i</p>
+                <img src="../../../../resources/img/img67_38s.png" alt="" />
+                <p>{{ answerArr[0] }}</p>
               </button>
             </article>
-            <article style="left: 0; top: 36%;" @dragstart="handleDragStart(2)" v-show="!dragHidden2">
+            <article
+              style="left: 0; top: 36%"
+              @dragstart="handleDragStart(2)"
+              v-show="!dragHidden2"
+            >
               <button id="drag2" draggable="true">
-                <img src="../../../../resources/img/img68_38s.png" alt="">
-                <p>have</p>
+                <img src="../../../../resources/img/img68_38s.png" alt="" />
+                <p>{{ answerArr[1] }}</p>
               </button>
             </article>
-            <article style="left: 50%; top: 10%;" @dragstart="handleDragStart(3)" v-show="!dragHidden3">
+            <article
+              style="left: 50%; top: 10%"
+              @dragstart="handleDragStart(3)"
+              v-show="!dragHidden3"
+            >
               <button id="drag3" draggable="true">
-                <img src="../../../../resources/img/img69_38s.png" alt="">
-                <p>banana</p>
+                <img src="../../../../resources/img/img69_38s.png" alt="" />
+                <p>{{ answerArr[2] }}</p>
               </button>
             </article>
           </div>
         </div>
       </div>
-      <div class="next-btn" @click="goToPage('Chapter2_10')"><img src="../../../../resources/img/right.png" alt="">
+      <div class="next-btn" @click="nextProblem()">
+        <img src="../../../../resources/img/right.png" alt="" />
       </div>
     </div>
   </div>
 </template>
 
 <script>
+import axios from "axios";
+
 export default {
   data() {
     return {
@@ -88,13 +137,19 @@
       dragHidden1: false,
       dragHidden2: false,
       dragHidden3: false,
-      currentDrag: null // 드래그 중인 퍼즐의 번호를 저장합니다.
-    }
+      currentDrag: null, // 드래그 중인 퍼즐의 번호를 저장합니다.
+      prblm_id: [],
+      problemData: [],
+      answerArr: [],
+    };
   },
   methods: {
     complete() {
       const { unit_id, book_id } = this.$route.query;
-      this.$router.push({ name: 'Dashboard', query: { value: 3, unit_id, book_id } });
+      this.$router.push({
+        name: "Dashboard",
+        query: { value: 3, unit_id, book_id },
+      });
     },
     goToPage(page) {
       this.$router.push({ name: page });
@@ -112,6 +167,9 @@
       if (this.currentDrag === dropNumber) {
         this.showButton(dropNumber); // 버튼을 보여주고
         this.hideDragButton(dropNumber); // 드래그한 퍼즐은 숨김
+      } else {
+        // 오답일 경우 알림 표시
+        alert("오답입니다! 다시 시도해보세요.");
       }
       // 드래그 후 상태 초기화
       this.currentDrag = null;
@@ -133,9 +191,140 @@
       } else if (dropNumber === 3) {
         this.showButton3 = true;
       }
-    }
-  }
-}
+    },
+    fetchProblemData() {
+      axios({
+        url: "/problem/problemInfo.json",
+        method: "post",
+        headers: {
+          "Content-Type": "application/json; charset=UTF-8",
+        },
+        data: {
+          prblmId: this.prblm_id.prblm_id,
+        },
+      })
+        .then((response) => {
+          this.problemData = response.data;
+          console.log("problemData", this.problemData);
+          this.sortingProblem();
+        })
+        .catch((error) => {
+          this.state = "noProblem";
+          console.error("Error fetching problemData:", error);
+        });
+    },
+    sortingProblem() {
+      let prblmExpln = this.problemData.problem.prblmExpln;
+      let prblmArr = prblmExpln.split("/");
+      this.answerArr = prblmArr;
+
+      // for (let i = prblmArr.length - 1; i > 0; i--) {
+      //   const j = Math.floor(Math.random() * (i + 1));
+      //   [prblmArr[i], prblmArr[j]] = [prblmArr[j], prblmArr[i]];
+      // }
+
+      // this.prblmArr = prblmArr;
+      // console.log(prblmArr);
+    },
+    nextProblem() {
+      if (
+        this.currentProblemIndex <
+        this.$store.state.currentLearningIds.length - 1
+      ) {
+        this.$store.dispatch("goToNextProblem");
+        this.handleProblemDetail(this.currentLearningId);
+        this.goToPage(this.problemType);
+      } else {
+        // 마지막 문제면 이동
+        this.goToPage("Chapter4");
+      }
+    },
+    previousProblem() {
+      if (this.currentProblemIndex > 0) {
+        this.$store.dispatch("goToPreviousProblem");
+        this.handleProblemDetail(this.currentLearningId);
+        this.goToPage(this.problemType);
+      }
+    },
+
+    handleProblemDetail(item) {
+      if (item.prblm_type_id === "prblm_type_001") {
+        this.problemType = "Chapter3";
+      } else if (item.prblm_type_id === "prblm_type_002") {
+        this.problemType = "Chapter3_1";
+      } else if (item.prblm_type_id === "prblm_type_003") {
+        this.problemType = "Chapter3_2";
+      } else if (item.prblm_type_id === "prblm_type_004") {
+        this.problemType = "Chapter3_3";
+      } else if (item.prblm_type_id === "prblm_type_005") {
+        this.problemType = "Chapter3_3_1";
+      } else if (item.prblm_type_id === "prblm_type_006") {
+        this.problemType = "Chapter3_4";
+      } else if (item.prblm_type_id === "prblm_type_007") {
+        this.problemType = "Chapter3_5";
+      } else if (item.prblm_type_id === "prblm_type_008") {
+        this.problemType = "Chapter3_6";
+      } else if (item.prblm_type_id === "prblm_type_009") {
+        this.problemType = "Chapter3_7";
+      } else if (item.prblm_type_id === "prblm_type_010") {
+        this.problemType = "Chapter3_8";
+      } else if (item.prblm_type_id === "prblm_type_011") {
+        this.problemType = "Chapter3_9";
+      } else if (item.prblm_type_id === "prblm_type_012") {
+        this.problemType = "Chapter3_10";
+      } else if (item.prblm_type_id === "prblm_type_013") {
+        this.problemType = "Chapter3_11";
+      } else if (item.prblm_type_id === "prblm_type_014") {
+        this.problemType = "Chapter3_12";
+      } else if (item.prblm_type_id === "prblm_type_015") {
+        this.problemType = "Chapter3_13";
+      } else if (item.prblm_type_id === "prblm_type_016") {
+        this.problemType = "Chapter3_14";
+      } else if (item.prblm_type_id === "prblm_type_017") {
+        this.problemType = "Chapter3_15";
+      } else if (item.prblm_type_id === "prblm_type_018") {
+        this.problemType = "Chapter2_8";
+      } else if (item.prblm_type_id === "prblm_type_019") {
+        this.problemType = "Chapter2_7";
+      } else if (item.prblm_type_id === "prblm_type_020") {
+        this.problemType = "Chapter2_5";
+      } else if (item.prblm_type_id === "prblm_type_021") {
+        this.problemType = "Chapter2_6";
+      } else if (item.prblm_type_id === "prblm_type_022") {
+        this.problemType = "Chapter2_10";
+      } else if (item.prblm_type_id === "prblm_type_023") {
+        this.problemType = "Chapter2_11";
+      } else if (item.prblm_type_id === "prblm_type_024") {
+        this.problemType = "Chapter2_13";
+      }
+    },
+  },
+  computed: {
+    currentLearningId() {
+      return this.$store.getters.currentLearningId;
+    },
+    currentLabel() {
+      return this.$store.getters.currentLabel;
+    },
+    currentProblemIndex() {
+      return this.$store.getters.currentProblemIndex;
+    },
+    isPreviousButtonDisabled() {
+      return this.currentProblemIndex === 0;
+    },
+  },
+  created() {
+    console.log("Current Learning ID:", this.currentLearningId);
+    this.prblm_id = this.currentLearningId;
+    console.log("Current Label:", this.currentLabel);
+    console.log("Current Problem Index:", this.currentProblemIndex);
+
+    // Fetch or process the current problem based on `currentLearningId`
+  },
+  mounted() {
+    this.fetchProblemData();
+  },
+};
 </script>
 
 <style scoped>
@@ -159,6 +348,6 @@
   padding: 10px 30px;
   border-radius: 10px;
   font-size: 28px;
-  font-family: 'ONEMobilePOPOTF';
+  font-family: "ONEMobilePOPOTF";
 }
 </style>
client/views/pages/main/Chapter/Chapter2_7.vue
--- client/views/pages/main/Chapter/Chapter2_7.vue
+++ client/views/pages/main/Chapter/Chapter2_7.vue
@@ -2,78 +2,129 @@
   <div id="Chapter1_1" class="content-wrap">
     <div style="margin: 30px 0px 50px; width: 20%">
       <router-link to="/MyPlan.page">
-        <div class="logo mb25"><img src="../../../../resources/img/logo2.png" alt=""></div>
+        <div class="logo mb25">
+          <img src="../../../../resources/img/logo2.png" alt="" />
+        </div>
       </router-link>
     </div>
-    <div class="title-box mb25 flex align-center mt40" style="
-    justify-content: space-between;
-">
+    <div
+      class="title-box mb25 flex align-center mt40"
+      style="justify-content: space-between"
+    >
       <div>
         <span class="title mr40">1. Hello WORLD</span>
         <span class="subtitle">my name is dd</span>
       </div>
-      <button class="completeBtn" @click="complete"> 학습 종료 </button>
+      <button class="completeBtn" @click="complete">학습 종료</button>
     </div>
     <div class="flex justify-between align-center">
-      <div class="pre-btn" @click="goToPage('Chapter2_8')"><img src="../../../../resources/img/left.png" alt=""></div>
+      <div class="pre-btn" @click="previousProblem()">
+        <img src="../../../../resources/img/left.png" alt="" />
+      </div>
       <div class="content title-box">
-        <div style="display: flex; justify-content: space-between;">
+        <div style="display: flex; justify-content: space-between">
           <p class="title mt25 title-bg">step3 - 놀면서 배우는 영어</p>
-          <button id="returnButton" @click="returnPage" style="margin: 4rem;">
-            <img src="../../../../resources/img/btn_return_50x50.png" alt="">
+          <button id="returnButton" @click="returnPage" style="margin: 4rem">
+            <img src="../../../../resources/img/btn_return_50x50.png" alt="" />
             <p>되돌리기</p>
           </button>
         </div>
         <div class="flex align-center mb30">
-          <p class="subtitle2 mr20">앗! 다리가 무너져서 건널 수가 없어! 다리 조각을 옮겨줘!</p>
+          <p class="subtitle2 mr20">
+            앗! 다리가 무너져서 건널 수가 없어! 다리 조각을 옮겨줘!
+          </p>
         </div>
 
-        <div class="text-ct flex justify-center" style="gap: 80px;">
+        <div class="text-ct flex justify-center" style="gap: 80px">
           <div class="dropGroup flex align-center justify-center">
-            <div class="flex" style="gap: 20px; position: relative;">
-              <img src="../../../../resources/img/img70_39s.png" alt="">
+            <div class="flex" style="gap: 20px; position: relative">
+              <img src="../../../../resources/img/img70_39s.png" alt="" />
               <div class="textbox">
-                <p style="left: -180px;bottom: -200px;">I</p>
-                <p id="bridgeTarget" style="left: -105px;bottom: -150px;" @dragover.prevent @drop="handleDrop">?</p>
-                <p style="left: -30px;bottom: -65px;">banana</p>
+                <p
+                  v-if="problemArr.length > 0"
+                  style="left: -180px; bottom: -200px"
+                >
+                  {{ problemArr[0] }}
+                </p>
+                <p
+                  v-if="problemArr.length > 1"
+                  id="bridgeTarget"
+                  style="left: -105px; bottom: -150px"
+                  @dragover.prevent
+                  @drop="handleDrop"
+                >
+                  {{ problemArr[1] }}
+                </p>
+                <p
+                  v-if="problemArr.length > 2"
+                  style="left: -30px; bottom: -65px"
+                >
+                  {{ problemArr[2] }}
+                </p>
               </div>
             </div>
           </div>
           <div class="dragGroup mt40">
             <div>
-              <button id="have" draggable="true" @dragstart="handleDragStart">
-                <img src="../../../../resources/img/img71_39s.png" alt="">
-                <p>have</p>
+              <button
+                v-if="answerArr.length > 0 && answerArr[0].prblmDtlExpln"
+                :id="answerArr[0].prblmDtlExpln"
+                draggable="true"
+                @dragstart="handleDragStart"
+              >
+                <img src="../../../../resources/img/img71_39s.png" alt="" />
+                <p>{{ answerArr[0].prblmDtlExpln }}</p>
               </button>
-              <button id="has" draggable="true" @dragstart="handleDragStart">
-                <img src="../../../../resources/img/img71_39s.png" alt="">
-                <p>has</p>
+              <button
+                v-if="answerArr.length > 1 && answerArr[1].prblmDtlExpln"
+                :id="answerArr[1].prblmDtlExpln"
+                draggable="true"
+                @dragstart="handleDragStart"
+              >
+                <img src="../../../../resources/img/img71_39s.png" alt="" />
+                <p>{{ answerArr[1].prblmDtlExpln }}</p>
               </button>
-              <button id="had" draggable="true" @dragstart="handleDragStart">
-                <img src="../../../../resources/img/img71_39s.png" alt="">
-                <p>had</p>
+              <button
+                v-if="answerArr.length > 2 && answerArr[2].prblmDtlExpln"
+                :id="answerArr[2].prblmDtlExpln"
+                draggable="true"
+                @dragstart="handleDragStart"
+              >
+                <img src="../../../../resources/img/img71_39s.png" alt="" />
+                <p>{{ answerArr[2].prblmDtlExpln }}</p>
               </button>
             </div>
           </div>
         </div>
       </div>
-      <div class="next-btn" @click="goToPage('Chapter2_5')"><img src="../../../../resources/img/right.png" alt=""></div>
+      <div class="next-btn" @click="nextProblem()">
+        <img src="../../../../resources/img/right.png" alt="" />
+      </div>
     </div>
   </div>
 </template>
 
 <script>
+import axios from "axios";
+
 export default {
   data() {
     return {
       draggedElementId: null, // 드래그한 요소의 ID를 저장
-      correctAnswer: "have",  // 정답 설정
+      correctAnswer: "", // 정답 설정
+      prblm_id: [],
+      problemData: [],
+      problemArr: [],
+      answerArr: [],
     };
   },
   methods: {
     complete() {
       const { unit_id, book_id } = this.$route.query;
-      this.$router.push({ name: 'Dashboard', query: { value: 4, unit_id, book_id } });
+      this.$router.push({
+        name: "Dashboard",
+        query: { value: 4, unit_id, book_id },
+      });
     },
     goToPage(page) {
       this.$router.push({ name: page });
@@ -93,7 +144,7 @@
       if (draggedElement) {
         // 새로운 버튼을 드롭 영역에 추가
         const cloneElement = draggedElement.cloneNode(true);
-        cloneElement.style.position = 'absolute';
+        cloneElement.style.position = "absolute";
         cloneElement.style.top = "-70px";
         cloneElement.style.left = "-50px";
         dropZone.innerHTML = ""; // 기존 ? 텍스트 제거
@@ -106,22 +157,167 @@
         setTimeout(() => {
           if (this.draggedElementId === this.correctAnswer) {
             alert("정답입니다!");
-
           } else {
             alert("오답입니다!");
-            window.location.reload();
+            // window.location.reload();
           }
 
           // 드래그 상태 초기화
           this.draggedElementId = null;
         }, 0);
       }
-    }
+    },
+
+    fetchProblemData() {
+      axios({
+        url: "/problem/problemInfo.json",
+        method: "post",
+        headers: {
+          "Content-Type": "application/json; charset=UTF-8",
+        },
+        data: {
+          prblmId: this.prblm_id.prblm_id,
+        },
+      })
+        .then((response) => {
+          this.problemData = response.data;
+          console.log("problemData", this.problemData);
+          this.sortingProblem();
+        })
+        .catch((error) => {
+          this.state = "noProblem";
+          console.error("Error fetching problemData:", error);
+        });
+    },
+    sortingProblem() {
+      let prblmExpln = this.problemData.problem.prblmExpln;
+      let prblmArr = prblmExpln.split("/");
+      this.problemArr = prblmArr;
+
+      for (let i = 0; i < this.problemData.problemDetail.length; i++) {
+        // this.answerArr[i].prblmDtlExpln =
+        //   this.problemData.problemDetail[i].prblmDtlExpln;
+        // this.answerArr[i].prblmYn = this.problemData.problemDetail[i].prblmYn;
+        this.answerArr[i] = this.problemData.problemDetail[i];
+      }
+      console.log("answerArr", this.answerArr);
+
+      for (let i = 0; i < this.answerArr.length; i++) {
+        if (this.answerArr[i].prblmYn == "Y") {
+          this.correctAnswer = this.answerArr[i].prblmDtlExpln;
+          break;
+        }
+      }
+
+      // for (let i = prblmArr.length - 1; i > 0; i--) {
+      //   const j = Math.floor(Math.random() * (i + 1));
+      //   [prblmArr[i], prblmArr[j]] = [prblmArr[j], prblmArr[i]];
+      // }
+
+      // this.prblmArr = prblmArr;
+      // console.log(prblmArr);
+    },
+
+    nextProblem() {
+      if (
+        this.currentProblemIndex <
+        this.$store.state.currentLearningIds.length - 1
+      ) {
+        this.$store.dispatch("goToNextProblem");
+        this.handleProblemDetail(this.currentLearningId);
+        this.goToPage(this.problemType);
+      } else {
+        // 마지막 문제면 이동
+        this.goToPage("Chapter4");
+      }
+    },
+    previousProblem() {
+      if (this.currentProblemIndex > 0) {
+        this.$store.dispatch("goToPreviousProblem");
+        this.handleProblemDetail(this.currentLearningId);
+        this.goToPage(this.problemType);
+      }
+    },
+
+    handleProblemDetail(item) {
+      if (item.prblm_type_id === "prblm_type_001") {
+        this.problemType = "Chapter3";
+      } else if (item.prblm_type_id === "prblm_type_002") {
+        this.problemType = "Chapter3_1";
+      } else if (item.prblm_type_id === "prblm_type_003") {
+        this.problemType = "Chapter3_2";
+      } else if (item.prblm_type_id === "prblm_type_004") {
+        this.problemType = "Chapter3_3";
+      } else if (item.prblm_type_id === "prblm_type_005") {
+        this.problemType = "Chapter3_3_1";
+      } else if (item.prblm_type_id === "prblm_type_006") {
+        this.problemType = "Chapter3_4";
+      } else if (item.prblm_type_id === "prblm_type_007") {
+        this.problemType = "Chapter3_5";
+      } else if (item.prblm_type_id === "prblm_type_008") {
+        this.problemType = "Chapter3_6";
+      } else if (item.prblm_type_id === "prblm_type_009") {
+        this.problemType = "Chapter3_7";
+      } else if (item.prblm_type_id === "prblm_type_010") {
+        this.problemType = "Chapter3_8";
+      } else if (item.prblm_type_id === "prblm_type_011") {
+        this.problemType = "Chapter3_9";
+      } else if (item.prblm_type_id === "prblm_type_012") {
+        this.problemType = "Chapter3_10";
+      } else if (item.prblm_type_id === "prblm_type_013") {
+        this.problemType = "Chapter3_11";
+      } else if (item.prblm_type_id === "prblm_type_014") {
+        this.problemType = "Chapter3_12";
+      } else if (item.prblm_type_id === "prblm_type_015") {
+        this.problemType = "Chapter3_13";
+      } else if (item.prblm_type_id === "prblm_type_016") {
+        this.problemType = "Chapter3_14";
+      } else if (item.prblm_type_id === "prblm_type_017") {
+        this.problemType = "Chapter3_15";
+      } else if (item.prblm_type_id === "prblm_type_018") {
+        this.problemType = "Chapter2_8";
+      } else if (item.prblm_type_id === "prblm_type_019") {
+        this.problemType = "Chapter2_7";
+      } else if (item.prblm_type_id === "prblm_type_020") {
+        this.problemType = "Chapter2_5";
+      } else if (item.prblm_type_id === "prblm_type_021") {
+        this.problemType = "Chapter2_6";
+      } else if (item.prblm_type_id === "prblm_type_022") {
+        this.problemType = "Chapter2_10";
+      } else if (item.prblm_type_id === "prblm_type_023") {
+        this.problemType = "Chapter2_11";
+      } else if (item.prblm_type_id === "prblm_type_024") {
+        this.problemType = "Chapter2_13";
+      }
+    },
+  },
+  computed: {
+    currentLearningId() {
+      return this.$store.getters.currentLearningId;
+    },
+    currentLabel() {
+      return this.$store.getters.currentLabel;
+    },
+    currentProblemIndex() {
+      return this.$store.getters.currentProblemIndex;
+    },
+    isPreviousButtonDisabled() {
+      return this.currentProblemIndex === 0;
+    },
+  },
+  created() {
+    console.log("Current Learning ID:", this.currentLearningId);
+    this.prblm_id = this.currentLearningId;
+    console.log("Current Label:", this.currentLabel);
+    console.log("Current Problem Index:", this.currentProblemIndex);
+
+    // Fetch or process the current problem based on `currentLearningId`
+  },
+  mounted() {
+    this.fetchProblemData();
   },
 };
 </script>
-
-
 
 <style scoped>
 .textbox p {
@@ -140,7 +336,7 @@
   border-radius: 5px;
   padding: 10px;
   font-size: 30px;
-  font-family: 'ONEMobilePOP';
+  font-family: "ONEMobilePOP";
 }
 
 .dragGroup button {
@@ -157,6 +353,6 @@
   padding: 10px 30px;
   border-radius: 10px;
   font-size: 28px;
-  font-family: 'ONEMobilePOPOTF';
+  font-family: "ONEMobilePOPOTF";
 }
 </style>
client/views/pages/main/Chapter/Chapter2_8.vue
--- client/views/pages/main/Chapter/Chapter2_8.vue
+++ client/views/pages/main/Chapter/Chapter2_8.vue
@@ -18,7 +18,7 @@
       <button class="completeBtn" @click="complete">학습 종료</button>
     </div>
     <div class="flex justify-between align-center">
-      <div class="pre-btn" @click="goToPage('Chapter2_4')">
+      <div class="pre-btn" @click="previousProblem()">
         <img src="../../../../resources/img/left.png" alt="" />
       </div>
       <div class="content title-box">
@@ -99,7 +99,7 @@
           </div>
         </div>
       </div>
-      <div class="next-btn" @click="goToPage('Chapter2_7')">
+      <div class="next-btn" @click="nextProblem()">
         <img src="../../../../resources/img/right.png" alt="" />
       </div>
     </div>
@@ -115,8 +115,9 @@
       draggedElement: null, // 현재 드래그 중인 요소
       prblm_id: [],
       problemData: [],
-      // prblmArr: [],
       answerArr: [],
+
+      // prblmArr: [],
     };
   },
   methods: {
@@ -176,16 +177,89 @@
           this.draggedElement.style.display = "none";
         } else {
           // 정답이 아닌 경우
-          alert("오답입니다!"); // 오답 경고 메시지
+          alert("오답입니다! 다시 시도해보세요."); // 오답 경고 메시지
         }
       }
 
       this.draggedElement = null; // 드래그 상태 초기화
     },
     storeProblemId() {
-      this.prblm_id = this.$store.getters.getLearningId;
+      this.prblm_id = this.$store.getters.currentLearningId;
       console.log("prblm_id", this.prblm_id);
-      this.fetchProblemData();
+      this.problemData = this.prblm_id;
+      // this.fetchProblemData();
+    },
+    nextProblem() {
+      if (
+        this.currentProblemIndex <
+        this.$store.state.currentLearningIds.length - 1
+      ) {
+        this.$store.dispatch("goToNextProblem");
+        this.handleProblemDetail(this.currentLearningId);
+        this.goToPage(this.problemType);
+      } else {
+        // 마지막 문제면 이동
+        this.goToPage("Chapter4");
+      }
+    },
+    previousProblem() {
+      if (this.currentProblemIndex > 0) {
+        this.$store.dispatch("goToPreviousProblem");
+        this.handleProblemDetail(this.currentLearningId);
+        this.goToPage(this.problemType);
+      }
+    },
+
+    handleProblemDetail(item) {
+      if (item.prblm_type_id === "prblm_type_001") {
+        this.problemType = "Chapter3";
+      } else if (item.prblm_type_id === "prblm_type_002") {
+        this.problemType = "Chapter3_1";
+      } else if (item.prblm_type_id === "prblm_type_003") {
+        this.problemType = "Chapter3_2";
+      } else if (item.prblm_type_id === "prblm_type_004") {
+        this.problemType = "Chapter3_3";
+      } else if (item.prblm_type_id === "prblm_type_005") {
+        this.problemType = "Chapter3_3_1";
+      } else if (item.prblm_type_id === "prblm_type_006") {
+        this.problemType = "Chapter3_4";
+      } else if (item.prblm_type_id === "prblm_type_007") {
+        this.problemType = "Chapter3_5";
+      } else if (item.prblm_type_id === "prblm_type_008") {
+        this.problemType = "Chapter3_6";
+      } else if (item.prblm_type_id === "prblm_type_009") {
+        this.problemType = "Chapter3_7";
+      } else if (item.prblm_type_id === "prblm_type_010") {
+        this.problemType = "Chapter3_8";
+      } else if (item.prblm_type_id === "prblm_type_011") {
+        this.problemType = "Chapter3_9";
+      } else if (item.prblm_type_id === "prblm_type_012") {
+        this.problemType = "Chapter3_10";
+      } else if (item.prblm_type_id === "prblm_type_013") {
+        this.problemType = "Chapter3_11";
+      } else if (item.prblm_type_id === "prblm_type_014") {
+        this.problemType = "Chapter3_12";
+      } else if (item.prblm_type_id === "prblm_type_015") {
+        this.problemType = "Chapter3_13";
+      } else if (item.prblm_type_id === "prblm_type_016") {
+        this.problemType = "Chapter3_14";
+      } else if (item.prblm_type_id === "prblm_type_017") {
+        this.problemType = "Chapter3_15";
+      } else if (item.prblm_type_id === "prblm_type_018") {
+        this.problemType = "Chapter2_8";
+      } else if (item.prblm_type_id === "prblm_type_019") {
+        this.problemType = "Chapter2_7";
+      } else if (item.prblm_type_id === "prblm_type_020") {
+        this.problemType = "Chapter2_5";
+      } else if (item.prblm_type_id === "prblm_type_021") {
+        this.problemType = "Chapter2_6";
+      } else if (item.prblm_type_id === "prblm_type_022") {
+        this.problemType = "Chapter2_10";
+      } else if (item.prblm_type_id === "prblm_type_023") {
+        this.problemType = "Chapter2_11";
+      } else if (item.prblm_type_id === "prblm_type_024") {
+        this.problemType = "Chapter2_13";
+      }
     },
 
     fetchProblemData() {
@@ -196,7 +270,7 @@
           "Content-Type": "application/json; charset=UTF-8",
         },
         data: {
-          prblmId: this.prblm_id[2].prblm_id,
+          prblmId: this.prblm_id.prblm_id,
         },
       })
         .then((response) => {
@@ -224,8 +298,32 @@
       // console.log(prblmArr);
     },
   },
+  computed: {
+    currentLearningId() {
+      return this.$store.getters.currentLearningId;
+    },
+    currentLabel() {
+      return this.$store.getters.currentLabel;
+    },
+    currentProblemIndex() {
+      return this.$store.getters.currentProblemIndex;
+    },
+    isPreviousButtonDisabled() {
+      return this.currentProblemIndex === 0;
+    },
+  },
+  created() {
+    console.log("Current Learning ID:", this.currentLearningId);
+    this.prblm_id = this.currentLearningId;
+    console.log("Current Label:", this.currentLabel);
+    console.log("Current Problem Index:", this.currentProblemIndex);
+
+    // Fetch or process the current problem based on `currentLearningId`
+  },
   mounted() {
-    this.storeProblemId();
+    this.fetchProblemData();
+    // this.storeProblemId();
+    // this.storeLearningId();
     this.$route.query;
     // 드래그 가능한 요소에 드래그 시작 및 종료 이벤트 추가
     document.querySelectorAll(".draggable").forEach((button) => {
Add a comment
List