From ca961ca89b101e134164019371ad6a31d9d6a429 Mon Sep 17 00:00:00 2001 From: Arne Baeumler Date: Sat, 12 Jun 2021 13:40:36 +0200 Subject: [PATCH] gemischteAufgaben 0 < e < 100 --- app.py | 13 +++++++++++-- templates/generator.html | 4 ++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/app.py b/app.py index e7aa139..6f847b8 100644 --- a/app.py +++ b/app.py @@ -43,16 +43,25 @@ def index(): else: count = len(alle) - for i in range(1,count): + while count > 1: if len(alle) == 0: break term = alle.pop(random.randint(0,len(alle)-1)) term.c = '' if request.form.get('gemischteAufgaben'): maxValue = eval(str(term.a) + term.t.typ + str(term.b)) - term.c += ' + ' if random.randint(0,1) else ' - ' + if random.randint(0,1): + term.c += ' + ' + t = int(100 - maxValue) + maxValue = t + else: + term.c += ' - ' + if maxValue <= 1: + alle.append(term) + continue term.c += str(random.randint(1,maxValue)) zufall.append(term) + count -= 1 return render_template('arbeitsblatt.html',aufgaben=zufall,maxPerPage=int(request.form.get('maxPerPage'))) else: return render_template('generator.html', reihen=rt_rechenreihen) diff --git a/templates/generator.html b/templates/generator.html index 01638d3..e99c064 100644 --- a/templates/generator.html +++ b/templates/generator.html @@ -28,12 +28,12 @@

-
+