Skip to content

Commit c585ccd

Browse files
committed
feat: add linear scale answer type and associated settings
Signed-off-by: Christian Hartmann <chris-hartmann@gmx.de>
1 parent aea0490 commit c585ccd

7 files changed

Lines changed: 386 additions & 6 deletions

File tree

lib/Constants.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class Constants {
7575
public const ANSWER_TYPE_DATETIME = 'datetime';
7676
public const ANSWER_TYPE_TIME = 'time';
7777
public const ANSWER_TYPE_FILE = 'file';
78+
public const ANSWER_TYPE_LINEARSCALE = 'linearscale';
7879

7980
// All AnswerTypes
8081
public const ANSWER_TYPES = [
@@ -87,13 +88,15 @@ class Constants {
8788
self::ANSWER_TYPE_DATETIME,
8889
self::ANSWER_TYPE_TIME,
8990
self::ANSWER_TYPE_FILE,
91+
self::ANSWER_TYPE_LINEARSCALE,
9092
];
9193

9294
// AnswerTypes, that need/have predefined Options
9395
public const ANSWER_TYPES_PREDEFINED = [
9496
self::ANSWER_TYPE_MULTIPLE,
9597
self::ANSWER_TYPE_MULTIPLEUNIQUE,
96-
self::ANSWER_TYPE_DROPDOWN
98+
self::ANSWER_TYPE_DROPDOWN,
99+
self::ANSWER_TYPE_LINEARSCALE
97100
];
98101

99102
// AnswerTypes for date/time questions
@@ -155,6 +158,13 @@ class Constants {
155158
'x-office/spreadsheet',
156159
];
157160

161+
public const EXTRA_SETTINGS_LINEARSCALE = [
162+
'optionsLowest' => ['integer'],
163+
'optionsHighest' => ['integer'],
164+
'optionsLabelLowest' => ['string'],
165+
'optionsLabelHighest' => ['string'],
166+
];
167+
158168
public const FILENAME_INVALID_CHARS = [
159169
"\n",
160170
'/',

lib/ResponseDefinitions.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,12 @@
2525
* allowedFileTypes?: list<string>,
2626
* maxAllowedFilesCount?: int,
2727
* maxFileSize?: int,
28+
* optionsEnd?: int,
29+
* optionsLabelBest?: string,
30+
* optionsLabelWorst?: string,
2831
* optionsLimitMax?: int,
2932
* optionsLimitMin?: int,
33+
* optionsStart?: int,
3034
* shuffleOptions?: bool,
3135
* validationRegex?: string,
3236
* validationType?: string

lib/Service/FormsService.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,9 @@ public function areExtraSettingsValid(array $extraSettings, string $questionType
629629
case Constants::ANSWER_TYPE_FILE:
630630
$allowed = Constants::EXTRA_SETTINGS_FILE;
631631
break;
632+
case Constants::ANSWER_TYPE_LINEARSCALE:
633+
$allowed = Constants::EXTRA_SETTINGS_LINEARSCALE;
634+
break;
632635
default:
633636
$allowed = [];
634637
}

openapi.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,16 @@
426426
"type": "integer",
427427
"format": "int64"
428428
},
429+
"optionsEnd": {
430+
"type": "integer",
431+
"format": "int64"
432+
},
433+
"optionsLabelBest": {
434+
"type": "string"
435+
},
436+
"optionsLabelWorst": {
437+
"type": "string"
438+
},
429439
"optionsLimitMax": {
430440
"type": "integer",
431441
"format": "int64"
@@ -434,6 +444,10 @@
434444
"type": "integer",
435445
"format": "int64"
436446
},
447+
"optionsStart": {
448+
"type": "integer",
449+
"format": "int64"
450+
},
437451
"shuffleOptions": {
438452
"type": "boolean"
439453
},
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<!--
2+
- SPDX-FileCopyrightText: 2025 Christian Hartmann <chris-hartmann@gmx.de>
3+
- SPDX-License-Identifier: AGPL-3.0-or-later
4+
-->
5+
6+
<template>
7+
<span
8+
:aria-hidden="!title"
9+
:aria-label="title"
10+
class="material-design-icon drag-indicator-icon"
11+
role="img"
12+
v-bind="$attrs"
13+
@click="$emit('click', $event)">
14+
<svg
15+
:fill="fillColor"
16+
class="material-design-icon__svg"
17+
:height="size"
18+
:width="size"
19+
viewBox="0 -960 960 960">
20+
<path
21+
d="M672-288q-71 0-123.38-44.36Q496.24-376.73 482.9-444H281q-11 26-35 43t-54 17q-40.32 0-68.16-27.77Q96-439.55 96-479.77 96-520 123.84-548q27.84-28 68.16-28 30 0 54 17t35.46 43H484q13.21-67.28 65.1-111.64Q601-672 672-672q79.68 0 135.84 56.23 56.16 56.22 56.16 136Q864-400 807.84-344 751.68-288 672-288Zm0-72q50 0 85-35t35-85q0-50-35-85t-85-35q-50 0-85 35t-35 85q0 50 35 85t85 35Z" />
22+
<title v-if="title">{{ title }}</title>
23+
</svg>
24+
</span>
25+
</template>
26+
27+
<script>
28+
export default {
29+
name: 'IconLinearScale',
30+
props: {
31+
title: {
32+
type: String,
33+
default: '',
34+
},
35+
fillColor: {
36+
type: String,
37+
default: 'currentColor',
38+
},
39+
size: {
40+
type: Number,
41+
default: 20,
42+
},
43+
},
44+
}
45+
</script>

0 commit comments

Comments
 (0)