Update Session should cycle through stimuli now
This commit is contained in:
parent
a3e3fd1a1b
commit
e22b1c0737
@ -171,6 +171,10 @@ def teststartpage():
|
||||
session["current_block_name"] = session["block_names"][session["current_block_index"]]
|
||||
session["number_of_blocks"] = len(session["block_names"])
|
||||
|
||||
# if the block has stimuli, get how many
|
||||
if "stimuli" in config[session["current_block_name"]]:
|
||||
session["number_of_stimuli"] = len(list(config[session["current_block_name"]]["list"]))
|
||||
|
||||
print("number of blocks: ",len(session["block_names"]))
|
||||
|
||||
print("Startpage post")
|
||||
@ -306,12 +310,40 @@ def sendpage_json():
|
||||
return redirect("/jsonform")
|
||||
|
||||
def update_session():
|
||||
#if session["current_stimulus_index"] < session["current_max_stimulus_index"]
|
||||
# session["current_stimulus_index"] += 1 #TODO do this properly
|
||||
if(session["current_block_index"] < session["number_of_blocks"]-1):
|
||||
session["current_block_index"] += 1
|
||||
if "stimuli" in config[session["current_block_name"]]:
|
||||
# if there are stimuli in this block
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
else:
|
||||
# if there arent any stimuli, go to the next block
|
||||
session["number_of_stimuli"] = 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"])
|
||||
print("current_stimulus_index: ", session["current_stimulus_index"])
|
||||
print("Current number_of_stimuli: ", session["number_of_stimuli"])
|
||||
|
||||
|
||||
|
||||
|
||||
session["current_block_name"] = session["block_names"][session["current_block_index"]]
|
||||
|
||||
|
||||
# Actual main code for Form etc --------------------------------------------------------------
|
||||
|
@ -16,5 +16,32 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Block 3":{
|
||||
"type": "TaskTemplate",
|
||||
"tempalte": "tempaltetest1.html",
|
||||
"number_of_pages":"3",
|
||||
"stimuli":{
|
||||
"type":"single_video",
|
||||
"order": "random",
|
||||
"list":{
|
||||
"video_1":"https://www.youtube-nocookie.com/embed/VtnwHmabyzo?si=H3rrG-GHtlSymR70",
|
||||
"video_2":"https://www.youtube-nocookie.com/embed/EL76Ok4r0aQ?si=hqUm8eUUfX39NN4L",
|
||||
"video_3":"https://www.youtube-nocookie.com/embed/XTMIomsXxKM?si=r2zB6OKERH6Jdpi6"
|
||||
},
|
||||
"configuration":{
|
||||
"embed":"yt"
|
||||
}
|
||||
},
|
||||
"database_table" :{
|
||||
"table_name": "tempaltetest1_responses",
|
||||
"fields": {
|
||||
"accepted":{
|
||||
"type": "string",
|
||||
"size": "7",
|
||||
"nullable": "false"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user