jichoi / lms_front star
권지수 2024-08-13
240813 권지수 선생님 문제 목록 페이지
@6908b9c1a99f18bcc3a448dc4e85d09606725c70
client/views/pages/teacher/QuestionDetail.vue
--- client/views/pages/teacher/QuestionDetail.vue
+++ client/views/pages/teacher/QuestionDetail.vue
@@ -1,83 +1,6 @@
 <template>
     <div class="title-box flex justify-between mb40">
-<<<<<<< HEAD
         <p class="title">문제 조회</p>
-    </div>
-    <div class="board-wrap">
-        <div class="flex align-center">
-            <label for="" class="title2">문제</label>
-            <p class="data-wrap">{{ questionExpln }}</p>
-        </div>
-        <hr>
-        <div class="flex align-center">
-            <label for="" class="title2">유형</label>
-            <p class="data-wrap">{{ questionTypeId }}</p>
-        </div>
-        <div class="flex align-center">
-            <label for="" class="title2">카테고리</label>
-            <p class="data-wrap">{{ questionCategoryId }}</p>
-        </div>
-        <div class="flex align-center">
-            <label for="" class="title2">사용자 아이디</label>
-            <p class="data-wrap">{{ userId }}</p>
-        </div>
-        <div class="flex align-center">
-            <label for="" class="title2">책 아이디</label>
-            <p class="data-wrap">{{ bookId }}</p>
-        </div>
-        <div class="flex align-center">
-            <label for="" class="title2">단원 아이디</label>
-            <p class="data-wrap">{{ unitId }}</p>
-        </div>
-        <hr>
-        <div class="flex align-center">
-            <label for="" class="title2">문제 점수</label>
-            <p class="data-wrap">{{ questionScore }}</p>
-        </div>
-        <div class="flex align-center">
-            <label for="" class="title2">문제 힌트</label>
-            <p class="data-wrap">{{ questionHint }}</p>
-        </div>
-        <div class="flex align-center">
-            <label for="" class="title2">문제 해설</label>
-            <p class="data-wrap">{{ questionExplanation }}</p>
-        </div>
-        <hr>
-        <div class="flex align-center">
-            <label for="" class="title2">첨부파일</label>
-            <p class="data-wrap">{{ questionFile }}</p>
-        </div>
-        <div class="flex align-center mb20">
-            <label for="" class="title2">답</label>
-            <p class="data-wrap">{{ questionAnswer }}</p>
-        </div>
-        <div>
-            <label for="" class="title2">오답 학생</label>
-            <div class="table-wrap mt20">
-                <table>
-                    <thead>
-                        <tr>
-                            <td>No.</td>
-                            <td>이름</td>
-                            <td>학년</td>
-                            <td>반</td>
-                            <td>오답</td>
-                        </tr>
-                    </thead>
-                    <tbody>
-                        <tr v-for="(student, index) in wrongStudents" :key="index" @click="goToPage('noticeDetail')">
-                            <td>{{ index + 1 }}</td>
-                            <td>{{ student.name }}</td>
-                            <td>{{ student.grade }}</td>
-                            <td>{{ student.class }}</td>
-                            <td>{{ student.wrongAnswer }}</td>
-                        </tr>
-                    </tbody>
-                </table>
-            </div>
-        </div>
-=======
-        <p class="title">문제 등록</p>
     </div>
     <div class="board-wrap">
         <div class="tab-box" >
@@ -257,37 +180,18 @@
             </div>
        </div>
        
->>>>>>> e47769b90c7ad4f0b34f38bb2a56a8a69a894941
     </div>
     <div class="flex justify-between mt50">
         <button type="button" title="글쓰기" class="new-btn" @click="goToPage('QuestionList')">
             목록
         </button>
         <div class="flex">
-<<<<<<< HEAD
-            <button type="button" title="글쓰기" class="new-btn mr10" @click="editQuestion">
-                수정
-            </button>
-            <button type="button" title="글쓰기" class="new-btn" @click="confirmDelete">
-                삭제
-            </button>
-        </div>
-    </div>
-
-    <!-- 모달 창 -->
-    <div v-if="showModal" class="modal-overlay">
-        <div class="modal-content">
-            <p>삭제하시겠습니까?</p>
-            <button @click="deleteQuestion">예, 삭제</button>
-            <button @click="cancelDelete">취소</button>
-=======
             <button type="button" title="글쓰기" class="new-btn mr10">
                 삭제
             </button>
             <button type="button" title="글쓰기" class="new-btn">
                 수정
             </button>
->>>>>>> e47769b90c7ad4f0b34f38bb2a56a8a69a894941
         </div>
     </div>
 </template>
