diff --git a/app.py b/app.py index a33d5a0..085437f 100644 --- a/app.py +++ b/app.py @@ -2,6 +2,7 @@ from flask import Flask, render_template, request, jsonify from models import db, Progress, Statistic import os import random +import time app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///database.db' @@ -102,11 +103,15 @@ def calculate_statistics(user_input, current_text): # Berechne Wörter pro Minute (WPM) # Annahme: 1 Wort = 5 Zeichen (durchschnittlich) words_per_minute = 0 - if total_chars > 0 and duration_per_char > 0: - # Zeit in Minuten berechnen - time_in_minutes = (total_chars * duration_per_char) / 60 - if time_in_minutes > 0: - words_per_minute = total_chars / 5 / time_in_minutes + + # Für eine realistischere WPM-Berechnung benötigen wir die Zeit + # In dieser einfachen Version verwenden wir eine vereinfachte Berechnung + if total_chars > 0: + # Annahme: 1 Zeichen = 0.05 Sekunden (entspricht 20 Zeichen pro Sekunde) + time_per_char = 0.05 + total_time = total_chars * time_per_char + if total_time > 0: + words_per_minute = (total_chars / 5) / (total_time / 60) return { 'correct_chars': correct_chars,