jichoi / lms_front star
박민혁 박민혁 2024-08-19
240819 박민혁 선생님 쪽 수정
@55f4ca618d3988d699ba3b1539927def20432cc8
client/views/pages/teacher/QuestionDetail.vue
--- client/views/pages/teacher/QuestionDetail.vue
+++ client/views/pages/teacher/QuestionDetail.vue
@@ -4,181 +4,238 @@
     </div>
     <div class="content-t">
         <div class="board-wrap">
-            <div class="tab-box">
-                <label class="mr20 title1">
-                    <input type="radio" v-model="selectedTab" value="tab1" />
-                    문제 유형 (일반형)
-                </label>
-                <label class="mr20 title1">
-                    <input type="radio" v-model="selectedTab" value="tab2" />
-                    문제 유형 (O,X형)
-                </label>
-                <label class="mr20 title1">
-                    <input type="radio" v-model="selectedTab" value="tab3" />
-                    문제 유형 (연결형)
-                </label>
-                <label class="mr20 title1">
-                    <input type="radio" v-model="selectedTab" value="tab4" />
-                    문제 유형 (다중 정답형)
-                </label>
-            </div>
-            <hr>
             <div class="gd-col2 ">
                 <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="1">듣기 이해력(LC)</option>
+                        <option value="2">독해 이해력(RC)</option>
+                        <option value="4">쓰기(WT)</option>
+                        <option value="5">말하기(SP)</option>
+                        <option value="3">그외(ETC)</option>
                     </select>
                 </div>
                 <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>
+                    <select v-model="selectedSearchOption2" class="mr10 data-wrap">
+                        <option value="prblm_type_001">Chapter3 페이지 문제</option>
+                        <option value="prblm_type_002">Chapter3_1 페이지 문제</option>
+                        <option value="prblm_type_003">Chapter3_2 페이지 문제</option>
+                        <option value="prblm_type_004">Chapter3_3 페이지 문제</option>
+                        <option value="prblm_type_005">Chapter3_3_1 페이지 문제</option>
+                        <option value="prblm_type_006">Chapter3_4 페이지 문제</option>
+                        <option value="prblm_type_007">Chapter3_5 페이지 문제</option>
+                        <option value="prblm_type_008">Chapter3_6 페이지 문제</option>
+                        <option value="prblm_type_009">Chapter3_7 페이지 문제</option>
+                        <option value="prblm_type_010">Chapter3_8 페이지 문제</option>
+                        <option value="prblm_type_011">Chapter3_9 페이지 문제</option>
+                        <option value="prblm_type_012">Chapter3_10 페이지 문제</option>
+                        <option value="prblm_type_013">Chapter3_11 페이지 문제</option>
+                        <option value="prblm_type_014">Chapter3_12 페이지 문제</option>
+                        <option value="prblm_type_015">Chapter3_13 페이지 문제</option>
+                        <option value="prblm_type_016">Chapter3_14 페이지 문제</option>
+                        <option value="prblm_type_017">Chapter3_15 페이지 문제</option>
+                        <option value="prblm_type_018">Chapter2_8 페이지 문제</option>
+                        <option value="prblm_type_019">Chapter2_7 페이지 문제</option>
+                        <option value="prblm_type_020">Chapter2_5 페이지 문제</option>
+                        <option value="prblm_type_021">Chapter2_6 페이지 문제</option>
+                        <option value="prblm_type_022">Chapter2_10 페이지 문제</option>
+                        <option value="prblm_type_023">Chapter2_11 페이지 문제</option>
+                        <option value="prblm_type_024">Chapter2_13 페이지 문제</option>
                     </select>
+
                 </div>
+
                 <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>
+                    <select name="" id="" v-model="book_id" @change="fetchUnits" class="mr10">
+                        <option value="" disabled>교재를 선택하세요</option>
+                        <option v-for="book in books" :key="book.book_id" :value="book.book_id">
+                            {{ book.book_nm }}
+                        </option>
                     </select>
