File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
<template>
<div id="Chapter1_1" class="content-wrap">
<div style="margin: 30px 0px 50px; width: 20%">
<router-link to="/MyPlan.page">
<div class="logo mb25">
<img src="../../../../resources/img/new_img/logo_v2.png" alt="" />
</div>
</router-link>
</div>
<div
class="title-box mb25 flex align-center mt40"
style="justify-content: space-between"
>
<div>
<span class="title mr40">1. Hello WORLD</span>
<span class="subtitle">my name is dd</span>
</div>
<button class="completeBtn" @click="complete">학습 종료</button>
</div>
<div class="flex justify-between align-center">
<div
class="pre-btn"
:style="{ visibility: hiddenState ? 'hidden' : 'visible' }"
@click="previousProblem()"
>
<img src="../../../../resources/img/left.png" alt="" />
</div>
<div class="content title-box">
<div style="display: flex; justify-content: space-between">
<p class="title mt25 title-bg">step3-놀면서 배우는 영어</p>
<button id="returnButton" @click="returnPage" style="margin: 4rem">
<img src="../../../../resources/img/btn_return_50x50.png" alt="" />
<p>되돌리기</p>
</button>
</div>
<div class="flex align-center mb30">
<p class="subtitle2 mr20">
방문이 자물쇠로 잠겨져 있네? 세 개 중에 맞는 열쇠 하나를 찾아줘!
</p>
</div>
<div class="flex align-center justify-center" style="gap: 113px">
<div class="imgGroup">
<div class="flex" style="gap: 60px">
<button>
<img src="../../../../resources/img/img82_42s.png" alt="" />
<p>{{ beforeQuestion }}</p>
</button>
<button>
<img src="../../../../resources/img/img159_42s.png" alt="" />
</button>
<button>
<img src="../../../../resources/img/img83_42s.png" alt="" />
<p>{{ afterQuestion }}</p>
</button>
</div>
</div>
<div class="pickGroup">
<div class="pickImg">
<img src="../../../../resources/img/img84_42s.png" alt="" />
<img src="../../../../resources/img/img85_42s.png" alt="" />
<img src="../../../../resources/img/img86_42s.png" alt="" />
</div>
<div class="pickChoice">
<article class="flex justify-center mb50" style="gap: 60px">
<div class="flex" style="align-items: center">
<button @click="handleClick(1)">
<img
src="../../../../resources/img/img136_71s.png"
alt=""
/>
<p :class="{ active: selectedButton === 1 }">1</p>
</button>
<p>{{ choice[0] }}</p>
</div>
</article>
<article class="flex justify-center mb50" style="gap: 60px">
<div class="flex" style="align-items: center">
<button @click="handleClick(2)">
<img
src="../../../../resources/img/img136_71s.png"
alt=""
/>
<p :class="{ active: selectedButton === 2 }">2</p>
</button>
<p>{{ choice[1] }}</p>
</div>
</article>
<article class="flex justify-center" style="gap: 60px">
<div class="flex" style="align-items: center">
<button @click="handleClick(3)">
<img
src="../../../../resources/img/img136_71s.png"
alt=""
/>
<p :class="{ active: selectedButton === 3 }">3</p>
</button>
<p>{{ choice[2] }}</p>
</div>
</article>
</div>
</div>
</div>
<div style="text-align: right">
<button class="answerButton" @click="confirmAnswer">정답 확인</button>
</div>
</div>
<div class="next-btn" @click="nextProblem()">
<img src="../../../../resources/img/right.png" alt="" />
</div>
</div>
</div>
</template>
<script>
import axios from "axios";
export default {
data() {
return {
selectedButton: null, // 선택된 버튼을 추적하기 위한 데이터
example: "",
beforeQuestion: "",
afterQuestion: "",
choice: [],
answer: "",
prblm_id: [],
problemData: [],
// problemArr: [],
answerArr: [],
seq: this.$store.getters.seqNum,
hiddenState: false,
};
},
methods: {
complete() {
// 로컬 스토리지에서 currentDashboard 값을 가져옴
const savedState = localStorage.getItem("vuexState");
if (savedState) {
const parsedState = JSON.parse(savedState);
const currentDashboard = parsedState.currentDashboard;
const { unit_id, book_id } = this.$route.query;
if (currentDashboard === "Learning") {
// Learning 모드일 때 Dashboard로 이동
this.$router.push({
name: "Dashboard",
query: { value: this.seq, unit_id, book_id },
});
} else if (currentDashboard === "AI") {
// AI 모드일 때 AIDashboard로 이동
this.$router.push({
name: "AIDashboard",
query: { value: this.seq, unit_id, book_id },
});
}
} else {
console.error("currentDashboard 값이 없습니다.");
}
},
goToPage(page) {
this.$router.push({ name: page });
},
handleClick(buttonNumber) {
this.selectedButton = buttonNumber; // 선택된 버튼 번호 저장
},
confirmAnswer() {
if (this.selectedButton === null) {
alert("정답을 선택해주세요.");
return;
}
if (this.selectedButton === this.answer) {
alert("정답입니다!");
this.nextProblem();
} else {
alert("오답입니다!");
}
this.selectedButton = null;
},
returnPage() {
window.location.reload();
},
nextProblem() {
if (
this.currentProblemIndex <
this.$store.state.currentLearningIds.length - 1
) {
this.$store.dispatch("goToNextProblem");
this.handleProblemDetail(this.currentLearningId);
this.goToPage(this.problemType);
} else {
// 마지막 문제면 이동
// this.goToPage("Chapter4");
alert("문제 학습 완료");
this.complete();
}
},
previousProblem() {
if (this.currentProblemIndex > 0) {
this.$store.dispatch("goToPreviousProblem");
this.handleProblemDetail(this.currentLearningId);
this.goToPage(this.problemType);
}
},
handleProblemDetail(item) {
if (item.prblm_type_id === "prblm_type_001") {
this.problemType = "Chapter3";
} else if (item.prblm_type_id === "prblm_type_002") {
this.problemType = "Chapter3_1";
} else if (item.prblm_type_id === "prblm_type_003") {
this.problemType = "Chapter3_2";
} else if (item.prblm_type_id === "prblm_type_004") {
this.problemType = "Chapter3_3";
} else if (item.prblm_type_id === "prblm_type_005") {
this.problemType = "Chapter3_3_1";
} else if (item.prblm_type_id === "prblm_type_006") {
this.problemType = "Chapter3_4";
} else if (item.prblm_type_id === "prblm_type_007") {
this.problemType = "Chapter3_5";
} else if (item.prblm_type_id === "prblm_type_008") {
this.problemType = "Chapter3_6";
} else if (item.prblm_type_id === "prblm_type_009") {
this.problemType = "Chapter3_7";
} else if (item.prblm_type_id === "prblm_type_010") {
this.problemType = "Chapter3_8";
} else if (item.prblm_type_id === "prblm_type_011") {
this.problemType = "Chapter3_9";
} else if (item.prblm_type_id === "prblm_type_012") {
this.problemType = "Chapter3_10";
} else if (item.prblm_type_id === "prblm_type_013") {
this.problemType = "Chapter3_11";
} else if (item.prblm_type_id === "prblm_type_014") {
this.problemType = "Chapter3_12";
} else if (item.prblm_type_id === "prblm_type_015") {
this.problemType = "Chapter3_13";
} else if (item.prblm_type_id === "prblm_type_016") {
this.problemType = "Chapter3_14";
} else if (item.prblm_type_id === "prblm_type_017") {
this.problemType = "Chapter3_15";
} else if (item.prblm_type_id === "prblm_type_018") {
this.problemType = "Chapter2_8";
} else if (item.prblm_type_id === "prblm_type_019") {
this.problemType = "Chapter2_7";
} else if (item.prblm_type_id === "prblm_type_020") {
this.problemType = "Chapter2_5";
} else if (item.prblm_type_id === "prblm_type_021") {
this.problemType = "Chapter2_6";
} else if (item.prblm_type_id === "prblm_type_022") {
this.problemType = "Chapter2_10";
} else if (item.prblm_type_id === "prblm_type_023") {
this.problemType = "Chapter2_11";
} else if (item.prblm_type_id === "prblm_type_024") {
this.problemType = "Chapter2_13";
}
},
// fetchProblemData() {
// axios({
// url: "/problem/problemInfo.json",
// method: "post",
// headers: {
// "Content-Type": "application/json; charset=UTF-8",
// },
// data: {
// prblmId: this.prblm_id.prblm_id,
// },
// })
// .then((response) => {
// this.problemData = response.data;
// console.log("problemData", this.problemData);
// this.sortingProblem();
// })
// .catch((error) => {
// this.state = "noProblem";
// console.error("Error fetching problemData:", error);
// });
// },
fetchProblemData() {
// 로컬 스토리지에서 currentDashboard를 확인
const savedState = localStorage.getItem("vuexState");
if (savedState) {
const parsedState = JSON.parse(savedState);
const currentDashboard = parsedState.currentDashboard;
if (currentDashboard === "AI") {
// AI 모드일 경우 로컬 스토리지에서 currentLearningId를 가져와 사용
const currentLearningId = parsedState.currentLearningIds;
console.log("AI 모드에서 currentLearningId 사용:", currentLearningId);
// currentLearningId로 문제 데이터 가져오기
axios({
url: "/problem/problemInfo.json",
method: "post",
headers: {
"Content-Type": "application/json; charset=UTF-8",
},
data: {
prblmId: currentLearningId, // 로컬스토리지에서 가져온 currentLearningId 사용
},
})
.then((response) => {
this.problemData = response.data;
console.log("AI 모드 problemData", this.problemData);
this.sortingProblem();
})
.catch((error) => {
this.state = "noProblem";
console.error("Error fetching AI problemData:", error);
});
} else {
// Learning 모드일 경우 기존 로직 사용
console.log("Learning 모드에서 prblm_id 사용:", this.prblm_id);
axios({
url: "/problem/problemInfo.json",
method: "post",
headers: {
"Content-Type": "application/json; charset=UTF-8",
},
data: {
prblmId: this.prblm_id.prblm_id, // 기존 방식 사용
},
})
.then((response) => {
this.problemData = response.data;
console.log("Learning 모드 problemData", this.problemData);
this.sortingProblem();
})
.catch((error) => {
this.state = "noProblem";
console.error("Error fetching problemData:", error);
});
}
} else {
console.error("vuexState가 로컬스토리지에 없습니다.");
}
},
sortingProblem() {
this.example = this.problemData.problem.prblmExpln;
const parts = this.example.split("/");
if (parts.length === 3) {
this.beforeQuestion = parts[0];
this.afterQuestion = parts[1];
}
for (let i = 0; i < this.problemData.problemDetail.length; i++) {
// this.answerArr[i].prblmDtlExpln =
// this.problemData.problemDetail[i].prblmDtlExpln;
// this.answerArr[i].prblmYn = this.problemData.problemDetail[i].prblmYn;
this.answerArr[i] = this.problemData.problemDetail[i];
this.choice[i] = this.problemData.problemDetail[i].prblmDtlExpln;
}
console.log("answerArr", this.answerArr);
for (let i = 0; i < this.answerArr.length; i++) {
if (this.answerArr[i].prblmYn == "Y") {
this.answer = i + 1;
break;
}
}
},
},
computed: {
currentLearningId() {
return this.$store.getters.currentLearningId;
},
currentLabel() {
return this.$store.getters.currentLabel;
},
currentProblemIndex() {
return this.$store.getters.currentProblemIndex;
},
isPreviousButtonDisabled() {
return this.currentProblemIndex === 0;
},
},
created() {
console.log("Current Learning ID:", this.currentLearningId);
this.prblm_id = this.currentLearningId;
console.log("Current Label:", this.currentLabel);
console.log("Current Problem Index:", this.currentProblemIndex);
// Fetch or process the current problem based on `currentLearningId`
},
mounted() {
this.fetchProblemData();
if (this.currentProblemIndex == 0) {
this.hiddenState = true;
}
},
};
</script>
<style scoped>
.imgGroup {
width: fit-content;
}
.imgGroup button {
position: relative;
}
.imgGroup button p,
.textbox p {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: fit-content;
height: fit-content;
background: #ffffffb8;
border-radius: 5px;
padding: 10px;
font-size: 23px;
font-family: "ONEMobilePOP";
}
.pickGroup {
display: flex;
flex-direction: row;
align-items: center;
gap: 40px;
}
.pickGroup button {
position: relative;
margin-right: 30px;
}
.pickGroup button p {
font-size: 34px;
color: #c6c6c6;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.pickGroup article img {
object-fit: contain;
width: -webkit-fill-available;
}
.pickGroup article > div > p {
font-size: 25px;
white-space: nowrap;
/* 텍스트가 줄 바꿈 없이 한 줄로 표시되도록 설정 */
}
.pickGroup button p.active {
color: #000;
/* 선택된 버튼의 숫자 색을 더 진하게 */
}
.pickImg {
display: flex;
flex-direction: column;
gap: 70px;
}
.pickChoice {
display: flex;
flex-direction: column;
align-items: flex-start;
}
.answerButton {
background-color: #ffc107;
border-radius: 30px;
padding: 20px 50px;
margin: 40px;
font-family: "ONEMobileOTF-Regular";
font-weight: bold;
font-size: 24px;
}
.completeBtn {
margin-right: 100px;
background-color: #ffba08;
padding: 10px 30px;
border-radius: 10px;
font-size: 28px;
font-family: "ONEMobilePOPOTF";
}
</style>