Created
January 30, 2021 03:43
-
-
Save syamjayaraj/af9c2daba1ff86ba4c50e28171e08a6b to your computer and use it in GitHub Desktop.
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
import React from "react"; | |
import { Card, ListGroup } from "react-bootstrap"; | |
function Question(props) { | |
let { question, checkOption } = props; | |
return ( | |
<Card> | |
<Card.Body> | |
<Card.Title>{question.name}</Card.Title> | |
<ListGroup> | |
{question.options.map((option) => { | |
console.log(option._id, question.selectedOption); | |
return ( | |
<ListGroup.Item | |
disabled={question.selectedOption ? true : null} | |
onClick={() => checkOption(question._id, option._id)} | |
style={ | |
question.selectedOption === question.trueOption && | |
option._id === question.selectedOption | |
? { border: "2px solid #38bb38", borderRadius: ".3rem" } | |
: question.selectedOption !== question.trueOption && | |
option._id === question.selectedOption | |
? { border: "2px solid #e24646", borderRadius: ".3rem" } | |
: null | |
} | |
> | |
<div className="number">{option._id}</div> | |
<div>{option.name}</div> | |
</ListGroup.Item> | |
); | |
})} | |
</ListGroup> | |
</Card.Body> | |
</Card> | |
); | |
} | |
export default Question; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment