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["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["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["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():
|
for column_name, column_info in schema["fields"].items():
|
||||||
if column_info["type"] == "integer":
|
if column_info["type"] == "integer":
|
||||||
@ -175,6 +177,7 @@ def teststartpage():
|
|||||||
# if the block has stimuli, get how many
|
# if the block has stimuli, get how many
|
||||||
if "stimuli" in current_block:
|
if "stimuli" in current_block:
|
||||||
session["number_of_stimuli"] = len(list(current_block["stimuli"]["list"]))
|
session["number_of_stimuli"] = len(list(current_block["stimuli"]["list"]))
|
||||||
|
|
||||||
|
|
||||||
print("number of blocks: ",len(session["block_names"]))
|
print("number of blocks: ",len(session["block_names"]))
|
||||||
|
|
||||||
@ -191,6 +194,10 @@ def teststartpage():
|
|||||||
random.shuffle(order) #in random order
|
random.shuffle(order) #in random order
|
||||||
session["block_order"][name] = 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
|
#save the new user to the database and the session
|
||||||
session["agreed_to_tos"] = True
|
session["agreed_to_tos"] = True
|
||||||
new_user_id = uuid.uuid4()
|
new_user_id = uuid.uuid4()
|
||||||
@ -291,8 +298,9 @@ def sendpage_json():
|
|||||||
session_user_id = session["slaeform_user_id"]
|
session_user_id = session["slaeform_user_id"]
|
||||||
new_id = uuid.uuid4()
|
new_id = uuid.uuid4()
|
||||||
date = datetime.today()
|
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():
|
for key, value in request.form.items():
|
||||||
print("hasattr key: ", key)
|
print("hasattr key: ", key)
|
||||||
@ -319,25 +327,27 @@ def update_session():
|
|||||||
if session["current_stimulus_index"] < session["number_of_stimuli"]-1:
|
if session["current_stimulus_index"] < session["number_of_stimuli"]-1:
|
||||||
# if there are still stimuli left, keep going through them
|
# if there are still stimuli left, keep going through them
|
||||||
session["current_stimulus_index"] += 1
|
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:
|
else:
|
||||||
# if there are no stimuli left..
|
# if there are no stimuli left..
|
||||||
if(session["current_block_index"] < session["number_of_blocks"]-1):
|
if(session["current_block_index"] < session["number_of_blocks"]-1):
|
||||||
# go to next block if possible
|
# go to next block if possible
|
||||||
session["current_block_index"] += 1
|
session["current_block_index"] += 1
|
||||||
|
session["current_block_name"] = session["block_names"][session["current_block_index"]]
|
||||||
session["current_block_name"] = session["block_names"][session["current_block_index"]]
|
session["current_stimulus_index"] = 0
|
||||||
session["number_of_stimuli"] = len(list(config[session["current_block_name"]]["list"]))
|
if "stimuli" in config[session["current_block_name"]]:
|
||||||
session["current_stimulus_index"] = 0
|
session["number_of_stimuli"] = len(list(config[session["current_block_name"]]["stimuli"]["list"]))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# if there arent any stimuli, go to the next block
|
# if there arent any stimuli, go to the next block
|
||||||
session["number_of_stimuli"] = 0
|
session["number_of_stimuli"] = 0
|
||||||
|
session["current_stimulus_index"] = 0
|
||||||
if(session["current_block_index"] < session["number_of_blocks"]-1):
|
if(session["current_block_index"] < session["number_of_blocks"]-1):
|
||||||
session["current_block_index"] += 1
|
session["current_block_index"] += 1
|
||||||
|
session["current_block_name"] = session["block_names"][session["current_block_index"]]
|
||||||
session["current_block_name"] = session["block_names"][session["current_block_index"]]
|
|
||||||
|
|
||||||
print("---Session updated---")
|
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_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"]))
|
||||||
|
@ -26,19 +26,19 @@
|
|||||||
},
|
},
|
||||||
"p2":{
|
"p2":{
|
||||||
"value":"2",
|
"value":"2",
|
||||||
"text":"I dont like it at all"
|
"text":"I dont like it"
|
||||||
},
|
},
|
||||||
"p3":{
|
"p3":{
|
||||||
"value":"3",
|
"value":"3",
|
||||||
"text":"I dont like it at all"
|
"text":"I am indifferent"
|
||||||
},
|
},
|
||||||
"p4":{
|
"p4":{
|
||||||
"value":"4",
|
"value":"4",
|
||||||
"text":"I dont like it at all"
|
"text":"I like it"
|
||||||
},
|
},
|
||||||
"p5":{
|
"p5":{
|
||||||
"value":"5",
|
"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">
|
<form action="http://localhost:5000/send_json" method="post">
|
||||||
{% for question in questions %}
|
{% for question in questions %}
|
||||||
{% if (questions[question]["type"] == "likert") %}
|
{% if (questions[question]["type"] == "likert") %}
|
||||||
<div class="likert"></div>
|
<div class="likercontainer">
|
||||||
|
<div class="likert">
|
||||||
{% for point in questions[question]["points"] %}
|
{% 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>
|
<label><input name="likertscale" type="radio" value="{{ questions[question]['points'][point]['value'] }}"/><span>{{ questions[question]['points'][point]['text'] }}</span></label>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
{% elif (questions[question]["type"] == "textinput") %}
|
{% elif (questions[question]["type"] == "textinput") %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>Error: Block {{config["question 1"]["blocks"][block]["type"]}} could not be loaded!</p>
|
<p>Error: Block {{config["question 1"]["blocks"][block]["type"]}} could not be loaded!</p>
|
||||||
|
Loading…
Reference in New Issue
Block a user