from question_model import Question
from quiz_brain import QuizBrain
import httpx

r = httpx.get("https://opentdb.com/api.php?amount=20&difficulty=easy&type=boolean")

question_data = r.json()

question_bank = []
for a_question in question_data['results']:
    question_bank.append(Question(a_question['question'], a_question['correct_answer']))

quiz = QuizBrain(question_bank)

while quiz.still_has_question():
    quiz.next_question()

print("You've completed the quiz")
print(f"You final score was {quiz.score}/{quiz.question_number}")