21.03.2022
This commit is contained in:
parent
6aa4845752
commit
7eca5bfedc
|
@ -5,3 +5,5 @@
|
|||
user = 'root'
|
||||
password = ''
|
||||
host = 'localhost'
|
||||
|
||||
json_file = 'questions_answers.json'
|
|
@ -1 +0,0 @@
|
|||
# TODO: einlesen der berreits vorhanden Daten im JSON File
|
10
main_menu.py
10
main_menu.py
|
@ -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
25
question_answer_output.py
Normal 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])
|
||||
|
|
@ -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": {
|
||||
"question": " ",
|
||||
"answer": " "
|
||||
}
|
||||
},
|
||||
{
|
||||
"#2": {
|
||||
"3": {
|
||||
"question": "",
|
||||
"answer": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"4": {
|
||||
"question": " ",
|
||||
"answer": " "
|
||||
}
|
||||
},
|
||||
{
|
||||
"#3": {
|
||||
"5": {
|
||||
"question": " ",
|
||||
"answer": " "
|
||||
}
|
||||
},
|
||||
{
|
||||
"#4": {
|
||||
"6": {
|
||||
"question": " ",
|
||||
"answer": " "
|
||||
}
|
||||
},
|
||||
{
|
||||
"#5": {
|
||||
"7": {
|
||||
"question": " ",
|
||||
"answer": " "
|
||||
}
|
||||
},
|
||||
{
|
||||
"#6": {
|
||||
"8": {
|
||||
"question": " ",
|
||||
"answer": " "
|
||||
}
|
||||
},
|
||||
{
|
||||
"#7": {
|
||||
"9": {
|
||||
"question": " ",
|
||||
"answer": " "
|
||||
}
|
||||
},
|
||||
{
|
||||
"#8": {
|
||||
"question": " ",
|
||||
"answer": " "
|
||||
}
|
||||
},
|
||||
{
|
||||
"#9": {
|
||||
"question": " ",
|
||||
"answer": " "
|
||||
}
|
||||
},
|
||||
{
|
||||
"#10": {
|
||||
"10": {
|
||||
"question": " ",
|
||||
"answer": " "
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user