diff --git a/app.py b/app.py index d75005b..e8b18fe 100644 --- a/app.py +++ b/app.py @@ -193,11 +193,18 @@ def index(): print(f"Rendering Index - Current Text Länge: {len(current_text)} Zeichen") + # Bestimme den Lektionstitel + current_lesson_title = "Unbekannte Lektion" + if lessons and progress.current_text_index < len(lessons): + lesson = lessons[progress.current_text_index] + current_lesson_title = lesson.get('description', f"Lektion {progress.current_text_index + 1}") + return render_template('index.html', current_text=current_text, current_position=progress.current_position, last_text=progress.last_text, - lessons=lessons) + lessons=lessons, + current_lesson_title=current_lesson_title) except Exception as e: print(f"Fehler in index(): {e}") @@ -394,10 +401,15 @@ def next_text(): db.session.commit() + # Bestimme den Titel der neuen Lektion + new_lesson = lessons[progress.current_text_index] + lesson_title = new_lesson.get('description', f"Lektion {progress.current_text_index + 1}") + return jsonify({ - 'text': lessons[progress.current_text_index]['text'], + 'text': new_lesson['text'], 'index': progress.current_text_index, - 'total': len(lessons) + 'total': len(lessons), + 'title': lesson_title }) except Exception as e: diff --git a/static/js/script.js b/static/js/script.js index 5ee56c7..dd0a128 100644 --- a/static/js/script.js +++ b/static/js/script.js @@ -37,6 +37,8 @@ document.addEventListener('DOMContentLoaded', function() { .then(data => { currentText = data.text; document.getElementById('target-text').textContent = currentText; + // Aktualisiere den Lektionstitel + document.getElementById('lesson-title').textContent = data.title; userInput.value = ''; userInput.focus(); // Fokus zurück auf Eingabefeld updateStatistics('', currentText); @@ -58,6 +60,8 @@ document.addEventListener('DOMContentLoaded', function() { .then(data => { currentText = data.text; document.getElementById('target-text').textContent = currentText; + // Aktualisiere den Lektionstitel + document.getElementById('lesson-title').textContent = data.title; userInput.value = ''; userInput.focus(); // Fokus zurück auf Eingabefeld updateStatistics('', currentText); diff --git a/templates/index.html b/templates/index.html index 0a0b689..6f9e3de 100644 --- a/templates/index.html +++ b/templates/index.html @@ -18,7 +18,7 @@
-
Vorlage: {{ current_lesson_title }}
+
Vorlage: {{ current_lesson_title }}
{{ current_text|safe }}