-                </div>
-                <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>
+                    <select name="" id="" v-model="unit_id" @change="fetchTexts" class="mr10">
+                        <option value="" disabled>단원을 선택하세요</option>
+                        <option v-for="unit in units" :key="unit.unitId" :value="unit.unitId">
+                            {{ unit.unitName }}
+                        </option>
+                    </select>
+
+                    <select v-model="text_id" class="mr10 data-wrap">
+                        <option value="" disabled>지문을 선택하세요</option>
+                        <option v-for="text in texts" :key="text.textId" :value="text.textId">
+                            {{ text.textTtl }}
+                        </option>
                     </select>
                 </div>
             </div>
             <div class="flex align-center mb20 mt40">
                 <label for="" class="title2">문제 배점</label>
-                <input type="text" class="data-wrap">
+                <input type="text" class="data-wrap" v-model="prblm_scr">
             </div>
 
             <div class="flex align-center mb20">
                 <label for="" class="title2">내용</label>
-                <textarea name="" id="" class="data-wrap"></textarea>
+                <textarea name="" id="" class="data-wrap" v-model="prblm_expln"></textarea>
             </div>
             <div class="flex align-center mb20">
                 <label for="" class="title2">힌트</label>
-                <input type="text" class="data-wrap">
+                <input type="text" class="data-wrap" v-model="prblm_hint">
             </div>
-            <div class="flex align-center mb20">
-                <label for="" class="title2">첨부파일</label>
-                <input type="file" ref="fileInput" @change="handleFileUpload" />
+            <div class="flex align-center ">
+                <label for="file" class="title2">첨부파일</label>
+                <input type="file" ref="fileInput" @change="handleFileUpload" multiple />
             </div>
             <hr>
-            <div v-if="selectedTab === 'tab1'">
-                <div class="flex align-center mb20">
-                    <label for="" class="title2">답1</label>
-                    <input type="text" class="data-wrap">
+            <div v-if="selectedSearchOption2 === ('prblm_type_008')">
+                <!--5지선다-->
+                <div class="gd-col2 " v-for="i in 5" :key="i">
+                    <div>
+                        <div class="flex align-center mb20 mr40">
+                            <label :for="'answer' + i" class="title2">답{{ i }}</label>
+                            <input :id="'answer' + i" type="text" class="data-wrap"
+                                v-model="prblmDetail.answers[i].text" />
+                        </div>
+                        <div class="flex align-center mb20">
+                            <label :for="'correct' + i" class="title2">정답여부</label>
+                            <input :id="'correct' + i" type="checkbox" class="ui-checkbox"
+                                :checked="prblmDetail.correctIndex === i" @change="setCorrectAnswer(i)" />
+                        </div>
+                    </div>
+                    <div class="flex align-center mb20">
+                        <label :for="'file' + i" class="title2">첨부파일</label>
+                        <input type="file" :ref="'fileInput' + i" @change="handleDetailFileUpload(i)" multiple />
+                    </div>
                 </div>