@@ -295,152 +199,29 @@
 <script>
 import SvgIcon from '@jamescoyle/vue-icon';
 import { mdiMagnify } from '@mdi/js';
-<<<<<<< HEAD
-import axios from 'axios';
-=======
-
->>>>>>> e47769b90c7ad4f0b34f38bb2a56a8a69a894941
 
 export default {
     data() {
         return {
             mdiMagnify: mdiMagnify,
-<<<<<<< HEAD
-            questionTitle: '샘플 제목',
-            questionExpln: '샘플 내용',
-            questionFile: null, // 파일 URL을 여기에 저장
-            questionAnswer: '샘플 답',
-            wrongStudents: [],
-            showModal: false,
-            parsedData: null, // parsedData 추가
-            questionTypeId: '',
-            questionCategoryId: '',
-            userId: '',
-            bookId: '',
-            unitId: '',
-            questionScore: '',
-            questionHint: '',
-            questionExplanation: ''
-=======
             selectedTab: 'tab1',
->>>>>>> e47769b90c7ad4f0b34f38bb2a56a8a69a894941
         }
     },
     methods: {
         goToPage(page) {
             this.$router.push({ name: page });
         },
-<<<<<<< HEAD
-        editQuestion() {
-            // 수정 로직 추가
-            console.log('수정 버튼 클릭');
-        },
-        confirmDelete() {
-            this.showModal = true;
-        },
-        async deleteQuestion() {
-            try {
-                const prblmId = this.parsedData.prblmId; // this.parsedData 사용
-                const response = await axios.post('/problem/deleteProblem.json', { prblmId : prblmId });
-                console.log('삭제 완료:', response.data);
-                this.showModal = false;
-                this.goToPage('QuestionList');
-            } catch (error) {
-                console.error('삭제 실패:', error);
-            }
-        },
-        cancelDelete() {
-            this.showModal = false;
-        },
-        loadFromLocalStorage() {
-            const data = sessionStorage.getItem('selectQuestionList');
-            if (data) {
-                this.parsedData = JSON.parse(data); // this.parsedData 설정
-                console.log('Loaded data from local storage:', this.parsedData);
-                
-                this.questionExpln = this.parsedData.prblmExpln || '내용 없음';
-                this.questionFile = this.parsedData.fileMngId || '첨부파일 없음'; // 파일 경로는 실제 경로에 맞게 수정
-                this.questionAnswer = this.parsedData.prblmCmmt || '답 없음';
-                this.wrongStudents = this.parsedData.wrongStudents || [];
-                this.questionTypeId = this.parsedData.prblmTypeId || '유형 아이디 없음';
-                this.questionCategoryId = this.parsedData.prblmCtgryId || '카테고리 아이디 없음';
-                this.userId = this.parsedData.userId || '사용자 아이디 없음';
-                this.bookId = this.parsedData.bookId || '책 아이디 없음';
-                this.unitId = this.parsedData.unitId || '단원 아이디 없음';
-                this.questionScore = this.parsedData.prblmScr || '점수 없음',
-                this.questionHint = this.parsedData.prblmHint || '힌트 없음',
-                this.questionExplanation = this.parsedData.prblmExpln || '해설 없음'
-            } else {
-                console.log('No data found in local storage');
-            }
-        },
-        downloadFile() {
-            window.open(this.questionFile, '_blank');
-        },
-        getProblemId() {
-            // 문제 ID를 얻는 로직을 추가하세요
-            return 'sampleProblemId';
-        }
-=======
     },
     watch: {
 
     },
     computed: {
 
->>>>>>> e47769b90c7ad4f0b34f38bb2a56a8a69a894941
     },
     components: {
         SvgIcon
     },
     mounted() {
-<<<<<<< HEAD
-        this.loadFromLocalStorage();
-    }
-}
-</script>
-
-<style>
-    .data-wrap {
-        width: -webkit-fill-available;
-        padding: 1.2rem;
-    }
-    .download-btn {
-        background-color: #007bff;
-        color: white;
-        border: none;
-        padding: 10px 20px;
-        cursor: pointer;
-        text-decoration: none;
-        font-size: 1rem;
-    }
-    .download-btn:hover {
-        background-color: #0056b3;
-    }
-    .modal-overlay {
-        position: fixed;
-        top: 0;
-        left: 0;
-        width: 100%;
-        height: 100%;
-        background-color: rgba(0, 0, 0, 0.5);
-        display: flex;
-        justify-content: center;
-        align-items: center;
-    }
-    .modal-content {
-        background-color: white;
-        padding: 20px;
-        border-radius: 5px;
-        text-align: center;
-    }
-    .modal-content button {
-        margin: 10px;
-        padding: 10px 20px;
-        cursor: pointer;
-    }
-</style>
-=======
         console.log('Main2 mounted');
     }
 }
