Commit 73225072 authored by baesangjune's avatar baesangjune
Browse files

push

parent 5d4ee11f
import React, { useState } from 'react'; import React, { useState } from 'react';
// import { Link } from 'react-router-dom';
function Admin() {
let QnAadmins = []
let QnAadmin = {}
// let QnAadmin = [] let Setadmins = []
// let Q = [] let Setadmin = {}
// let choose = []
// let N = []
function Admin() {
const [question, setQuestion] = useState('') const [question, setQuestion] = useState('')
const [choose, setChoose] = useState('') const [choose, setChoose] = useState('')
...@@ -20,41 +18,84 @@ function Admin() { ...@@ -20,41 +18,84 @@ function Admin() {
const [addQuiz, setaddQuiz] = useState('') const [addQuiz, setaddQuiz] = useState('')
const [selectOption, setselectOption] = useState('') const [selectOption, setselectOption] = useState('')
const [done, setDone] = useState(false)
const handleChangeQuestion = (event) => { const handleChangeQuestion = (event) => {
QnAadmin['Q'] = event.target.value
setQuestion(event.target.value) setQuestion(event.target.value)
} }
const handleChangechoose = (event) => { const handleChangechoose = (event) => {
QnAadmin['Choose'] = event.target.value
setChoose(event.target.value) setChoose(event.target.value)
} }
const handleChangeanswer = (event) => { const handleChangeanswer = (event) => {
QnAadmin['A'] = event.target.value
setAnswer(event.target.value) setAnswer(event.target.value)
} }
const handleChangePassword = (event) => { const handleChangePassword = (event) => {
Setadmin['password'] = event.target.value
setPassword(event.target.value) setPassword(event.target.value)
} }
const handleChangeAdminPassword = (event) => { const handleChangeAdminPassword = (event) => {
Setadmin['AdminPassword'] = event.target.value
setAdminPassword(event.target.value) setAdminPassword(event.target.value)
} }
const handleChangeTime = (event) => { const handleChangeTime = (event) => {
Setadmin['Time'] = event.target.value
setTime(event.target.value) setTime(event.target.value)
} }
function handleClick() { function handleClickQnA() {
if (!question) {
alert('입력이 완료되었습니다') alert('문제가 입력되지 않았습니다.')
localStorage.setItem('Q', question) }
localStorage.setItem('Choose', choose) else if (!choose) {
localStorage.setItem('Answer', answer) alert('보기가 입력되지 않았습니다.')
localStorage.setItem('P', password) }
localStorage.setItem('AP', adminpassword) else if (!answer) {
localStorage.setItem('T', time * 1000) alert('정답이 입력되지 않았습니다.')
}
setDone(true) else {
console.log(QnAadmin)
QnAadmins.push(QnAadmin)
localStorage.setItem('QnA', JSON.stringify(QnAadmins))
console.log(QnAadmins)
alert('입력이 완료되었습니다.')
}
}
function handleClicksetting() {
if (!password) {
alert('비밀번호가 입력되지 않았습니다.')
}
else if (!adminpassword) {
alert('관리자 비밀번호가 입력되지 않았습니다.')
}
else if (!time) {
alert('제한시간이 입력되지 않았습니다.') //타임은 조건은 빼도 될 듯
}
else {
Setadmins.push(Setadmin)
localStorage.setItem('Set', JSON.stringify(Setadmins))
console.log(Setadmins)
alert('저장이 완료되었습니다.')
console.log(Setadmin)
// setDoneset(true)
}
} }
function addSelectOption() { function addSelectOption() {
...@@ -72,14 +113,16 @@ function Admin() { ...@@ -72,14 +113,16 @@ function Admin() {
} }
function handleClickQuiz() { function handleClickQuiz() {
let addQuiz = function () { let addQuiz = function () {
return <a className="nav-link" id="Quiz4-tab" data-toggle="pill" href="#Quiz4" role="tab" >Quiz4</a> return <a className="nav-link" id="Quiz4-tab" data-toggle="pill" href="#Quiz" role="tab" >Quiz4</a>
} }
setaddQuiz(addQuiz) setaddQuiz(addQuiz)
} }
return ( return (
<> <>
{done ? alert('모두 입력되었습니다.') : ''} {/* {doneQnA ? alert('모두 입력되었습니다.') : ''}
{doneset ? alert('모두 입력되었습니다.') : ''} */}
<div className="row justify-content-md-center mt-5 "> <div className="row justify-content-md-center mt-5 ">
<div className="col-2 text-center border"> <div className="col-2 text-center border">
<div className="container-fluid "> <div className="container-fluid ">
...@@ -93,11 +136,11 @@ function Admin() { ...@@ -93,11 +136,11 @@ function Admin() {
<a className="nav-link" id="setting-tab" data-toggle='pill' href="#setting">Setting</a> <a className="nav-link" id="setting-tab" data-toggle='pill' href="#setting">Setting</a>
<p className="navbar-text border-bottom">Quiz 입력하기</p> <p className="navbar-text border-bottom">Quiz 입력하기</p> {/*Quiz1 버튼에 무언갈 쓰고 Quiz2를 누르면 초기화되도록하기*/}
<a className="nav-link" id="Quiz1-tab" data-toggle="pill" href="#Quiz1" >Quiz1</a> <a className="nav-link" id="Quiz-tab" data-toggle="pill" href="#Quiz" >Quiz1</a>
<a className="nav-link" id="Quiz2-tab" data-toggle="pill" href="#Quiz2" >Quiz2</a> <a className="nav-link" id="Quiz-tab" data-toggle="pill" href="#Quiz" >Quiz2</a>
<a className="nav-link" id="Quiz3-tab" data-toggle="pill" href="#Quiz3" >Quiz3</a> <a className="nav-link" id="Quiz-tab" data-toggle="pill" href="#Quiz" >Quiz3</a>
{addQuiz} {addQuiz}
<button className="btn btn-danger navbar-btn" onClick={handleClickQuiz} >Quiz 추가</button> <button className="btn btn-danger navbar-btn" onClick={handleClickQuiz} >Quiz 추가</button>
...@@ -132,55 +175,7 @@ function Admin() { ...@@ -132,55 +175,7 @@ function Admin() {
<label for="inputLogin" className="d-flex justify-content-center"> <label for="inputLogin" className="d-flex justify-content-center">
<button className="mt-4 btn btn-dark" onClick={handleClick}>작성완료</button> <button className="mt-4 btn btn-dark" onClick={handleClicksetting}>작성완료</button>
</label>
</div>
</div>
</div>
</div>
</div>
<div className="tab-pane fade" id="Quiz1" role="tabpanel" >
<div className="container">
<div className="row d-flex justify-content-center">
<div className="col-8">
<h2 className="p-3 border text-center bg-danger ">문제만들기</h2>
<div className="p-3 borber">
<div className="p-3 ">
<span className="font-weight-bold mr-2 h3">1.</span>
{/* <input type="text" onChange={handleChangenumber} placeholder="Number" /> */}
<input className='p-2' type="text" onChange={handleChangeQuestion} placeholder="문제를 입력하세요" />
</div>
<div className="p-3 ">
<div className="input-group">
<div className="input-group-prepend">
<div className="input-group-text p-3">
<input type="radio" id="option" />
</div>
</div>
<input type="text" className="form-control p-4" placeholder="보기를 입력하세요" onChange={handleChangechoose} />
</div>
{selectOption}
<button className="btn btn-outline-secondary btn-sm" onClick={addSelectOption}>+</button>
</div>
<div className="p-3 ">
<span className="font-weight-bold mr-2 h3">정답:</span>
<input className='p-2' type="text" onChange={handleChangeanswer} placeholder="정답을 입력하세요" />
</div>
<label for="inputLogin" className="d-flex justify-content-center">
<button className="mt-4 btn btn-dark" onClick={handleClick}>작성완료</button>
</label> </label>
</div> </div>
...@@ -188,54 +183,10 @@ function Admin() { ...@@ -188,54 +183,10 @@ function Admin() {
</div> </div>
</div> </div>
</div>
<div className="tab-pane fade" id="Quiz2" role="tabpanel">
<div className="container">
<div className="row d-flex justify-content-center">
<div className="col-8">
<h2 className="p-3 border text-center bg-danger">문제만들기</h2>
<div className="p-3 borber">
<div className="p-3 ">
<span className="font-weight-bold mr-2 h3">1.</span>
{/* <input type="text" onChange={handleChangenumber} placeholder="Number" /> */}
<input className='p-2' type="text" onChange={handleChangeQuestion} placeholder="문제를 입력하세요" />
</div>
<div className="p-3 ">
<div className="input-group">
<div className="input-group-prepend">
<div className="input-group-text p-3">
<input type="radio" id="option" />
</div>
</div>
<input type="text" className="form-control p-4" placeholder="보기를 입력하세요" onChange={handleChangechoose} />
</div>
{selectOption}
<button className="btn btn-outline-secondary btn-sm" onClick={addSelectOption}>+</button>
</div>
<div className="p-3 ">
<span className="font-weight-bold mr-2 h3">정답:</span>
<input className='p-2' type="text" onChange={handleChangeanswer} placeholder="정답을 입력하세요" />
</div> </div>
<label for="inputLogin" className="d-flex justify-content-center"> <div className="tab-pane fade" id="Quiz" role="tabpanel">
<button className="mt-4 btn btn-dark" onClick={handleClick}>작성완료</button>
</label>
</div>
</div>
</div>
</div>
</div>
<div className="tab-pane fade" id="Quiz3" role="tabpanel">
<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">
...@@ -271,7 +222,7 @@ function Admin() { ...@@ -271,7 +222,7 @@ function Admin() {
</div> </div>
<label for="inputLogin" className="d-flex justify-content-center"> <label for="inputLogin" className="d-flex justify-content-center">
<button className="mt-4 btn btn-dark" onClick={handleClick}>작성완료</button> <button className="mt-4 btn btn-dark" onClick={handleClickQnA}>작성완료</button>
</label> </label>
</div> </div>
......
...@@ -3,8 +3,8 @@ import { Link, Redirect } from 'react-router-dom'; ...@@ -3,8 +3,8 @@ import { Link, Redirect } from 'react-router-dom';
import Timer from 'react-compound-timer'; // 타이머쓰기위해 import import Timer from 'react-compound-timer'; // 타이머쓰기위해 import
import logo from './img_question.png' import logo from './img_question.png'
const localQnA=JSON.parse(localStorage.getItem('QnA'))
console.log(localQnA)
const QnA = [ const QnA = [
{ Q: "6 X 4 = ?", Choose: [6, 12, 18, 24], N: 1 }, { Q: "6 X 4 = ?", Choose: [6, 12, 18, 24], N: 1 },
{ Q: "3 + 3 = ?", Choose: [2, 4, 6, 8], N: 2 }, { Q: "3 + 3 = ?", Choose: [2, 4, 6, 8], N: 2 },
......
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