2024-05-17 19:42:50 +02:00
|
|
|
#!/usr/bin/python3
|
|
|
|
|
|
|
|
from random import randint, random, choice
|
|
|
|
|
2024-06-02 21:10:30 +02:00
|
|
|
from choice_network import Choice, FixedText, RandInt, Network
|
|
|
|
|
2024-06-02 21:27:26 +02:00
|
|
|
def get_names(filename):
|
2024-06-03 10:39:40 +02:00
|
|
|
lines = []
|
|
|
|
with open(filename) as file:
|
|
|
|
lines = file.read().split("\n")
|
|
|
|
names = [
|
|
|
|
name + " "
|
|
|
|
for name in lines
|
|
|
|
if len(name) > 1
|
|
|
|
]
|
|
|
|
return names
|
2024-05-17 19:42:50 +02:00
|
|
|
|
|
|
|
greeting = """
|
2024-06-03 10:39:53 +02:00
|
|
|
Re: AW: Exmatrikulationsgefährdete Studierende
|
|
|
|
---------
|
2024-05-17 19:42:50 +02:00
|
|
|
Englisch version below.
|
|
|
|
|
|
|
|
Hallo,
|
|
|
|
|
2024-06-03 12:45:40 +02:00
|
|
|
Zur angefragten Prüfung gibt es leider noch keine Datenbank,
|
|
|
|
daher hier unsere Notizen aus Prüfungsakten und Personendatenbank.
|
|
|
|
Vielleicht können Sie die ja mit regulären Ausdrücken filtern.
|
|
|
|
Das funktioniert wie normale Text-Suche, nur etwas flexibler:
|
|
|
|
(Erst|Zweit)versuch z.B. würde sowohl 'Erstversuch'
|
|
|
|
als auch 'Zweitversuch' markieren.
|
|
|
|
.+ akzeptiert alle Zeichen, das können Sie vorn anfügen,
|
|
|
|
um im unteren Menü 'List' den Rest der Zeile zu sehen.
|
2024-05-17 19:42:50 +02:00
|
|
|
|
|
|
|
Viel Spaß
|
|
|
|
|
|
|
|
=== ENGLISCH VERSION ===
|
2024-06-03 12:45:40 +02:00
|
|
|
Hi,
|
|
|
|
there is no database for this exam, so we can only send our digitized notes.
|
|
|
|
Maybe you can filter it with regular expressions?
|
|
|
|
They are like normal text-search but not flexible:
|
|
|
|
E.g.: (Erst|Zweit)versuch would select both words:
|
|
|
|
'Erstversuch' (first attempt) and 'Zweitversuch' (second attempt).
|
|
|
|
.+ will accept any text, add it at the start to see the whole line
|
|
|
|
in the lower menu 'List'.
|
2024-05-17 19:42:50 +02:00
|
|
|
"""
|
|
|
|
|
|
|
|
# fünf Tatverdächtige
|
|
|
|
# Uhrzeiten, siehe Infos von Verantwortlichen
|
|
|
|
# Groß-Klein-Schreibung
|
2024-06-03 11:41:53 +02:00
|
|
|
date = "05.06.2024"
|
2024-06-03 11:02:01 +02:00
|
|
|
hidden_data = [
|
|
|
|
"Anna Bartel hat den Zweitversuch nicht bestanden.",
|
2024-06-03 12:22:04 +02:00
|
|
|
"Boris Parsch hat den Zweitversuch nicht bestanden.",
|
|
|
|
"Carola Winter hat den 2. Versuch nicht bestanden.",
|
2024-06-03 12:17:12 +02:00
|
|
|
"Dennis Meier hat den 2. Versuch nicht bestanden.",
|
2024-06-03 12:22:04 +02:00
|
|
|
"Elisa Menniz hat den Zweitversuch nicht bestanden.",
|
2024-06-03 12:10:45 +02:00
|
|
|
f"Anna Bartel hat die Prüfung am {date} um 13:00.",
|
|
|
|
f"Boris Parsch hat die Prüfung am {date} um 14:00.",
|
|
|
|
f"Carola Winter hat die Prüfung am {date} um 13:30.",
|
|
|
|
f"Dennis Meier hat die Prüfung am {date} um 10:00.",
|
|
|
|
f"Elisa Menniz hat die Prüfung am {date} um 14:30.",
|
2024-06-03 12:00:14 +02:00
|
|
|
f"Anna Bartel hat blaue Augen.",
|
|
|
|
f"Boris Parsch hat blaue Augen.",
|
|
|
|
f"Carola Winter hat blaue Augen.",
|
|
|
|
f"Dennis Meier hat grüne Augen.",
|
|
|
|
f"Elisa Menniz hat grüne Augen.",
|
2024-06-03 11:02:01 +02:00
|
|
|
]
|
2024-05-17 19:42:50 +02:00
|
|
|
|
2024-05-17 20:13:48 +02:00
|
|
|
network = Network(
|
|
|
|
start = Choice(
|
2024-06-03 12:17:12 +02:00
|
|
|
#student_mit = ["Student ", "Studentin ", "Studierende:r "],
|
2024-06-03 12:10:45 +02:00
|
|
|
student = [""],
|
2024-05-17 20:13:48 +02:00
|
|
|
),
|
|
|
|
student = Choice(
|
2024-06-02 21:27:26 +02:00
|
|
|
last_name = get_names("vornamen.csv"),
|
2024-05-17 20:13:48 +02:00
|
|
|
),
|
|
|
|
last_name = Choice(
|
2024-06-02 21:27:26 +02:00
|
|
|
student_mit = get_names("nachnamen.csv"),
|
2024-05-17 20:13:48 +02:00
|
|
|
),
|
|
|
|
student_mit = Choice(
|
2024-06-03 12:17:12 +02:00
|
|
|
#matr_nr = ["mit "],
|
|
|
|
hat_den = [""],
|
2024-05-17 20:13:48 +02:00
|
|
|
),
|
|
|
|
matr_nr = Choice(
|
2024-05-17 20:17:35 +02:00
|
|
|
matr_number = ["Matrikelnummer ", "Matrikel-Nummer ", "MatrNr. ", "Matrikel-Nr. "],
|
2024-05-17 20:13:48 +02:00
|
|
|
),
|
|
|
|
matr_number = RandInt(
|
|
|
|
hat_den = [
|
|
|
|
40_000_000,
|
|
|
|
55_000_000,
|
2024-06-03 11:12:40 +02:00
|
|
|
],
|
2024-05-17 20:13:48 +02:00
|
|
|
),
|
2024-06-03 11:12:40 +02:00
|
|
|
hat_den = Choice(
|
|
|
|
versuch = ["hat den ",],
|
2024-06-03 12:10:45 +02:00
|
|
|
prüfungszeit = [f"hat die Prüfung am {date} um ",],
|
2024-06-03 12:00:14 +02:00
|
|
|
augenfarbe = ["hat ",],
|
|
|
|
),
|
|
|
|
augenfarbe = Choice(
|
|
|
|
augen = ["grüne ", "braune ", "blaue ",],
|
|
|
|
),
|
|
|
|
augen = FixedText(
|
|
|
|
stop = "Augen.",
|
2024-06-03 12:18:07 +02:00
|
|
|
#körpergröße = "Augen und ist ",
|
|
|
|
),
|
|
|
|
körpergröße = RandInt(
|
|
|
|
cm_groß = [
|
|
|
|
150,
|
|
|
|
200,
|
|
|
|
],
|
|
|
|
),
|
|
|
|
cm_groß = FixedText(
|
|
|
|
stop = "cm groß.",
|
2024-06-03 11:12:40 +02:00
|
|
|
),
|
|
|
|
prüfungszeit = Choice(
|
|
|
|
uhr = [
|
|
|
|
"09:00",
|
|
|
|
"09:30",
|
|
|
|
"10:00",
|
|
|
|
"10:30",
|
|
|
|
"11:00",
|
|
|
|
"11:30",
|
|
|
|
"12:00",
|
|
|
|
"12:30",
|
|
|
|
"13:00",
|
|
|
|
"13:30",
|
|
|
|
"14:00",
|
|
|
|
"14:30",
|
|
|
|
"15:00",
|
|
|
|
"15:30",
|
|
|
|
],
|
|
|
|
),
|
|
|
|
uhr = FixedText(
|
2024-06-03 12:10:45 +02:00
|
|
|
stop = " Uhr.",
|
2024-06-03 11:12:40 +02:00
|
|
|
),
|
2024-06-03 11:34:05 +02:00
|
|
|
prüfungsart = Choice( #inactive
|
2024-06-03 11:12:40 +02:00
|
|
|
prüfung = ["schriftliche ", "mündliche "],
|
|
|
|
),
|
2024-06-03 12:10:45 +02:00
|
|
|
prüfung = FixedText( #inactive
|
2024-06-03 11:36:29 +02:00
|
|
|
stop = "Prüfung.",
|
2024-06-03 11:34:05 +02:00
|
|
|
),
|
2024-06-03 11:36:29 +02:00
|
|
|
prüfungsname = Choice( #inactive
|
2024-06-03 11:37:25 +02:00
|
|
|
prüfungsname_end = get_names("chemie.csv"),
|
2024-06-03 11:34:05 +02:00
|
|
|
),
|
2024-06-03 11:36:29 +02:00
|
|
|
prüfungsname_end = FixedText( #incative
|
2024-06-03 11:34:05 +02:00
|
|
|
stop = "'.",
|
2024-05-17 20:13:48 +02:00
|
|
|
),
|
|
|
|
versuch = Choice(
|
2024-05-17 20:17:35 +02:00
|
|
|
nicht = ["Erstversuch ", "1. Versuch "],
|
2024-06-03 11:37:25 +02:00
|
|
|
bestanden = ["Erstversuch ", "1. Versuch ", "Zweitversuch ", "2. Versuch "],
|
2024-05-17 20:13:48 +02:00
|
|
|
),
|
|
|
|
nicht = Choice(
|
|
|
|
bestanden = ["nicht ", ""],
|
|
|
|
),
|
|
|
|
bestanden = FixedText(
|
2024-06-03 11:12:40 +02:00
|
|
|
stop = "bestanden.",
|
2024-05-17 20:13:48 +02:00
|
|
|
),
|
|
|
|
)
|
|
|
|
|
2024-06-03 11:02:01 +02:00
|
|
|
def pop_hidden_data():
|
|
|
|
global hidden_data
|
|
|
|
index = randint(0, len(hidden_data) - 1)
|
|
|
|
return hidden_data.pop(index)
|
|
|
|
|
|
|
|
def generate_text(number_of_lines = 200):
|
2024-05-17 20:40:29 +02:00
|
|
|
result = ""
|
2024-06-03 11:02:01 +02:00
|
|
|
for i in range(number_of_lines):
|
2024-05-17 20:13:48 +02:00
|
|
|
emissions, _ = network.choose()
|
|
|
|
line = ''.join(emissions)
|
2024-05-17 20:40:29 +02:00
|
|
|
result += line + "\n"
|
2024-06-03 11:02:01 +02:00
|
|
|
if random() < len(hidden_data) / (number_of_lines - i):
|
|
|
|
result += pop_hidden_data() + "\n"
|
2024-05-17 20:40:29 +02:00
|
|
|
return result
|
|
|
|
|
|
|
|
def read_template(filename = "./template.html"):
|
|
|
|
with open(filename, "r") as file:
|
|
|
|
return file.read()
|
|
|
|
|
|
|
|
def write_index(text, filename = "./deploy/index.html"):
|
|
|
|
with open(filename, "w") as file:
|
|
|
|
file.write(text)
|
|
|
|
|
|
|
|
def main():
|
|
|
|
template = read_template()
|
|
|
|
generated = generate_text()
|
2024-06-03 10:39:53 +02:00
|
|
|
generated = greeting + "\n" + generated
|
2024-05-17 20:40:29 +02:00
|
|
|
text = template.replace("<replace with text>", generated)
|
|
|
|
write_index(text)
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|
|
|
|
|