@@ -448,4 +229,3 @@
 <style scoped>
 .ui-checkbox{width: 30px; height: 30px;}
 </style>
->>>>>>> e47769b90c7ad4f0b34f38bb2a56a8a69a894941
client/views/pages/teacher/QuestionInsert.vue
--- client/views/pages/teacher/QuestionInsert.vue
+++ client/views/pages/teacher/QuestionInsert.vue
@@ -26,10 +26,11 @@
             <div class="flex align-center mb20">
                 <label for="" class="title2">카테고리</label>
                 <select v-model="selectedSearchOption" class="mr10 data-wrap">
-                    <option value="bbsTtl">제목</option>
-                    <option value="bbsCnt">내용</option>
-                    <option value="userNm">작성자</option>
-                    <option value="bbsCls">카테고리</option>
+                    <option value="LC">듣기 이해력</option>
+                    <option value="RC">독해 이해력</option>
+                    <option value="WT">쓰기</option>
+                    <option value="SP">말하기</option>
+                    <option value="ETC">그외</option>
                 </select>
             </div>
             <div class="flex align-center mb20">
@@ -53,10 +54,9 @@
             <div class="flex align-center">
                 <label for="" class="title2">문제 지표</label>
                 <select v-model="selectedSearchOption" class="mr10 data-wrap">
-                    <option value="bbsTtl">제목</option>
-                    <option value="bbsCnt">내용</option>
-                    <option value="userNm">작성자</option>
-                    <option value="bbsCls">카테고리</option>
+                    <option value="bbsTtl">지표1</option>
+                    <option value="bbsCnt">지표2</option>
+                    <option value="userNm">지표3</option>
                 </select>
             </div>
        </div>
@@ -189,7 +189,7 @@
             <button type="button" title="글쓰기" class="new-btn mr10">
                 취소
             </button>
-            <button type="button" title="글쓰기" class="new-btn">
+            <button type="button" title="글쓰기" class="new-btn" @click="submitForm">
                 등록
             </button>
         </div>
