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:
|
||||
- Fragen und Antworen einließt
|
||||
- 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
|
||||
|
||||
|
||||
# Aufbau der verbindung zum Mysql Server
|
||||
|
||||
|
||||
def db_connection(user, password, host, database):
|
||||
connection = ''
|
||||
|
||||
try:
|
||||
# Verbindung - Eingaben in der config.py bestimmen
|
||||
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('Veruche deinen Mysql Server neu zu starten')
|
||||
return connection
|
||||
|
||||
|
|
13
main.py
13
main.py
|
@ -1,21 +1,22 @@
|
|||
# TODO: Datenbankabfrage
|
||||
# Auswahlmenü ( Neue Fragen/ Oder Abfrage)
|
||||
# Auswahlmenü (Neue Fragen/ Oder Abfrage)
|
||||
# Ein und Ausgabe der Fragen/Antworten
|
||||
# Datenbanken (CRUD) Tabellen (CRUD)
|
||||
import time
|
||||
|
||||
import main_menu
|
||||
import requirements_installer
|
||||
|
||||
|
||||
|
||||
|
||||
# Aufruf des Main Menüs
|
||||
def main():
|
||||
print('Programm wird in 5 Sekunden gestartet, bitte gewährleiste, dass beim Programmstart dein Mysql Server '
|
||||
'online ist\n')
|
||||
time.sleep(5)
|
||||
print('Installation vom Mysql Connector')
|
||||
# requirements_installer.installer()
|
||||
|
||||
print('Installation vom Mysql Connector\n')
|
||||
# Installiert die nötigen Ressourcen
|
||||
requirements_installer.installer()
|
||||
print('\n ----IHK Prüfungsfragen---- \n')
|
||||
main_menu.main_menu()
|
||||
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import question_answer_output
|
|||
|
||||
# Main Menu
|
||||
|
||||
|
||||
def main_menu():
|
||||
enable_menu = True
|
||||
selection = {0: 'Datenbank Menü', 1: 'Zufallsfrage', 2: 'Programm beenden\n'}
|
||||
|
@ -19,8 +20,11 @@ def main_menu():
|
|||
break
|
||||
case 1:
|
||||
while True:
|
||||
question_answer_output.random_question(config.json_file)
|
||||
number = int(input('Zurück zum Hauptmenü\n 1: Ja \n 2: Nein\n'))
|
||||
print('#Frage#\n' + '-'*60 + '\n' + question_answer_output.random_question(config.json_file)[0])
|
||||
|
||||
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:
|
||||
break
|
||||
case 2:
|
||||
|
|
|
@ -1,22 +1,21 @@
|
|||
# TODO: einlesen der berreits vorhanden Daten im JSON File
|
||||
|
||||
import json
|
||||
from random import randrange
|
||||
|
||||
|
||||
# Einlesen Json File
|
||||
# Einlesen vom Json File
|
||||
def read_json(filename):
|
||||
with open(filename) as filename:
|
||||
with open(filename,encoding='utf-8') 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']
|
||||
question = f'Frage #{random_number}: ' + questions[random_number][str(random_number)]['question']
|
||||
answer = questions[random_number][str(random_number)]['answer']
|
||||
return question, answer
|
||||
|
||||
|
|
|
@ -2,68 +2,9 @@
|
|||
{
|
||||
"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": " "
|
||||
}
|
||||
},
|
||||
{
|
||||
"3": {
|
||||
"question": "",
|
||||
"answer": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"4": {
|
||||
"question": " ",
|
||||
"answer": " "
|
||||
}
|
||||
},
|
||||
{
|
||||
"5": {
|
||||
"question": " ",
|
||||
"answer": " "
|
||||
}
|
||||
},
|
||||
{
|
||||
"6": {
|
||||
"question": " ",
|
||||
"answer": " "
|
||||
}
|
||||
},
|
||||
{
|
||||
"7": {
|
||||
"question": " ",
|
||||
"answer": " "
|
||||
}
|
||||
},
|
||||
{
|
||||
"8": {
|
||||
"question": " ",
|
||||
"answer": " "
|
||||
}
|
||||
},
|
||||
{
|
||||
"9": {
|
||||
"question": " ",
|
||||
"answer": " "
|
||||
}
|
||||
},
|
||||
{
|
||||
"10": {
|
||||
"question": " ",
|
||||
"answer": " "
|
||||
"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"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
]
|
|
@ -2,7 +2,7 @@ import sys
|
|||
import subprocess
|
||||
|
||||
|
||||
# implement pip as a subprocess:
|
||||
# Ressourcen für den Autoinstall
|
||||
def installer():
|
||||
subprocess.check_call([sys.executable, '-m', 'pip', 'install',
|
||||
'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