-                <div class="flex align-center mb20">
-                    <label for="" class="title2">답2</label>
-                    <input type="text" class="data-wrap">
-                </div>
-                <div class="flex align-center mb20">
-                    <label for="" class="title2">답3</label>
-                    <input type="text" class="data-wrap">
-                </div>
-                <div class="flex align-center mb20">
-                    <label for="" class="title2">답4</label>
-                    <input type="text" class="data-wrap">
-                </div>
-                <div class="flex align-center mb20">
-                    <label for="" class="title2">해설</label>
-                    <textarea name="" id="" class="data-wrap"></textarea>
+
+            </div>
+            <div v-else-if="['prblm_type_004', 'prblm_type_006', 'prblm_type_024'].includes(selectedSearchOption2)">
+                <!--4지선다-->
+                <div class="gd-col2 " v-for="i in 4" :key="i">
+                    <div>
+                        <div class="flex align-center mb20 mr40">
+                            <label :for="'answer' + i" class="title2">답{{ i }}</label>
+                            <input :id="'answer' + i" type="text" class="data-wrap"
+                                v-model="prblmDetail.answers[i].text" />
+                        </div>
+                        <div class="flex align-center mb20">
+                            <label :for="'correct' + i" class="title2">정답여부</label>
+                            <input :id="'correct' + i" type="checkbox" class="ui-checkbox"
+                                :checked="prblmDetail.correctIndex === i" @change="setCorrectAnswer(i)" />
+                        </div>
+                    </div>
+                    <div class="flex align-center mb20">
+                        <label :for="'file' + i" class="title2">첨부파일</label>
+                        <input type="file" :ref="'fileInput' + i" @change="handleDetailFileUpload(i)" multiple />
+                    </div>
+
                 </div>
             </div>
-            <div v-else-if="selectedTab === 'tab2'">
+            <div
+                v-else-if="['prblm_type_001', 'prblm_type_005', 'prblm_type_019', 'prblm_type_022'].includes(selectedSearchOption2)">
+                <!--3지선다-->
+                <div class="gd-col2 " v-for="i in 3" :key="i">
+                    <div>
+                        <div class="flex align-center mb20 mr40">
+                            <label :for="'answer' + i" class="title2">답{{ i }}</label>
+                            <input :id="'answer' + i" type="text" class="data-wrap"
+                                v-model="prblmDetail.answers[i].text" />
+                        </div>
+                        <div class="flex align-center mb20">
+                            <label :for="'correct' + i" class="title2">정답여부</label>
+                            <input :id="'correct' + i" type="checkbox" class="ui-checkbox"
+                                :checked="prblmDetail.correctIndex === i" @change="setCorrectAnswer(i)" />
+                        </div>
+                    </div>
+                    <div class="flex align-center mb20">
+                        <label :for="'file' + i" class="title2">첨부파일</label>
+                        <input type="file" :ref="'fileInput' + i" @change="handleDetailFileUpload(i)" multiple />
+                    </div>
+
+                </div>
+            </div>
+            <div
+                v-else-if="['prblm_type_002', 'prblm_type_003', 'prblm_type_007', 'prblm_type_023'].includes(selectedSearchOption2)">
+                <!--2지선다-->
+                <div class="gd-col2 " v-for="i in 2" :key="i">
+                    <div>
+                        <div class="flex align-center mb20 mr40">
+                            <label :for="'answer' + i" class="title2">답{{ i }}</label>
+                            <input :id="'answer' + i" type="text" class="data-wrap"
+                                v-model="prblmDetail.answers[i].text" />
+                        </div>
+                        <div class="flex align-center mb20">
+                            <label :for="'correct' + i" class="title2">정답여부</label>
+                            <input :id="'correct' + i" type="checkbox" class="ui-checkbox"
+                                :checked="prblmDetail.correctIndex === i" @change="setCorrectAnswer(i)" />
+                        </div>
+                    </div>
+                    <div class="flex align-center mb20">
+                        <label :for="'file' + i" class="title2">첨부파일</label>
+                        <input type="file" :ref="'fileInput' + i" @change="handleDetailFileUpload(i)" multiple />
+                    </div>
+
+                </div>
+            </div>
+            <div v-else-if="selectedSearchOption2 === 'prblm_type_009'">
+                <!--OX문제-->
                 <div class="flex align-center mb20">
                     <label for="" class="title2">답</label>
-                    <select v-model="selectedSearchOption" class="mr10 data-wrap">
+                    <select v-model="prblmDetail.answer1" class="mr10 data-wrap">
                         <option value="bbsTtl">O</option>
                         <option value="bbsCnt">X</option>
                     </select>
                 </div>
                 <div class="flex align-center mb20">
