-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from emmanueposu/jbranch4
updated trivia gen page using classes and components
- Loading branch information
Showing
11 changed files
with
160 additions
and
44 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React from "react"; | ||
import { Choice } from "../Model/Choice"; | ||
|
||
function Choices({ choices }) { | ||
return ( | ||
<div> | ||
{choices.map((choice, index) => { | ||
return ( | ||
<div className="card-body" key={index}> | ||
<textarea className="form-control" defaultValue={choice.choice}></textarea> | ||
</div> | ||
); | ||
})} | ||
</div> | ||
); | ||
} | ||
export default Choices; |
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,30 @@ | ||
import React from "react"; | ||
import Choices from "../Components/Choices"; | ||
import { Card } from "react-bootstrap"; | ||
|
||
import { Question } from "../Model/Question"; | ||
|
||
function Questions({ data }) { | ||
let choices = data.choices; | ||
return ( | ||
<div> | ||
<Card className="CardPadding"> | ||
<h2 className="centered">Question</h2> | ||
<div className="card-body"> | ||
<textarea className="form-control" defaultValue={data.question}></textarea> | ||
</div> | ||
<h2>Choices</h2> | ||
<Choices choices={choices} /> | ||
<h2>Answer</h2> | ||
<div className="card-body"> | ||
<textarea className="form-control" defaultValue={data.answer}></textarea> | ||
</div> | ||
<h2>Hint</h2> | ||
<div className="card-body"> | ||
<textarea className="form-control" defaultValue={data.hint}></textarea> | ||
</div> | ||
</Card> | ||
</div> | ||
) | ||
} | ||
export default Questions; |
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
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,18 @@ | ||
import * as db from './TF-db_services'; | ||
|
||
export const addAllForGame = async (game) => { | ||
const newGame = await db.addGame(game); | ||
game.categories.forEach(async (category) => { | ||
category.gameID = newGame.id; | ||
const newCategory = await db.addCategory(category); | ||
category.questions.forEach(async (question) => { | ||
question.categoryID = newCategory.id; | ||
const newQuestion = await db.addQuestion(question); | ||
question.choices.forEach(async (choice) => { | ||
choice.questionID = newQuestion.id; | ||
await db.addChoice(choice); | ||
}); | ||
}); | ||
}); | ||
return newGame; | ||
} |