
--- client/views/pages/teacher/QuestionDetail.vue
+++ client/views/pages/teacher/QuestionDetail.vue
... | ... | @@ -84,6 +84,9 @@ |
84 | 84 |
</div> |
85 | 85 |
<div class="flex align-center "> |
86 | 86 |
<label for="file" class="title2">첨부파일</label> |
87 |
+ <div v-for="(data, index) in mainfile" :key="index"> |
|
88 |
+ <label>{{ data.fileNm }}</label> |
|
89 |
+ </div> |
|
87 | 90 |
<input type="file" ref="fileInput" @change="handleFileUpload" multiple /> |
88 | 91 |
</div> |
89 | 92 |
<hr> |
... | ... | @@ -99,11 +102,15 @@ |
99 | 102 |
<div class="flex align-center mb20"> |
100 | 103 |
<label :for="'correct' + i" class="title2">정답여부</label> |
101 | 104 |
<input :id="'correct' + i" type="checkbox" class="ui-checkbox" |
102 |
- :checked="prblmDetail.correctIndex === i" @change="setCorrectAnswer(i)" /> |
|
105 |
+ :checked="prblmDetail.correctIndex === i" @change="setCorrectAnswer(i, 5)" /> |
|
103 | 106 |
</div> |
104 | 107 |
</div> |
105 | 108 |
<div class="flex align-center mb20"> |
106 | 109 |
<label :for="'file' + i" class="title2">첨부파일</label> |
110 |
+ <div v-for="(data, index) in prblmDetail.answers[i].fileInfo" :key="index"> |
|
111 |
+ <label>{{ data.fileNm }}</label> |
|
112 |
+ </div> |
|
113 |
+ |
|
107 | 114 |
<input type="file" :ref="'fileInput' + i" @change="handleDetailFileUpload(i)" multiple /> |
108 | 115 |
</div> |
109 | 116 |
</div> |
... | ... | @@ -121,18 +128,22 @@ |
121 | 128 |
<div class="flex align-center mb20"> |
122 | 129 |
<label :for="'correct' + i" class="title2">정답여부</label> |
123 | 130 |
<input :id="'correct' + i" type="checkbox" class="ui-checkbox" |
124 |
- :checked="prblmDetail.correctIndex === i" @change="setCorrectAnswer(i)" /> |
|
131 |
+ :checked="prblmDetail.correctIndex === i" @change="setCorrectAnswer(i, 4)" /> |
|
125 | 132 |
</div> |
126 | 133 |
</div> |
127 | 134 |
<div class="flex align-center mb20"> |
128 | 135 |
<label :for="'file' + i" class="title2">첨부파일</label> |
136 |
+ <div v-for="(data, index) in prblmDetail.answers[i].fileInfo" :key="index"> |
|
137 |
+ <label>{{ data.fileNm }}</label> |
|
138 |
+ </div> |
|
139 |
+ |
|
129 | 140 |
<input type="file" :ref="'fileInput' + i" @change="handleDetailFileUpload(i)" multiple /> |
130 | 141 |
</div> |
131 | 142 |
|
132 | 143 |
</div> |
133 | 144 |
</div> |
134 | 145 |
<div |
135 |
- v-else-if="['prblm_type_001', 'prblm_type_005', 'prblm_type_019', 'prblm_type_022'].includes(selectedSearchOption2)"> |
|
146 |
+ v-else-if="['prblm_type_001', 'prblm_type_005', 'prblm_type_018', 'prblm_type_019', 'prblm_type_022'].includes(selectedSearchOption2)"> |
|
136 | 147 |
<!--3지선다--> |
137 | 148 |
<div class="gd-col2 " v-for="i in 3" :key="i"> |
138 | 149 |
<div> |
... | ... | @@ -144,14 +155,16 @@ |
144 | 155 |
<div class="flex align-center mb20"> |
145 | 156 |
<label :for="'correct' + i" class="title2">정답여부</label> |
146 | 157 |
<input :id="'correct' + i" type="checkbox" class="ui-checkbox" |
147 |
- :checked="prblmDetail.correctIndex === i" @change="setCorrectAnswer(i)" /> |
|
158 |
+ :checked="prblmDetail.correctIndex === i" @change="setCorrectAnswer(i, 3)" /> |
|
148 | 159 |
</div> |
149 | 160 |
</div> |
150 | 161 |
<div class="flex align-center mb20"> |
151 | 162 |
<label :for="'file' + i" class="title2">첨부파일</label> |
163 |
+ <div v-for="(data, index) in prblmDetail.answers[i].fileInfo" :key="index"> |
|
164 |
+ <label>{{ data.fileNm }}</label> |
|
165 |
+ </div> |
|
152 | 166 |
<input type="file" :ref="'fileInput' + i" @change="handleDetailFileUpload(i)" multiple /> |
153 | 167 |
</div> |
154 |
- |
|
155 | 168 |
</div> |
156 | 169 |
</div> |
157 | 170 |
<div |
... | ... | @@ -167,11 +180,15 @@ |
167 | 180 |
<div class="flex align-center mb20"> |
168 | 181 |
<label :for="'correct' + i" class="title2">정답여부</label> |
169 | 182 |
<input :id="'correct' + i" type="checkbox" class="ui-checkbox" |
170 |
- :checked="prblmDetail.correctIndex === i" @change="setCorrectAnswer(i)" /> |
|
183 |
+ :checked="prblmDetail.correctIndex === i" @change="setCorrectAnswer(i, 2)" /> |
|
171 | 184 |
</div> |
172 | 185 |
</div> |
173 | 186 |
<div class="flex align-center mb20"> |
174 | 187 |
<label :for="'file' + i" class="title2">첨부파일</label> |
188 |
+ <div v-for="(data, index) in prblmDetail.answers[i].fileInfo" :key="index"> |
|
189 |
+ <label>{{ data.fileNm }}</label> |
|
190 |
+ </div> |
|
191 |
+ |
|
175 | 192 |
<input type="file" :ref="'fileInput' + i" @change="handleDetailFileUpload(i)" multiple /> |
176 | 193 |
</div> |
177 | 194 |
|
... | ... | @@ -188,13 +205,16 @@ |
188 | 205 |
</div> |
189 | 206 |
<div class="flex align-center mb20"> |
190 | 207 |
<label :for="'file' + i" class="title2">첨부파일</label> |
208 |
+ <div v-for="(data, index) in prblmDetail.answers[i].fileInfo" :key="index"> |
|
209 |
+ <label>{{ data.fileNm }}</label> |
|
210 |
+ </div> |
|
211 |
+ |
|
191 | 212 |
<input type="file" :ref="'fileInput' + 1" @change="handleDetailFileUpload(1)" multiple /> |
192 | 213 |
</div> |
193 |
- |
|
194 | 214 |
</div> |
195 | 215 |
<div |
196 | 216 |
v-else-if="['prblm_type_010', 'prblm_type_011', 'prblm_type_012', 'prblm_type_013', 'prblm_type_014', |
197 |
- 'prblm_type_015', 'prblm_type_016', 'prblm_type_017', 'prblm_type_018', 'prblm_type_020', 'prblm_type_021'].includes(selectedSearchOption2)"> |
|
217 |
+ 'prblm_type_015', 'prblm_type_016', 'prblm_type_017', 'prblm_type_020', 'prblm_type_021'].includes(selectedSearchOption2)"> |
|
198 | 218 |
<!--서술형--> |
199 | 219 |
<div class="gd-col2 "> |
200 | 220 |
<div class="flex align-center mb20"> |
... | ... | @@ -203,6 +223,10 @@ |
203 | 223 |
</div> |
204 | 224 |
<div class="flex align-center mb20"> |
205 | 225 |
<label :for="'file' + i" class="title2">첨부파일</label> |
226 |
+ <div v-for="(data, index) in prblmDetail.answers[i].fileInfo" :key="index"> |
|
227 |
+ <label>{{ data.fileNm }}</label> |
|
228 |
+ </div> |
|
229 |
+ |
|
206 | 230 |
<input type="file" :ref="'fileInput' + 1" @change="handleDetailFileUpload(1)" multiple /> |
207 | 231 |
</div> |
208 | 232 |
|
... | ... | @@ -284,20 +308,21 @@ |
284 | 308 |
prblm_mtr4: '', |
285 | 309 |
prblm_mtr5: '', |
286 | 310 |
prblm_mtr6: '', |
311 |
+ file_mng_id: '', |
|
287 | 312 |
prblmDetail: { |
288 | 313 |
answers: { |
289 |
- 1: { text: '', isCorrect: 'N', fileMngId: null }, |
|
290 |
- 2: { text: '', isCorrect: 'N', fileMngId: null }, |
|
291 |
- 3: { text: '', isCorrect: 'N', fileMngId: null }, |
|
292 |
- 4: { text: '', isCorrect: 'N', fileMngId: null }, |
|
293 |
- 5: { text: '', isCorrect: 'N', fileMngId: null }, |
|
314 |
+ 1: { text: '', isCorrect: 'N', fileMngId: null, fileInfo: '' }, |
|
315 |
+ 2: { text: '', isCorrect: 'N', fileMngId: null, fileInfo: '' }, |
|
316 |
+ 3: { text: '', isCorrect: 'N', fileMngId: null, fileInfo: '' }, |
|
317 |
+ 4: { text: '', isCorrect: 'N', fileMngId: null, fileInfo: '' }, |
|
318 |
+ 5: { text: '', isCorrect: 'N', fileMngId: null, fileInfo: '' }, |
|
294 | 319 |
}, |
295 | 320 |
correctIndex: null, // 정답으로 선택된 답의 인덱스 |
296 | 321 |
}, |
297 | 322 |
books: [], |
298 | 323 |
units: [], |
299 | 324 |
texts: [], |
300 |
- file: '', |
|
325 |
+ mainfile: null, |
|
301 | 326 |
selectedFiles: {}, |
302 | 327 |
} |
303 | 328 |
}, |
... | ... | @@ -314,61 +339,78 @@ |
314 | 339 |
this.selectedFiles[index] = files; |
315 | 340 |
}, |
316 | 341 |
|
317 |
- problemSearch() { |
|
318 |
- const vm = this; |
|
319 |
- vm.prblm = JSON.parse(sessionStorage.getItem("selectQuestionList")); |
|
320 |
- axios({ |
|
321 |
- url: "problem/problemInfo.json", |
|
322 |
- method: "post", |
|
323 |
- headers: { |
|
324 |
- "Content-Type": "application/json; charset=UTF-8", |
|
325 |
- }, |
|
326 |
- data: { |
|
327 |
- prblmId: vm.prblm.prblmId, |
|
328 |
- }, |
|
329 |
- }) |
|
330 |
- .then(function (res) { |
|
331 |
- console.log("problem - response : ", res.data); |
|
332 |
- vm.dataList = res.data.problem; |
|
333 |
- vm.problemDetail = res.data.problemDetail; |
|
342 |
+ // 문제 정보 가져오기 |
|
343 |
+ async problemSearch() { |
|
344 |
+ try { |
|
345 |
+ const vm = this; |
|
346 |
+ vm.prblm = JSON.parse(sessionStorage.getItem("selectQuestionList")); |
|
334 | 347 |
|
335 |
- vm.selectedSearchOption = vm.dataList.prblmCtgryId; |
|
336 |
- vm.selectedSearchOption2 = vm.dataList.prblmTypeId; |
|
337 |
- vm.book_id = vm.dataList.bookId; |
|
338 |
- vm.unit_id = vm.dataList.unitId; |
|
339 |
- vm.text_id = vm.dataList.textId; |
|
340 |
- vm.prblm_scr = vm.dataList.prblmScr; |
|
341 |
- vm.prblm_expln = vm.dataList.prblmExpln; |
|
342 |
- vm.prblm_hint = vm.dataList.prblmHint; |
|
343 |
- vm.prblm_cmmt = vm.dataList.prblmCmmt; |
|
344 |
- vm.prblm_mtr1 = vm.dataList.prblmMtr1; |
|
345 |
- vm.prblm_mtr2 = vm.dataList.prblmMtr2; |
|
346 |
- vm.prblm_mtr3 = vm.dataList.prblmMtr3; |
|
347 |
- vm.prblm_mtr4 = vm.dataList.prblmMtr4; |
|
348 |
- vm.prblm_mtr5 = vm.dataList.prblmMtr5; |
|
349 |
- vm.prblm_mtr6 = vm.dataList.prblmMtr6; |
|
348 |
+ const res = await axios({ |
|
349 |
+ url: "problem/problemInfo.json", |
|
350 |
+ method: "post", |
|
351 |
+ headers: { |
|
352 |
+ "Content-Type": "application/json; charset=UTF-8", |
|
353 |
+ }, |
|
354 |
+ data: { |
|
355 |
+ prblmId: vm.prblm.prblmId, |
|
356 |
+ }, |
|
357 |
+ }); |
|
350 | 358 |
|
351 |
- if (vm.problemDetail.length > 0) { |
|
352 |
- vm.prblmDetail.answers = vm.problemDetail.reduce((acc, detail, index) => { |
|
353 |
- acc[index + 1] = { |
|
354 |
- text: detail.prblmDtlExpln, |
|
355 |
- isCorrect: detail.prblmYn === 'Y' ? 'Y' : 'N', |
|
356 |
- fileMngId: detail.fileMngId || null |
|
357 |
- }; |
|
358 |
- return acc; |
|
359 |
- }, {}); |
|
359 |
+ console.log("problem - response : ", res.data); |
|
360 |
+ vm.dataList = res.data.problem; |
|
361 |
+ vm.problemDetail = res.data.problemDetail; |
|
360 | 362 |
|
361 |
- vm.prblmDetail.correctIndex = vm.problemDetail.findIndex(detail => detail.prblmYn === 'Y'); |
|
363 |
+ vm.selectedSearchOption = vm.dataList.prblmCtgryId; |
|
364 |
+ vm.selectedSearchOption2 = vm.dataList.prblmTypeId; |
|
365 |
+ vm.book_id = vm.dataList.bookId; |
|
366 |
+ vm.unit_id = vm.dataList.unitId; |
|
367 |
+ vm.text_id = vm.dataList.textId; |
|
368 |
+ vm.prblm_scr = vm.dataList.prblmScr; |
|
369 |
+ vm.prblm_expln = vm.dataList.prblmExpln; |
|
370 |
+ vm.prblm_hint = vm.dataList.prblmHint; |
|
371 |
+ vm.prblm_cmmt = vm.dataList.prblmCmmt; |
|
372 |
+ vm.prblm_mtr1 = vm.dataList.prblmMtr1; |
|
373 |
+ vm.prblm_mtr2 = vm.dataList.prblmMtr2; |
|
374 |
+ vm.prblm_mtr3 = vm.dataList.prblmMtr3; |
|
375 |
+ vm.prblm_mtr4 = vm.dataList.prblmMtr4; |
|
376 |
+ vm.prblm_mtr5 = vm.dataList.prblmMtr5; |
|
377 |
+ vm.prblm_mtr6 = vm.dataList.prblmMtr6; |
|
378 |
+ vm.file_mng_id = vm.dataList.fileMngId; |
|
362 | 379 |
|
363 |
- if (vm.dataList.prblmTypeId === 'prblm_type_009') { |
|
364 |
- vm.prblmDetail.answer1 = vm.problemDetail.find(detail => detail.prblmYn === 'Y') ? 'O' : 'X'; |
|
380 |
+ if (vm.problemDetail.length > 0) { |
|
381 |
+ vm.prblmDetail.answers = {}; |
|
382 |
+ |
|
383 |
+ for (let index = 0; index < vm.problemDetail.length; index++) { |
|
384 |
+ const detail = vm.problemDetail[index]; |
|
385 |
+ let fileInfo = null; |
|
386 |
+ |
|
387 |
+ if (detail.fileMngId) { |
|
388 |
+ fileInfo = await vm.findFile(detail.fileMngId); |
|
365 | 389 |
} |
390 |
+ |
|
391 |
+ vm.prblmDetail.answers[index + 1] = { |
|
392 |
+ prblmDtlId: detail.prblmDtlId, |
|
393 |
+ text: detail.prblmDtlExpln, |
|
394 |
+ isCorrect: detail.prblmYn === 'Y' ? 'Y' : 'N', |
|
395 |
+ fileMngId: detail.fileMngId || null, |
|
396 |
+ fileInfo: fileInfo |
|
397 |
+ }; |
|
366 | 398 |
} |
367 | 399 |
|
368 |
- }) |
|
369 |
- .catch(function (error) { |
|
370 |
- console.log("problem - error : ", error); |
|
371 |
- }); |
|
400 |
+ vm.prblmDetail.correctIndex = vm.problemDetail.findIndex(detail => detail.prblmYn === 'Y') + 1; |
|
401 |
+ |
|
402 |
+ if (vm.dataList.prblmTypeId === 'prblm_type_009') { |
|
403 |
+ vm.prblmDetail.answer1 = vm.problemDetail.find(detail => detail.prblmYn === 'Y') ? 'O' : 'X'; |
|
404 |
+ } |
|
405 |
+ } |
|
406 |
+ |
|
407 |
+ if (vm.file_mng_id) { |
|
408 |
+ vm.mainfile = await vm.findFile(vm.file_mng_id); |
|
409 |
+ } |
|
410 |
+ |
|
411 |
+ } catch (error) { |
|
412 |
+ console.log("problem - error : ", error); |
|
413 |
+ } |
|
372 | 414 |
}, |
373 | 415 |
|
374 | 416 |
// 문제 수정 |
... | ... | @@ -405,7 +447,7 @@ |
405 | 447 |
textId: this.text_id, // 지문 아이디 |
406 | 448 |
unitId: this.unit_id, // 단원 아이디 |
407 | 449 |
bookId: this.book_id, // 교재 아이디 |
408 |
- // userId: this.user_id, // 유저 아이디 |
|
450 |
+ // userId: this.user_id, // 유저 아이디 |
|
409 | 451 |
userId: 'USID_000000000000004', // 유저 아이디 |
410 | 452 |
prblmMtr1: this.prblm_mtr1, // 문제 지표 |
411 | 453 |
prblmMtr2: this.prblm_mtr2, |
... | ... | @@ -461,7 +503,7 @@ |
461 | 503 |
answerCount = 5; |
462 | 504 |
} else if (['prblm_type_004', 'prblm_type_006', 'prblm_type_024'].includes(this.selectedSearchOption2)) { |
463 | 505 |
answerCount = 4; |
464 |
- } else if (['prblm_type_001', 'prblm_type_005', 'prblm_type_019', 'prblm_type_022'].includes(this.selectedSearchOption2)) { |
|
506 |
+ } else if (['prblm_type_001', 'prblm_type_005', 'prblm_type_018', 'prblm_type_019', 'prblm_type_022'].includes(this.selectedSearchOption2)) { |
|
465 | 507 |
answerCount = 3; |
466 | 508 |
} else if (['prblm_type_002', 'prblm_type_003', 'prblm_type_007', 'prblm_type_023'].includes(this.selectedSearchOption2)) { |
467 | 509 |
answerCount = 2; |
... | ... | @@ -476,7 +518,7 @@ |
476 | 518 |
} |
477 | 519 |
|
478 | 520 |
details.push({ |
479 |
- prblmId, |
|
521 |
+ prblmDtlId: answers[i].prblmDtlId, |
|
480 | 522 |
prblmDtlExpln: answers[i].text || '', |
481 | 523 |
prblmYn: answers[i].isCorrect, // isCorrect가 'Y' 또는 'N'으로 설정됨 |
482 | 524 |
fileMngId: answers[i].fileMngId, |
... | ... | @@ -487,10 +529,10 @@ |
487 | 529 |
return details; |
488 | 530 |
}, |
489 | 531 |
|
490 |
- setCorrectAnswer(index) { |
|
532 |
+ setCorrectAnswer(index, size) { |
|
491 | 533 |
this.prblmDetail.correctIndex = index; |
492 | 534 |
// 선택된 인덱스의 답만 'Y'로 설정하고, 나머지는 'N'으로 설정 |
493 |
- for (let i = 1; i <= 5; i++) { |
|
535 |
+ for (let i = 1; i <= size; i++) { |
|
494 | 536 |
this.prblmDetail.answers[i].isCorrect = i === index ? 'Y' : 'N'; |
495 | 537 |
} |
496 | 538 |
}, |
... | ... | @@ -625,6 +667,32 @@ |
625 | 667 |
}); |
626 | 668 |
}, |
627 | 669 |
|
670 |
+ // 업로드한 파일 정보 가져오기 |
|
671 |
+ async findFile(fileMngId) { |
|
672 |
+ try { |
|
673 |
+ const response = await axios({ |
|
674 |
+ url: "/file/find.json", |
|
675 |
+ method: "post", |
|
676 |
+ headers: { |
|
677 |
+ "Content-Type": "application/json; charset=UTF-8", |
|
678 |
+ }, |
|
679 |
+ data: { |
|
680 |
+ file_mng_id: fileMngId, |
|
681 |
+ }, |
|
682 |
+ }); |
|
683 |
+ |
|
684 |
+ if (response.data && response.data.list) { |
|
685 |
+ return response.data.list; // 파일 정보를 반환 |
|
686 |
+ } else { |
|
687 |
+ console.error("파일 정보를 가져오는 데 실패했습니다: ", response.data); |
|
688 |
+ return []; |
|
689 |
+ } |
|
690 |
+ } catch (error) { |
|
691 |
+ console.log("result - error : ", error); |
|
692 |
+ return []; |
|
693 |
+ } |
|
694 |
+ } |
|
695 |
+ |
|
628 | 696 |
}, |
629 | 697 |
watch: { |
630 | 698 |
}, |
... | ... | @@ -641,6 +709,7 @@ |
641 | 709 |
|
642 | 710 |
this.fetchBooks(); |
643 | 711 |
this.fetchUnits(); |
712 |
+ this.fetchTexts(); |
|
644 | 713 |
|
645 | 714 |
this.problemSearch(); |
646 | 715 |
} |
--- client/views/pages/teacher/QuestionInsert.vue
+++ client/views/pages/teacher/QuestionInsert.vue
... | ... | @@ -620,6 +620,7 @@ |
620 | 620 |
|
621 | 621 |
this.fetchBooks(); |
622 | 622 |
this.fetchUnits(); |
623 |
+ this.fetchTexts(); |
|
623 | 624 |
} |
624 | 625 |
} |
625 | 626 |
|
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?