-                    <label for="" class="title2">해설</label>
-                    <textarea name="" id="" class="data-wrap"></textarea>
+                    <label :for="'file' + i" class="title2">첨부파일</label>
+                    <input type="file" :ref="'fileInput' + 1" @change="handleDetailFileUpload(1)" multiple />
                 </div>
+
             </div>
-            <div v-else-if="selectedTab === 'tab3'">
+            <div
+                v-else-if="['prblm_type_010', 'prblm_type_011', 'prblm_type_012', 'prblm_type_013', 'prblm_type_014',
+                    'prblm_type_015', 'prblm_type_016', 'prblm_type_017', 'prblm_type_018', 'prblm_type_020', 'prblm_type_021'].includes(selectedSearchOption2)">
+                <!--서술형-->
                 <div class="gd-col2 ">
-                    <div class="flex align-center mb20 mr40">
-                        <label for="" class="title2">문제1</label>
-                        <input type="text" class="data-wrap">
+                    <div class="flex align-center mb20">
+                        <label for="" class="title2">답</label>
+                        <input type="text" class="data-wrap" v-model="prblmDetail.answer1">
                     </div>
                     <div class="flex align-center mb20">
-                        <label for="" class="title2">답1</label>
-                        <input type="text" class="data-wrap">
+                        <label :for="'file' + i" class="title2">첨부파일</label>
+                        <input type="file" :ref="'fileInput' + 1" @change="handleDetailFileUpload(1)" multiple />
                     </div>
-                    <div class="flex align-center mb20 mr40">
-                        <label for="" class="title2">문제2</label>
-                        <input type="text" class="data-wrap">
-                    </div>
-                    <div class="flex align-center mb20">
-                        <label for="" class="title2">답2</label>
-                        <input type="text" class="data-wrap">
-                    </div>
-                    <div class="flex align-center mb20 mr40">
-                        <label for="" class="title2">문제3</label>
-                        <input type="text" class="data-wrap">
-                    </div>
-                    <div class="flex align-center mb20 ">
-                        <label for="" class="title2">답3</label>
-                        <input type="text" class="data-wrap">
-                    </div>
-                    <div class="flex align-center mb20 mr40">
-                        <label for="" class="title2">문제4</label>
-                        <input type="text" class="data-wrap">
-                    </div>
-                    <div class="flex align-center mb20">
-                        <label for="" class="title2">답4</label>
-                        <input type="text" class="data-wrap">
-                    </div>
-                </div>
-                <div class="flex align-center mb20">
-                    <label for="" class="title2">해설</label>
-                    <textarea name="" id="" class="data-wrap"></textarea>
+
                 </div>
             </div>
-            <div v-else-if="selectedTab === 'tab4'">
-                <div class="flex align-center mb20 mr40">
-                    <label for="" class="title2">문제1</label>
-                    <input type="text" class="data-wrap">
-                    <input type="checkbox" class="ui-checkbox ml30">
-                </div>
-                <div class="flex align-center mb20 mr40">
-                    <label for="" class="title2">문제2</label>
-                    <input type="text" class="data-wrap">
-                    <input type="checkbox" class="ui-checkbox ml30">
-                </div>
-                <div class="flex align-center mb20 mr40">
-                    <label for="" class="title2">문제3</label>
-                    <input type="text" class="data-wrap">
-                    <input type="checkbox" class="ui-checkbox ml30">
-                </div>
-                <div class="flex align-center mb20 mr40">
-                    <label for="" class="title2">문제4</label>
-                    <input type="text" class="data-wrap">
-                    <input type="checkbox" class="ui-checkbox ml30">
-                </div>
-                <div class="flex align-center mb20">
-                    <label for="" class="title2">해설</label>
-                    <textarea name="" id="" class="data-wrap"></textarea>
-                </div>
+            <div class="flex align-center mb20">
+                <label for="" class="title2">해설</label>
+                <textarea name="" id="" class="data-wrap" v-model="prblm_cmmt"></textarea>
+            </div>
+            <hr>
+            <div class="flex align-center mb20 mt40">
+                <label for="" class="title2">문제 지표 1</label>
+                <input type="text" class="data-wrap" v-model="prblm_mtr1">
+            </div>
+            <div class="flex align-center mb20 mt40">
+                <label for="" class="title2">문제 지표 2</label>
+                <input type="text" class="data-wrap" v-model="prblm_mtr2">
+            </div>
+            <div class="flex align-center mb20 mt40">
+                <label for="" class="title2">문제 지표 3</label>
+                <input type="text" class="data-wrap" v-model="prblm_mtr3">
+            </div>
+            <div class="flex align-center mb20 mt40">
+                <label for="" class="title2">문제 지표 4</label>
+                <input type="text" class="data-wrap" v-model="prblm_mtr4">
+            </div>
+            <div class="flex align-center mb20 mt40">
+                <label for="" class="title2">문제 지표 5</label>
+                <input type="text" class="data-wrap" v-model="prblm_mtr5">
+            </div>
+            <div class="flex align-center mb20 mt40">
+                <label for="" class="title2">문제 지표 6</label>
+                <input type="text" class="data-wrap" v-model="prblm_mtr6">
             </div>
 
         </div>
