-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6a44fed
commit b19dc01
Showing
15 changed files
with
472 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
.countrycapitalquiz { | ||
/* border: 1px solid red; */ | ||
display: flex; | ||
flex-direction: column; | ||
text-align: center; | ||
} | ||
|
||
.countrycapitalquiz__question { | ||
/* border: 2px solid blue; */ | ||
} | ||
|
||
.countrycapitalquiz__answers { | ||
/* border: 2px solid green; */ | ||
margin-top: 20px; | ||
} | ||
|
||
.countrycapitalquiz_checkanswer { | ||
margin-top: 20px !important; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import React, { useState } from "react"; | ||
import Radio from "@material-ui/core/Radio"; | ||
import RadioGroup from "@material-ui/core/RadioGroup"; | ||
import FormControlLabel from "@material-ui/core/FormControlLabel"; | ||
import FormControl from "@material-ui/core/FormControl"; | ||
import FormLabel from "@material-ui/core/FormLabel"; | ||
import FormHelperText from "@material-ui/core/FormHelperText"; | ||
import Button from "@material-ui/core/Button"; | ||
|
||
import "./CountryCapitalQuiz.css"; | ||
|
||
function CountryCapitalQuiz(props) { | ||
console.log("I am in CountryCapitalQuiz"); | ||
const [value, setValue] = useState(""); | ||
const [error, setError] = useState(false); | ||
const [helperText, setHelperText] = useState("What do you think?"); | ||
|
||
const handleRadioChange = (event) => { | ||
setValue(event.target.value); | ||
setHelperText(" "); | ||
setError(false); | ||
}; | ||
|
||
const handleSubmit = (event) => { | ||
console.log("Initial value of radio", value); | ||
event.preventDefault(); | ||
|
||
if (value === props.question.capital) { | ||
setHelperText("You got it!"); | ||
setError(false); | ||
} else if (value === "") { | ||
setHelperText("Please select an option."); | ||
setError(true); | ||
} else { | ||
setHelperText("Sorry, wrong answer!"); | ||
setError(true); | ||
} | ||
}; | ||
|
||
return ( | ||
<div> | ||
<div className="countrycapitalquiz"> | ||
<div className="countrycapitalquiz__question"> | ||
<h1>What is the capital of {props.question.name}?</h1> | ||
</div> | ||
<div className="countrycapitalquiz__answers"> | ||
<form onSubmit={handleSubmit}> | ||
<FormControl component="fieldset" error={error}> | ||
{/* <FormLabel component="legend"> | ||
What is the capital of {props.question.name} | ||
</FormLabel> */} | ||
<RadioGroup | ||
aria-label={`Option${props.question.name}`} | ||
name={`Option${props.question.name}`} | ||
value={value} | ||
onChange={handleRadioChange} | ||
> | ||
{props.question.options.map((o) => ( | ||
<FormControlLabel value={o} control={<Radio />} label={o} /> | ||
))} | ||
</RadioGroup> | ||
<FormHelperText>{helperText}</FormHelperText> | ||
<Button | ||
type="submit" | ||
color="primary" | ||
variant="contained" | ||
className="countrycapitalquiz_checkanswer" | ||
> | ||
Check Answer | ||
</Button> | ||
</FormControl> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default CountryCapitalQuiz; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.quizcountrycurrency { | ||
display: flex; | ||
margin-top: 100px; | ||
} |
Oops, something went wrong.