PluginProbe
The Innovative Form Builder – IvyForms / 0.9
The Innovative Form Builder – IvyForms v0.9
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 0.9, at backend/src/Services/Template/TrainerFeedbackFormTemplate.php

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