21.03.2022

This commit is contained in:
marcus 2022-03-21 15:46:51 +01:00
parent 6aa4845752
commit 7eca5bfedc
5 changed files with 60 additions and 24 deletions

View File

@ -5,3 +5,5 @@
user = 'root' user = 'root'
password = '' password = ''
host = 'localhost' host = 'localhost'
json_file = 'questions_answers.json'

View File

@ -1 +0,0 @@
# TODO: einlesen der berreits vorhanden Daten im JSON File

View File

@ -1,5 +1,6 @@
import config
import database_menu import database_menu
import question_answer_output
# Main Menu # Main Menu
@ -17,7 +18,10 @@ def main_menu():
database_menu.menu() database_menu.menu()
break break
case 1: case 1:
# TODO Starte Zufallsfragenausgabe while True:
return question_answer_output.random_question(config.json_file)
number = int(input('Zurück zum Hauptmenü\n 1: Ja \n 2: Nein\n'))
if number == 1:
break
case 2: case 2:
break break

25
question_answer_output.py Normal file
View File

@ -0,0 +1,25 @@
# TODO: einlesen der berreits vorhanden Daten im JSON File
import json
from random import randrange
# Einlesen Json File
def read_json(filename):
with open(filename) as filename:
data = json.load(filename)
return data
# Zufällige Frage erstellen
def random_question(filename):
min = 0
max = len(read_json(filename))
random_number = randrange(min,max)
questions = read_json(filename)
question = f'Frage Nr:', random_number, questions[random_number][str(random_number)]['question']
answer = questions[random_number][str(random_number)]['answer']
return question, answer
#print(random_question(config.json_file)[0])

View File

@ -1,60 +1,66 @@
[ [
{ {
"#1": { "0": {
"question": "Was versteht man unter dem Begriff Cross-Selling?",
"answer": "Eine Verkaufsstrategie, bei der zu einem Produkt, zusätzliche ( inhalte, produkte, services etc...) angeboten werden, um einen höheren Umsatz und die Kundenanbindung zu erhöhen"
}
},
{
"1": {
"question": "", "question": "",
"answer": "" "answer": ""
} }
}, },
{ {
"#2": { "2": {
"question": " ", "question": " ",
"answer": " " "answer": " "
} }
}, },
{ {
"#3": { "3": {
"question": "", "question": "",
"answer": "" "answer": ""
} }
}, },
{ {
"#4": { "4": {
"question": " ", "question": " ",
"answer": " " "answer": " "
} }
}, },
{ {
"#5": { "5": {
"question": " ", "question": " ",
"answer": " " "answer": " "
} }
}, },
{ {
"#6": { "6": {
"question": " ", "question": " ",
"answer": " " "answer": " "
} }
}, },
{ {
"#7": { "7": {
"question": " ", "question": " ",
"answer": " " "answer": " "
} }
}, },
{ {
"#8": { "8": {
"question": " ", "question": " ",
"answer": " " "answer": " "
} }
}, },
{ {
"#9": { "9": {
"question": " ", "question": " ",
"answer": " " "answer": " "
} }
}, },
{ {
"#10": { "10": {
"question": " ", "question": " ",
"answer": " " "answer": " "
} }