diff --git a/slaeforms/app.py b/slaeforms/app.py index da66d7c..d52c72b 100644 --- a/slaeforms/app.py +++ b/slaeforms/app.py @@ -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": @@ -175,6 +177,7 @@ def teststartpage(): # if the block has stimuli, get how many if "stimuli" in current_block: session["number_of_stimuli"] = len(list(current_block["stimuli"]["list"])) + print("number of blocks: ",len(session["block_names"])) @@ -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,25 +327,27 @@ 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 + session["current_block_name"] = session["block_names"][session["current_block_index"]] + 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"]] + 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"])) diff --git a/slaeforms/default.json b/slaeforms/default.json index 076f055..3dada63 100644 --- a/slaeforms/default.json +++ b/slaeforms/default.json @@ -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" } } } diff --git a/slaeforms/templates/old_unused/Study1 b/slaeforms/templates/old_unused/Study1.html similarity index 100% rename from slaeforms/templates/old_unused/Study1 rename to slaeforms/templates/old_unused/Study1.html diff --git a/slaeforms/templates/old_unused/layout3.html b/slaeforms/templates/old_unused/layout3.html deleted file mode 100644 index e69de29..0000000 diff --git a/slaeforms/templates/standard_template.html b/slaeforms/templates/standard_template.html index 07deb5e..17ea526 100644 --- a/slaeforms/templates/standard_template.html +++ b/slaeforms/templates/standard_template.html @@ -44,11 +44,14 @@
{% for question in questions %} {% if (questions[question]["type"] == "likert") %} -
+
+
{% for point in questions[question]["points"] %} {% endfor %}
+
+ {% elif (questions[question]["type"] == "textinput") %} {% else %}

Error: Block {{config["question 1"]["blocks"][block]["type"]}} could not be loaded!

diff --git a/slaeforms/templates/tempaltetest1.html b/slaeforms/templates/tempaltetest1.html deleted file mode 100644 index e69de29..0000000