From 6d29156977bcc9010a07a411e894aed52c4ac0ca Mon Sep 17 00:00:00 2001 From: Arne Baeumler <arne@br0tkasten.de> Date: Mon, 31 May 2021 14:45:59 +0200 Subject: [PATCH] initial import --- .gitignore | 2 ++ .vscode/settings.json | 3 +++ README.md | 7 ++++++- app.py | 29 +++++++++++++++++++++++++++++ requirements.txt | 10 ++++++++++ templates/arbeitsblatt.html | 11 +++++++++++ templates/base.html | 22 ++++++++++++++++++++++ templates/generator.html | 33 +++++++++++++++++++++++++++++++++ templates/index.html | 20 ++++++++++++++++++++ 9 files changed, 136 insertions(+), 1 deletion(-) create mode 100644 .gitignore create mode 100644 .vscode/settings.json create mode 100644 app.py create mode 100644 requirements.txt create mode 100644 templates/arbeitsblatt.html create mode 100644 templates/base.html create mode 100644 templates/generator.html create mode 100644 templates/index.html diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..06a47c5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +env/ +__pycache__/ diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..b1e9d05 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "python.pythonPath": "/home/arne/Desktop/Development/python3/flask/vocabulary/env/bin/python3.8" +} \ No newline at end of file diff --git a/README.md b/README.md index 64a781b..1e03584 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,8 @@ # Rechentrainer -Einmaleins Übungsblätter generieren \ No newline at end of file +Einmaleins Übungsblätter generieren + +``` +. env/bin/activate +pip3 install -r requirements.txt +``` diff --git a/app.py b/app.py new file mode 100644 index 0000000..220763f --- /dev/null +++ b/app.py @@ -0,0 +1,29 @@ +from flask import Flask, render_template, url_for, request, redirect, Response, abort, session +from flask_sqlalchemy import SQLAlchemy +from datetime import datetime +import magic +import random +import string + + +app = Flask(__name__) +app.secret_key = 'eng5iikeiwah3lae4idoo0woh4eiy6Th' + +@app.route('/', methods = ['GET', 'POST']) +def index(): + if request.method == 'POST': + alle = [] + zufall = [] + for r in request.form.getlist('rechenreihen'): + for i in range(1,11): + alle.append({str(r)+"x"+str(i): int(r)*int(i) }) + + while len(alle): + zufall.append(alle.pop(random.randint(0,len(alle)-1))) + return render_template('arbeitsblatt.html',aufgaben=zufall) + else: + return render_template('generator.html') + + +if __name__ == "__main__": + app.run(debug=True) \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..ecc8f4a --- /dev/null +++ b/requirements.txt @@ -0,0 +1,10 @@ +python-magic==0.4.15 +Click==7.0 +Flask==1.1.1 +Flask-SQLAlchemy==2.4.1 +gunicorn==20.0.4 +itsdangerous==1.1.0 +Jinja2==2.10.3 +MarkupSafe==1.1.1 +SQLAlchemy==1.3.12 +Werkzeug==0.16.0 diff --git a/templates/arbeitsblatt.html b/templates/arbeitsblatt.html new file mode 100644 index 0000000..b0c7e90 --- /dev/null +++ b/templates/arbeitsblatt.html @@ -0,0 +1,11 @@ +{% extends 'base.html' %} + +{% block content %} +<div class="w3-responsive"> + {% for a in aufgaben %} + {% for k in a %} + <table class="w3-left" width="auto"><tr><td class="w3-right-align" style="width: 3em">{{ k }}</td><td> = </td><td class="w3-border-bottom" style="width: 5em; height: 2em"></td></tr></table> + {% endfor %} + {% endfor %} +</div> +{% endblock %} \ No newline at end of file diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 0000000..54dc429 --- /dev/null +++ b/templates/base.html @@ -0,0 +1,22 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <meta http-equiv="X-UA-Compatible" content="ie=edge"> + <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css"> + <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"> + {% block head %}<title>Rechentrainer</title>{% endblock %} +</head> +<body> +<header class="w3-container w3-blue-grey"> + {% block header %}<h1><a class="w3-button" href="/"><i class="material-icons w3-xxlarge">home</i></a>Rechentrainer</h1>{% endblock %} +</header> +<div class="w3-container" style="margin-bottom: 1.5em;"> + {% block content %}{% endblock %} +</div> +<footer class="w3-container w3-blue-grey w3-center" style="position: fixed; bottom: 0; width: 100vw; height: 1.5em"> + {% block footer %}<span>(c) br0tkasten.de</span>{% endblock %} +</footer> +</body> +</html> \ No newline at end of file diff --git a/templates/generator.html b/templates/generator.html new file mode 100644 index 0000000..a9f3dbf --- /dev/null +++ b/templates/generator.html @@ -0,0 +1,33 @@ +{% extends 'base.html' %} + +{% block content %} +<div class="w3-display-container"> + <form method="POST"> + <!--label for="rechenreihen">Rechenreihen wählen:</label> + <select name="rechenreihen" id="rechenreihen" multiple> + <option value="1">1er Reihe</option> + <option value="2">2er Reihe</option> + <option value="3">3er Reihe</option> + <option value="4">4er Reihe</option> + <option value="5">5er Reihe</option> + <option value="6">6er Reihe</option> + <option value="7">7er Reihe</option> + <option value="8">8er Reihe</option> + <option value="9">9er Reihe</option> + <option value="10">10er Reihe</option> + </select--> + <input type="checkbox" name="rechenreihen" value="1"> 1er Reihe<br/> + <input type="checkbox" name="rechenreihen" value="2"> 2er Reihe<br/> + <input type="checkbox" name="rechenreihen" value="3"> 3er Reihe<br/> + <input type="checkbox" name="rechenreihen" value="4"> 4er Reihe<br/> + <input type="checkbox" name="rechenreihen" value="5"> 5er Reihe<br/> + <input type="checkbox" name="rechenreihen" value="6"> 6er Reihe<br/> + <input type="checkbox" name="rechenreihen" value="7"> 7er Reihe<br/> + <input type="checkbox" name="rechenreihen" value="8"> 8er Reihe<br/> + <input type="checkbox" name="rechenreihen" value="9"> 9er Reihe<br/> + <input type="checkbox" name="rechenreihen" value="10"> 10er Reihe<br/> + + <input type="submit" value="zum Arbeitsblatt"> + </form> +</div> +{% endblock %} \ No newline at end of file diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..c2da5a2 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,20 @@ +{% extends 'base.html' %} + +{% block content %} +<div class="w3-display-container" style="height: 200px"> + <div class="w3-row w3-half w3-display-middle"> + <div class="w3-blue-grey w3-col w3-mobile s6"> + <a class="w3-block w3-button" href="/train"> + <i class="material-icons w3-jumbo">school</i> + <p>train</p> + </a> + </div> + <div class="w3-blue-grey w3-col w3-mobile s6"> + <a class="w3-block w3-button" href="/manage"> + <i class="material-icons w3-jumbo">settings_applications</i> + <p>manage vocabulary</p> + </a> + </div> + </div> +</div> +{% endblock %} \ No newline at end of file