PluginProbe
The Innovative Form Builder – IvyForms / 1.1
The Innovative Form Builder – IvyForms v1.1
1.5.1 1.5 1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 All 27 releases
ivyforms / backend / src / Services / Template / TrainerFeedbackFormTemplate.php

TrainerFeedbackFormTemplate.php in The Innovative Form Builder – IvyForms 1.1, at backend/src/Services/Template/TrainerFeedbackFormTemplate.php

334 lines 10.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace IvyForms\Services\Template;
4
5 use IvyForms\Services\Translations\BackendStrings;
6
7 class TrainerFeedbackFormTemplate
8 {
9 /**
10 * Get template metadata (without form_data)
11 *
12 * @return array<string, mixed>
13 */
14 public static function getTemplateMeta(): array
15 {
16 return [
17 'id' => 'trainer_feedback_form',
18 'name' => BackendStrings::getTemplateStrings()['trainer_feedback_form'],
19 'description' => BackendStrings::getTemplateStrings()['trainer_feedback_form_desc'],
20 'category' => 'feedback-forms',
21 'subcategory' => 'training-feedback-forms',
22 'is_pro' => false,
23 'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'trainer-feedback-form.svg',
24 'showRatingText' => true,
25 ];
26 }
27
28 /**
29 * Get the full template including form data
30 *
31 * @return array<string, mixed>
32 */
33 public static function getTemplate(): array
34 {
35 return array_merge(
36 self::getTemplateMeta(),
37 [
38 'form_data' => [
39 'name' => BackendStrings::getTemplateStrings()['trainer_feedback_form'],
40 'published' => 1,
41 'showTitle' => 1,
42 'storeEntries' => 1,
43 'integrationSettings' => TemplateDefaults::getDefaultIntegrationSettings(),
44 'fields' => array_merge(
45 self::getTrainerClarityRatingField(),
46 self::getTrainerExpertiseRatingField(),
47 self::getEngagementInteractionRatingField(),
48 self::getTrainerStrengthsField(),
49 self::getAreasForImprovementField(),
50 self::getNameField()
51 ),
52 'settings' => []
53 ]
54 ]
55 );
56 }
57
58 /**
59 * Trainer clarity rating with custom options
60 *
61 * @return array<int, array<string, mixed>>
62 */
63 private static function getTrainerClarityRatingField(): array
64 {
65 return [[
66 'id' => 5,
67 'fieldIndex' => 1,
68 'type' => 'rating',
69 'label' => BackendStrings::getTemplateStrings()['trainer_clarity_communication'],
70 'required' => true,
71 'defaultValue' => '',
72 'placeholder' => '',
73 'position' => 1,
74 'labelPosition' => 'default',
75 'ratingIcon' => 'star',
76 'fieldOptions' => [
77 [
78 'id' => 1,
79 'label' => BackendStrings::getTemplateStrings()['poor'],
80 'value' => 'poor',
81 'isDefault' => false,
82 'position' => 1
83 ],
84 [
85 'id' => 2,
86 'label' => BackendStrings::getTemplateStrings()['fair'],
87 'value' => 'fair',
88 'isDefault' => false,
89 'position' => 2
90 ],
91 [
92 'id' => 3,
93 'label' => BackendStrings::getNewFormStrings()['good'],
94 'value' => 'good',
95 'isDefault' => false,
96 'position' => 3
97 ],
98 [
99 'id' => 4,
100 'label' => BackendStrings::getTemplateStrings()['excellent'],
101 'value' => 'excellent',
102 'isDefault' => false,
103 'position' => 4
104 ],
105 ],
106 'showValues' => false,
107 'showRatingText' => true,
108 ]];
109 }
110
111 /**
112 * Trainer expertise rating
113 *
114 * @return array<int, array<string, mixed>>
115 */
116 private static function getTrainerExpertiseRatingField(): array
117 {
118 return [[
119 'id' => 6,
120 'fieldIndex' => 2,
121 'type' => 'rating',
122 'label' => BackendStrings::getTemplateStrings()['trainer_expertise'],
123 'required' => true,
124 'defaultValue' => '',
125 'placeholder' => '',
126 'position' => 2,
127 'labelPosition' => 'default',
128 'ratingIcon' => 'star',
129 'fieldOptions' => self::getStandardRatingOptions(5),
130 'showValues' => false,
131 'showRatingText' => false,
132 ]];
133 }
134
135 /**
136 * Engagement and interaction rating
137 *
138 * @return array<int, array<string, mixed>>
139 */
140 private static function getEngagementInteractionRatingField(): array
141 {
142 return [[
143 'id' => 7,
144 'fieldIndex' => 3,
145 'type' => 'rating',
146 'label' => BackendStrings::getTemplateStrings()['engagement_interaction'],
147 'required' => true,
148 'defaultValue' => '',
149 'placeholder' => '',
150 'position' => 3,
151 'labelPosition' => 'default',
152 'ratingIcon' => 'star',
153 'fieldOptions' => self::getStandardRatingOptions(10),
154 'showValues' => false,
155 'showRatingText' => false,
156 ]];
157 }
158
159 /**
160 * Trainer strengths checkbox
161 *
162 * @return array<int, array<string, mixed>>
163 */
164 private static function getTrainerStrengthsField(): array
165 {
166 return [[
167 'id' => 13,
168 'fieldIndex' => 4,
169 'type' => 'checkbox',
170 'label' => BackendStrings::getTemplateStrings()['trainer_strengths'],
171 'required' => false,
172 'parentId' => null,
173 'defaultValue' => '',
174 'placeholder' => '',
175 'position' => 4,
176 'fieldOptions' => [
177 [
178 'id' => 8,
179 'label' => BackendStrings::getTemplateStrings()['subject_knowledge'],
180 'value' => 'subject_knowledge',
181 'isDefault' => false,
182 'position' => 1
183 ],
184 [
185 'id' => 9,
186 'label' => BackendStrings::getTemplateStrings()['clear_explanations'],
187 'value' => 'clear_explanations',
188 'isDefault' => false,
189 'position' => 2
190 ],
191 [
192 'id' => 10,
193 'label' => BackendStrings::getTemplateStrings()['approachability'],
194 'value' => 'approachability',
195 'isDefault' => false,
196 'position' => 3
197 ],
198 [
199 'id' => 11,
200 'label' => BackendStrings::getTemplateStrings()['encouraged_participation'],
201 'value' => 'encouraged_participation',
202 'isDefault' => false,
203 'position' => 4
204 ],
205 [
206 'id' => 12,
207 'label' => BackendStrings::getTemplateStrings()['time_management'],
208 'value' => 'time_management',
209 'isDefault' => false,
210 'position' => 5
211 ],
212 ]
213 ]];
214 }
215
216 /**
217 * Areas for improvement textarea
218 *
219 * @return array<int, array<string, mixed>>
220 */
221 private static function getAreasForImprovementField(): array
222 {
223 return [[
224 'id' => 14,
225 'fieldIndex' => 5,
226 'type' => 'textarea',
227 'label' => BackendStrings::getTemplateStrings()['areas_for_improvement'],
228 'placeholder' => BackendStrings::getTemplateStrings()['areas_for_improvement_placeholder'],
229 'required' => false,
230 'parentId' => null,
231 'defaultValue' => '',
232 'position' => 5,
233 'rows' => 3,
234 ]];
235 }
236
237 /**
238 * Optional name field
239 *
240 * @return array<int, array<string, mixed>>
241 */
242 private static function getNameField(): array
243 {
244 return [
245 [
246 'id' => 15,
247 'fieldIndex' => 6,
248 'type' => 'name',
249 'label' => BackendStrings::getTemplateStrings()['name_optional'],
250 'parentId' => null,
251 'defaultValue' => '',
252 'placeholder' => '',
253 'required' => false,
254 'readonly' => false,
255 'position' => 6,
256 ],
257 [
258 'id' => 16,
259 'type' => 'text',
260 'label' => BackendStrings::getNewFormStrings()['first_name'],
261 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_first_name'],
262 'required' => false,
263 'parentId' => 6,
264 'fieldIndex' => 6,
265 'defaultValue' => '',
266 'position' => 1,
267 'optionHide' => false,
268 'description' => '',
269 'settings' => json_encode(['nameFieldType' => 'nameField1']),
270 ],
271 [
272 'id' => 17,
273 'type' => 'text',
274 'label' => BackendStrings::getTemplateStrings()['last_name'],
275 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_last_name'],
276 'required' => false,
277 'parentId' => 6,
278 'fieldIndex' => 6,
279 'defaultValue' => '',
280 'position' => 2,
281 'optionHide' => false,
282 'description' => '',
283 'settings' => json_encode(['nameFieldType' => 'nameField2']),
284 ],
285 ];
286 }
287
288 /**
289 * Standard rating options
290 *
291 * @return array<int, array<string, mixed>>
292 */
293 private static function getStandardRatingOptions(int $startId): array
294 {
295 return [
296 [
297 'id' => $startId,
298 'label' => BackendStrings::getNewFormStrings()['good'],
299 'value' => '1',
300 'isDefault' => false,
301 'position' => 1
302 ],
303 [
304 'id' => $startId + 1,
305 'label' => BackendStrings::getNewFormStrings()['nice'],
306 'value' => '2',
307 'isDefault' => false,
308 'position' => 2
309 ],
310 [
311 'id' => $startId + 2,
312 'label' => BackendStrings::getNewFormStrings()['very_good'],
313 'value' => '3',
314 'isDefault' => false,
315 'position' => 3
316 ],
317 [
318 'id' => $startId + 3,
319 'label' => BackendStrings::getNewFormStrings()['awesome'],
320 'value' => '4',
321 'isDefault' => false,
322 'position' => 4
323 ],
324 [
325 'id' => $startId + 4,
326 'label' => BackendStrings::getNewFormStrings()['amazing'],
327 'value' => '5',
328 'isDefault' => false,
329 'position' => 5
330 ],
331 ];
332 }
333 }
334