22.03.2022
This commit is contained in:
parent
d4dee206e2
commit
5d4c14043d
|
@ -11,4 +11,5 @@ Ziel ist es ein Programm mit einer Datenbank zu erstellen, welches:
|
||||||
<blockquote>
|
<blockquote>
|
||||||
Du kannst die start_app.py in einer IDE starten
|
Du kannst die start_app.py in einer IDE starten
|
||||||
oder in der Konsole unter Windows "py main.py" ausführen
|
oder in der Konsole unter Windows "py main.py" ausführen
|
||||||
|
|
||||||
</blockquote >
|
</blockquote >
|
|
@ -5,5 +5,4 @@
|
||||||
user = 'root'
|
user = 'root'
|
||||||
password = ''
|
password = ''
|
||||||
host = 'localhost'
|
host = 'localhost'
|
||||||
|
|
||||||
json_file = 'questions_answers.json'
|
json_file = 'questions_answers.json'
|
|
@ -65,4 +65,8 @@ def show_tables(db_cursor):
|
||||||
try:
|
try:
|
||||||
db_cursor.execute(query)
|
db_cursor.execute(query)
|
||||||
except mysql.connector.Error as err:
|
except mysql.connector.Error as err:
|
||||||
print('Something went wrong', err)
|
print('Something went wrong', err)
|
||||||
|
|
||||||
|
|
||||||
|
def show(cursor, use_type):
|
||||||
|
return None
|
|
@ -1,4 +1,6 @@
|
||||||
import mysql.connector
|
import mysql.connector
|
||||||
|
|
||||||
|
|
||||||
# Aufbau der verbindung zum Mysql Server
|
# Aufbau der verbindung zum Mysql Server
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,4 +12,4 @@ def db_connection(user, password, host, database):
|
||||||
except mysql.connector.Error as err:
|
except mysql.connector.Error as err:
|
||||||
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
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import database
|
import database
|
||||||
|
from database import *
|
||||||
import database_connection
|
import database_connection
|
||||||
import config
|
import config
|
||||||
import main_menu
|
import main_menu
|
||||||
|
|
|
@ -4,7 +4,6 @@ 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'}
|
||||||
|
|
|
@ -11,9 +11,9 @@ def read_json(filename):
|
||||||
|
|
||||||
# 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 #{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']
|
||||||
|
|
|
@ -2,9 +2,68 @@
|
||||||
{
|
{
|
||||||
"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 höhere Kundenanbindung zu erzielen"
|
"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": " "
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
]
|
]
|
|
@ -2,7 +2,7 @@ import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
|
||||||
# Ressourcen für den Autoinstall
|
# Ressourcen für den Autoinstaller
|
||||||
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'])
|
||||||
|
|
12
start.bat
12
start.bat
|
@ -1,7 +1,11 @@
|
||||||
@echo off
|
@echo off
|
||||||
echo Autor : Marcus Ferl
|
chcp 65001
|
||||||
echo Beschreibung : IHK Prüfungsfragen
|
echo #####################################
|
||||||
echo Programm gestartet
|
echo # Autor : Marcus Ferl #
|
||||||
@py.exe main.py
|
echo # Beschreibung : IHK Prüfungsfragen #
|
||||||
|
echo # Programm gestartet #
|
||||||
|
echo #####################################
|
||||||
|
echo
|
||||||
|
@py.exe app.py
|
||||||
|
|
||||||
pause
|
pause
|
|
@ -1,4 +1,5 @@
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
# Startet das Programm in der Windows Konsole
|
# Startet das Programm in der Windows Konsole
|
||||||
os.system("start /wait cmd /c py main.py")
|
os.system("start /wait cmd /c py main.py")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user