First commit, already played around a bit
This commit is contained in:
commit
4fc6765b1d
14
.gitignore
vendored
Normal file
14
.gitignore
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
.venv/
|
||||||
|
|
||||||
|
*.pyc
|
||||||
|
__pycache__/
|
||||||
|
|
||||||
|
instance/
|
||||||
|
|
||||||
|
.pytest_cache/
|
||||||
|
.coverage
|
||||||
|
htmlcov/
|
||||||
|
|
||||||
|
dist/
|
||||||
|
build/
|
||||||
|
*.egg-info/
|
46
slaeforms/app.py
Normal file
46
slaeforms/app.py
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
import sys
|
||||||
|
from flask import Flask, redirect, url_for, request
|
||||||
|
from flask import render_template
|
||||||
|
from flask_sqlalchemy import SQLAlchemy
|
||||||
|
from sqlalchemy.orm import DeclarativeBase
|
||||||
|
from sqlalchemy import Integer, String
|
||||||
|
from sqlalchemy.orm import Mapped, mapped_column
|
||||||
|
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
# configure the SQLite database, relative to the app instance folder
|
||||||
|
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///database.db"
|
||||||
|
# initialize the app with the extension
|
||||||
|
db.init_app(app)
|
||||||
|
data = {}
|
||||||
|
|
||||||
|
class Base(DeclarativeBase):
|
||||||
|
pass
|
||||||
|
|
||||||
|
class User(db.Model):
|
||||||
|
id: Mapped[int] = mapped_column(primary_key=True)
|
||||||
|
username: Mapped[str] = mapped_column(unique=True)
|
||||||
|
email: Mapped[str]
|
||||||
|
|
||||||
|
with app.app_context():
|
||||||
|
db.create_all()
|
||||||
|
|
||||||
|
db = SQLAlchemy(model_class=Base)
|
||||||
|
|
||||||
|
@app.route("/", methods=["GET", "POST"])
|
||||||
|
def testpage():
|
||||||
|
global data
|
||||||
|
if request.method == "POST":
|
||||||
|
data = request.form
|
||||||
|
print(data)
|
||||||
|
return redirect(url_for("datapage"))
|
||||||
|
return render_template(
|
||||||
|
"layout1.html"
|
||||||
|
)
|
||||||
|
|
||||||
|
@app.route("/data")
|
||||||
|
def datapage():
|
||||||
|
return render_template(
|
||||||
|
"data.html",
|
||||||
|
value = str(data)
|
||||||
|
)
|
BIN
slaeforms/database.db
Normal file
BIN
slaeforms/database.db
Normal file
Binary file not shown.
9
slaeforms/db.py
Normal file
9
slaeforms/db.py
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import click
|
||||||
|
from flask import current_app, g
|
||||||
|
from flask_sqlalchemy import SQLAlchemy
|
||||||
|
from sqlalchemy.orm import DeclarativeBase
|
||||||
|
|
||||||
|
class Base(DeclarativeBase):
|
||||||
|
pass
|
||||||
|
|
||||||
|
db = SQLAlchemy(model_class=Base)
|
17
slaeforms/schema.sql
Normal file
17
slaeforms/schema.sql
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
DROP TABLE IF EXISTS user;
|
||||||
|
DROP TABLE IF EXISTS post;
|
||||||
|
|
||||||
|
CREATE TABLE user (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
username TEXT UNIQUE NOT NULL,
|
||||||
|
password TEXT NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE post (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
author_id INTEGER NOT NULL,
|
||||||
|
created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
title TEXT NOT NULL,
|
||||||
|
body TEXT NOT NULL,
|
||||||
|
FOREIGN KEY (author_id) REFERENCES user (id)
|
||||||
|
);
|
3
slaeforms/static/attributions.txt
Normal file
3
slaeforms/static/attributions.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
https://jamesalvarez.co.uk/blog/how-to-make-responsive-likert-scales-in-css-(like-qualtrics)/
|
||||||
|
|
||||||
|
|
94
slaeforms/static/styles.css
Normal file
94
slaeforms/static/styles.css
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
body {
|
||||||
|
width: 100%;
|
||||||
|
height: 100vh;
|
||||||
|
margin: 0;
|
||||||
|
background-color: #a4b5ff;
|
||||||
|
color: #000000;
|
||||||
|
font-family: Tahoma;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.columncontainer {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.columnleft {
|
||||||
|
width: 100%;
|
||||||
|
border: 3px solid black;
|
||||||
|
}
|
||||||
|
.columnright {
|
||||||
|
width: 100%;
|
||||||
|
border: 3px solid black;
|
||||||
|
}
|
||||||
|
|
||||||
|
iframe {
|
||||||
|
display:block;
|
||||||
|
margin: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.centertext {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2,h3 {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.likert {
|
||||||
|
--likert-rows: 5;
|
||||||
|
margin: auto;
|
||||||
|
text-align: center;
|
||||||
|
display: inline-grid;
|
||||||
|
max-width: 900px;
|
||||||
|
grid-auto-rows: 1fr;
|
||||||
|
gap: 1em;
|
||||||
|
grid-template-columns: repeat(var(--likert-rows), minmax(0, 1fr));
|
||||||
|
}
|
||||||
|
|
||||||
|
@media only screen and (max-width: 680px) {
|
||||||
|
.likert {
|
||||||
|
grid-template-columns: minmax(0, 400px);
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.likert input {
|
||||||
|
max-width: 250px;
|
||||||
|
position: fixed;
|
||||||
|
opacity: 0;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.likercontainer{
|
||||||
|
margin: 30px auto;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.likert span {
|
||||||
|
border-radius: 5px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
text-align: center;
|
||||||
|
box-sizing: border-box;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
padding: 20px;
|
||||||
|
background: #dcdcdc;
|
||||||
|
transition: background .2s ease-in-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
.likert input:checked + span {
|
||||||
|
outline: black auto 1px;
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.likert input:focus + span {
|
||||||
|
outline: -webkit-focus-ring-color auto 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.likert span:hover {
|
||||||
|
background: #f1f1f1;
|
||||||
|
outline: lightgrey auto 0.5px;
|
||||||
|
}
|
15
slaeforms/templates/data.html
Normal file
15
slaeforms/templates/data.html
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<link rel="stylesheet" type="text/css" href="styles.css" />
|
||||||
|
<title>Testform</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h2>Task number 1</h2>
|
||||||
|
<p>The Likertscale value is: {{ value }}</p>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
54
slaeforms/templates/layout1.html
Normal file
54
slaeforms/templates/layout1.html
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='styles.css')}}"" />
|
||||||
|
<title>Testform</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h2>Task number 1</h2>
|
||||||
|
<div class="columncontainer">
|
||||||
|
|
||||||
|
<div class="columnleft center">
|
||||||
|
<h3>Video 1</h3>
|
||||||
|
<iframe width="560" height="315" class="center"
|
||||||
|
src="https://www.youtube-nocookie.com/embed/VtnwHmabyzo?si=H3rrG-GHtlSymR70"
|
||||||
|
title="YouTube video player" frameborder="0"
|
||||||
|
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
|
||||||
|
allowfullscreen></iframe>
|
||||||
|
</div>
|
||||||
|
<div class="columnright">
|
||||||
|
<h3>Video 2</h3>
|
||||||
|
<iframe width="560" height="315"
|
||||||
|
src="https://www.youtube-nocookie.com/embed/PdvSPBdX2T0?si=8R2ZAMnPuoe50X-7"
|
||||||
|
title="YouTube video player" frameborder="0"
|
||||||
|
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
|
||||||
|
allowfullscreen></iframe>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<form action = "http://localhost:5000/" method = "post">
|
||||||
|
<div class="likercontainer">
|
||||||
|
<div class="likert">
|
||||||
|
<label><input name="likertscale" type="radio" value="1" /><span>I dont like it at all</span></label>
|
||||||
|
<label><input name="likertscale" type="radio" value="2" /><span>I dont like it</span></label>
|
||||||
|
<label><input name="likertscale" type="radio" value="3" /><span>I am indifferent</span></label>
|
||||||
|
<label><input name="likertscale" type="radio" value="4" /><span>I like it</span></label>
|
||||||
|
<label><input name="likertscale" type="radio" value="5" /><span>I like it a lot</span></label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="likercontainer">
|
||||||
|
<div class="likert">
|
||||||
|
<label><input name="likertscale2" type="radio" value="1" /><span>I dont like it at all</span></label>
|
||||||
|
<label><input name="likertscale2" type="radio" value="2" /><span>I dont like it</span></label>
|
||||||
|
<label><input name="likertscale2" type="radio" value="3" /><span>I am indifferent</span></label>
|
||||||
|
<label><input name="likertscale2" type="radio" value="4" /><span>I like it</span></label>
|
||||||
|
<label><input name="likertscale2" type="radio" value="5" /><span>I like it a lot</span></label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<p><input type = "submit" value = "submit";"/></p>
|
||||||
|
</form>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
94
slaeforms/templates/styles.css
Normal file
94
slaeforms/templates/styles.css
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
body {
|
||||||
|
width: 100%;
|
||||||
|
height: 100vh;
|
||||||
|
margin: 0;
|
||||||
|
background-color: #a4b5ff;
|
||||||
|
color: #000000;
|
||||||
|
font-family: Tahoma;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.columncontainer {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.columnleft {
|
||||||
|
width: 100%;
|
||||||
|
border: 3px solid black;
|
||||||
|
}
|
||||||
|
.columnright {
|
||||||
|
width: 100%;
|
||||||
|
border: 3px solid black;
|
||||||
|
}
|
||||||
|
|
||||||
|
iframe {
|
||||||
|
display:block;
|
||||||
|
margin: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.centertext {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2,h3 {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.likert {
|
||||||
|
--likert-rows: 5;
|
||||||
|
margin: auto;
|
||||||
|
text-align: center;
|
||||||
|
display: inline-grid;
|
||||||
|
max-width: 900px;
|
||||||
|
grid-auto-rows: 1fr;
|
||||||
|
gap: 1em;
|
||||||
|
grid-template-columns: repeat(var(--likert-rows), minmax(0, 1fr));
|
||||||
|
}
|
||||||
|
|
||||||
|
@media only screen and (max-width: 680px) {
|
||||||
|
.likert {
|
||||||
|
grid-template-columns: minmax(0, 400px);
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.likert input {
|
||||||
|
max-width: 250px;
|
||||||
|
position: fixed;
|
||||||
|
opacity: 0;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.likercontainer{
|
||||||
|
margin: 30px auto;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.likert span {
|
||||||
|
border-radius: 5px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
text-align: center;
|
||||||
|
box-sizing: border-box;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
padding: 20px;
|
||||||
|
background: #dcdcdc;
|
||||||
|
transition: background .2s ease-in-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
.likert input:checked + span {
|
||||||
|
outline: black auto 1px;
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.likert input:focus + span {
|
||||||
|
outline: -webkit-focus-ring-color auto 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.likert span:hover {
|
||||||
|
background: #f1f1f1;
|
||||||
|
outline: lightgrey auto 0.5px;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user