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'
password = ''
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 question_answer_output
# Main Menu
@ -17,7 +18,10 @@ def main_menu():
database_menu.menu()
break
case 1:
# TODO Starte Zufallsfragenausgabe
return
while True:
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:
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": "",
"answer": ""
}
},
{
"#2": {
"2": {
"question": " ",
"answer": " "
}
},
{
"#3": {
"3": {
"question": "",
"answer": ""
}
},
{
"#4": {
"4": {
"question": " ",
"answer": " "
}
},
{
"#5": {
"5": {
"question": " ",
"answer": " "
}
},
{
"#6": {
"6": {
"question": " ",
"answer": " "
}
},
{
"#7": {
"7": {
"question": " ",
"answer": " "
}
},
{
"#8": {
"8": {
"question": " ",
"answer": " "
}
},
{
"#9": {
"9": {
"question": " ",
"answer": " "
}
},
{
"#10": {
"10": {
"question": " ",
"answer": " "
}