Text with input fields veryfing its correctness
This commit is contained in:
parent
39ee608e56
commit
8318b82952
7
README.md
Normal file
7
README.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# Development
|
||||||
|
|
||||||
|
To run the app:
|
||||||
|
1. ```pipenv shell```
|
||||||
|
2. ```export FLASK_APP=main.py```
|
||||||
|
3. ```export FLASK_ENV=development```
|
||||||
|
4. ```flask run```
|
7
app/__init__.py
Normal file
7
app/__init__.py
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
from flask import Flask
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
app.config["SECRET_KEY"] = "asdasfgrwee"
|
||||||
|
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///latin.sqlite"
|
||||||
|
|
||||||
|
from app import routes
|
23
app/main.py
Normal file
23
app/main.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
from app import app
|
||||||
|
|
||||||
|
# from flask import render_template
|
||||||
|
# from flask_sqlalchemy import SQLAlchemy
|
||||||
|
# from sqlalchemy import func
|
||||||
|
# from flask_wtf import FlaskForm
|
||||||
|
# from wtforms import Form, RadioField, SubmitField, HiddenField
|
||||||
|
|
||||||
|
# db = SQLAlchemy(app)
|
||||||
|
|
||||||
|
# class Word(db.Model):
|
||||||
|
# id = db.Column(db.Integer, primary_key=True)
|
||||||
|
# dictionarium = db.Column(db.String, unique=True, nullable=False)
|
||||||
|
# coniugatio = db.Column(db.Integer, unique=False, nullable=False)
|
||||||
|
|
||||||
|
# def __repr__(self):
|
||||||
|
# return '%r; %d conjugation' % (self.dictionarium, self.coniugatio)
|
||||||
|
|
||||||
|
# class ConjugatioAnswer(FlaskForm):
|
||||||
|
# radio = RadioField('', choices=[(1, 'Prima'), (2, 'Secunda'), (3, 'Tertia'), (4, 'Quarta')])
|
||||||
|
# word = HiddenField()
|
||||||
|
# submit = SubmitField('Check')
|
||||||
|
# next_word = SubmitField('Next word')
|
@ -1,33 +1,19 @@
|
|||||||
from flask import Flask
|
from app import app
|
||||||
from flask import render_template
|
from flask import render_template
|
||||||
from flask_sqlalchemy import SQLAlchemy
|
|
||||||
from sqlalchemy import func
|
|
||||||
from flask_wtf import FlaskForm
|
|
||||||
from wtforms import Form, RadioField, SubmitField, HiddenField
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
@app.route('/')
|
||||||
app.config["SECRET_KEY"] = "asdasfgrwee"
|
@app.route('/index')
|
||||||
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///latin.sqlite"
|
def index():
|
||||||
db = SQLAlchemy(app)
|
return "Hello, World!"
|
||||||
|
|
||||||
class Word(db.Model):
|
|
||||||
id = db.Column(db.Integer, primary_key=True)
|
|
||||||
dictionarium = db.Column(db.String, unique=True, nullable=False)
|
|
||||||
coniugatio = db.Column(db.Integer, unique=False, nullable=False)
|
|
||||||
|
|
||||||
def __repr__(self):
|
|
||||||
return '%r; %d conjugation' % (self.dictionarium, self.coniugatio)
|
|
||||||
|
|
||||||
class ConjugatioAnswer(FlaskForm):
|
|
||||||
radio = RadioField('', choices=[(1, 'Prima'), (2, 'Secunda'), (3, 'Tertia'), (4, 'Quarta')])
|
|
||||||
word = HiddenField()
|
|
||||||
submit = SubmitField('Check')
|
|
||||||
next_word = SubmitField('Next word')
|
|
||||||
|
|
||||||
@app.route('/latin')
|
@app.route('/latin')
|
||||||
def latin():
|
def latin():
|
||||||
return render_template('latin.html')
|
return render_template('latin.html')
|
||||||
|
|
||||||
|
@app.route('/latin/llpsi')
|
||||||
|
def llpsi():
|
||||||
|
return render_template('LLPSI/01_Imperium_Romanum/Pensum_A.html')
|
||||||
|
|
||||||
@app.route('/latin/coniugationes')
|
@app.route('/latin/coniugationes')
|
||||||
def coniugationes():
|
def coniugationes():
|
||||||
return render_template('coniugationes.html')
|
return render_template('coniugationes.html')
|
32
app/templates/LLPSI/01_Imperium_Romanum/Pensum_A.html
Normal file
32
app/templates/LLPSI/01_Imperium_Romanum/Pensum_A.html
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="la">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Familia Romana – Pensum A</title>
|
||||||
|
<script type="text/javascript">
|
||||||
|
function validate() {
|
||||||
|
const forms = document.querySelectorAll('form');
|
||||||
|
const form = forms[0];
|
||||||
|
|
||||||
|
|
||||||
|
Array.from(form.elements).forEach((input) => {
|
||||||
|
console.log(input);
|
||||||
|
if (input.type=="text" && input.value != input.dataset.expected) {
|
||||||
|
input.setAttribute("style", "border-color:red");
|
||||||
|
console.log('incorrect!')
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log('dupa');
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<form class="Pensum_A" onsubmit="return validate();">
|
||||||
|
Nilus fluvi<input type="text" id=1 data-expected="us" size=2 required> est.<br>
|
||||||
|
<input type="submit" value="Submit">
|
||||||
|
</form>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -5,6 +5,7 @@
|
|||||||
<title>Lingua Latina</title>
|
<title>Lingua Latina</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<a href="/latin/llpsi">Lingua Latina Per Se Illustrata</a><br>
|
||||||
<a href="/latin/coniugationes">Coniugationes</a>
|
<a href="/latin/coniugationes">Coniugationes</a>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
Loading…
Reference in New Issue
Block a user