@@ -205,13 +205,40 @@
     data() {
         return {
             mdiMagnify: mdiMagnify,
-            selectedTab: 'tab1',
+            selectedTab: '1',
+            selectedSearchOption: '', // 카테고리 선택
+            prblm_ctgry_id: '', // 카테고리 ID
+            prblm_type_id: '', // 문제 유형 ID
+            prblm_scr: '', // 문제 배점
+            prblm_expln: '', // 내용
+            prblm_hint: '', // 힌트
+            file_mng_id: null, // 첨부파일 ID
         }
     },
     methods: {
         goToPage(page) {
             this.$router.push({ name: page });
         },
+        submitForm() {
+        const payload = {
+            prblm_ctgry_id: this.selectedSearchOption, // 카테고리
+            prblm_type_id: this.selectedTab, // 문제 유형
+            prblm_scr: this.prblm_scr, // 문제 배점
+            prblm_expln: this.prblm_expln, // 내용
+            prblm_hint: this.prblm_hint, // 힌트
+            file_mng_id: this.file_mng_id // 첨부파일 ID
+        };
+
+        axios.post('/problem/insertProblem.json', payload)
+            .then(response => {
+                console.log('성공:', response.data);
+                // 성공적으로 저장한 후 처리 로직 추가
+            })
+            .catch(error => {
+                console.error('오류:', error);
+                // 오류 처리 로직 추가
+            });
+    }
     },
     watch: {
 
client/views/pages/teacher/QuestionList.vue
--- client/views/pages/teacher/QuestionList.vue
+++ client/views/pages/teacher/QuestionList.vue
@@ -7,17 +7,16 @@
     </div>
     <label for="" class="title2">단원</label>
         <div class="unit-pagination flex mt10 mb20" style="gap: 10px;">
-            <button class="selected-btn">1</button>
-            <button>2</button>
-            <button>3</button>
+            <button @click="selectUnit('UNIT_000000000000001')" :class="{ 'selected-btn': selectedUnitId === 'UNIT_000000000000001' }">1</button>
+            <button @click="selectUnit('UNIT_000000000000002')" :class="{ 'selected-btn': selectedUnitId === 'UNIT_000000000000002' }">2</button>
+            <button @click="selectUnit('UNIT_000000000000003')" :class="{ 'selected-btn': selectedUnitId === 'UNIT_000000000000003' }">3</button>
         </div>
     <div class="search-wrap flex justify-end mb20">
         <select name="" id="" class="mr10 data-wrap" v-model="searchOption">
             <option value="">전체</option>
-            <option value="">제목</option>
             <option value="prblm_expln">문제</option>
+            <option value="prblm_type_id">유형</option>
             <option value="user_id">작성자</option>
-            <option value="">등록일</option>
         </select>
         <input type="text" placeholder="검색하세요." v-model="searchKeyword">
         <button type="button" title="위원회 검색" @click="searchProblems">
@@ -29,22 +28,21 @@
             <thead>
                 <tr>
                     <td>No.</td>
-                    <td>제목</td>
-                    <td>내용</td>
+                    <td>문제</td>
                     <td>유형</td>
-                    <td>지문</td>
+                   <td>점수</td>
+                   <td>작성자</td>
                     <td>등록일</td>
-<<<<<<< HEAD
                 </tr>
             </thead>
             <tbody>
                 <tr v-for="(problem, index) in problems" :key="problem.prblmId" @click="[goToPage('QuestionDetail', selectQuestionList(problem))]">
                     <td>{{ (currentPage - 1) * 10 + index + 1 }}</td>
-                    <td>제목</td>
                     <td>{{ problem.prblmExpln }}</td>
+                    <td>{{ problem.prblmTypeId }}</td>
+                    <td>{{ problem.prblmScr }}</td>
                     <td>{{ problem.userId }}</td>
-                    <td>오답률</td>
-                    <td>등록일</td>
+                    <td>{{ problem.regDt}}</td>
                 </tr>
             </tbody>
         </table>
@@ -59,36 +57,10 @@
                 <img src="../../../resources/img/btn28_90t_normal.png" alt="">
             </button>
         </article>
-        <div class="flex justify-end">
+        <div class="flex justify-end ">
             <button type="button" title="등록" class="new-btn" @click="goToPage('QuestionInsert')">
                 등록
             </button>
-=======
-                </thead>
-                <tbody>
-                    <tr @click="goToPage('QuestionDetail')">
-                        <td></td>
-                        <td></td>
-                        <td></td>
-                        <td></td>
-                        <td></td>
-                        <td></td>
-                    </tr>
-                </tbody>
-            </table>
-            <article class="table-pagination flex justify-center align-center mb20 mt30" style="gap: 10px;">
-                    <button><img src="../../../resources/img/btn27_90t_normal.png" alt=""></button>
-                    <button class="selected-btn">1</button>
-                    <button>2</button>
-                    <button>3</button>
-                    <button><img src="../../../resources/img/btn28_90t_normal.png" alt=""></button>
-                </article>
-                <div class="flex justify-end ">
-                <button type="button" title="등록" class="new-btn" @click="goToPage('QuestionInsert')">
-                    등록
-                </button>
-        </div>
->>>>>>> e47769b90c7ad4f0b34f38bb2a56a8a69a894941
         </div>
     </div>
 </template>
@@ -101,20 +73,18 @@
 export default {
     data() {
         return {
-            problems: [],
             mdiMagnify: mdiMagnify,
+            problems: [],
             currentPage: 1,
             totalPages: 3,
             searchOption: '',
             searchKeyword: '',
+            selectedUnitId: 'UNIT_000000000000001'
         }
     },
     methods: {
         goToPage(page) {
             this.$router.push({ name: page });
-        },
-        selectQuestionList(item) {
-            sessionStorage.setItem("selectQuestionList", JSON.stringify(item));
         },
         showConfirm(type) {
             let message = '';
@@ -130,11 +100,19 @@
                 this.goBack();
             }
         },
+        selectQuestionList(item) {
+            sessionStorage.setItem("selectQuestionList", JSON.stringify(item));
+        },
+        selectUnit(unitId) {
+        this.selectedUnitId = unitId; // 선택된 단원 ID 설정
+        this.fetchProblems(1); // 첫 페이지로 문제 목록 새로 고침
+        },
         async fetchProblems(page = 1) {
             try {
                 const response = await axios.post('/problem/problemList.json', {
                     option: this.searchOption,
                     keyword: this.searchKeyword,
+                    unitId: this.selectedUnitId,
                     pageSize: 10,
                     startIndex: (page - 1) * 10
                 });
@@ -146,13 +124,20 @@
         },
         changePage(page) {
             if (page < 1 || page > this.totalPages) return;
-            this.fetchProblems(page);
             this.currentPage = page;
+            this.fetchProblems(page);
         },
         searchProblems() {
             this.fetchProblems(1);
         }
     },
+    watch: {
+    },
+    computed: {
+    },
+    components: {
+        SvgIcon
+    },
     mounted() {
         console.log('Main2 mounted');
         this.fetchProblems();
Add a comment
List