이수빈

update test 2

[{"C:\\Users\\subin\\Desktop\\khuhub_color\\Find_your_own_personal_color\\front\\src\\App.js":"1","C:\\Users\\subin\\Desktop\\khuhub_color\\Find_your_own_personal_color\\front\\src\\Home.js":"2","C:\\Users\\subin\\Desktop\\khuhub_color\\Find_your_own_personal_color\\front\\src\\test.js":"3","C:\\Users\\subin\\Desktop\\khuhub_color\\Find_your_own_personal_color\\front\\src\\index.js":"4"},{"size":450,"mtime":1606585705558,"results":"5","hashOfConfig":"6"},{"size":493,"mtime":1606590087333,"results":"7","hashOfConfig":"6"},{"size":2683,"mtime":1606596439882,"results":"8","hashOfConfig":"6"},{"size":238,"mtime":1606589880919,"results":"9","hashOfConfig":"6"},{"filePath":"10","messages":"11","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"pqxpq",{"filePath":"12","messages":"13","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"14","messages":"15","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"16","messages":"17","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"C:\\Users\\subin\\Desktop\\khuhub_color\\Find_your_own_personal_color\\front\\src\\App.js",[],"C:\\Users\\subin\\Desktop\\khuhub_color\\Find_your_own_personal_color\\front\\src\\Home.js",[],"C:\\Users\\subin\\Desktop\\khuhub_color\\Find_your_own_personal_color\\front\\src\\test.js",[],"C:\\Users\\subin\\Desktop\\khuhub_color\\Find_your_own_personal_color\\front\\src\\index.js",[]]
\ No newline at end of file
[{"C:\\Users\\subin\\Desktop\\khuhub_color\\Find_your_own_personal_color\\front\\src\\App.js":"1","C:\\Users\\subin\\Desktop\\khuhub_color\\Find_your_own_personal_color\\front\\src\\Home.js":"2","C:\\Users\\subin\\Desktop\\khuhub_color\\Find_your_own_personal_color\\front\\src\\test.js":"3","C:\\Users\\subin\\Desktop\\khuhub_color\\Find_your_own_personal_color\\front\\src\\index.js":"4"},{"size":450,"mtime":1606585705558,"results":"5","hashOfConfig":"6"},{"size":493,"mtime":1606590087333,"results":"7","hashOfConfig":"6"},{"size":2628,"mtime":1606613746724,"results":"8","hashOfConfig":"6"},{"size":238,"mtime":1606589880919,"results":"9","hashOfConfig":"6"},{"filePath":"10","messages":"11","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"pqxpq",{"filePath":"12","messages":"13","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"14","messages":"15","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"16","messages":"17","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"C:\\Users\\subin\\Desktop\\khuhub_color\\Find_your_own_personal_color\\front\\src\\App.js",[],"C:\\Users\\subin\\Desktop\\khuhub_color\\Find_your_own_personal_color\\front\\src\\Home.js",[],"C:\\Users\\subin\\Desktop\\khuhub_color\\Find_your_own_personal_color\\front\\src\\test.js",[],"C:\\Users\\subin\\Desktop\\khuhub_color\\Find_your_own_personal_color\\front\\src\\index.js",[]]
\ No newline at end of file
......
//import React from 'react';
/*const test = ( { history } ) =>
{
return(
<div>
<h3>test </h3>
</div>
);
}*/
import React, { useState } from 'react';
import './test.css';
const Test = ( { history } ) =>
......@@ -51,41 +39,47 @@ const Test = ( { history } ) =>
const [showScore, setShowScore] = useState(false);
const [score_c, setScore_cool] = useState(0);
const [score_w, setScore_warm] = useState(0);
var score = '';
const [score, setPersonal] = useState(0);
var isTrue = 0;
const handleAnswerOptionClick = (isCorrect) => {
if (isCorrect) {
setScore_cool(score_c + 1);
setScore_cool(score_c + 1); //c,c,w,w
}
else{
setScore_warm(score_w + 1);
}
console.log(isCorrect);
console.log(score_c);
}
const nextQuestion = currentQuestion + 1;
if (nextQuestion < questions.length) {
setCurrentQuestion(nextQuestion);
} else {
setCurrentQuestion(nextQuestion); //0,0 -> 0,1 -> 1,2 -> 2,3
} else if(nextQuestion === questions.length){
if(score_c>score_w){
setPersonal('cool');
}
else if(score_c<score_w){
setPersonal('warm');
}
else{
setPersonal('restart');
}
isTrue = 1;
}
if(isTrue===1)
{
setShowScore(true);
}
if(score_c>score_w){
score='cool';
}
else if(score_c<score_w){
score='warm';
}
else{
score='restart';
}
}
};
return (
<div className='app'>
{showScore ? (
<div className='score-section'>
You scored {score} out of {questions.length}
</div>
<span className='score-section'>
You scored {currentQuestion}{questions.length}{score} out of {questions.length}
</span>
) : (
<>
<div className='question-section'>
......