some testing prep, but probably obsolete

This commit is contained in:
Jan 2024-04-25 16:51:08 +02:00
parent b14bc2d608
commit dfa7156b9f
3 changed files with 69 additions and 85 deletions

View File

@ -12,6 +12,9 @@ from sqlalchemy.dialects.postgresql import UUID
from datetime import datetime
import uuid
# get all dbtables that the user created
from dbtables import *
random_order = True
# activate environment: cd C:\Users\Jan\Google Drive\Master Stuff\Code\SLAEForms Testing\.venv\Scripts\
@ -33,9 +36,17 @@ config = json.load(configfile)
config2 = json.load(configfile2)
configfile.close()
configfile2.close()
# get the questions:
# get the questions: Questions is a list that contains the keys of the dictionary
questions = list(config)
# JSON TEST-------------------------------------------
configtest = open("test.json")
config = json.load(configtest) #convert json to dict
configtest.close()
blocks = list(config) # get the block names, aka a list of all keys
# create the model for the response table
class Response(db.Model):
id = db.Column(db.UUID(as_uuid=True), primary_key=True, nullable=False)
@ -47,8 +58,8 @@ class Response(db.Model):
def __repr__(self) -> str:
return "<Response %r>" % self.id
class User(db.Model):
# This table is created always
class User(db.Model):
user_id = db.Column(db.UUID(as_uuid=True), primary_key=True, nullable=False)
device_id = db.Column(db.UUID(as_uuid=True), nullable=False)
question_order = db.Column(db.String(60))
@ -61,6 +72,39 @@ with app.app_context():
db.create_all()
@app.route("/customsend/<inputid>", methods=["POST"])
def customsend():
session_user_id = session["slaeform_user_id"]
likert_score = request.form["likertscale"]
text_input = request.form["feedback"]
question_title = session["current_question"]
new_id = uuid.uuid4()
date = datetime.today()
print("new idea: {new_id} ".format(new_id=new_id))
new_response = Response(id=new_id,user_id = session_user_id, question_title = question_title,likert_result = likert_score,notes = text_input, date_created = date)
try:
db.session.add(new_response)
db.session.commit()
return redirect("/form")
except:
return "There was a problem while adding the response to the Database"
@app.route("/custom")
def custom():
return render_template(
"templatetest1.html"
)
@app.route("/video", methods=["GET", "POST"])
def videopage():

12
slaeforms/dbtables.py Normal file
View File

@ -0,0 +1,12 @@
from app import db
class Response(db.Model):
id = db.Column(db.UUID(as_uuid=True), primary_key=True, nullable=False)
user_id = db.Column(db.UUID(as_uuid=True), nullable=False)
question_title = db.Column(db.String(30))
likert_result = db.Column(db.Integer, nullable=False)
notes = db.Column(db.String(200))
date_created = db.Column(db.DateTime)
def __repr__(self) -> str:
return "<Response %r>" % self.id

View File

@ -1,87 +1,15 @@
{
"question 1":{
"type": "single",
"video1": "https://www.youtube-nocookie.com/embed/VtnwHmabyzo?si=H3rrG-GHtlSymR70",
"blocks": {
"block1":{
"type": "likert",
"numberofpoints": "5",
"points":{
"point1": "1",
"point2": "2",
"point3": "3",
"point4": "4",
"point5": "5"
}
},
"block2":{
"type": "likert",
"numberofpoints": "5",
"points":{
"point1": "1",
"point2": "2",
"point3": "3",
"point4": "4",
"point5": "5"
}
},
"block3":{
"type": "textinput",
"length": "200"
},
"block4":{
"type": "likert",
"numberofpoints": "5",
"points":{
"point1": "1",
"point2": "2",
"point3": "3",
"point4": "4",
"point5": "5"
}
}
}
"Block 1":{
"type": "SinglePage",
"template": "startpage.html"
},
"question 2":{
"type": "single",
"video1": "https://www.youtube-nocookie.com/embed/EL76Ok4r0aQ?si=hqUm8eUUfX39NN4L",
"blocks": {
"block1":{
"type": "likert",
"numberofpoints": "5",
"points":{
"point1": "1",
"point2": "2",
"point3": "3",
"point4": "4",
"point5": "5"
}
},
"block2":{
"type": "likert",
"numberofpoints": "5",
"points":{
"point1": "1",
"point2": "2",
"point3": "3",
"point4": "4",
"point5": "5"
}
},
"block3":{
"type": "textinput",
"length": "200"
},
"block4":{
"type": "likert",
"numberofpoints": "5",
"points":{
"point1": "1",
"point2": "2",
"point3": "3",
"point4": "4",
"point5": "5"
}
"Block 2":{
"type": "TaskTemplate",
"tempalte": "tempaltetest1.html",
"name" : "Block2Responses"
"databasetable": {
"question_title" : {
"type:"
}
}
},