diff --git a/slaeforms/app.py b/slaeforms/app.py index c94e7a9..fdcfb0b 100644 --- a/slaeforms/app.py +++ b/slaeforms/app.py @@ -170,10 +170,11 @@ def teststartpage(): session["current_stimulus_index"] = 0 session["current_block_name"] = session["block_names"][session["current_block_index"]] session["number_of_blocks"] = len(session["block_names"]) + current_block = config[session["current_block_name"]] # 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"])) + if "stimuli" in current_block: + session["number_of_stimuli"] = len(list(current_block["stimuli"]["list"])) print("number of blocks: ",len(session["block_names"])) @@ -182,11 +183,12 @@ def teststartpage(): for name in block_names: if config[name]["type"] == "TaskTemplate": - match config[name]["stimulus"]["type"]: + match config[name]["stimuli"]["type"]: case "single_video": - order = list(config[name]["stimulus"]["list"]) # order = list of simuli keys - if config[name]["stimulus"]["order"] == "random": - random.shuffle(order[name]) #in random order + order = list(config[name]["stimuli"]["list"]) # order = list of simuli keys + print("order: ",order) + if config[name]["stimuli"]["order"] == "random": + random.shuffle(order) #in random order session["block_order"][name] = order #save the new user to the database and the session @@ -240,19 +242,19 @@ def jsonform(): # ansonsten, templates: - current_block_order = session["block_order"][current_block] - current_block_stimuli = config[current_block]["stimuli"] - current_stimulus = current_block_order[0] - stimulus_type=current_stimulus["type"] - stimulus_configuration = config[current_block]["stimulus"]["configuration"] + current_block_order = session["block_order"][session["current_block_name"]] + current_block_stimuli = current_block["stimuli"] + current_stimulus = current_block_order[session["current_stimulus_index"]] + stimulus_type=current_block["stimuli"]["type"] + stimulus_configuration = current_block["stimuli"]["configuration"] # dict with the config - if current_block[type] == "TaskTemplate": + if current_block["type"] == "TaskTemplate": print("case: TaskTemplate") match stimulus_type: case "single_video": - stimulus_configuration["video_url"] = config[current_block]["stimuli"]["list"] - + stimulus_configuration["video_url"] = config[session["current_block_name"]]["stimuli"]["list"][current_stimulus] + print("-------------videourl: ", stimulus_configuration["video_url"]) return render_template( "standard_template.html", stimuli=current_block_stimuli, diff --git a/slaeforms/default.json b/slaeforms/default.json index 61685d7..cbbb9f4 100644 --- a/slaeforms/default.json +++ b/slaeforms/default.json @@ -1,4 +1,21 @@ { + "Block 3":{ + "type": "TaskTemplate", + "tempalte": "standard_template.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" + } + } + }, "Block_1":{ "type": "SinglePage", "template": "test_page0.html" @@ -16,32 +33,5 @@ } } } - }, - "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" - } - } - } } } \ No newline at end of file diff --git a/slaeforms/templates/standard_template.html b/slaeforms/templates/standard_template.html index 71a07b1..29cea06 100644 --- a/slaeforms/templates/standard_template.html +++ b/slaeforms/templates/standard_template.html @@ -1,6 +1,25 @@ +{% macro single_video(video_url, embed="yt", title="",width="560", height="315", class="center", code="
No code given
") -%} + {% if (embed == "yt") %} +No code given
) -%} - {% if (embed == "yt") %} -