multiple choice implemented + Dem Quest implemented

This commit is contained in:
Jan 2024-09-05 16:36:44 +02:00
parent 73127d9950
commit cdbb57d50d
7 changed files with 240 additions and 58 deletions

1
.gitignore vendored
View File

@ -6,6 +6,7 @@ __pycache__/
instance/ instance/
uploads/ uploads/
zip_exports/
.pytest_cache/ .pytest_cache/
.coverage .coverage

View File

@ -42,8 +42,8 @@ app.secret_key = b"29fe9e8edd407c5491d4f1c05632d9fa33e26ed8734a3f5e080ebac3772a5
UPLOAD_FOLDER = 'uploads' UPLOAD_FOLDER = 'uploads'
EXPORT_FOLDER = 'exports' EXPORT_FOLDER = 'exports'
PASSWORD = '#1ACGmsjd' PASSWORD = '#1ACGmsjd'
# CONFIGFILE = 'userstudy1.json' CONFIGFILE = 'userstudy1.json'
CONFIGFILE = 'test.json' # CONFIGFILE = 'test.json'
# CONFIGFILE = 'default.json' # CONFIGFILE = 'default.json'
#csrf = CSRFProtect(app) #enable CSRF protection globally #csrf = CSRFProtect(app) #enable CSRF protection globally
@ -364,7 +364,19 @@ def sendpage():
setattr(new_entry, "video_upload", video_name) setattr(new_entry, "video_upload", video_name)
for key, value in request.form.items(): # TODO maybe find a prettier solution, this handeles multiple choice now, so the fact that there can be
# multiple keys that are the same in the form data, but I want to bring them together to 1 key value pair
form_data = {}
for key in request.form:
values = request.form.getlist(key)
# If there's more than one value for the key, join them with commas
if len(values) > 1:
form_data[key] = ','.join(map(str, values)) # Join multiple values into a single comma-separated string
else:
form_data[key] = values[0] # If only one value, store it directly
for key, value in form_data.items():
print("hasattr key: ", key) print("hasattr key: ", key)
if hasattr(new_entry, key): if hasattr(new_entry, key):
print("key exists: ", key) print("key exists: ", key)

View File

