Fix: last_text Initialisierung - leere Benutzereingabe statt vollem Text beim Start
Behebt Bug, bei dem beim ersten Aufruf oder Lektionswechsel alle Zeichen bereits als eingegeben markiert waren. last_text sollte die Benutzereingabe enthalten, nicht den Lektionstext. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
f0918de32c
commit
673cc6e9ae
1 changed files with 16 additions and 26 deletions
42
app.py
42
app.py
|
|
@ -354,26 +354,15 @@ def train():
|
|||
progress = Progress.query.first()
|
||||
|
||||
if not progress:
|
||||
# Falls keine Daten vorhanden sind, initialisiere mit ersten Text
|
||||
if lessons:
|
||||
initial_text = lessons[0]['text']
|
||||
progress = Progress(
|
||||
current_text_index=0,
|
||||
current_position=0,
|
||||
last_text=initial_text
|
||||
)
|
||||
db.session.add(progress)
|
||||
db.session.commit()
|
||||
logger.info(f"Neuen Fortschritt initialisiert mit Text: {initial_text[:50]}...")
|
||||
else:
|
||||
# Fallback, falls lessons immer noch leer sein sollte
|
||||
progress = Progress(
|
||||
current_text_index=0,
|
||||
current_position=0,
|
||||
last_text="Keine Lektionen verfügbar"
|
||||
)
|
||||
db.session.add(progress)
|
||||
db.session.commit()
|
||||
# Falls keine Daten vorhanden sind, initialisiere mit leerer Eingabe
|
||||
progress = Progress(
|
||||
current_text_index=0,
|
||||
current_position=0,
|
||||
last_text=""
|
||||
)
|
||||
db.session.add(progress)
|
||||
db.session.commit()
|
||||
logger.info("Neuen Fortschritt initialisiert mit leerer Benutzereingabe")
|
||||
|
||||
# Hole den aktuellen Text
|
||||
current_text = ""
|
||||
|
|
@ -384,7 +373,7 @@ def train():
|
|||
current_text = lessons[0]['text'] if lessons else "Keine Lektionen verfügbar"
|
||||
progress.current_text_index = 0
|
||||
progress.current_position = 0
|
||||
progress.last_text = current_text
|
||||
progress.last_text = ""
|
||||
db.session.commit()
|
||||
|
||||
logger.debug(f"Rendering Index - Current Text Länge: {len(current_text)} Zeichen")
|
||||
|
|
@ -398,7 +387,8 @@ def train():
|
|||
progress.current_text_index = user_settings.current_lesson_index
|
||||
if lessons and progress.current_text_index < len(lessons):
|
||||
current_text = lessons[progress.current_text_index]['text']
|
||||
progress.last_text = current_text
|
||||
# Setze Position zurück, aber behalte last_text (Benutzereingabe)
|
||||
progress.current_position = 0
|
||||
db.session.commit()
|
||||
|
||||
# Bestimme den Lektionstitel
|
||||
|
|
@ -692,8 +682,8 @@ def next_text():
|
|||
progress.current_text_index = 0
|
||||
|
||||
progress.current_position = 0
|
||||
progress.last_text = lessons[progress.current_text_index]['text']
|
||||
|
||||
progress.last_text = ""
|
||||
|
||||
db.session.commit()
|
||||
|
||||
# Bestimme den Titel der neuen Lektion
|
||||
|
|
@ -730,8 +720,8 @@ def set_lesson():
|
|||
|
||||
progress.current_text_index = lesson_index
|
||||
progress.current_position = 0
|
||||
progress.last_text = lessons[lesson_index]['text']
|
||||
|
||||
progress.last_text = ""
|
||||
|
||||
db.session.commit()
|
||||
|
||||
# Bestimme den Titel der neuen Lektion
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue