<template>
<div id="app" class="container fw-bold">
<QuestionComponent
v-for="(question, index) in questions"
:key="index"
:question="question.question"
:answer="question.answer"
:index="index"
:total-count="questions.length"
v-show="index == showIndex"
:image="question.image"
@next-move="nextMove"
@prev-move="prevMove"
@save-answer="saveAnswer"
/>
<button
class="submit-button"
@click="submitAnswers"
v-show="showIndex != -1"
>
Submit
</button>
<ResultComponent
v-if="showIndex === -1"
:correct-answer-count="correctAnswerCount"
:total-count="questions.length"
:wrongAnswerList="getWrongtAnswerList"
:wrongQuestionList="getWrongQuestionList"
/>
</div>
</template>
<script>
import QuestionComponent from "@/components/QuestionComponent.vue";
import ResultComponent from "@/components/ResultComponent.vue";
import _ from 'lodash';
export default {
name: "App",
data() {
return {
questions: [
{
question:
"다음 중, Vue 인스턴스와 div를 연동하기 위해 빈칸에 넣어주어야 할 속성은?",
answer: {
a: "computed",
b: "methods",
c: "method",
d: "el",
},
image: require("@/assets/problem1.png"),
correctAnswer: "d",
},
{
question:
"html에 입력한 값이 달라지면 자동으로 Vue의 data 값도 바뀌도록 프로그램을 짜려고 할 때, input 태그 안에 넣어야 할 속성으로 알맞은 것은? ",
answer: {
a: "v-for",
b: "v-model",
c: "v-if",
d: "v-bind",
},
image: require("@/assets/problem2.png"),
correctAnswer: "b",
},
{
question:
"app 이라는 이름으로 만든 Vue 인스턴스 안에서 methods를 이용하여 message값을 바꾸려고 한다. 다음 중 methods를 잘못 정의한것은?",
answer: {
a: 'myFunction(){ this.message ="Hi"}',
b: 'myFunction : function(){ this.message = "hi"}',
c: 'myFunction : ()=>{ app.message = "hi" }',
d: 'myFunction : ()=>{ this.message = "hi"}',
},
image: require("@/assets/problem3.png"),
correctAnswer: "d",
},
{
question:
"다음 중, Vue 인스턴스의 watch 속성에서 오브젝트의 변화를 감지하기 위해 추가해야하는 속성은?",
answer: {
a: "handler",
b: "deep",
c: "set",
d: "on",
},
image: require("@/assets/problem4.png"),
correctAnswer: "b",
},
{
question:
"다음 중, Vue 인스턴스의 watch 속성에서 해당 data의 변화를 감지하면 실행되는 함수의 이름은?",
answer: {
a: "handler",
b: "deep",
c: "set",
d: "handle",
},
image: require("@/assets/problem5.png"),
correctAnswer: "a",
},
{
question:
"vue/cli 에서 style scoped를 주지 않고 스타일을 적용시켰을 때, 적용되는 범위로 알맞은것은?",
answer: {
a: "해당 컴포넌트에만 스타일이 적용된다.",
b: "해당 컴포넌트와 부모 컴포넌트에만 스타일 적용된다.",
c: "해당 컴포넌트와 자식 컴포넌트에만 스타일 적용된다.",
d: "모든 컴포넌트에 스타일이 적용된다.",
},
image: require("@/assets/problem6.png"),
correctAnswer: "d",
},
{
question: "style scoped의 설명으로 옳지 않은것은?",
answer: {
a: "전역 스타일과 겹치는 스타일이 있더라도 해당 스타일이 적용된다.",
b: "해당 컴포넌트에만 스타일이 적용된다 .",
c: "부모 태그에게도 해당 스타일이 적용된다.",
d: "스타일 태그의 적용 범위를 조절하기 위해 사용한다",
},
image: require("@/assets/problem7.png"),
correctAnswer: "c",
},
{
question: "다음 중 코드에 들어간 @는 어느 폴더를 가리키는가??",
answer: {
a: "dist",
b: "public",
c: "components",
d: "src",
},
image: require("@/assets/problem8.png"),
correctAnswer: "d",
},
{
question:
"특정 조건이 false일 때, display:none을 이용하여 화면 출력을 제어할 수 있는 속성은?",
answer: {
a: "v-if",
b: "v-else",
c: "v-bind",
d: "v-show",
},
image: require("@/assets/problem9.png"),
correctAnswer: "d",
},
{
question:
"특정 조건이 false일 때, 해당 요소를 HTML태그에서 제거하여 화면 출력을 제어할 수 있는 속성은?",
answer: {
a: "v-if",
b: "v-else",
c: "v-bind",
d: "v-show",
},
image: require("@/assets/problem10.png"),
correctAnswer: "a",
},
{
question:
"다음 코드와 같이 자식 컴포넌트에 props를 전달하고자 한다. html태그 안에 들어가야 할 속성의 case로 알맞은것은?",
answer: {
a: "camelCase",
b: "kebab-case",
c: "snake_case",
d: "PascalCase",
},
image: require("@/assets/problem11.png"),
correctAnswer: "b",
},
{
question:
"static prop을 이용하여 다음과 같이 값을 넘겨 주었을 때, 값의 type으로 알맞은것은?",
answer: {
a: "Object",
b: "Number",
c: "String",
d: "Array",
},
image: require("@/assets/problem12.png"),
correctAnswer: "c",
},
{
question:
"dynamic prop을 이용하여 다음과 같이 값을 넘겨 주었을 때, 자식 태그의 props 에서 받게되는 변수명의 이름은?",
answer: {
a: "passTotalCount",
b: "totalCount",
c: "total-count",
d: "pass_total_count",
},
image: require("@/assets/problem13.png"),
correctAnswer: "b",
},
{
question:
"dynamic prop으로 다음과 같이 값을 내려주었을 때, 해당 값의 타입으로 알맞은것은?",
answer: {
a: "Object",
b: "Number",
c: "String",
d: "Array",
},
image: require("@/assets/problem14.png"),
correctAnswer: "b",
},
{
question:
"버튼을 눌러 부모에게 받은 index값을 수정하려고 한다. 해당 메소드의 빈칸에 들어갈 값으로 알맞은것은?",
answer: {
a: "$store",
b: "$event",
c: "$on",
d: "$emit",
},
image: require("@/assets/problem15.png"),
correctAnswer: "d",
},
{
question:
"자식 객체에서 발생시킨 이벤트를 가져올 때, 컴포넌트의 html태그 안에서 @이후에 사용되는 case는?",
answer: {
a: "kebab-case",
b: "camelCase",
c: "PascalCase",
d: "snake_case",
},
image: require("@/assets/problem16.png"),
correctAnswer: "a",
},
{
question:
"다음 중 Vuex에서 Vue의 data와 비슷한 기능을 하는 속성으로, Vue 인스턴스의 상태를 정의하는 곳은?",
answer: {
a: "state",
b: "mutations",
c: "getters",
d: "actions",
},
image: require("@/assets/problem17.png"),
correctAnswer: "a",
},
{
question:
"다음 중 Vuex에서 state를 값을 변경하는 함수들을 정의하는 곳으로, 동기 함수들만 사용이 가능한 곳은?",
answer: {
a: "state",
b: "mutations",
c: "getters",
d: "actions",
},
image: require("@/assets/problem18.png"),
correctAnswer: "b",
},
{
question:
"다음 중 Vuex에서 state를 값을 변경하는 함수들을 정의하는 곳으로, 비동기 함수의 사용이 가능한 곳은?",
answer: {
a: "state",
b: "mutations",
c: "getters",
d: "actions",
},
image: require("@/assets/problem19.png"),
correctAnswer: "d",
},
{
question:
"다음 중 Vuex에서 state를 값을 변경하지 않고, state를 이용하여 계산된 식을 return해주는 함수를 정의하는 곳은?",
answer: {
a: "state",
b: "mutations",
c: "getters",
d: "actions",
},
image: require("@/assets/problem20.png"),
correctAnswer: "c",
},
{
question: "mutations의 첫번째 함수에 들어오는 값은?",
answer: {
a: "state",
b: "store",
c: "context",
d: "index",
},
image: require("@/assets/problem21.png"),
correctAnswer: "a",
},
{
question: "actions의 함수에 첫번째 인자로 들어오는 값은?",
answer: {
a: "state",
b: "store",
c: "context",
d: "index",
},
image: require("@/assets/problem22.png"),
correctAnswer: "c",
},
{
question:
"Vue 컴포넌트에서 Vue store에 있는 mutations를 사용하기 위해 사용해야하는 함수로 올바른것은?",
answer: {
a: "dispatch",
b: "emit",
c: "getters",
d: "commit",
},
image: require("@/assets/problem23.png"),
correctAnswer: "d",
},
{
question:
"Vue 컴포넌트에서 Vue store에 있는 actions를 사용하기 위해 사용해야하는 함수로 올바른것은?",
answer: {
a: "emit",
b: "dispatch",
c: "commit",
d: "store",
},
image: require("@/assets/problem24.png"),
correctAnswer: "b",
},
{
question:
"Vuex의 state 중 message를 Component에서 가져와 사용하려고 할 때, 올바르게 호출한 것은?",
answer: {
a: "this.store.state.message",
b: "this.store.$state.message",
c: "this.$store.$state.message",
d: "this.$store.state.message",
},
image: require("@/assets/problem25.png"),
correctAnswer: "d",
},
{
question:
"Vuex의 getters 중 messageLength라는 함수의 리턴값을 Component에서 가져와 사용하려고 할 때, 올바르게 호출한 것은?",
answer: {
a: "this.$store.getters.messageLength",
b: "this.$getters.messageLength()",
c: "this.$store.getters.messageLength()",
d: "this.$store.getters('messageLength')",
},
image: require("@/assets/problem26.png"),
correctAnswer: "a",
},
{
question:
"Vuex의 getters에서 해당 getters에 선언된 다른 함수를 사용하려고 한다. b 변수에 할당되는 값으로 알맞은것은?",
answer: {
a: "context",
b: "state",
c: "this",
d: "getters",
},
image: require("@/assets/problem27.png"),
correctAnswer: "d",
},
{
question: "해당 코드에서 a변수에 할당되는 값으로 알맞은것은?",
answer: {
a: "this",
b: "window",
c: "state",
d: "store",
},
image: require("@/assets/problem28.png"),
correctAnswer: "c",
},
{
question:
"dynamic prop을 이용하여 다음과 같이 값을 넘겨 주었을 때, 값의 type으로 알맞은것은?",
answer: {
a: "Object",
b: "Number",
c: "String",
d: "Array",
},
image: require("@/assets/problem29.png"),
correctAnswer: "a",
},
{
question:
"다음 중 vue/cli에서 data를 정의하는 방법으로 옳은 것은?",
answer: {
a: "data : { message:'duljji' }",
b: "data(){ {message : 'duljji'} }",
c: "data(){ return message : 'duljji'}",
d: "data(){ return { message : 'duljji'} }",
},
image: require("@/assets/problem30.png"),
correctAnswer: "d",
},
{
question:
"다음은 v-for를 활용하여 li를 반복하는 코드이다. a, b, 에 들어오는 값과 c에 넣어야 할 속성으로 알맞은것은?",
answer: {
a: "a : key(index), b:value, c : :key ",
b: "a : key(index), b:value, c : key",
c: "a : value, b : key(index), c : :key",
d: "a : value, b : key(index), c : key",
},
image: require("@/assets/problem31.png"),
correctAnswer: "c",
},
{
question:
"Life Cycle Hooks 중 Vue 인스턴스가 생성될 때 실행되며, HTML태그에 접근할 수 없는 Hook은?",
answer: {
a: "created",
b: "mounted",
c: "updated",
d: "destroyed",
},
image: require("@/assets/problem19.png"),
correctAnswer: "a",
},
{
question:
"Life Cycle Hooks 중 Vue 인스턴스가 HTML태그에 등록될 때, HTML태그에 접근이 가능한 Hook은?",
answer: {
a: "created",
b: "mounted",
c: "updated",
d: "destroyed",
},
image: require("@/assets/problem19.png"),
correctAnswer: "b",
},
{
question:
"Life Cycle Hooks 중 Vue 인스턴스에 변화가 발생할 때 실행되는 Hook은?",
answer: {
a: "created",
b: "mounted",
c: "updated",
d: "watch",
},
image: require("@/assets/problem19.png"),
correctAnswer: "c",
},
{
question:
"다음 코드의 설명으로 옳지 않은 것은?",
answer: {
a: "cute 클래스는 vue data와 관계없이 무조건 적용된다.",
b: "pretty 클래스는 isActive의 값이 true인지 false인지에 따라 적용 여부가 결정된다.",
c: "style color는 vue data의 color값이 true인지 false인지에 따라 적용 여부가 결정된다.",
d: "li 태그의 글자색은 빨간색이다",
},
image: require("@/assets/problem32.png"),
correctAnswer: "c",
},
],
showIndex: 0,
selectedAnswerList: [],
};
},
components: {
QuestionComponent,
ResultComponent,
},
methods: {
nextMove() {
this.showIndex =
this.showIndex + 1 > this.questions.length - 1
? this.questions.length - 1
: this.showIndex + 1;
},
prevMove() {
this.showIndex = this.showIndex - 1 < 0 ? 0 : this.showIndex - 1;
},
saveAnswer({ index, selectedAnswer }) {
this.selectedAnswerList[index] = selectedAnswer;
console.log(this.selectedAnswerList);
},
submitAnswers() {
this.showIndex = -1;
},
},
computed: {
correctAnswerCount() {
let correctAnswerCount = 0;
this.selectedAnswerList.forEach((selectedAnswer, idx) => {
console.log(selectedAnswer, this.questions[idx].correctAnswer);
if (selectedAnswer === this.questions[idx].correctAnswer) {
correctAnswerCount++;
}
});
return correctAnswerCount;
},
getWrongtAnswerList() {
const wrongAnswerList = this.selectedAnswerList.filter(
(selectedAnswer, idx) => {
return selectedAnswer != this.questions[idx].correctAnswer;
}
);
console.log(wrongAnswerList);
return wrongAnswerList;
},
getWrongQuestionList() {
const wrongQuestionList = this.questions.filter((question, idx) => {
return this.selectedAnswerList[idx] != question.correctAnswer;
});
console.log(wrongQuestionList);
return wrongQuestionList;
},
},
created() {
this.questions = _.shuffle(this.questions)
this.selectedAnswerList = new Array(this.questions.length).fill("");
},
};
</script>
<style scoped>
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
margin-top: 60px;
}
.container {
background-color: #fce4ec;
border-radius: 10px;
box-shadow: 0 0 20px 0 rgba(255, 105, 180, 0.5);
padding: 40px;
}
.question-text {
font-size: 24px;
color: #333333;
margin-bottom: 20px;
}
.answer-label {
font-size: 20px;
color: #333333;
margin-bottom: 10px;
}
.answer-input {
margin-right: 10px;
}
.submit-button {
background-color: #ff69b4;
border: none;
border-radius: 50px;
color: white;
font-size: 18px;
padding: 10px 30px;
margin-top: 30px;
box-shadow: 0 0 20px 0 rgba(255, 105, 180, 0.5);
transition: all 0.3s ease-in-out;
}
.submit-button:hover {
background-color: #ff94c2;
box-shadow: 0 0 20px 0 rgba(255, 105, 180, 0.8);
cursor: pointer;
}
</style>