jichoi / lms_front star
이은진 이은진 2024-08-23
240823 이은진 문제 2_11
@4ae6a8f929508757babdcdfa948dcf721ad01bc6
client/views/pages/main/Chapter/Chapter2_11.vue
--- client/views/pages/main/Chapter/Chapter2_11.vue
+++ client/views/pages/main/Chapter/Chapter2_11.vue
@@ -17,7 +17,7 @@
       <button class="completeBtn" @click="complete"> 학습 종료 </button>
     </div>
     <div class="flex justify-between align-center">
-      <div class="pre-btn" @click="goToPage('Chapter2_10')">
+      <div class="pre-btn" @click="previousProblem()">
         <img src="../../../../resources/img/left.png" alt="" />
       </div>
       <div class="content title-box">
@@ -73,7 +73,7 @@
           </div>
         </div>
       </div>
-      <div class="next-btn" @click="goToPage('Chapter2_13')">
+      <div class="next-btn" @click="nextProblem()">
         <img src="../../../../resources/img/right.png" alt="" />
       </div>
     </div>
@@ -81,6 +81,7 @@
 </template>
 
 <script>
+import axios from "axios";
 export default {
   data() {
     return {
@@ -89,8 +90,12 @@
       beforeQuestion: "I",
       afterQuestion: "very hungry.",
 
-      choice: ["am", "is"],
+      choice: [],
       answer: 1,
+
+      prblm_id: [],
+      unit_id: null,
+      dataList: [],
     };
   },
   methods: {
@@ -122,11 +127,145 @@
     returnPage() {
       window.location.reload();
     },
+    splitExample() {
+      const parts = this.example.split("/?/");
+      if (parts.length === 2) {
+        this.beforeQuestion = parts[0];
+        this.afterQuestion = parts[1];
+      }
+    },
+    getProblem() {
+      const vm = this;
+      // const prblmId = this.currentLearningId.prblm_id;
+      const prblmId = "PROBLEM_000000000000076"
+      axios({
+        url: "problem/problemInfo.json",
+        method: "post",
+        headers: {
+          "Content-Type": "application/json; charset=UTF-8",
+        },
+        data: {
+          prblmId: prblmId,
+        },
+      })
+        .then(function (res) {
+          console.log("problem - response : ", res.data);
+          vm.dataList = res.data.problem;
+          vm.problemDetail = res.data.problemDetail;
+          vm.example = vm.dataList.prblmExpln;
+          vm.problemDetail.forEach((detail, index) => {
+            vm.choice.push(detail.prblmDtlExpln);
+            if (detail.prblmYn === "Y") {
+              vm.answer = index + 1;
+            }
+          });
+
+          console.log(vm.example)
+          console.log(vm.choice)
+          console.log(vm.answer)
+          vm.splitExample();
+
+        })
+        .catch(function (error) {
+          console.log("problem - error : ", error);
+        });
+    },
+    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";
+      }
+    },
   },
   watch: {},
   computed: {},
-  components: {},
-  mounted() { },
+  components: {
+    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);
+    console.log('Current Label:', this.currentLabel);
+    console.log('Current Problem Index:', this.currentProblemIndex);
+
+    // Fetch or process the current problem based on `currentLearningId`
+  },
+  mounted() {
+    this.getProblem()
+  },
 };
 </script>
 <style scoped>
Add a comment
List