Commit c3ab49b5 authored by baesangjune's avatar baesangjune
Browse files

Admin 화면

parent aef34567
import React from 'react'; import React, { useState } from 'react';
// import { Link } from 'react-router-dom'; // import { Link } from 'react-router-dom';
function Admin() { function Admin() {
// let QnAadmin = []
// let Q = []
// let choose = []
// let N = []
const [number, setNumber] = useState('')
const [question, setQuestion] = useState('')
const [choose, setChoose] = useState('')
const [answer, setAnswer] = useState('')
const [done, setDone] = useState(false)
const handleChangenumber = (event) => {
setNumber(event.target.value)
}
const handleChangequestion = (event) => {
setQuestion(event.target.value)
}
const handleChangechoose = (event) => {
setChoose(event.target.value)
}
const handleChangeanswer = (event) => {
setAnswer(event.target.value)
}
function handleClick() {
alert('입력이 완료되었습니다')
localStorage.setItem('N', number)
localStorage.setItem('Q', question)
localStorage.setItem('Choose', choose)
localStorage.setItem('Answer',answer)
setDone(true)
}
return ( return (
<> <>
{done ? alert('모두 입력되었습니다.') : ''}
<div> <div>
<div className="container"> <div className="container">
<div className="row d-flex justify-content-center"> <div className="row d-flex justify-content-center">
<div className="col-8"> <div className="col-8">
<div>
<h1 className="p-3 border">관리자 문제제출 </h1>
<div className="p-3 border">
<h2>문제번호를 입력하세요</h2>
<input type="text" onChange={handleChangenumber} placeholder="Nunber" />
</div>
<div className="p-3 border">
<h2>문제를 입력하세요</h2> <h2>문제를 입력하세요</h2>
<input type="text" /><button>전송</button> <input type="text" onChange={handleChangequestion} placeholder="Question" />
</div> </div>
<div> <div className="p-3 border">
<h2>보기를 입력하세요</h2> <h2>보기를 입력하세요(배열형태)</h2>
<input type="text" /><button>전송</button> <input type="text" onChange={handleChangechoose} placeholder="Choose" />
</div> </div>
<div> <div className="p-3 border">
<h2>답을 입력하세요</h2> <h2>답을 입력하세요</h2>
<input type="text" /><button>전송</button> <input type="text" onChange={handleChangeanswer} placeholder="Answer" />
</div> </div>
<label for="inputLogin" className="d-flex justify-content-center">
<button className="mt-4 btn btn-dark" onClick={handleClick}>작성완료</button>
</label>
</div> </div>
</div> </div>
</div> </div>
{/* <div className="p-3 border">
<h2>패스워드를 입력하세요</h2>
<input type="text" onChange={handleChangeanswer} placeholder="Answer" />
</div> */}
</div> </div>
</> </>
) )
......
...@@ -41,8 +41,7 @@ function Quiz() { ...@@ -41,8 +41,7 @@ function Quiz() {
} }
return ( return (
<> <>
<div className="container-fluid">
<div className="container-fluid position-absolute">
<div className="text-center h2 font-weight-bold bg-warning py-2">미적분학 퀴즈</div> <div className="text-center h2 font-weight-bold bg-warning py-2">미적분학 퀴즈</div>
<div className="row justify-content-md-center" > <div className="row justify-content-md-center" >
<div className="col text-right"> <div className="col text-right">
...@@ -58,17 +57,16 @@ function Quiz() { ...@@ -58,17 +57,16 @@ function Quiz() {
<form> <form>
{question.Choose.map((a, index) => {question.Choose.map((a, index) =>
<div key={index}> <div key={index}>
<input type="radio" name='answer' id={index} value={a} onClick={handleChange} /> <input type="radio" name='answer' id={index} value={a} onChange={handleChange} checked={parseInt(selected) === a} />
<label className="font-weight-bold" htmlFor={a}>{a}</label> <label className="font-weight-bold" htmlFor={a}>{a}</label>
</div> </div>
)} )}
<input hidden type="submit" value="확인" /> {/*버튼 숨김*/}
</form> </form>
<span className="h5 font-weight-bold"> Your Answer :</span> <span className="h5 font-weight-bold"> Your Answer :</span>
<span className="h2 font-weight-bold text-danger"> {selected}</span> {/* 선택한 보여줌 */} <span className="h2 font-weight-bold text-danger"> {selected}</span> {/* 선택한 보여줌 */}
<div className="text-center my-3"> {(question.page === QnA.length - 1) <div className="text-center my-3"> {(question.page === QnA.length - 1)
? <Link to="/end"> ? <Link to="/end">
<button className="btn btn-outline-success">제출</button> <button className="btn btn-outline-success" onClick={localStorage.setItem('Solutions', JSON.stringify(Solutions))}>제출</button>
</Link> </Link>
: <button type="button" className="btn btn-outline-dark" onClick={handleQuestion}>다음</button> : <button type="button" className="btn btn-outline-dark" onClick={handleQuestion}>다음</button>
} }
......
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