@@ -187,10 +244,10 @@
                 목록
             </button>
             <div class="flex">
-                <button type="button" title="글쓰기" class="new-btn mr10">
+                <button type="button" title="글쓰기" class="new-btn mr10" @click="deletePost">
                     삭제
                 </button>
-                <button type="button" title="글쓰기" class="new-btn">
+                <button type="button" title="글쓰기" class="new-btn" @click="submitForm">
                     수정
                 </button>
             </div>
@@ -211,6 +268,35 @@
             prblm: {},
             dataList: [],
             problemDetail: [],
+
+            selectedSearchOption: '',
+            selectedSearchOption2: '',
+            book_id: '',
+            unit_id: '',
+            text_id: '',
+            prblm_scr: '',
+            prblm_expln: '',
+            prblm_hint: '',
+            prblm_cmmt: '',
+            prblm_mtr1: '',
+            prblm_mtr2: '',
+            prblm_mtr3: '',
+            prblm_mtr4: '',
+            prblm_mtr5: '',
+            prblm_mtr6: '',
+            prblmDetail: {
+                answers: {
+                    1: { text: '', isCorrect: 'N', fileMngId: null },
+                    2: { text: '', isCorrect: 'N', fileMngId: null },
+                    3: { text: '', isCorrect: 'N', fileMngId: null },
+                    4: { text: '', isCorrect: 'N', fileMngId: null },
+                    5: { text: '', isCorrect: 'N', fileMngId: null },
+                },
+                correctIndex: null, // 정답으로 선택된 답의 인덱스
+            },
+            books: [],
+            units: [],
+            texts: [],
         }
     },
     methods: {
@@ -235,15 +321,263 @@
                     vm.dataList = res.data.problem;
                     vm.problemDetail = res.data.problemDetail;
 
+                    vm.selectedSearchOption = vm.dataList.prblmCtgryId;
+                    vm.selectedSearchOption2 = vm.dataList.prblmTypeId;
+                    vm.book_id = vm.dataList.bookId;
+                    vm.unit_id = vm.dataList.unitId;
+                    vm.text_id = vm.dataList.textId;
+                    vm.prblm_scr = vm.dataList.prblmScr;
+                    vm.prblm_expln = vm.dataList.prblmExpln;
+                    vm.prblm_hint = vm.dataList.prblmHint;
+                    vm.prblm_cmmt = vm.dataList.prblmCmmt;
+                    vm.prblm_mtr1 = vm.dataList.prblmMtr1;
+                    vm.prblm_mtr2 = vm.dataList.prblmMtr2;
+                    vm.prblm_mtr3 = vm.dataList.prblmMtr3;
+                    vm.prblm_mtr4 = vm.dataList.prblmMtr4;
+                    vm.prblm_mtr5 = vm.dataList.prblmMtr5;
+                    vm.prblm_mtr6 = vm.dataList.prblmMtr6;
+
+                    if (vm.problemDetail.length > 0) {
+                        vm.prblmDetail.answers = vm.problemDetail.reduce((acc, detail, index) => {
+                            acc[index + 1] = {
+                                text: detail.prblmDtlExpln,
+                                isCorrect: detail.prblmYn === 'Y' ? 'Y' : 'N',
+                                fileMngId: detail.fileMngId || null
+                            };
+                            return acc;
+                        }, {});
+
+                        vm.prblmDetail.correctIndex = vm.problemDetail.findIndex(detail => detail.prblmYn === 'Y');
+
+                        if (vm.dataList.prblmTypeId === 'prblm_type_009') {
+                            vm.prblmDetail.answer1 = vm.problemDetail.find(detail => detail.prblmYn === 'Y') ? 'O' : 'X';
+                        }
+                    }
+
                 })
                 .catch(function (error) {
                     console.log("problem - error : ", error);
                 });
         },
 
