Commit befbdcdb authored by Jiwon Yoon's avatar Jiwon Yoon
Browse files

A

parent a79e9b83
...@@ -3,65 +3,58 @@ import AdminQuiz from './AdminQuiz' ...@@ -3,65 +3,58 @@ import AdminQuiz from './AdminQuiz'
import AdminSetting from './AdminSetting' import AdminSetting from './AdminSetting'
let QuizBtn=[] let QuizBtn = []
function Admin() { function Admin() {
const[result, setresult] = useState('') const [result, setresult] = useState('')
const[QuizBtnCount, setQuizBtnCount] = useState(4) const [QuizBtnCount, setQuizBtnCount] = useState(4)
function handleClickSetting(){
setresult(<AdminSetting/>) function handleClickSetting() {
setresult(<AdminSetting />)
} }
function handleClickQuiz(){ function handleClickQuiz(e) {
setresult(<AdminQuiz/>) setresult(<AdminQuiz name={e.target.id} />)
} }
function handleClickAddQuiz(){ function handleClickAddQuiz() {
QuizBtnCount.push( QuizBtn.push(
<button type='button' className='btn btn-outline-primary' id={QuizBtnCount} onClick={handleClickQuiz}>Quiz {QuizBtnCount}</button> <button type='button' className='btn btn-outline-primary' id={QuizBtnCount} onClick={handleClickQuiz}>Quiz {QuizBtnCount}</button>
) )
setQuizBtnCount(QuizBtnCount+1) setQuizBtnCount(QuizBtnCount + 1)
} }
return ( return (
<> <>
<div className="container-fluid"> <div className="container-fluid">
<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="my-5"> <div className="my-5">
<h4>관리자페이지</h4> <h4>관리자페이지</h4>
</div> </div>
<div> <div>
<button type="button" className="btn btn-outline-info mb-5" onClick={handleClickSetting}>Setting</button> <button type="button" className="btn btn-outline-info mb-5" onClick={handleClickSetting}>Setting</button>
</div> </div>
<div class="btn-group-vertical"> <div class="btn-group-vertical">
<button type="button" className="btn btn-outline-primary" id="1" onClick={handleClickQuiz}>Quiz 1</button> <button type="button" className="btn btn-outline-primary" id="1" onClick={handleClickQuiz}>Quiz 1</button>
<button type="button" className="btn btn-outline-primary" id="2" onClick={handleClickQuiz}>Quiz 2</button> <button type="button" className="btn btn-outline-primary" id="2" onClick={handleClickQuiz}>Quiz 2</button>
<button type="button" className="btn btn-outline-primary" id="3" onClick={handleClickQuiz}>Quiz 3</button> <button type="button" className="btn btn-outline-primary" id="3" onClick={handleClickQuiz}>Quiz 3</button>
{QuizBtn.map((element) => element)} {QuizBtn.map((element) => element)}
<button type="button" className="btn btn-outline-primary" onClick={handleClickAddQuiz}>+</button> <button type="button" className="btn btn-outline-primary" onClick={handleClickAddQuiz}>+</button>
</div>
</div> </div>
</div>
<div className="col-8"> <div className="col-8">
<div className="tab-content" id="v-pills-tabContent">
<div className="tab-pane fade show active" id="setting" role="tabpanel" >
<div className="row d-flex justify-content-center">
</div>
</div>
{result} {result}
</div> </div>
</div> </div>
</div> </div>
</div>
</> </>
) )
} }
......
import React, { useState } from 'react'; import React, { useState } from 'react';
// import Admin from './Admin'
let list = [] let list = []
...@@ -8,7 +9,7 @@ let QnAadmin = {} ...@@ -8,7 +9,7 @@ let QnAadmin = {}
let c = {} let c = {}
function AdminQuiz() { function AdminQuiz(props) {
const [question, setQuestion] = useState('') const [question, setQuestion] = useState('')
...@@ -46,13 +47,13 @@ function AdminQuiz() { ...@@ -46,13 +47,13 @@ function AdminQuiz() {
<input type="radio" name="answer" /> <input type="radio" name="answer" />
</div> </div>
</div> </div>
<input type="text" class="form-control" id={String(selectOption + 1)} placeholder="보기를 입력하세요" onChange={handleChangeChoose} /> <input type="text" class="form-control" id={String(selectOption + 1)} placeholder="보기를 입력하세요" onChange={handleChangeChoose} />
</div> </div>
) )
setselectOption(selectOption + 1) setselectOption(selectOption + 1)
} }
function handleClick() { function handleClick() {
if (!question) { if (!question) {
alert('문제가 입력되지 않았습니다.') alert('문제가 입력되지 않았습니다.')
...@@ -64,9 +65,11 @@ function AdminQuiz() { ...@@ -64,9 +65,11 @@ function AdminQuiz() {
alert('정답이 입력되지 않았습니다.') alert('정답이 입력되지 않았습니다.')
} }
else { else {
// let data = localStorage.getItem('QnA')
// data=data?JSON.parse(data):''
// QnAadmins.push(data)
console.log(QnAadmin) console.log(QnAadmin)
QnAadmin['Choose']=Object.values(c) QnAadmin['Choose'] = Object.values(c)
QnAadmins.push(QnAadmin) QnAadmins.push(QnAadmin)
localStorage.setItem('QnA', JSON.stringify(QnAadmins)) localStorage.setItem('QnA', JSON.stringify(QnAadmins))
console.log(QnAadmins) console.log(QnAadmins)
...@@ -80,25 +83,29 @@ function AdminQuiz() { ...@@ -80,25 +83,29 @@ function AdminQuiz() {
return ( return (
<div className="" id="Quiz1"> <div className="" id="Quiz1">
<h2 className="p-3 border text-center">문제만들기</h2> <h2 className="p-3 border text-center">{String(props.name)} 문제만들기</h2>
<div className="p-3 borber"> <div className="p-3 borber">
<div className="p-3 "> <div className="p-3 ">
<span className="font-weight-bold mr-2 h3">1.</span> <span className="font-weight-bold mr-2 h3">1. 문제 입력하기</span>
<input type="text" className="form-control" onChange={handleChangeQuestion} placeholder="문제를 입력하세요" /> <input type="text" className="form-control" onChange={handleChangeQuestion} placeholder="문제를 입력하세요" />
</div> </div>
<div className="p-3 "> <div className="p-3 ">
<div className="input-group"> <span className="font-weight-bold mr-2 h3">2. 보기 입력하기</span>
<div className="input-group-prepend"> <div className="p-3 ">
<div className="input-group-text"> <div className="input-group">
<input type="radio" id={selectOption} name="answer" /> <div className="input-group-prepend">
<div className="input-group-text">
<input type="radio" id={selectOption} name="answer" />
</div>
</div> </div>
<input type="text" className="form-control" id='1' placeholder="보기를 입력하세요" onChange={handleChangeChoose} />
</div> </div>
<input type="text" className="form-control" id='1' placeholder="보기를 입력하세요" onChange={handleChangeChoose} /> {list.map((element) => element)}
<button className="btn btn-outline-secondary btn-sm" onClick={addSelectOption}>+</button>
</div> </div>
{list.map((element) => element)}
<button className="btn btn-outline-secondary btn-sm" onClick={addSelectOption}>+</button>
</div> </div>
<div className="p-3 "> <div className="p-3 ">
<span className="font-weight-bold mr-2 h3">정답:</span> <span className="font-weight-bold mr-2 h3">정답:</span>
<input type="text" onChange={handleChangeanswer} placeholder="정답을 입력하세요" /> <input type="text" onChange={handleChangeanswer} placeholder="정답을 입력하세요" />
......
import React from 'react';
import './App.css';
function App() {
return (
<div>
<header>
<Link to="/">
<button>Calculus</button>
</Link>
</header>
<hr />
</div>
)
}
export default App;
\ No newline at end of file
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