Testtemplate with questions loading now

This commit is contained in:
Jan 2024-05-30 17:54:28 +02:00
parent 6e6868e230
commit 01a8e5f021
3 changed files with 49 additions and 6 deletions

View File

@ -248,6 +248,7 @@ def jsonform():
stimulus_type=current_block["stimuli"]["type"] stimulus_type=current_block["stimuli"]["type"]
stimulus_configuration = current_block["stimuli"]["configuration"] # dict with the config stimulus_configuration = current_block["stimuli"]["configuration"] # dict with the config
if current_block["type"] == "TaskTemplate": if current_block["type"] == "TaskTemplate":
print("case: TaskTemplate") print("case: TaskTemplate")
@ -260,7 +261,8 @@ def jsonform():
stimuli=current_block_stimuli, stimuli=current_block_stimuli,
stimulus_type=stimulus_type, stimulus_type=stimulus_type,
current_stimulus=current_stimulus, current_stimulus=current_stimulus,
stimulus_configuration=stimulus_configuration stimulus_configuration=stimulus_configuration,
questions=current_block["questions"]
) )

View File

@ -14,6 +14,43 @@
"configuration":{ "configuration":{
"embed":"yt" "embed":"yt"
} }
},
"questions":{
"question1":{
"type": "likert",
"name": "likertscale",
"points":{
"p1":{
"value":"1",
"text":"I dont like it at all"
},
"p2":{
"value":"2",
"text":"I dont like it at all"
},
"p3":{
"value":"3",
"text":"I dont like it at all"
},
"p4":{
"value":"4",
"text":"I dont like it at all"
},
"p5":{
"value":"5",
"text":"I dont like it at all"
}
}
}
},
"database_table" :{
"table_name": "default_block3_test",
"fields": {
"likertscale":{
"type": "integer",
"nullable": "false"
}
}
} }
}, },
"Block_1":{ "Block_1":{

View File

@ -41,11 +41,15 @@
<h2>Questions</h2> <h2>Questions</h2>
<form action="http://localhost:5000/send_json" method="post"></form> <form action="http://localhost:5000/send_json" method="post">
{% for question in questions %} {% for question in questions %}
{% if (questions[question] == "likert") %} {% if (questions[question]["type"] == "likert") %}
<div class="likert"></div>
{% elif (config["question 1"]["blocks"][block]["type"] == "textinput") %} {% 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>
{% 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>
{% endif %} {% endif %}
@ -53,6 +57,6 @@
<p><input id="submitbutton" type = "submit" value = "submit";/></p> <p><input id="submitbutton" type = "submit" value = "submit";/></p>
</form> </form>
</body> </body>
</html> </html>