added scaleType configuration to questionnaire import and display

This commit is contained in:
2026-05-26 14:15:37 +02:00
parent 8e56a42f7e
commit 1b3d74d822
5 changed files with 26 additions and 2 deletions

View File

@ -74,6 +74,7 @@ if ($qnID) {
if (isset($config['hint1'])) $q['hint1'] = $config['hint1']; if (isset($config['hint1'])) $q['hint1'] = $config['hint1'];
if (isset($config['hint2'])) $q['hint2'] = $config['hint2']; if (isset($config['hint2'])) $q['hint2'] = $config['hint2'];
if (isset($config['symptoms'])) $q['symptoms'] = $config['symptoms']; if (isset($config['symptoms'])) $q['symptoms'] = $config['symptoms'];
if (isset($config['scaleType'])) $q['scaleType'] = $config['scaleType'];
if (isset($config['range'])) $q['range'] = $config['range']; if (isset($config['range'])) $q['range'] = $config['range'];
if (isset($config['constraints'])) $q['constraints'] = $config['constraints']; if (isset($config['constraints'])) $q['constraints'] = $config['constraints'];
if (isset($config['precision'])) $q['precision'] = $config['precision']; if (isset($config['precision'])) $q['precision'] = $config['precision'];

View File

@ -265,6 +265,7 @@ if ($qnID) {
if (isset($config['hint1'])) $q['hint1'] = $config['hint1']; if (isset($config['hint1'])) $q['hint1'] = $config['hint1'];
if (isset($config['hint2'])) $q['hint2'] = $config['hint2']; if (isset($config['hint2'])) $q['hint2'] = $config['hint2'];
if (isset($config['symptoms'])) $q['symptoms'] = $config['symptoms']; if (isset($config['symptoms'])) $q['symptoms'] = $config['symptoms'];
if (isset($config['scaleType'])) $q['scaleType'] = $config['scaleType'];
if (isset($config['range'])) $q['range'] = $config['range']; if (isset($config['range'])) $q['range'] = $config['range'];
if (isset($config['constraints'])) $q['constraints'] = $config['constraints']; if (isset($config['constraints'])) $q['constraints'] = $config['constraints'];
if (isset($config['precision'])) $q['precision'] = $config['precision']; if (isset($config['precision'])) $q['precision'] = $config['precision'];

View File

@ -83,6 +83,7 @@ try {
if (isset($q['hint1'])) $config['hint1'] = $q['hint1']; if (isset($q['hint1'])) $config['hint1'] = $q['hint1'];
if (isset($q['hint2'])) $config['hint2'] = $q['hint2']; if (isset($q['hint2'])) $config['hint2'] = $q['hint2'];
if (isset($q['symptoms'])) $config['symptoms'] = $q['symptoms']; if (isset($q['symptoms'])) $config['symptoms'] = $q['symptoms'];
if (isset($q['scaleType'])) $config['scaleType'] = $q['scaleType'];
if (isset($q['range'])) $config['range'] = $q['range']; if (isset($q['range'])) $config['range'] = $q['range'];
if (isset($q['constraints'])) $config['constraints'] = $q['constraints']; if (isset($q['constraints'])) $config['constraints'] = $q['constraints'];
if (isset($q['precision'])) $config['precision'] = $q['precision']; if (isset($q['precision'])) $config['precision'] = $q['precision'];
@ -92,7 +93,7 @@ try {
if (isset($q['otherNextQuestionId'])) $config['otherNextQuestionId'] = $q['otherNextQuestionId']; if (isset($q['otherNextQuestionId'])) $config['otherNextQuestionId'] = $q['otherNextQuestionId'];
if (isset($q['otherOptionKey'])) $config['otherOptionKey'] = $q['otherOptionKey']; if (isset($q['otherOptionKey'])) $config['otherOptionKey'] = $q['otherOptionKey'];
if (isset($q['config']) && is_array($q['config'])) { if (isset($q['config']) && is_array($q['config'])) {
foreach (['otherNextQuestionId', 'otherOptionKey', 'hint', 'maxLength', 'multiline', 'textKey', 'precision'] as $ck) { foreach (['otherNextQuestionId', 'otherOptionKey', 'hint', 'maxLength', 'multiline', 'textKey', 'precision', 'scaleType'] as $ck) {
if (isset($q['config'][$ck])) { if (isset($q['config'][$ck])) {
$config[$ck] = $q['config'][$ck]; $config[$ck] = $q['config'][$ck];
} }

View File

@ -123,13 +123,22 @@ function configFormHTML(layout, config, prefix) {
<input type="number" id="${prefix}_minSelection" value="${config.minSelection || 0}" min="0"> <input type="number" id="${prefix}_minSelection" value="${config.minSelection || 0}" min="0">
</div>`; </div>`;
break; break;
case 'glass_scale_question': case 'glass_scale_question': {
const scaleType = config.scaleType || 'glass';
html = ` html = `
<div class="form-group">
<label>Scale display</label>
<select id="${prefix}_scaleType">
<option value="glass" ${scaleType === 'glass' ? 'selected' : ''}>Glass (pain scale)</option>
<option value="thermometer" ${scaleType === 'thermometer' ? 'selected' : ''}>Thermometer</option>
</select>
</div>
<div class="form-group"> <div class="form-group">
<label>Symptom keys (one per line)</label> <label>Symptom keys (one per line)</label>
<textarea id="${prefix}_symptoms" rows="5" style="font-family:monospace;font-size:.85rem">${(config.symptoms || []).join('\n')}</textarea> <textarea id="${prefix}_symptoms" rows="5" style="font-family:monospace;font-size:.85rem">${(config.symptoms || []).join('\n')}</textarea>
</div>`; </div>`;
break; break;
}
case 'value_spinner': case 'value_spinner':
html = ` html = `
<div class="form-row"> <div class="form-row">
@ -254,6 +263,8 @@ function readConfigFromForm(layout, prefix) {
break; break;
} }
case 'glass_scale_question': { case 'glass_scale_question': {
const st = val('scaleType') || 'glass';
if (st && st !== 'glass') config.scaleType = st;
const raw = val('symptoms'); const raw = val('symptoms');
const syms = raw.split('\n').map(s => s.trim()).filter(Boolean); const syms = raw.split('\n').map(s => s.trim()).filter(Boolean);
if (syms.length) config.symptoms = syms; if (syms.length) config.symptoms = syms;

View File

@ -76,6 +76,16 @@
}, },
{
"id": "q5b",
"_comment": "Glas-Skala (Symptome als Zeilen, 5 Stufen). scaleType: glass (Standard) oder thermometer.",
"layout": "glass_scale_question",
"question": "example_symptom_scale",
"scaleType": "thermometer",
"symptoms": ["symptom_a", "symptom_b"]
},
{ {
"id": "q6", "id": "q6",
"_comment": "Frage mit Spinner, dessen Antwortmöglichkeiten über range selbst definiert werden können.", "_comment": "Frage mit Spinner, dessen Antwortmöglichkeiten über range selbst definiert werden können.",