24.03.2022 Question/ Answer update
This commit is contained in:
parent
954b048ce8
commit
089f180ac4
|
@ -1,5 +1,6 @@
|
||||||
import json
|
import json
|
||||||
from random import randrange
|
from random import randrange
|
||||||
|
import re
|
||||||
|
|
||||||
|
|
||||||
# Einlesen vom Json File
|
# Einlesen vom Json File
|
||||||
|
@ -20,5 +21,9 @@ def random_question(filename):
|
||||||
return question, answer
|
return question, answer
|
||||||
|
|
||||||
|
|
||||||
#print(random_question(config.json_file)[0])
|
# Ausgabe der Liste mit allen Fragen/Antworten
|
||||||
|
def complete_list(filename):
|
||||||
|
data = read_json(filename)
|
||||||
|
for obj in data:
|
||||||
|
obj_string = re.sub('[{}]', '', str(obj))
|
||||||
|
print('\n' + obj_string)
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
13
json_writer.py
Normal file
13
json_writer.py
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
import json
|
||||||
|
|
||||||
|
# Fills my Json File with object from 0 to 299
|
||||||
|
counter = 0
|
||||||
|
data = [{counter: {'question': '', 'answer': ''}}]
|
||||||
|
|
||||||
|
while counter < 300:
|
||||||
|
data.append({counter: {'question': '', 'answer': ''}})
|
||||||
|
counter += 1
|
||||||
|
|
||||||
|
json_string = json.dumps(data)
|
||||||
|
with open('jsontest.json', 'w') as file:
|
||||||
|
file.write(json_string)
|
1
jsontest.json
Normal file
1
jsontest.json
Normal file
File diff suppressed because one or more lines are too long
|
@ -4,9 +4,12 @@ from menu import database_menu
|
||||||
|
|
||||||
# Main Menu
|
# Main Menu
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def main_menu():
|
def main_menu():
|
||||||
enable_menu = True
|
enable_menu = True
|
||||||
selection = {0: 'Datenbank Menü (Nur möglich wenn der Mysql-Server gestartet wurde)', 1: 'Zufallsfrage', 2: 'Programm beenden\n'}
|
selection = {0: 'Datenbank Tool (Nur möglich wenn der Mysql-Server gestartet wurde)', 1: 'Zufallsfrage', 2: 'Info', 3: 'Komplette Liste', 4: 'Programm beenden\n'}
|
||||||
|
|
||||||
print('# Main Menü #\n')
|
print('# Main Menü #\n')
|
||||||
while enable_menu:
|
while enable_menu:
|
||||||
|
@ -27,4 +30,9 @@ def main_menu():
|
||||||
if number == 1:
|
if number == 1:
|
||||||
break
|
break
|
||||||
case 2:
|
case 2:
|
||||||
|
print('# Info # \n In diesem Programm sind ca 300 Prüfungsrelevante Fragen zur ersten Prüfung gespeichert. \n')
|
||||||
|
case 3:
|
||||||
|
print('\n Liste der Fragen und Antworten')
|
||||||
|
print(question_answer_output.complete_list(config.json_file))
|
||||||
|
case 4:
|
||||||
break
|
break
|
Loading…
Reference in New Issue
Block a user