修复了量表计算逻辑,修复了量表required提示
This commit is contained in:
parent
7e85847a41
commit
4fc9660f8b
6
app.py
6
app.py
@ -88,10 +88,12 @@ async def result(request: Request, scale_id: str):
|
|||||||
ranges = {}
|
ranges = {}
|
||||||
for subscale, qids in scale['subscales'].items():
|
for subscale, qids in scale['subscales'].items():
|
||||||
responses[subscale] = 0
|
responses[subscale] = 0
|
||||||
ranges[subscale] = [len(scale['range'][0]*qids),len(scale['range'][1]*qids)]
|
min_val = min(scale['range'].keys())
|
||||||
|
max_val = max(scale['range'].keys())
|
||||||
|
ranges[subscale] = [min_val*len(qids),max_val*len(qids)]
|
||||||
for qid in qids:
|
for qid in qids:
|
||||||
if qid<0:
|
if qid<0:
|
||||||
responses[subscale] += scale['range'][0] + scale['range'][1] - int(form_data[str(-qid)])
|
responses[subscale] += min_val + max_val - int(form_data[str(-qid)])
|
||||||
else:
|
else:
|
||||||
responses[subscale] += int(form_data[str(qid)])
|
responses[subscale] += int(form_data[str(qid)])
|
||||||
return templates.TemplateResponse("result.html", {
|
return templates.TemplateResponse("result.html", {
|
||||||
|
@ -119,7 +119,11 @@ main {
|
|||||||
display: flex;
|
display: flex;
|
||||||
|
|
||||||
input[type="radio"] {
|
input[type="radio"] {
|
||||||
display: none;
|
position: absolute;
|
||||||
|
clip: rect(0 0 0 0);
|
||||||
|
width: 1px;
|
||||||
|
height: 1px;
|
||||||
|
margin: -1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
label {
|
label {
|
||||||
|
@ -14,8 +14,7 @@
|
|||||||
<label for="{{ id }}">{{ id }}. {{ question }}</label>
|
<label for="{{ id }}">{{ id }}. {{ question }}</label>
|
||||||
<div class="scale-button">
|
<div class="scale-button">
|
||||||
{% for option, lable in scale.range.items() %}
|
{% for option, lable in scale.range.items() %}
|
||||||
<input type="radio" id="{{ id }}_{{ option }}" name="{{ id }}" value="{{ option }}" {% if not ( 'optional' in
|
<input type="radio" id="{{ id }}_{{ option }}" name="{{ id }}" value="{{ option }}" required>
|
||||||
question and question.optional) %}required{% endif %}>
|
|
||||||
<label for="{{ id }}_{{ option }}">{{ option }}</label>
|
<label for="{{ id }}_{{ option }}">{{ option }}</label>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user