jichoi / lms_front star
PsHooN7979 2024-08-22
240822 박세훈 Chapter3관련 Dashboard, AppStore 수정
@1ec532241e1a080ddb1c4f9dff85d4ba09843ec3
client/views/pages/AppStore.js
--- client/views/pages/AppStore.js
+++ client/views/pages/AppStore.js
@@ -9,7 +9,10 @@
         schdlId: null,
         bookId: null,
         unitId: null,
-        learningId: null,
+        LearningId: null,
+        currentLearningIds: [], // Stores multiple learning_ids (prblm_id)
+        currentLabel: null,
+        currentProblemIndex: 0,
     },
     getters: {
         isLoggedIn(state) {
@@ -36,6 +39,11 @@
         getLearningId(state) {
             return state.learningId;
         },
+        currentLearningId(state) {
+            return state.currentLearningIds[state.currentProblemIndex];
+        },
+        currentLabel: state => state.currentLabel,
+        currentProblemIndex: state => state.currentProblemIndex
     },
     mutations: {
         setToken(state, token) {
@@ -72,6 +80,21 @@
         setLearningId(state, learningId) {
             state.learningId = learningId;
         },
+        setLearningData(state, payload) {
+            state.currentLearningIds = payload.learning_id; // Array of IDs
+            state.currentLabel = payload.label;
+            state.currentProblemIndex = 0; // Reset to the first problem
+        },
+        incrementProblemIndex(state) {
+            if (state.currentProblemIndex < state.currentLearningIds.length - 1) {
+                state.currentProblemIndex++;
+            }
+        },
+        decrementProblemIndex(state) {
+            if (state.currentProblemIndex > 0) {
+                state.currentProblemIndex--;
+            }
+        }
     },
     actions: {
         login({ commit }, token) {
@@ -109,5 +132,14 @@
         updateLearningId({ commit }, learningId) {
             commit("setLearningId", learningId);
         },
+        updateLearningData({ commit }, payload) {
+            commit('setLearningData', payload);
+        },
+        goToNextProblem({ commit }) {
+            commit('incrementProblemIndex');
+        },
+        goToPreviousProblem({ commit }) {
+            commit('decrementProblemIndex');
+        }
     },
 });
client/views/pages/main/Chapter/Chapter3.vue
--- client/views/pages/main/Chapter/Chapter3.vue
+++ client/views/pages/main/Chapter/Chapter3.vue
@@ -88,6 +88,7 @@
             timer: "00",
             selectedButton: null, // 선택한 버튼
             prblm_id: [],
+            unit_id: null,
         };
     },
     methods: {
@@ -118,21 +119,18 @@
         handleSubmit() {
             console.log("선택된 번호 : ", this.selectedButton);
         },
-        storeProblemId() {
-            this.prblm_id = this.$store.getters.getLearningId
-            console.log("prblm_id", this.prblm_id)
-        }
     },
     watch: {},
     computed: {
-        // learningId() {
-        //     this.$store.getters.getLearningId
-        // },
+        learningId() {
+            return this.$store.getters.getLearningId
+        },
+    },
+    created() {
+        this.prblm_id = this.learningId
     },
     components: {},
-    mounted() {
-        this.storeProblemId();
-    },
+    mounted() { },
 };
 </script>
 <style scoped>
client/views/pages/main/Chapter/Chapter3_1.vue
--- client/views/pages/main/Chapter/Chapter3_1.vue
+++ client/views/pages/main/Chapter/Chapter3_1.vue
@@ -10,7 +10,8 @@
       <span class="subtitle">my name is dd</span>
     </div>
     <div class="flex justify-between align-center">
-      <div class="pre-btn" @click="goToPage('Chapter3')"><img src="../../../../resources/img/left.png" alt="" /></div>
+      <div class="pre-btn" @click="g[oToPage('Chapter3'), previousProblem]"><img
+          src="../../../../resources/img/left.png" alt="" /></div>
       <div class="content title-box">
         <p class="title mt25 title-bg">step3.</p>
         <div class="flex align-center mb30">
@@ -49,7 +50,9 @@
         </div>
         <button class="submit-button" @click="handleSubmit()">제출하기</button>
       </div>
-      <div class="next-btn" @click="goToPage('Chapter3_2')"><img src="../../../../resources/img/right.png" alt="" /></div>
+      <div class="next-btn" @click="[goToPage('Chapter3_2'), nextProblem()]"><img
+          src="../../../../resources/img/right.png" alt="" />
+      </div>
     </div>
   </div>
 </template>
