(Aug-25-2023, 01:46 PM)deanhystad Wrote: The quiz data should know nothing about the GUI. The GUI should know enough about the quiz data to use it.basically the data py file's function returns a list of dictionaries into the main py file
For example, the GUI should ask quiz data for a question. Quiz data should return a question. GUI uses the returned question to update the panels.
As for your other questions, I have no clue. What is the quiz brain answer checker file? If it relates to quiz data, why isn't it part of the quiz brain? You talk like we're collaborating on this project, but all I've seen is one function. Please provide some context for your questions.
code for main file is as follows
data=Data()
ui=Gui()
question_data=data.choose_cat(ui.output_url())
print(question_data)
score=Score()
quiz_brain=QuizBrain(question_data)
then the quiz brain gets the list of dicitonaries and generates an example for which the code is
def generate_question(self):
self.q_number+=1
self.new_q=rand.choice(self.q_data)
question=html.unescape(self.new_q["question"])
answer=self.new_q["correct answer"]
self.q_text=f'Q{self.q_number}/50: {question}"
return self.q_text
in order to avoid a loop problem with the UI file (because the quizbrain functions output goes to UI in order to update the text on the canvas) i have since created a new answer checker file to receive the correct answer from the quiz brain file and the user answer from the UI file in order to compare the two answers. the code from the answer checker is as follows
def check_answer(self):
user_ans=Gui.get_ans()
cor_ans=QuizBrain.corr_answer()
if user_ans==cor_ans:
Gui.right()
else:
Gui.wrong()
the GUI wrong and right functions simply change the background color to the canvas widget in the UI file according to whether the answer was right or wrong
what i still need to figure out is how to generate a new question from the UI file when the appropriate function is taken as well as how to get the question data list of dictionaries assigned based on the UI optionmenu output