Commit bcab53af authored by baesangjune's avatar baesangjune
Browse files

.

parent f96b4778
...@@ -14,7 +14,9 @@ function Menu() { ...@@ -14,7 +14,9 @@ function Menu() {
return ( return (
<Navbar sticky="top" bg="dark" variant="dark" expand="sm"> <Navbar sticky="top" bg="dark" variant="dark" expand="sm">
<Navbar.Brand href="/"> <Navbar.Brand href="/">
<i className="fas fa-diagnoses fa-2x"></i> <i className="text-center mt-1 pb-3 font-italic text-danger">
KU-Quiz
</i>
</Navbar.Brand> </Navbar.Brand>
<Navbar.Toggle aria-controls="basic-navbar-nav" /> <Navbar.Toggle aria-controls="basic-navbar-nav" />
<Navbar.Collapse id="basic-navbar-nav"> <Navbar.Collapse id="basic-navbar-nav">
......
// import React, { useState, useEffect } from 'react'
// import { Link, Redirect } from 'react-router-dom';
// import Timer from 'react-compound-timer'; // 타이머쓰기위해 import
// function Problems() {
// let Time = 0
// if (JSON.parse(localStorage.getItem("Set")) === null) {
// Time = 30010
// }
// else {
// Time = Number(JSON.parse(localStorage.getItem("Set"))[0].Time)
// }
// const [question, setQuestion] = useState({
// ...localQnA[0]
// })
// const [selected, setSelected] = useState("") //선택한 답을 보여줄 것
// const [timeout, settimeout] = useState(false)
// //for each 사용하기
// let Solutions = [] //빈 배열
// console.log(localQnA)
// localQnA.forEach((element) => {
// Solutions.push(Number(element.A))
// });
// useEffect(() => {
// for (let i = 1; i <= Solutions.length; i++) {
// Answers.push(0)
// localStorage.setItem('Answers', JSON.stringify(Answers))
// localStorage.setItem("Solutions", JSON.stringify(Solutions))
// }
// // eslint-disable-next-line
// }, [])
// function handleQuestion() {
// setQuestion({ ...localQnA[question.N] })
// setSelected("") //페이지 넘어가면 selected 초기화
// }
// let handleChange = (ev) => {
// setSelected(ev.target.value) //selected값 변경
// Answers[question.N - 1] = Number(ev.target.id) + 1
// localStorage.setItem('Answers', JSON.stringify(Answers))
// }
// return (
// <>
// <div className="container-fluid">
// <div className="text-center font-italic font-weight-bold py-2 text-muted">해석학 2 (이연주 교수)</div>
// <div className="row justify-content-md-center">
// <div className="col-md-auto mt-4">
// <div className="mb-4small">문제 진척도 {question.N}/{localQnA.length}</div>
// <span className="h5 text-left text-danger ">
// <Timer
// initialTime={Time}
// direction="backward"
// checkpoints={[
// {
// time: 1,
// callback: () => alert('시간이 초과되었습니다.'),
// },
// {
// time: 0,
// callback: () => settimeout(true),
// }
// ]}
// >
// {() => (
// <>
// <Timer.Minutes /> : <Timer.Seconds></Timer.Seconds> / 30 : 00 </>
// )}
// </Timer> {/* npm i react-compound-timer */}
// </span>
// <span className=" float-right "> {(question.N - 1 === localQnA.length - 1)
// ? <Link to="/end">
// <button className="btn btn-outline-success" /*onClick={localStorage.setItem('Solutions', JSON.stringify(Solutions))}*/>제출</button>
// </Link>
// : <button type="button" className="btn btn-outline-dark" onClick={handleQuestion}>다음</button>
// }
// </span>
// <div className="h2 mt-5">
// <span className='mr-4 font-weight-bold text-danger'>Quiz{question.N}.</span>{question.Q}
// </div>
// <div className="mt-2">
// <form>
// {question.Choose.map((a, index) =>
// <div>
// <input type="radio" name='answer' id={index} value={a} onChange={handleChange} checked={selected === String(a)} />
// <label className="font-weight-bold" htmlFor={a}>{a}</label>
// </div>
// )}
// </form>
// <span className="h5 font-weight-bold"> Your Answer :</span>
// <span className="h2 font-weight-bold text-danger"> {selected}</span> {/* 선택한 값 보여줌 */}
// </div>
// </div>
// <div className="col">
// </div>
// </div>
// </div>
// {timeout ? <Redirect to='/end' /> : ''}
// </>
// )
// // return (
// // <div> </div>
// // )
// }
// export default Problems
import React, { useEffect, useState } from "react"; import React, { useEffect, useState } from "react";
import { Link, useParams } from 'react-router-dom'; import { Link, useParams, Redirect } from 'react-router-dom';
import Card from "react-bootstrap/Card"; import Card from "react-bootstrap/Card";
import Button from "react-bootstrap/Button"; import Button from "react-bootstrap/Button";
import { listByUserId } from "./api-quiz"; import { listByUserId } from "./api-quiz";
import authHelpers from "../auth/auth-helpers"; import authHelpers from "../auth/auth-helpers";
import Timer from 'react-compound-timer';
function Problems({ problem, number, onUpdate, onRemove }) { function Problems({ problem, number, onUpdate, onRemove }) {
let Time = 0
const [timeout, settimeout] = useState(false)
const { userId } = useParams(); const { userId } = useParams();
const [quizzes, setQuizzes] = useState([]); const [quizzes, setQuizzes] = useState([{title : ""}]);
const jwt = authHelpers.isAuthenticated(); const jwt = authHelpers.isAuthenticated();
...@@ -144,7 +24,7 @@ function Problems({ problem, number, onUpdate, onRemove }) { ...@@ -144,7 +24,7 @@ function Problems({ problem, number, onUpdate, onRemove }) {
if (data.error) { if (data.error) {
console.log(data.error); console.log(data.error);
} else { } else {
// console.log(data); console.log(data);
setQuizzes(data); setQuizzes(data);
} }
}); });
...@@ -155,7 +35,69 @@ function Problems({ problem, number, onUpdate, onRemove }) { ...@@ -155,7 +35,69 @@ function Problems({ problem, number, onUpdate, onRemove }) {
}, [userId]); }, [userId]);
return ( return (
<div>{console.log(quizzes)})</div> <>
<div>
{console.log("quizzes=", quizzes[0])}
<div className="container-fluid">
<div className="text-center font-italic font-weight-bold py-2 text-muted">{quizzes}</div>
<div className="row justify-content-md-center">
<div className="col-md-auto mt-4">
<div className="mb-4small">문제 진척도 </div>
<span className="h5 text-left text-danger ">
<Timer
initialTime={Time}
direction="backward"
checkpoints={[
{
time: 1,
callback: () => alert('시간이 초과되었습니다.'),
},
{
time: 0,
callback: () => settimeout(true),
}
]}
>
{() => (
<>
<Timer.Minutes /> : <Timer.Seconds></Timer.Seconds> / 30 : 00 </>
)}
</Timer> {/* npm i react-compound-timer */}
</span>
<span className=" float-right "> 버튼자리
{/* {(question.N - 1 === localQnA.length - 1)
? <Link to="/end">
<button className="btn btn-outline-success" >제출</button>
</Link>
: <button type="button" className="btn btn-outline-dark" onClick={handleQuestion}>다음</button>} */}
</span>
<div className="h2 mt-5">
<span className='mr-4 font-weight-bold text-danger'>Quiz</span>
</div>
<div className="mt-2">
<form>
보기자리
{/* {question.Choose.map((a, index) =>
<div>
<input type="radio" name='answer' id={index} value={a} onChange={handleChange} checked={selected === String(a)} />
<label className="font-weight-bold" htmlFor={a}>{a}</label>
</div>
)} */}
</form>
<span className="h5 font-weight-bold"> Your Answer :</span>
<span className="h2 font-weight-bold text-danger"> selected</span> </div>
</div>
<div className="col">
</div>
</div>
</div>
{timeout ? <Redirect to='/end' /> : ''}
</div>
</>
// <div> // <div>
// {quizzes.map((quiz, i) => { // {quizzes.map((quiz, i) => {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment