
--- client/resources/css/style.css
+++ client/resources/css/style.css
... | ... | @@ -969,6 +969,7 @@ |
969 | 969 |
height: 100%; |
970 | 970 |
top: 0; |
971 | 971 |
left: 0; |
972 |
+ |
|
972 | 973 |
} |
973 | 974 |
|
974 | 975 |
.popup-box { |
... | ... | @@ -976,8 +977,9 @@ |
976 | 977 |
min-width: 670px; |
977 | 978 |
/* min-height: 219px; */ |
978 | 979 |
background-color: var(--color-white); |
979 |
- top:23%; |
|
980 |
- left: 37%; |
|
980 |
+ top:50%; |
|
981 |
+ left: 5%; |
|
982 |
+ right: 5%; |
|
981 | 983 |
transform: translateY(-50%); |
982 | 984 |
border: 1px solid var(--color-gray); |
983 | 985 |
border-radius: 1rem; |
--- client/views/pages/teacher/RoadMap.vue
+++ client/views/pages/teacher/RoadMap.vue
... | ... | @@ -122,9 +122,9 @@ |
122 | 122 |
<P class="title2 mt10">{{ prblm.prblmExpln }}</P> |
123 | 123 |
</td> |
124 | 124 |
<td><button type="button" title="글쓰기" class="new-btn" |
125 |
- @click="deleteRoadMap('2', prblm.prblmId)"> |
|
126 |
- 삭제 |
|
127 |
- </button></td> |
|
125 |
+ @click="deleteRoadMap('2', prblm.prblmId)"> |
|
126 |
+ 삭제 |
|
127 |
+ </button></td> |
|
128 | 128 |
</tr> |
129 | 129 |
</tbody> |
130 | 130 |
</table> |
... | ... | @@ -200,7 +200,7 @@ |
200 | 200 |
<table> |
201 | 201 |
<thead> |
202 | 202 |
<tr> |
203 |
- <td>지문</td> |
|
203 |
+ <td>단어장</td> |
|
204 | 204 |
<td></td> |
205 | 205 |
</tr> |
206 | 206 |
</thead> |
... | ... | @@ -319,7 +319,7 @@ |
319 | 319 |
<table> |
320 | 320 |
<thead> |
321 | 321 |
<tr> |
322 |
- <td>지문</td> |
|
322 |
+ <td>단어장</td> |
|
323 | 323 |
<td></td> |
324 | 324 |
</tr> |
325 | 325 |
</thead> |
... | ... | @@ -427,8 +427,7 @@ |
427 | 427 |
</thead> |
428 | 428 |
<tbody> |
429 | 429 |
<tr v-for="(post, index) in posts" :key="index" class="post"> |
430 |
- <td><input type="checkbox" :checked="post.check" |
|
431 |
- @change="selectText(post)"></td> |
|
430 |
+ <td><input type="checkbox" :checked="post.check" @change="selectText(post)"></td> |
|
432 | 431 |
<td>{{ index + 1 }}</td> |
433 | 432 |
<td>{{ post.textTtl.slice(0, 20) }}{{ post.textTtl.length > 20 ? '...' : '' }}</td> |
434 | 433 |
<td>{{ post.textCnt.slice(0, 20) }}{{ post.textCnt.length > 20 ? '...' : '' }}</td> |
... | ... | @@ -659,7 +658,7 @@ |
659 | 658 |
|
660 | 659 |
<script> |
661 | 660 |
import SvgIcon from '@jamescoyle/vue-icon'; |
662 |
-import { mdiMagnify, mdilArrowRight } from '@mdi/js'; |
|
661 |
+import { mdiAccountTieHat, mdiMagnify, mdilArrowRight } from '@mdi/js'; |
|
663 | 662 |
import { mdilArrowDown } from '@mdi/light-js'; |
664 | 663 |
import ProgressBar from '../../component/ProgressBar.vue'; |
665 | 664 |
import axios from 'axios'; |
... | ... | @@ -678,11 +677,20 @@ |
678 | 677 |
units: [], |
679 | 678 |
posts: [], |
680 | 679 |
RoadMap: [], |
680 |
+ OrginRoadMap: [], |
|
681 | 681 |
problems: [], |
682 | 682 |
wordBooks: [], |
683 | 683 |
evals: [], |
684 | 684 |
selectedBook: "", |
685 | 685 |
selectedUnit: null, |
686 |
+ |
|
687 |
+ wordContentId1: "", |
|
688 |
+ wordContentId2: "", |
|
689 |
+ wordContentId3: "", |
|
690 |
+ |
|
691 |
+ learningId1: "", |
|
692 |
+ learningId2: "", |
|
693 |
+ learningId3: "", |
|
686 | 694 |
|
687 | 695 |
currentPage: 1, |
688 | 696 |
pageSize: 5, |
... | ... | @@ -696,6 +704,10 @@ |
696 | 704 |
searchEvalOpen: false, |
697 | 705 |
|
698 | 706 |
selectedPop: 0, |
707 |
+ |
|
708 |
+ isFirst: false, |
|
709 |
+ |
|
710 |
+ insertRoadId: '' |
|
699 | 711 |
} |
700 | 712 |
}, |
701 | 713 |
methods: { |
... | ... | @@ -763,7 +775,7 @@ |
763 | 775 |
}, |
764 | 776 |
|
765 | 777 |
// 로드맵 지정된 것 삭제 |
766 |
- deleteRoadMap(page, id){ |
|
778 |
+ deleteRoadMap(page, id) { |
|
767 | 779 |
if (page === '2' || page === '3' || page === '6') { |
768 | 780 |
this.RoadMap[page] = this.RoadMap[page].filter(prblm => prblm.prblmId !== id); |
769 | 781 |
} else if (page === '0' || page === '4' || page === '8') { |
... | ... | @@ -772,7 +784,7 @@ |
772 | 784 |
this.RoadMap[page] = this.RoadMap[page].filter(wordBook => wordBook.wdBookId !== id); |
773 | 785 |
} else if (page === '7' || page === '10') { |
774 | 786 |
this.RoadMap[page] = this.RoadMap[page].filter(evaluation => evaluation.evalId !== id); |
775 |
- } |
|
787 |
+ } |
|
776 | 788 |
}, |
777 | 789 |
|
778 | 790 |
fetchBooks() { |
... | ... | @@ -819,7 +831,7 @@ |
819 | 831 |
// 단원을 선택했을 때 호출되는 메서드 |
820 | 832 |
selectUnit(unitId) { |
821 | 833 |
this.selectedUnit = unitId; |
822 |
- //this.fetchData(); |
|
834 |
+ this.fetchRoadmapData(); |
|
823 | 835 |
}, |
824 | 836 |
|
825 | 837 |
// 문제 가져오기 |
... | ... | @@ -1073,8 +1085,15 @@ |
1073 | 1085 |
// 이미 있는 데이터인지 확인 |
1074 | 1086 |
selectedProblems.forEach(problem => { |
1075 | 1087 |
const exists = this.RoadMap[this.selectedPop].some(existingProblem => existingProblem.prblmId === problem.prblmId); |
1088 |
+ |
|
1076 | 1089 |
if (!exists) { |
1077 |
- this.RoadMap[this.selectedPop].push(problem); // 존재하지 않으면 추가 |
|
1090 |
+ // isFirst가 true일 경우, 기존 learningId를 유지하도록 처리 |
|
1091 |
+ const learningId = this.isFirst ? (this.RoadMap[this.selectedPop][0]?.learningId || null) : null; |
|
1092 |
+ this.RoadMap[this.selectedPop].push({ |
|
1093 |
+ prblmId: problem.prblmId, |
|
1094 |
+ prblmExpln: problem.prblmExpln, |
|
1095 |
+ learningId: learningId |
|
1096 |
+ }); |
|
1078 | 1097 |
} |
1079 | 1098 |
}); |
1080 | 1099 |
this.closeBtn(); |
... | ... | @@ -1083,7 +1102,16 @@ |
1083 | 1102 |
// 팝업 지문 데이터 가져오기 |
1084 | 1103 |
insertRoadMap2() { |
1085 | 1104 |
const selectedTexts = this.posts.filter(post => post.check); |
1086 |
- this.RoadMap[this.selectedPop] = selectedTexts; |
|
1105 |
+ if (selectedTexts.length > 0) { |
|
1106 |
+ const selectedText = selectedTexts[0]; |
|
1107 |
+ const learningId = this.isFirst ? (this.RoadMap[this.selectedPop][0]?.learningId || null) : null; |
|
1108 |
+ |
|
1109 |
+ this.RoadMap[this.selectedPop] = [{ |
|
1110 |
+ textId: selectedText.textId, |
|
1111 |
+ textTtl: selectedText.textTtl, |
|
1112 |
+ learningId: learningId |
|
1113 |
+ }]; |
|
1114 |
+ } |
|
1087 | 1115 |
this.closeBtn(); |
1088 | 1116 |
}, |
1089 | 1117 |
// 팝업 단어장 데이터 가져오기 |
... | ... | @@ -1097,36 +1125,445 @@ |
1097 | 1125 |
// 이미 있는 데이터인지 확인 |
1098 | 1126 |
selectedBooks.forEach(wordBook => { |
1099 | 1127 |
const exists = this.RoadMap[this.selectedPop].some(existingBook => existingBook.wdBookId === wordBook.wdBookId); |
1128 |
+ |
|
1100 | 1129 |
if (!exists) { |
1101 |
- this.RoadMap[this.selectedPop].push(wordBook); // 존재하지 않으면 추가 |
|
1130 |
+ const existingItem = this.RoadMap[this.selectedPop][0] || {}; |
|
1131 |
+ const learningId = this.isFirst ? existingItem.learningId : null; |
|
1132 |
+ |
|
1133 |
+ this.RoadMap[this.selectedPop].push({ |
|
1134 |
+ wdBookId: wordBook.wdBookId, |
|
1135 |
+ learningId: learningId, |
|
1136 |
+ textTtl: wordBook.textTtl |
|
1137 |
+ }); |
|
1102 | 1138 |
} |
1103 | 1139 |
}); |
1104 | 1140 |
this.closeBtn(); |
1105 | 1141 |
}, |
1106 |
- |
|
1107 | 1142 |
// 평가 데이터 가져오기 |
1108 | 1143 |
insertRoadMap4() { |
1109 | 1144 |
const selectedEval = this.evals.filter(evaluation => evaluation.check); |
1110 |
- this.RoadMap[this.selectedPop] = selectedEval; |
|
1145 |
+ if (selectedEval.length > 0) { |
|
1146 |
+ const evalData = selectedEval[0]; |
|
1147 |
+ const learningId = this.isFirst ? (this.RoadMap[this.selectedPop][0]?.learningId || null) : null; |
|
1148 |
+ |
|
1149 |
+ this.RoadMap[this.selectedPop] = [{ |
|
1150 |
+ evalId: evalData.evalId, |
|
1151 |
+ problemCount: evalData.problemCount, |
|
1152 |
+ learningId: learningId |
|
1153 |
+ }]; |
|
1154 |
+ } |
|
1111 | 1155 |
this.closeBtn(); |
1112 | 1156 |
}, |
1113 | 1157 |
|
1114 |
- // 로드맵 등록하기 |
|
1115 |
- postRoadMaps(){ |
|
1116 |
- console.log(this.RoadMap); |
|
1158 |
+ // 로드맵 정보 가져오기 |
|
1159 |
+ fetchRoadmapData() { |
|
1160 |
+ axios({ |
|
1161 |
+ url: "/unitLearning/find.json", |
|
1162 |
+ method: "post", |
|
1163 |
+ headers: { |
|
1164 |
+ "Content-Type": "application/json; charset=UTF-8", |
|
1165 |
+ }, |
|
1166 |
+ data: { |
|
1167 |
+ unit_id: this.selectedUnit, |
|
1168 |
+ book_id: this.selectedBook |
|
1169 |
+ } |
|
1170 |
+ }) |
|
1171 |
+ .then(response => { |
|
1172 |
+ if (response.data.length != 0) { |
|
1173 |
+ // RoadMap을 초기화 |
|
1174 |
+ this.RoadMap = Array.from({ length: 11 }, () => []); |
|
1117 | 1175 |
|
1176 |
+ // RoadMap을 구성하는 데이터 삽입 |
|
1177 |
+ response.data.forEach(item => { |
|
1178 |
+ const seqIndex = item.seq - 1; |
|
1179 |
+ |
|
1180 |
+ if (item.text_id && item.text_ttl) { |
|
1181 |
+ this.RoadMap[seqIndex].push({ |
|
1182 |
+ learningId: item.learning_id, |
|
1183 |
+ textId: item.text_id, |
|
1184 |
+ textTtl: item.text_ttl |
|
1185 |
+ }); |
|
1186 |
+ } |
|
1187 |
+ |
|
1188 |
+ if (item.wd_cnt_id) { |
|
1189 |
+ if (seqIndex === 1) { |
|
1190 |
+ this.wordContentId1 = item.wd_cnt_id; |
|
1191 |
+ } |
|
1192 |
+ if (seqIndex === 5) { |
|
1193 |
+ this.wordContentId2 = item.wd_cnt_id; |
|
1194 |
+ } |
|
1195 |
+ if (seqIndex === 9) { |
|
1196 |
+ this.wordContentId3 = item.wd_cnt_id; |
|
1197 |
+ } |
|
1198 |
+ this.RoadMap[seqIndex].push(...item.wordBooks.map(wb => ({ |
|
1199 |
+ wdCntId: item.wd_cnt_id, |
|
1200 |
+ learningId: item.learning_id, |
|
1201 |
+ wdBookId: wb.wd_book_id, |
|
1202 |
+ textTtl: wb.text_ttl2 |
|
1203 |
+ }))); |
|
1204 |
+ } |
|
1205 |
+ |
|
1206 |
+ if (item.prblm_id && item.prblm_id.length > 0) { |
|
1207 |
+ item.prblm_id.forEach(prblm => { |
|
1208 |
+ this.RoadMap[seqIndex].push({ |
|
1209 |
+ learningId: item.learning_id, |
|
1210 |
+ prblmId: prblm.prblm_id, |
|
1211 |
+ prblmExpln: prblm.prblm_expln |
|
1212 |
+ }); |
|
1213 |
+ }); |
|
1214 |
+ } |
|
1215 |
+ |
|
1216 |
+ if (item.eval_id) { |
|
1217 |
+ this.RoadMap[seqIndex].push({ |
|
1218 |
+ learningId: item.learning_id, |
|
1219 |
+ evalId: item.eval_id, |
|
1220 |
+ problemCount: item.problem_count |
|
1221 |
+ }); |
|
1222 |
+ } |
|
1223 |
+ }); |
|
1224 |
+ // 완성된 RoadMap을 OrginRoadMap에 깊은 복사하여 저장 |
|
1225 |
+ this.isFirst = true; |
|
1226 |
+ this.OrginRoadMap = JSON.parse(JSON.stringify(this.RoadMap)); |
|
1227 |
+ |
|
1228 |
+ } else { |
|
1229 |
+ this.RoadMap = []; |
|
1230 |
+ this.OrginRoadMap = []; |
|
1231 |
+ this.isFirst = false; |
|
1232 |
+ } |
|
1233 |
+ }) |
|
1234 |
+ .catch(error => { |
|
1235 |
+ console.error("Error fetching roadmap data:", error); |
|
1236 |
+ }); |
|
1237 |
+ }, |
|
1238 |
+ // wordcontent 처리하기 |
|
1239 |
+ async postWordContent() { |
|
1240 |
+ |
|
1241 |
+ const validPositions = [1, 5, 9]; |
|
1242 |
+ |
|
1243 |
+ for (const position of validPositions) { |
|
1244 |
+ const currentSeq = this.RoadMap[position]; |
|
1245 |
+ const originalSeq = this.OrginRoadMap[position] || []; |
|
1246 |
+ const insertList = []; |
|
1247 |
+ const insertExistList = []; |
|
1248 |
+ const updateList = []; |
|
1249 |
+ const deleteList = []; |
|
1250 |
+ |
|
1251 |
+ // 원본 데이터의 wdCntId와 wdBookId를 매핑하여 쉽게 조회할 수 있도록 객체화 |
|
1252 |
+ const originalMap = {}; |
|
1253 |
+ originalSeq.forEach(item => { |
|
1254 |
+ originalMap[item.wdCntId] = item.wdBookId; |
|
1255 |
+ }); |
|
1256 |
+ |
|
1257 |
+ // currentSeq와 originalSeq 비교 |
|
1258 |
+ const isEqual = currentSeq.length === originalSeq.length && currentSeq.every((currentItem, index) => { |
|
1259 |
+ const originalItem = originalSeq[index]; |
|
1260 |
+ return currentItem.wdCntId === originalItem.wdCntId && currentItem.wdBookId === originalItem.wdBookId; |
|
1261 |
+ }); |
|
1262 |
+ |
|
1263 |
+ // 동일할 경우 아무 작업도 하지 않음 |
|
1264 |
+ if (isEqual) { |
|
1265 |
+ console.log(`Position ${position}: currentSeq and originalSeq are identical. No action taken.`); |
|
1266 |
+ continue; // 다음 위치로 넘어감 |
|
1267 |
+ } |
|
1268 |
+ // 삭제할 데이터 찾기 |
|
1269 |
+ originalSeq.forEach(originalItem => { |
|
1270 |
+ const { wdCntId, wdBookId } = originalItem; |
|
1271 |
+ const currentItemExists = currentSeq.some(item => item.wdCntId === wdCntId); |
|
1272 |
+ |
|
1273 |
+ // 현재 시퀀스에 존재하지 않는 경우 삭제 리스트에 추가 |
|
1274 |
+ if (!currentItemExists) { |
|
1275 |
+ deleteList.push({ |
|
1276 |
+ wordContentId: wdCntId, |
|
1277 |
+ wordBookId: wdBookId, |
|
1278 |
+ }); |
|
1279 |
+ } |
|
1280 |
+ }); |
|
1281 |
+ |
|
1282 |
+ currentSeq.forEach(currentItem => { |
|
1283 |
+ const { wdBookId, wdCntId } = currentItem; |
|
1284 |
+ |
|
1285 |
+ if (!this.isFirst) { |
|
1286 |
+ insertList.push({ wordBookId: wdBookId }); |
|
1287 |
+ } else { |
|
1288 |
+ // 현재 아이템의 wdCntId가 원본에 존재하는지 확인 |
|
1289 |
+ if (originalMap[wdCntId] !== undefined) { |
|
1290 |
+ // 원본에 존재하는 경우 |
|
1291 |
+ const originalWdBookId = originalMap[wdCntId]; |
|
1292 |
+ |
|
1293 |
+ if (originalWdBookId !== wdBookId) { |
|
1294 |
+ // wdBookId가 변경된 경우 업데이트 리스트에 추가 |
|
1295 |
+ updateList.push({ |
|
1296 |
+ wordContentId: wdCntId, |
|
1297 |
+ wordBookId: originalWdBookId, // 기존 wdBookId |
|
1298 |
+ NewWordBookId: wdBookId, // 새로운 wdBookId |
|
1299 |
+ }); |
|
1300 |
+ } |
|
1301 |
+ } else { |
|
1302 |
+ // 원본에 존재하지 않는 경우 |
|
1303 |
+ let cntId = null; |
|
1304 |
+ if (position === 1) { |
|
1305 |
+ cntId = this.wordContentId1; |
|
1306 |
+ } else if (position === 5) { |
|
1307 |
+ cntId = this.wordContentId2; |
|
1308 |
+ } else if (position === 9) { |
|
1309 |
+ cntId = this.wordContentId3; |
|
1310 |
+ } |
|
1311 |
+ insertExistList.push({ wordBookId: wdBookId, wordContentId: cntId }); |
|
1312 |
+ } |
|
1313 |
+ } |
|
1314 |
+ }); |
|
1315 |
+ |
|
1316 |
+ // ID 생성 및 삽입 요청 |
|
1317 |
+ if (insertList.length > 0) { |
|
1318 |
+ const insertedId = await this.sendInsertRequest(insertList); |
|
1319 |
+ currentSeq.forEach(currentItem => { |
|
1320 |
+ if (!currentItem.wdCntId) { |
|
1321 |
+ if (position === 1) { |
|
1322 |
+ this.wordContentId1 = insertedId; |
|
1323 |
+ } else if (position === 5) { |
|
1324 |
+ this.wordContentId2 = insertedId; |
|
1325 |
+ } else if (position === 9) { |
|
1326 |
+ this.wordContentId3 = insertedId; |
|
1327 |
+ } |
|
1328 |
+ } |
|
1329 |
+ }); |
|
1330 |
+ } |
|
1331 |
+ |
|
1332 |
+ // 필요 시에만 추가 요청 보내기 |
|
1333 |
+ const promises = []; |
|
1334 |
+ if (insertExistList.length > 0) { |
|
1335 |
+ promises.push(this.sendInsertExistRequest(insertExistList)); |
|
1336 |
+ } |
|
1337 |
+ if (updateList.length > 0) { |
|
1338 |
+ promises.push(this.sendUpdateRequest(updateList)); |
|
1339 |
+ } |
|
1340 |
+ if (deleteList.length > 0) { |
|
1341 |
+ promises.push(this.sendDeleteRequest(deleteList)); |
|
1342 |
+ } |
|
1343 |
+ |
|
1344 |
+ // 모든 요청을 병렬로 실행 |
|
1345 |
+ if (promises.length > 0) { |
|
1346 |
+ await Promise.all(promises); |
|
1347 |
+ } |
|
1348 |
+ |
|
1349 |
+ } |
|
1350 |
+ }, |
|
1351 |
+ |
|
1352 |
+ // 데이터 삽입 요청 보내기 |
|
1353 |
+ async sendInsertRequest(insertList) { |
|
1354 |
+ try { |
|
1355 |
+ const response = await axios.post("/wordContent/insertContent.json", insertList); |
|
1356 |
+ console.log("Insert response:", response.data); |
|
1357 |
+ return response.data; // 응답에서 새로 생성된 ID 반환 |
|
1358 |
+ } catch (error) { |
|
1359 |
+ console.error("Error inserting data:", error); |
|
1360 |
+ throw error; // 오류 발생 시 재던지기 |
|
1361 |
+ } |
|
1362 |
+ }, |
|
1363 |
+ |
|
1364 |
+ // 존재하는 데이터 삽입 요청 보내기 |
|
1365 |
+ async sendInsertExistRequest(insertExistList) { |
|
1366 |
+ try { |
|
1367 |
+ const response = await axios.post("/wordContent/insertContentExist.json", insertExistList); |
|
1368 |
+ console.log("Insert Exist response:", response.data); |
|
1369 |
+ } catch (error) { |
|
1370 |
+ console.error("Error inserting existing data:", error); |
|
1371 |
+ } |
|
1372 |
+ }, |
|
1373 |
+ |
|
1374 |
+ // 데이터 업데이트 요청 보내기 |
|
1375 |
+ async sendUpdateRequest(updateList) { |
|
1376 |
+ try { |
|
1377 |
+ const response = await axios.post("/wordContent/updateContent.json", updateList); |
|
1378 |
+ console.log("Update response:", response.data); |
|
1379 |
+ } catch (error) { |
|
1380 |
+ console.error("Error updating data:", error); |
|
1381 |
+ } |
|
1382 |
+ }, |
|
1383 |
+ |
|
1384 |
+ // 데이터 삭제 요청 보내기 |
|
1385 |
+ async sendDeleteRequest(deleteList) { |
|
1386 |
+ try { |
|
1387 |
+ const response = await axios.post("/wordContent/deleteContent.json", deleteList); |
|
1388 |
+ console.log("Delete response:", response.data); |
|
1389 |
+ } catch (error) { |
|
1390 |
+ console.error("Error deleting data:", error); |
|
1391 |
+ } |
|
1392 |
+ }, |
|
1393 |
+ |
|
1394 |
+ // 로드맵 데이터 사용 |
|
1395 |
+ async postRoadMaps() { |
|
1396 |
+ console.log("로드맵", this.RoadMap); |
|
1397 |
+ |
|
1398 |
+ // RoadMap 배열의 각 요소 체크 |
|
1399 |
+ let isEmpty = false; |
|
1400 |
+ |
|
1401 |
+ this.RoadMap.forEach((item, index) => { |
|
1402 |
+ if (!item) { |
|
1403 |
+ isEmpty = true; |
|
1404 |
+ } |
|
1405 |
+ }); |
|
1406 |
+ |
|
1407 |
+ // 배열이 비어있으면 함수 종료 |
|
1408 |
+ if (isEmpty) { |
|
1409 |
+ alert(`학습 로드맵에 비어있는 데이터가 존재합니다.`); |
|
1410 |
+ return; |
|
1411 |
+ } |
|
1412 |
+ |
|
1413 |
+ // 먼저 워드 콘텐츠 등록 |
|
1414 |
+ await this.postWordContent();; |
|
1415 |
+ |
|
1416 |
+ if (this.isFirst) { |
|
1417 |
+ this.updateRoadData(); |
|
1418 |
+ } else { |
|
1419 |
+ this.insertRoadData(); |
|
1420 |
+ } |
|
1421 |
+ |
|
1422 |
+ |
|
1423 |
+ }, |
|
1424 |
+ |
|
1425 |
+ // 로드맵 등록하기 |
|
1426 |
+ insertRoadData() { |
|
1427 |
+ const unitLearningList = this.RoadMap.map((item, index) => { |
|
1428 |
+ // item이 배열인 경우 첫 번째 요소를 가져옵니다. |
|
1429 |
+ let firstItem = item.length > 0 ? item[0] : {}; |
|
1430 |
+ |
|
1431 |
+ // RoadMap의 인덱스에 따라 wordContentId 설정 |
|
1432 |
+ let wd_cnt_id; |
|
1433 |
+ if (index === 1) { |
|
1434 |
+ wd_cnt_id = this.wordContentId1; |
|
1435 |
+ firstItem.textId = null; |
|
1436 |
+ } else if (index === 5) { |
|
1437 |
+ wd_cnt_id = this.wordContentId2; |
|
1438 |
+ firstItem.textId = null; |
|
1439 |
+ } else if (index === 9) { |
|
1440 |
+ wd_cnt_id = this.wordContentId3; |
|
1441 |
+ firstItem.textId = null; |
|
1442 |
+ } else { |
|
1443 |
+ wd_cnt_id = null; // 다른 인덱스에 대해선 null 설정 |
|
1444 |
+ } |
|
1445 |
+ |
|
1446 |
+ return { |
|
1447 |
+ unit_id: this.selectedUnit, |
|
1448 |
+ wd_cnt_id: wd_cnt_id, // wordContentId |
|
1449 |
+ text_id: firstItem.textId || null, // 텍스트 ID |
|
1450 |
+ eval_id: firstItem.evalId || null, // 평가 ID |
|
1451 |
+ seq: index + 1 // seq는 1부터 시작 |
|
1452 |
+ }; |
|
1453 |
+ }); |
|
1454 |
+ |
|
1455 |
+ axios.post("/unitLearning/insert.json", unitLearningList) |
|
1456 |
+ .then(response => { |
|
1457 |
+ console.log(`Insert successful:`, response.data); |
|
1458 |
+ if (response.data) { |
|
1459 |
+ const learningIds = response.data; |
|
1460 |
+ learningIds.forEach(item => { |
|
1461 |
+ if (item.seq === 3) { |
|
1462 |
+ this.learningId1 = item.learning_id; |
|
1463 |
+ } else if (item.seq === 4) { |
|
1464 |
+ this.learningId2 = item.learning_id; |
|
1465 |
+ } else if (item.seq === 7) { |
|
1466 |
+ this.learningId3 = item.learning_id; |
|
1467 |
+ } |
|
1468 |
+ }); |
|
1469 |
+ this.postPrblmBook(); |
|
1470 |
+ } |
|
1471 |
+ |
|
1472 |
+ }) |
|
1473 |
+ .catch(error => { |
|
1474 |
+ console.error(`Error during insert`, error); |
|
1475 |
+ }); |
|
1476 |
+ }, |
|
1477 |
+ |
|
1478 |
+ // 로드맵 업데이트하기 |
|
1479 |
+ updateRoadData() { |
|
1480 |
+ const unitLearningList = this.RoadMap.map((item, index) => { |
|
1481 |
+ // item이 배열인 경우 첫 번째 요소를 가져옵니다. |
|
1482 |
+ let firstItem = item.length > 0 ? item[0] : {}; |
|
1483 |
+ |
|
1484 |
+ // RoadMap의 인덱스에 따라 wordContentId 설정 |
|
1485 |
+ let wd_cnt_id; |
|
1486 |
+ if (index === 1) { |
|
1487 |
+ wd_cnt_id = this.wordContentId1; |
|
1488 |
+ firstItem.textId = null; |
|
1489 |
+ } else if (index === 5) { |
|
1490 |
+ wd_cnt_id = this.wordContentId2; |
|
1491 |
+ firstItem.textId = null; |
|
1492 |
+ } else if (index === 9) { |
|
1493 |
+ wd_cnt_id = this.wordContentId3; |
|
1494 |
+ firstItem.textId = null; |
|
1495 |
+ } else { |
|
1496 |
+ wd_cnt_id = null; // 다른 인덱스에 대해선 null 설정 |
|
1497 |
+ } |
|
1498 |
+ |
|
1499 |
+ return { |
|
1500 |
+ learning_id: firstItem.learningId, // 기존 학습 ID를 사용 |
|
1501 |
+ wd_cnt_id: wd_cnt_id, // wordContentId |
|
1502 |
+ text_id: firstItem.textId || null, // 텍스트 ID |
|
1503 |
+ eval_id: firstItem.evalId || null, // 평가 ID |
|
1504 |
+ seq: index + 1 // seq는 1부터 시작 |
|
1505 |
+ }; |
|
1506 |
+ }); |
|
1507 |
+ |
|
1508 |
+ // 업데이트 요청 보내기 |
|
1509 |
+ axios.post("/unitLearning/update.json", unitLearningList) |
|
1510 |
+ .then(response => { |
|
1511 |
+ console.log(`Update successful:`, response.data); |
|
1512 |
+ if (response.data > 0) { |
|
1513 |
+ } |
|
1514 |
+ }) |
|
1515 |
+ .catch(error => { |
|
1516 |
+ console.error(`Error during update`, error); |
|
1517 |
+ }); |
|
1118 | 1518 |
}, |
1119 | 1519 |
|
1120 | 1520 |
// prblmbook 만들어 id 가져오기 |
1121 | 1521 |
postPrblmBook() { |
1522 |
+ const problemList = []; |
|
1122 | 1523 |
|
1524 |
+ // RoadMap에서 문제 ID 가져오기 |
|
1525 |
+ const roadMapIndices = [2, 3, 6]; |
|
1526 |
+ |
|
1527 |
+ if (this.learningId1) { |
|
1528 |
+ this.RoadMap[roadMapIndices[0]].forEach(prblm => { |
|
1529 |
+ problemList.push({ |
|
1530 |
+ learningId: this.learningId1, |
|
1531 |
+ prblmId: prblm.prblmId // RoadMap에서 가져온 문제 ID |
|
1532 |
+ }); |
|
1533 |
+ }); |
|
1534 |
+ } |
|
1535 |
+ |
|
1536 |
+ // learningId2에 대해 문제 등록 |
|
1537 |
+ if (this.learningId2) { |
|
1538 |
+ this.RoadMap[roadMapIndices[1]].forEach(prblm => { |
|
1539 |
+ problemList.push({ |
|
1540 |
+ learningId: this.learningId2, |
|
1541 |
+ prblmId: prblm.prblmId // RoadMap에서 가져온 문제 ID |
|
1542 |
+ }); |
|
1543 |
+ }); |
|
1544 |
+ } |
|
1545 |
+ |
|
1546 |
+ // learningId3에 대해 문제 등록 |
|
1547 |
+ if (this.learningId3) { |
|
1548 |
+ this.RoadMap[roadMapIndices[2]].forEach(prblm => { |
|
1549 |
+ problemList.push({ |
|
1550 |
+ learningId: this.learningId3, |
|
1551 |
+ prblmId: prblm.prblmId // RoadMap에서 가져온 문제 ID |
|
1552 |
+ }); |
|
1553 |
+ }); |
|
1554 |
+ } |
|
1555 |
+ |
|
1556 |
+ // 문제 등록 API 호출 |
|
1557 |
+ axios.post("/problemBook/register.json", problemList) |
|
1558 |
+ .then(response => { |
|
1559 |
+ console.log("Problems registered successfully:", response.data); |
|
1560 |
+ this.fetchRoadmapData(); |
|
1561 |
+ alert("학습로드맵 등록이 완료되었습니다!"); |
|
1562 |
+ }) |
|
1563 |
+ .catch(error => { |
|
1564 |
+ console.error("Error during registering problems:", error); |
|
1565 |
+ }); |
|
1123 | 1566 |
}, |
1124 |
- // wordcontent 만들어 id 가져오기 |
|
1125 |
- postWordContent() { |
|
1126 |
- |
|
1127 |
- }, |
|
1128 |
- |
|
1129 |
- // 로드맵 정보 가져오기 |
|
1130 | 1567 |
}, |
1131 | 1568 |
watch: { |
1132 | 1569 |
|
... | ... | @@ -1162,7 +1599,7 @@ |
1162 | 1599 |
|
1163 | 1600 |
this.fetchBooks(); |
1164 | 1601 |
this.fetchUnits(); |
1165 |
- |
|
1602 |
+ this.fetchRoadmapData(); |
|
1166 | 1603 |
} |
1167 | 1604 |
} |
1168 | 1605 |
</script> |
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?