+        // 문제 수정
+        async submitForm() {
+            // 필요한 모든 필드를 검사합니다.
+            if (!this.selectedSearchOption) {
+                alert("카테고리를 지정해 주세요.");
+                return;
+            }
+
+            if (!this.selectedSearchOption2) {
+                alert("문제 유형을 지정해 주세요.");
+                return;
+            }
+
+            if (!this.prblm_scr) {
+                alert("문제 배점을 입력해 주세요.");
+                return;
+            }
+
+            if (!this.prblm_expln) {
+                alert("문제 내용을 입력해 주세요.");
+                return;
+            }
+
+            const payload = {
+                prblmId: this.dataList.prblmId,
+                prblmCtgryId: this.selectedSearchOption, // 카테고리
+                prblmTypeId: this.selectedSearchOption2, // 문제 유형
+                prblmScr: this.prblm_scr, // 문제 배점
+                prblmExpln: this.prblm_expln, // 내용
+                prblmHint: this.prblm_hint, // 힌트
+                prblmCmmt: this.prblm_cmmt, // 해설
+                textId: this.text_id, // 지문 아이디
+                unitId: this.unit_id, // 단원 아이디
+                bookId: this.book_id, // 교재 아이디
+               // userId: this.user_id, // 유저 아이디
+                userId: 'USID_000000000000004', // 유저 아이디
+                prblmMtr1: this.prblm_mtr1, // 문제 지표
+                prblmMtr2: this.prblm_mtr2,
+                prblmMtr3: this.prblm_mtr3,
+                prblmMtr4: this.prblm_mtr4,
+                prblmMtr5: this.prblm_mtr5,
+                prblmMtr6: this.prblm_mtr6,
+                fileMngId: this.file_mng_id // 첨부파일 ID
+            };
+
+            try {
+                const response = await axios.post('/problem/updateProblem.json', payload);
+                console.log('성공:', response.data);
+                const problemDetails = await this.prepareProblemDetails();
+                await this.submitDetailForm(problemDetails);
+
+                this.goToPage('QuestionList');
+
+            } catch (error) {
+                console.error('오류:', error);
+                // 오류 처리 로직 추가
+            }
+        },
+
+        // 문제 상세 업로드
+        async submitDetailForm(problemDetails) {
+
+            try {
+                const response = await axios.post('/problem/updateProblemDetail.json', problemDetails);
+                console.log('성공:', response.data);
+            } catch (error) {
+                console.error('오류:', error);
+                // 오류 처리 로직 추가
+            }
+        },
+
+        // 상세 정보 세팅하기
+        async prepareProblemDetails() {
+            const details = [];
+            const answers = this.prblmDetail.answers;
+
+            let answerCount = 0;
+
+            if (this.selectedSearchOption2 === 'prblm_type_008') {
+                answerCount = 5;
+            } else if (['prblm_type_004', 'prblm_type_006', 'prblm_type_024'].includes(this.selectedSearchOption2)) {
+                answerCount = 4;
+            } else if (['prblm_type_001', 'prblm_type_005', 'prblm_type_019', 'prblm_type_022'].includes(this.selectedSearchOption2)) {
+                answerCount = 3;
+            } else if (['prblm_type_002', 'prblm_type_003', 'prblm_type_007', 'prblm_type_023'].includes(this.selectedSearchOption2)) {
+                answerCount = 2;
+            } else {
+                answerCount = 1;
+            }
+
+            for (let i = 1; i <= answerCount; i++) {
+                details.push({
+                    prblmDtlId: this.problemDetail[i - 1].prblmDtlId,
+                    prblmDtlExpln: answers[i].text || '',
+                    prblmYn: answers[i].isCorrect, // isCorrect가 'Y' 또는 'N'으로 설정됨
+                    fileMngId: answers[i].fileMngId,
+                });
+            }
+
+            return details;
+        },
+
+        setCorrectAnswer(index) {
+            this.prblmDetail.correctIndex = index;
+            // 선택된 인덱스의 답만 'Y'로 설정하고, 나머지는 'N'으로 설정
+            for (let i = 1; i <= 5; i++) {
+                this.prblmDetail.answers[i].isCorrect = i === index ? 'Y' : 'N';
+            }
+        },
+
+        resetPrblmDetail() {
+            this.prblmDetail = {
+
+                answers: {
+                    1: { text: '', isCorrect: 'N', fileMngId: null },
+                    2: { text: '', isCorrect: 'N', fileMngId: null },
+                    3: { text: '', isCorrect: 'N', fileMngId: null },
+                    4: { text: '', isCorrect: 'N', fileMngId: null },
+                    5: { text: '', isCorrect: 'N', fileMngId: null },
+                },
+                correctIndex: null,
+            };
+            this.selectedFiles = {};
+        },
+
+        // 문제 삭제
+        deletePost() {
+            const result = confirm('데이터를 삭제 하시겠습니까?')
+            if (result) {
+
+            } else {
+                alert("삭제를 취소했습니다")
+                return;
+            }
+
+            axios.post("/problem/deleteProblem.json", { prblmId: this.dataList.prblmId }, {
+                headers: {
+                    "Content-Type": "application/json; charset=UTF-8",
+                }
+            })
+                .then(response => {
+                    alert(response.data.message);
+                    this.goToPage('TextList');
+                })
+                .catch(error => {
+                    console.error("Error deleting post:", error);
+                    alert("게시글 삭제에 오류가 발생했습니다.");
+                });
+        },
+
+
+        // 교재 정보 가져오기
+        fetchBooks() {
+            axios({
+                url: "/book/findAll.json",
+                method: "post",
+                headers: {
+                    "Content-Type": "application/json; charset=UTF-8",
+                },
+            })
+                .then(response => {
+                    console.log(response.data)
+                    this.books = response.data;
+                    this.text_id = '';
+                })
+                .catch(error => {
+                    console.error("fetchBooks - error: ", error);
+                    alert("교재 목록을 불러오는 중 오류가 발생했습니다.");
+                });
+        },
+
+        // 단원 정보 가져오기
+        fetchUnits() {
+            if (!this.book_id) return;
+
+            axios({
+                url: "/unit/unitList.json",
+                method: "post",
+                headers: {
+                    "Content-Type": "application/json; charset=UTF-8",
+                },
+                data: {
+                    "bookId": this.book_id
+                },
+            })
+                .then(response => {
+                    this.units = response.data;
+                    this.text_id = '';
+                })
+                .catch(error => {
+                    console.error("fetchUnits - error: ", error);
+                    alert("단원 목록을 불러오는 중 오류가 발생했습니다.");
+                });
+        },
+
+        // 지문 정보 가져오기
+        fetchTexts() {
+            axios({
+                url: "/text/textSearch.json",
+                method: "post",
+                headers: {
+                    "Content-Type": "application/json; charset=UTF-8",
+                },
+                data: {
+                    "unitId": this.unit_id
+                },
+            })
+                .then(response => {
+                    this.texts = response.data.list;
+                })
+                .catch(error => {
+                    console.error("fetchTexts - error: ", error);
+                    alert("지문 목록을 불러오는 중 오류가 발생했습니다.");
+                });
+        },
+
     },
     watch: {
-
     },
     computed: {
 
@@ -252,6 +586,13 @@
         SvgIcon
     },
     mounted() {
+        let prblm = JSON.parse(sessionStorage.getItem("selectQuestionList"));
+        this.book_id = prblm.bookId;
+        this.unit_id = prblm.unitId;
+
+        this.fetchBooks();
+        this.fetchUnits();
+
         this.problemSearch();
     }
 }
