likert visuals fixed, random order fixed
This commit is contained in:
parent
01a8e5f021
commit
1b1b37d108
@ -123,6 +123,8 @@ def create_model_class(schema):
|
||||
attributes["id"] = Column("id",db.UUID(as_uuid=True), primary_key=True, nullable=False)
|
||||
attributes["user_id"] = Column("user_id",db.UUID(as_uuid=True), primary_key=True, nullable=False)
|
||||
attributes["date_created"] = db.Column("date_created",db.DateTime)
|
||||
attributes["stimulus_name"] = db.Column("stimulus_name",db.String(30))
|
||||
|
||||
|
||||
for column_name, column_info in schema["fields"].items():
|
||||
if column_info["type"] == "integer":
|
||||
@ -176,6 +178,7 @@ def teststartpage():
|
||||
if "stimuli" in current_block:
|
||||
session["number_of_stimuli"] = len(list(current_block["stimuli"]["list"]))
|
||||
|
||||
|
||||
print("number of blocks: ",len(session["block_names"]))
|
||||
|
||||
print("Startpage post")
|
||||
@ -191,6 +194,10 @@ def teststartpage():
|
||||
random.shuffle(order) #in random order
|
||||
session["block_order"][name] = order
|
||||
|
||||
if "stimuli" in current_block:
|
||||
#get the name of the current stimulus
|
||||
session["current_stimulus_name"] = session["block_order"][session["current_block_name"]][session["current_stimulus_index"]]
|
||||
|
||||
#save the new user to the database and the session
|
||||
session["agreed_to_tos"] = True
|
||||
new_user_id = uuid.uuid4()
|
||||
@ -291,8 +298,9 @@ def sendpage_json():
|
||||
session_user_id = session["slaeform_user_id"]
|
||||
new_id = uuid.uuid4()
|
||||
date = datetime.today()
|
||||
stimulus_name = session["current_stimulus_name"]
|
||||
|
||||
new_entry = db_tables[table_name](id=new_id,user_id = session_user_id,date_created = date)
|
||||
new_entry = db_tables[table_name](id=new_id,user_id = session_user_id,date_created = date,stimulus_name=stimulus_name)
|
||||
|
||||
for key, value in request.form.items():
|
||||
print("hasattr key: ", key)
|
||||
@ -319,26 +327,28 @@ def update_session():
|
||||
if session["current_stimulus_index"] < session["number_of_stimuli"]-1:
|
||||
# if there are still stimuli left, keep going through them
|
||||
session["current_stimulus_index"] += 1
|
||||
# set the name of the current stimulus
|
||||
session["current_stimulus_name"] = session["block_order"][session["current_block_name"]][session["current_stimulus_index"]]
|
||||
|
||||
else:
|
||||
# if there are no stimuli left..
|
||||
if(session["current_block_index"] < session["number_of_blocks"]-1):
|
||||
# go to next block if possible
|
||||
session["current_block_index"] += 1
|
||||
|
||||
session["current_block_name"] = session["block_names"][session["current_block_index"]]
|
||||
session["number_of_stimuli"] = len(list(config[session["current_block_name"]]["list"]))
|
||||
session["current_stimulus_index"] = 0
|
||||
if "stimuli" in config[session["current_block_name"]]:
|
||||
session["number_of_stimuli"] = len(list(config[session["current_block_name"]]["stimuli"]["list"]))
|
||||
|
||||
else:
|
||||
# if there arent any stimuli, go to the next block
|
||||
session["number_of_stimuli"] = 0
|
||||
|
||||
session["current_stimulus_index"] = 0
|
||||
if(session["current_block_index"] < session["number_of_blocks"]-1):
|
||||
session["current_block_index"] += 1
|
||||
|
||||
session["current_block_name"] = session["block_names"][session["current_block_index"]]
|
||||
|
||||
|
||||
print("---Session updated---")
|
||||
print("current_block_index / number_of_blocks: {current_block_index} / {number_of_blocks}".format(current_block_index=session["current_block_index"],number_of_blocks=session["number_of_blocks"]))
|
||||
print("current_block_name: ", session["current_block_name"])
|
||||
|
@ -26,19 +26,19 @@
|
||||
},
|
||||
"p2":{
|
||||
"value":"2",
|
||||
"text":"I dont like it at all"
|
||||
"text":"I dont like it"
|
||||
},
|
||||
"p3":{
|
||||
"value":"3",
|
||||
"text":"I dont like it at all"
|
||||
"text":"I am indifferent"
|
||||
},
|
||||
"p4":{
|
||||
"value":"4",
|
||||
"text":"I dont like it at all"
|
||||
"text":"I like it"
|
||||
},
|
||||
"p5":{
|
||||
"value":"5",
|
||||
"text":"I dont like it at all"
|
||||
"text":"I like it a lot"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -44,11 +44,14 @@
|
||||
<form action="http://localhost:5000/send_json" method="post">
|
||||
{% for question in questions %}
|
||||
{% if (questions[question]["type"] == "likert") %}
|
||||
<div class="likert"></div>
|
||||
<div class="likercontainer">
|
||||
<div class="likert">
|
||||
{% for point in questions[question]["points"] %}
|
||||
<label><input name="likertscale" type="radio" value="{{ questions[question]['points'][point]['value'] }}"/><span>{{ questions[question]['points'][point]['text'] }}</span></label>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% elif (questions[question]["type"] == "textinput") %}
|
||||
{% else %}
|
||||
<p>Error: Block {{config["question 1"]["blocks"][block]["type"]}} could not be loaded!</p>
|
||||
|
Loading…
Reference in New Issue
Block a user