21.3.2022
This commit is contained in:
parent
7eca5bfedc
commit
328de250d2
10
README.md
10
README.md
|
@ -3,4 +3,12 @@
|
||||||
Ziel ist es ein Programm mit einer Datenbank zu erstellen, welches:
|
Ziel ist es ein Programm mit einer Datenbank zu erstellen, welches:
|
||||||
- Fragen und Antworen einließt
|
- Fragen und Antworen einließt
|
||||||
- Ein Auswahlmenü bietet
|
- Ein Auswahlmenü bietet
|
||||||
- Fragen abfragt und die Antwor vergleicht
|
- Fragen abfragt und die Antwort ausgibt
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<h4>Um das Programm zu starten:</h4>
|
||||||
|
<blockquote>
|
||||||
|
Du kannst die start_app.py in einer IDE starten
|
||||||
|
oder in der Konsole unter Windows "py main.py" ausführen
|
||||||
|
</blockquote >
|
|
@ -1,14 +1,9 @@
|
||||||
|
|
||||||
|
|
||||||
import mysql.connector
|
import mysql.connector
|
||||||
|
|
||||||
|
|
||||||
# Aufbau der verbindung zum Mysql Server
|
# Aufbau der verbindung zum Mysql Server
|
||||||
|
|
||||||
|
|
||||||
def db_connection(user, password, host, database):
|
def db_connection(user, password, host, database):
|
||||||
connection = ''
|
connection = ''
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Verbindung - Eingaben in der config.py bestimmen
|
# Verbindung - Eingaben in der config.py bestimmen
|
||||||
connection = mysql.connector.connect(user=user, password=password, host=host, database=database)
|
connection = mysql.connector.connect(user=user, password=password, host=host, database=database)
|
||||||
|
@ -16,4 +11,3 @@ def db_connection(user, password, host, database):
|
||||||
print('Something went wrong', err)
|
print('Something went wrong', err)
|
||||||
print('Veruche deinen Mysql Server neu zu starten')
|
print('Veruche deinen Mysql Server neu zu starten')
|
||||||
return connection
|
return connection
|
||||||
|
|
||||||
|
|
11
main.py
11
main.py
|
@ -2,20 +2,21 @@
|
||||||
# Auswahlmenü (Neue Fragen/ Oder Abfrage)
|
# Auswahlmenü (Neue Fragen/ Oder Abfrage)
|
||||||
# Ein und Ausgabe der Fragen/Antworten
|
# Ein und Ausgabe der Fragen/Antworten
|
||||||
# Datenbanken (CRUD) Tabellen (CRUD)
|
# Datenbanken (CRUD) Tabellen (CRUD)
|
||||||
import time
|
|
||||||
|
|
||||||
import main_menu
|
import main_menu
|
||||||
import requirements_installer
|
import requirements_installer
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Aufruf des Main Menüs
|
# Aufruf des Main Menüs
|
||||||
def main():
|
def main():
|
||||||
print('Programm wird in 5 Sekunden gestartet, bitte gewährleiste, dass beim Programmstart dein Mysql Server '
|
print('Programm wird in 5 Sekunden gestartet, bitte gewährleiste, dass beim Programmstart dein Mysql Server '
|
||||||
'online ist\n')
|
'online ist\n')
|
||||||
time.sleep(5)
|
print('Installation vom Mysql Connector\n')
|
||||||
print('Installation vom Mysql Connector')
|
# Installiert die nötigen Ressourcen
|
||||||
# requirements_installer.installer()
|
requirements_installer.installer()
|
||||||
|
print('\n ----IHK Prüfungsfragen---- \n')
|
||||||
main_menu.main_menu()
|
main_menu.main_menu()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import question_answer_output
|
||||||
|
|
||||||
# Main Menu
|
# Main Menu
|
||||||
|
|
||||||
|
|
||||||
def main_menu():
|
def main_menu():
|
||||||
enable_menu = True
|
enable_menu = True
|
||||||
selection = {0: 'Datenbank Menü', 1: 'Zufallsfrage', 2: 'Programm beenden\n'}
|
selection = {0: 'Datenbank Menü', 1: 'Zufallsfrage', 2: 'Programm beenden\n'}
|
||||||
|
@ -19,8 +20,11 @@ def main_menu():
|
||||||
break
|
break
|
||||||
case 1:
|
case 1:
|
||||||
while True:
|
while True:
|
||||||
question_answer_output.random_question(config.json_file)
|
print('#Frage#\n' + '-'*60 + '\n' + question_answer_output.random_question(config.json_file)[0])
|
||||||
number = int(input('Zurück zum Hauptmenü\n 1: Ja \n 2: Nein\n'))
|
|
||||||
|
input('\nBitte Enter drücken um die Antwort zu sehen\n')
|
||||||
|
print('#Antwort#\n' + question_answer_output.random_question(config.json_file)[1])
|
||||||
|
number = int(input('\nZurück zum Hauptmenü\n 1: Ja \n 2: Nein, nächste Frage\n'))
|
||||||
if number == 1:
|
if number == 1:
|
||||||
break
|
break
|
||||||
case 2:
|
case 2:
|
||||||
|
|
|
@ -1,22 +1,21 @@
|
||||||
# TODO: einlesen der berreits vorhanden Daten im JSON File
|
|
||||||
|
|
||||||
import json
|
import json
|
||||||
from random import randrange
|
from random import randrange
|
||||||
|
|
||||||
|
|
||||||
# Einlesen Json File
|
# Einlesen vom Json File
|
||||||
def read_json(filename):
|
def read_json(filename):
|
||||||
with open(filename) as filename:
|
with open(filename,encoding='utf-8') as filename:
|
||||||
data = json.load(filename)
|
data = json.load(filename)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
# Zufällige Frage erstellen
|
# Zufällige Frage erstellen
|
||||||
def random_question(filename):
|
def random_question(filename):
|
||||||
min = 0
|
min = 0
|
||||||
max = len(read_json(filename))
|
max = len(read_json(filename))
|
||||||
random_number = randrange(min,max)
|
random_number = randrange(min,max)
|
||||||
questions = read_json(filename)
|
questions = read_json(filename)
|
||||||
question = f'Frage Nr:', random_number, questions[random_number][str(random_number)]['question']
|
question = f'Frage #{random_number}: ' + questions[random_number][str(random_number)]['question']
|
||||||
answer = questions[random_number][str(random_number)]['answer']
|
answer = questions[random_number][str(random_number)]['answer']
|
||||||
return question, answer
|
return question, answer
|
||||||
|
|
||||||
|
|
|
@ -2,68 +2,9 @@
|
||||||
{
|
{
|
||||||
"0": {
|
"0": {
|
||||||
"question": "Was versteht man unter dem Begriff Cross-Selling?",
|
"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"
|
"answer": "Eine Verkaufsstrategie, bei der zu einem Produkt, zusätzliche ( Inhalte, Produkte, Services etc...) angeboten werden, um einen höheren Umsatz und höhere Kundenanbindung zu erzielen"
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"1": {
|
|
||||||
"question": "",
|
|
||||||
"answer": ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"2": {
|
|
||||||
"question": " ",
|
|
||||||
"answer": " "
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"3": {
|
|
||||||
"question": "",
|
|
||||||
"answer": ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"4": {
|
|
||||||
"question": " ",
|
|
||||||
"answer": " "
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"5": {
|
|
||||||
"question": " ",
|
|
||||||
"answer": " "
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"6": {
|
|
||||||
"question": " ",
|
|
||||||
"answer": " "
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"7": {
|
|
||||||
"question": " ",
|
|
||||||
"answer": " "
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"8": {
|
|
||||||
"question": " ",
|
|
||||||
"answer": " "
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"9": {
|
|
||||||
"question": " ",
|
|
||||||
"answer": " "
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"10": {
|
|
||||||
"question": " ",
|
|
||||||
"answer": " "
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
]
|
]
|
|
@ -2,7 +2,7 @@ import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
|
||||||
# implement pip as a subprocess:
|
# Ressourcen für den Autoinstall
|
||||||
def installer():
|
def installer():
|
||||||
subprocess.check_call([sys.executable, '-m', 'pip', 'install',
|
subprocess.check_call([sys.executable, '-m', 'pip', 'install',
|
||||||
'mysql-connector-python'])
|
'mysql-connector-python'])
|
||||||
|
|
7
start.bat
Normal file
7
start.bat
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
@echo off
|
||||||
|
echo Autor : Marcus Ferl
|
||||||
|
echo Beschreibung : IHK Prüfungsfragen
|
||||||
|
echo Programm gestartet
|
||||||
|
@py.exe main.py
|
||||||
|
|
||||||
|
pause
|
4
start_app.py
Normal file
4
start_app.py
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
import os
|
||||||
|
|
||||||
|
# Startet das Programm in der Windows Konsole
|
||||||
|
os.system("start /wait cmd /c py main.py")
|
Loading…
Reference in New Issue
Block a user