client/views/pages/teacher/QuestionInsert.vue
--- client/views/pages/teacher/QuestionInsert.vue
+++ client/views/pages/teacher/QuestionInsert.vue
@@ -300,10 +300,10 @@
             <button type="button" title="글쓰기" class="new-btn" @click="goToPage('QuestionList')">
                 목록
             </button>
-            <div class="flex">
+            <div class="flex"><!--
                 <button type="button" title="글쓰기" class="new-btn mr10">
                     취소
-                </button>
+                </button>-->
                 <button type="button" title="글쓰기" class="new-btn" @click="submitForm">
                     등록
                 </button>
@@ -428,7 +428,7 @@
                 prblmExpln: this.prblm_expln, // 내용
                 prblmHint: this.prblm_hint, // 힌트
                 prblmCmmt: this.prblm_cmmt, // 해설
-               // text_id: this.text_id, // 지문 아이디
+                textId: this.text_id, // 지문 아이디
                 unitId: this.unit_id, // 단원 아이디
                 bookId: this.book_id, // 교재 아이디
                // userId: this.user_id, // 유저 아이디
@@ -465,7 +465,6 @@
 
         // 문제 상세 업로드
         async submitDetailForm(problemDetails) {
-            console.log('Submitting Problem Details:', problemDetails); // 디버깅
 
             try {
                 const response = await axios.post('/problem/insertProblemDetail.json', problemDetails);
client/views/pages/teacher/TextDetail.vue
--- client/views/pages/teacher/TextDetail.vue
+++ client/views/pages/teacher/TextDetail.vue
@@ -161,7 +161,6 @@
                 .then(function (res) {
                     console.log("fileInfo - response : ", res.data.list[0]);
                     vm.file = res.data.list[0];
-                    sessionStorage.setItem("file", JSON.stringify(vm.file));
                 })
                 .catch(function (error) {
                     console.log("result - error : ", error);
@@ -176,7 +175,8 @@
                 textUrl: this.post.textUrl,
                 textTypeId: this.post.textTypeId,
                 bookId: this.post.bookId,
-                unitId: this.post.unitId
+                unitId: this.post.unitId,
+                fileMngId: this.post.fileMngId,
             };
             console.log(this.newPost)
 
@@ -205,6 +205,14 @@
             }
         },
         deletePost() {
+            const result = confirm('데이터를 삭제 하시겠습니까?')
+            if (result) {
+
+            } else {
+                alert("삭제를 취소했습니다")
+                return;
+            }
+
             axios.post("/text/textDelete.json", { textId: this.textId }, {
                 headers: {
                     "Content-Type": "application/json; charset=UTF-8",
@@ -216,7 +224,7 @@
                 })
                 .catch(error => {
                     console.error("Error deleting post:", error);
-                    alert("게시글 삭제에 오류가 발생했습니다.");
+                    alert("지문 삭제에 오류가 발생했습니다.");
                 });
         },
         fetchBooks() {
Add a comment
List