@@ -66,7 +69,7 @@
   },
   methods: {
     goToPage(page) {
-      this.$router.push({ name: page });
+      // this.$router.push({ name: page });
     },
     startTimer() {
       if (this.intervalId) {
@@ -88,17 +91,42 @@
     handleSubmit() {
       console.log("선택된 번호 : ", this.selectedButton);
     },
+    nextProblem() {
+      this.$store.dispatch('goToNextProblem')
+      console.log('Current Problem Index:', this.currentProblemIndex);
+    },
+    previousProblem() {
+      this.$store.dispatch('goToPreviousProblem');
+    }
   },
   watch: {},
-  computed: {},
+  computed: {
+    currentLearningId() {
+      return this.$store.getters.currentLearningId;
+    },
+    currentLabel() {
+      return this.$store.getters.currentLabel;
+    },
+    currentProblemIndex() {
+      return this.$store.getters.currentProblemIndex;
+    }
+  },
+  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`
+  },
   components: {},
-  mounted() {},
+  mounted() { },
 };
 </script>
 <style scoped>
 .imgGroup {
   width: fit-content;
 }
+
 .imgGroup button {
   position: relative;
 }
client/views/pages/main/Dashboard.vue
--- client/views/pages/main/Dashboard.vue
+++ client/views/pages/main/Dashboard.vue
@@ -41,7 +41,7 @@
                     </div>
                 </div>
                 <div class="lcon flex justify-between mb5">
-                    <div class="race-btn" @click="[goToPage('Chapter3'), storeLearningId(labeledItems[6].learning_id)]">
+                    <div class="race-btn" @click="[storeLearningId(labeledItems[6]), viewDetail(item)]">
                         <div class="rabbit-running"><img src="../../../resources/img/img09_s.png" alt=""
                                 :style="{ display: rabbitPos[7] ? 'block' : 'none' }"></div>
                         <button class="popTxt" v-for="(item, index) in items" :key="index" @click="toggleImage(index)"
@@ -53,7 +53,8 @@
                         </button>
                         <p>{{ labeledItems[6].label }}</p>
                     </div>
-                    <div class="race-btn" @click="[goToPage('Chapter6'), storeLearningId(labeledItems[5].learning_id)]">
+                    <div class="race-btn"
+                        @click="[goToPage('Chapter2_8'), storeLearningId(labeledItems[5].learning_id)]">
                         <div class="rabbit-running"><img src="../../../resources/img/img09_s.png" alt=""
                                 :style="{ display: rabbitPos[6] ? 'block' : 'none' }"></div>
                         <button class="popTxt" v-for="(item, index) in items" :key="index" @click="toggleImage(index)"
@@ -340,6 +341,8 @@
             ],
 
             isHeartFilled: false, // 하트가 채워졌는지 여부
+
+            problemType: null,
         }
     },
     methods: {
@@ -586,10 +589,50 @@
             // this.$router.push({ name: page, query: { unit_id, book_id } });
             this.$router.push({ name: page });
         },
-        storeLearningId(learningId) {
-            // console.log(learningId)
-            this.$store.dispatch('updateLearningId', learningId);
-            // console.log(this.$store.getters.getLearningId)
+        storeLearningId(labeledItems) {
+            this.$store.dispatch('updateLearningData', labeledItems)
+            if (labeledItems.label === "문제3") {
+                axios({
+                    url: "problem/problemInfo.json",
+                    method: "post",
+                    headers: {
+                        "Content-Type": "application/json; charset=UTF-8",
+                    },
+                    data: {
+                        prblmId: this.$store.getters.currentLearningId.prblm_id,
+                    },
+                })
+                    .then(response => {
+                        this.handleProblemDetail(response.data.problem);
+                        this.goToPage(this.problemType);
+                    })
+            }
+        },
+        handleProblemDetail(item) {
+            console.log(item);
+            if (item.prblmTypeId === "prblm_type_001") {
+                this.problemType = "Chapter3";
+            } else if (item.prblmTypeId === "prblm_type_002") {
+                this.problemType = "Chapter3_1";
+            } else if (item.prblmTypeId === "prblm_type_003") {
+                this.problemType = "Chapter3_2";
+            } else if (item.prblmTypeId === "prblm_type_004") {
+                this.problemType = "Chapter3_3";
+            } else if (item.prblmTypeId === "prblm_type_005") {
+                this.problemType = "Chapter3_3_1";
+            } else if (item.prblmTypeId === "prblm_type_006") {
+                this.problemType = "Chapter3_4";
+            } else if (item.prblmTypeId === "prblm_type_007") {
+                this.problemType = "Chapter3_5";
+            } else if (item.prblmTypeId === "prblm_type_008") {
+                this.problemType = "Chapter3_6";
+            } else if (item.prblmTypeId === "prblm_type_009") {
+                this.problemType = "Chapter3_7";
+            } else if (item.prblmTypeId === "prblm_type_010") {
+                this.problemType = "Chapter3_8";
+            } else if (item.prblmTypeId === "prblm_type_011") {
+                this.problemType = "Chapter3_9";
+            }
         },
         openCameraModal() {
             this.closeModal();
Add a comment
List