@ -118,9 +118,7 @@ label {
margin-bottom: 1.5rem; margin-bottom: 1.5rem;
} }
input, .inputs {
textarea,
select {
margin: 10px 0 0 0; margin: 10px 0 0 0;
width: 60%; width: 60%;
min-height: 2em; min-height: 2em;

View File

@ -73,7 +73,7 @@ step={{question["step"]}}
{% macro input(name, value='', type='text', size=20) -%} {% macro input(name, value='', type='text', size=20) -%}
<input type="{{ type }}" name="{{ name }}" value="{{ <input type="{{ type }}" name="{{ name }}" value="{{
value|e }}" size="{{ size }}"> value|e }}" size="{{ size }}" class="inputs">
{%- endmacro %} {%- endmacro %}
<head> <head>
@ -132,7 +132,7 @@ step={{question["step"]}}
<div class="likert" style="--likert-rows: {{ questions[question]['points']|length() }}"> <div class="likert" style="--likert-rows: {{ questions[question]['points']|length() }}">
{% for point in questions[question]["points"] %} {% for point in questions[question]["points"] %}
<label> <label>
<input name="{{ questions[question]['name']}}" type="radio" <input class="inputs" name="{{ questions[question]['name']}}" type="radio"
id="{{ questions[question]['name'] }}" id="{{ questions[question]['name'] }}"
value="{{ questions[question]['points'][point]['value'] }}" value="{{ questions[question]['points'][point]['value'] }}"
{{required(questions[question])}} /><span>{{ questions[question]['points'][point]['text'] {{required(questions[question])}} /><span>{{ questions[question]['points'][point]['text']
@ -145,7 +145,7 @@ step={{question["step"]}}
<div class="textarea-container"> <div class="textarea-container">
<label class="textarea-label"> <label class="textarea-label">
{{ questions[question]['text']}} {{ questions[question]['text']}}
<textarea id="{{ questions[question]['name'] }}" name="{{ questions[question]['name'] }}" rows="6" <textarea class="inputs" id="{{ questions[question]['name'] }}" name="{{ questions[question]['name'] }}" rows="6"
cols="60" maxlength="{{ questions[question]['size'] }}" cols="60" maxlength="{{ questions[question]['size'] }}"
{{required(questions[question])}}></textarea> {{required(questions[question])}}></textarea>
</label> </label>
@ -154,14 +154,14 @@ step={{question["step"]}}
{% elif (questions[question]["type"] == "dateinput") %} {% elif (questions[question]["type"] == "dateinput") %}
<div class="compressWidth"> <div class="compressWidth">
<label> <label>
{{ questions[question]['text']}}<input type="date" name="{{ questions[question]['name']}}" {{ questions[question]['text']}}<input class="inputs" type="date" name="{{ questions[question]['name']}}"
id="{{ questions[question]['name'] }}" {{required(questions[question])}}> id="{{ questions[question]['name'] }}" {{required(questions[question])}}>
</label> </label>
</div> </div>
{% elif (questions[question]["type"] == "numberinput") %} {% elif (questions[question]["type"] == "numberinput") %}
<div class="compressWidth"> <div class="compressWidth">
<label> <label>
{{ questions[question]['text']}}<input type="number" name="{{ questions[question]['name']}}" {{ questions[question]['text']}}<input class="inputs" type="number" name="{{ questions[question]['name']}}"
id="{{ questions[question]['name'] }}" {{inputconfig(questions[question])}} id="{{ questions[question]['name'] }}" {{inputconfig(questions[question])}}
{{required(questions[question])}}> {{required(questions[question])}}>
</label> </label>
@ -170,7 +170,7 @@ step={{question["step"]}}
{% elif (questions[question]["type"] == "emailinput") %} {% elif (questions[question]["type"] == "emailinput") %}
<div class="compressWidth"> <div class="compressWidth">
<label> <label>
{{ questions[question]['text']}}<input type="email" name="{{ questions[question]['name']}}" {{ questions[question]['text']}}<input class="inputs" type="email" name="{{ questions[question]['name']}}"
id="{{ questions[question]['name'] }}" {{required(questions[question])}}> id="{{ questions[question]['name'] }}" {{required(questions[question])}}>
</label> </label>
</div> </div>
@ -178,7 +178,7 @@ step={{question["step"]}}
{% elif (questions[question]["type"] == "dropdowninput") %} {% elif (questions[question]["type"] == "dropdowninput") %}
<div class="compressWidth"> <div class="compressWidth">
<label> <label>
{{ questions[question]['text']}}<select name="{{ questions[question]['name']}}" {{ questions[question]['text']}}<select class="inputs" name="{{ questions[question]['name']}}"
{{required(questions[question])}}> {{required(questions[question])}}>
<option value="" disabled selected>{{ questions[question]['defaulttext']}}</option> <option value="" disabled selected>{{ questions[question]['defaulttext']}}</option>
{% for point in questions[question]["points"] %} {% for point in questions[question]["points"] %}
@ -192,6 +192,20 @@ step={{question["step"]}}
</label> </label>
</div> </div>
{% elif (questions[question]["type"] == "multiplechoice") %}
<div class="compressWidth">
<label>
{{ questions[question]['text']}}
{% for point in questions[question]["points"] %}
<label for="{{ point }}">
<input type="checkbox" id="{{ point }}" name="{{ questions[question]['name'] }}" value="{{ questions[question]['points'][point]['value'] }}">
{{ questions[question]['points'][point]['text']}}</label>
{% endfor %}
</label>
</div>
{% elif (questions[question]["type"] == "videoinput") %} {% elif (questions[question]["type"] == "videoinput") %}
<div class="spacer" aria-hidden="true" style="height:30px"></div> <div class="spacer" aria-hidden="true" style="height:30px"></div>
<h3>{{ questions[question]['text']}}</h3> <h3>{{ questions[question]['text']}}</h3>
@ -231,7 +245,7 @@ step={{question["step"]}}
{% endif %} {% endif %}
{% endfor %} {% endfor %}
<div class="button-container"> <div class="button-container">
<input id="submitbutton" type="submit" value="submit" /> <input class="inputs" id="submitbutton" type="submit" value="submit" />
<!-- TODO maybe I want to use this instead: <button id="submitbutton" type="submit">Submit</button> --> <!-- TODO maybe I want to use this instead: <button id="submitbutton" type="submit">Submit</button> -->
</div> </div>
</form> </form>

View File

@ -12,7 +12,7 @@
"question1_alter": { "question1_alter": {
"type": "numberinput", "type": "numberinput",
"name": "alter", "name": "alter",
"text": "Alter:", "text": "Wie alt sind sie?",
"required": "true", "required": "true",
"min": "1", "min": "1",
"max": "120" "max": "120"
@ -20,7 +20,7 @@
"question2_geschlecht": { "question2_geschlecht": {
"type": "dropdowninput", "type": "dropdowninput",
"name": "geschlecht", "name": "geschlecht",
"text": "Geschlecht:", "text": "Wie ist ihr Geschlecht?",
"required": "true", "required": "true",
"defaulttext": "", "defaulttext": "",
"points": { "points": {
@ -42,64 +42,196 @@
} }
} }
}, },
"question3_hoerstatus": { "question3_bildung": {
"type": "dropdowninput", "type": "dropdowninput",
"name": "hoerstatus", "name": "bildung",
"text": "Hörstatus:", "text": "Was ist ihr höchster Bildungsabschluss?",
"required": "true", "required": "true",
"defaulttext": "", "defaulttext": "",
"points": { "points": {
"hörend": { "keiner": {
"value": "Hörend", "value": "Keiner",
"text": "Hörend" "text": "Keiner"
},
"hauptschule": {
"value": "Hauptschule",
"text": "Hauptschule"
},
"realschule": {
"value": "Realschule",
"text": "Realschule"
},
"ausbildung": {
"value": "Ausbildung",
"text": "Abgeschlossene Ausbildung"
},
"abitur": {
"value": "Abitur",
"text": "Abitur "
},
"fachhochschulreife": {
"value": "Fachhochschulreife",
"text": "Fachhochschulreife"
},
"bachelor": {
"value": "Bachelor",
"text": "Bachelor"
},
"master": {
"value": "Master",
"text": "Master"
},
"diplom": {
"value": "Diplom",
"text": "Diplom"
},
"magister": {
"value": "Magister",
"text": "Magister"
},
"promotion": {
"value": "Promotion",
"text": "Promotion"
}
}
},
"question4_hoerstatus": {
"type": "dropdowninput",
"name": "hoerstatus",
"text": "Wie ist ihr Hörstatus?",
"required": "true",
"defaulttext": "",
"points": {
"gehörlos": {
"value": "Gehörlos",
"text": "Gehörlos/Taub"
}, },
"schwerhörig": { "schwerhörig": {
"value": "Schwerhörig", "value": "Schwerhörig",
"text": "Schwerhörig" "text": "Schwerhörig"
}, },
"gehörlos": { "gehörlosCI": {
"value": "Gehörlos", "value": "GehörlosCI",
"text": "Gehörlos" "text": "Gehörlos mit Cochlea-Implantat"
},
"hörend": {
"value": "Hörend",
"text": "Hörend"
} }
} }
}, },
"question4_bevorzugte_kommunikation": { "question5_wann_gehörlos": {
"type": "numberinput",
"name": "wann_gehörlos",
"text": "In welchem Alter wurden sie gehörlos/schwerhörig? (\"0\" für ab Geburt, \"-1\" falls sie hören können)",
"required": "true",
"min": "-1",
"max": "120"
},
"question6_wann_gebärdensprache": {
"type": "numberinput",
"name": "wann_gebärdensprache",
"text": "Seit welchem Alter lernen sie Gebärdensprache?",
"required": "true",
"min": "0",
"max": "120"
},
"question7_eltern_gehörlos": {
"type": "dropdowninput", "type": "dropdowninput",
"name": "bevorzugte_kommunikation", "name": "eltern_gehörlos",
"text": "Bevorzugte Kommunikationsform:", "text": "Sind ihre Eltern Gehörlos?",
"required": "true", "required": "true",
"defaulttext": "", "defaulttext": "",
"points": { "points": {
"gesprochen": { "einer": {
"value": "Gesprochene Sprache", "value": "einer",
"text": "Gesprochene Sprache" "text": "Ein Elternteil"
}, },
"text": { "beide": {
"value": "Text", "value": "beide",
"text": "Text" "text": "Beide"
},
"keiner": {
"value": "keiner",
"text": "Nein"
}
}
},
"question8_zuhause_sl": {
"type": "multiplechoice",
"name": "zuhause_sl",
"text": "Welche Sprache(n) verwenden sie zuhause?",
"required": "true",
"defaulttext": "",
"points": {
"deutsch": {
"value": "Deutsch",
"text": "Deutsch"
}, },
"gebärdensprache": { "gebärdensprache": {
"value": "Gebärdensprache", "value": "Gebärdensprache",
"text": "Gebärdensprache" "text": "Gebärdensprache"
},
"sonstige": {
"value": "Sonstige",
"text": "Sonstige"
} }
} }
}, },
"question5_gebeardenzeitraum": { "question9_arbeit_sl": {
"type": "numberinput", "type": "multiplechoice",
"name": "gebärdenzeitraum", "name": "arbeit_sl",
"text": "Wie viele Jahre verwenden sie schon Gebärdensprache:", "text": "Welche Sprache(n) verwenden sie auf der Arbeit/in der Schule?",
"required": "true", "required": "true",
"min": "0", "defaulttext": "",
"max": "100", "points": {
"step": "0.5" "deutsch": {
"value": "Deutsch",
"text": "Deutsch"
},
"gebärdensprache": {
"value": "Gebärdensprache",
"text": "Gebärdensprache"
},
"sonstige": {
"value": "Sonstige",
"text": "Sonstige"
}
}
}, },
"question6_sprachkompetenz": { "question10_schule": {
"type": "numberinput", "type": "dropdowninput",
"name": "gebärdensprachkompetenz", "name": "schule",
"text": "Wie schätzen sie ihre Gebärdensprachkompetenz ein (1-10):", "text": "Haben sie eine Förderschule für Gehörlose und Schwerhörige besucht?",
"required": "true", "required": "true",
"min": "1", "defaulttext": "",
"max": "10" "points": {
"ja": {
"value": "Ja",
"text": "Ja"
},
"Nein": {
"value": "Nein",
"text": "Nein"
}
}
},
"question11_avatar_erfahrung": {
"type": "dropdowninput",
"name": "avatar_erfahrung",
"text": "Haben sie schonmal Computeranimationen von Gebärdensprache gesehen? (Gebärdenavatare)",
"required": "true",
"defaulttext": "",
"points": {
"ja": {
"value": "Ja",
"text": "Ja"
},
"Nein": {
"value": "Nein",
"text": "Nein"
}
}
} }
}, },
"infovideo": { "infovideo": {
@ -121,22 +253,47 @@
"size": "14", "size": "14",
"nullable": "false" "nullable": "false"
}, },
"bildung": {
"type": "string",
"size": "30",
"nullable": "false"
},
"hoerstatus": { "hoerstatus": {
"type": "string", "type": "string",
"size": "14", "size": "35",
"nullable": "false" "nullable": "false"
}, },
"bevorzugte_kommunikation": { "wann_gehörlos": {
"type": "int",
"nullable": "false"
},
"wann_gebärdensprache": {
"type": "int",
"nullable": "false"
},
"eltern_gehörlos": {
"type": "string", "type": "string",
"size": "22", "size": "6",
"nullable": "false" "nullable": "false"
}, },
"gebärdenzeitraum": { "zuhause_sl": {
"type": "float", "type": "string",
"size": "40",
"nullable": "false" "nullable": "false"
}, },
"gebärdensprachkompetenz": { "arbeit_sl": {
"type": "integer", "type": "string",
"size": "40",
"nullable": "false"
},
"schule": {
"type": "string",
"size": "4",
"nullable": "false"
},
"avatar_erfahrung": {
"type": "string",
"size": "4",
"nullable": "false" "nullable": "false"
} }
} }
@ -236,12 +393,12 @@
"stimuli": { "stimuli": {
"type": "double_video", "type": "double_video",
"list_1": { "list_1": {
"video_1": "https://www.youtube-nocookie.com/embed/IqGVT1q1PtM?si=kel7ZWEQl3h-h522", "video_1": "https://www.youtube-nocookie.com/embed/pQCfrTyC-1s?si=-4nATwbeQ_U4wbDg",
"video_2": "https://www.youtube-nocookie.com/embed/g9KA72jN5SM?si=O7dfqTXdFCCAScJ-" "video_2": "https://www.youtube-nocookie.com/embed/pQCfrTyC-1s?si=-4nATwbeQ_U4wbDg"
}, },
"list_2": { "list_2": {
"video_2": "https://www.youtube-nocookie.com/embed/g9KA72jN5SM?si=O7dfqTXdFCCAScJ-", "video_2": "https://www.youtube-nocookie.com/embed/trUewX8XBO4?si=14Q4s2Pn2M3ENPNd",
"video_1": "https://www.youtube-nocookie.com/embed/IqGVT1q1PtM?si=kel7ZWEQl3h-h522" "video_1": "https://www.youtube-nocookie.com/embed/trUewX8XBO4?si=14Q4s2Pn2M3ENPNd"
}, },
"configuration": { "configuration": {
"embed": "yt" "embed": "yt"

Binary file not shown.

Binary file not shown.