/
_question.php
1024 lines (827 loc) · 48.3 KB
/
_question.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php $myfield = "{$surveyid}X{$flt[1]}X{$flt[0]}"; $niceqtext=flattenText($flt[5]); ?>
<?php
// If boilerplate don't render anything
if (in_array( $flt[2],[Question::QT_X_TEXT_DISPLAY,Question::QT_ASTERISK_EQUATION])) return;
//$specialQuestionTypes = array("M","P","T","S","Q","|","","N","K","D");
$specialQuestionTypes = array(Question::QT_M_MULTIPLE_CHOICE, Question::QT_P_MULTIPLE_CHOICE_WITH_COMMENTS);
if ( in_array( $flt[2], $specialQuestionTypes))
{
$myfield = $flt[2].$myfield;
}
$counter2 = 0;
?>
<div class="question-filter-container grow-3 nofloat ls-space padding all-10">
<?php echo "<!-- Question type : $flt[2] -->"; ?>
<?php if ($flt[2]==Question::QT_M_MULTIPLE_CHOICE || $flt[2]==Question::QT_VERTICAL_FILE_UPLOAD || $flt[2]==Question::QT_P_MULTIPLE_CHOICE_WITH_COMMENTS || $flt[2]==Question::QT_L_LIST || $flt[2]==Question::QT_5_POINT_CHOICE || $flt[2]==Question::QT_G_GENDER || $flt[2]==Question::QT_I_LANGUAGE || $flt[2]==Question::QT_O_LIST_WITH_COMMENT || $flt[2]==Question::QT_Y_YES_NO_RADIO || $flt[2]==Question::QT_EXCLAMATION_LIST_DROPDOWN): ?>
<!-- TYPE =='M' || 'P' || 'N' || 'L' || '5' || 'G' || 'I' || 'O' || 'Y' || '!' -->
<div class="statistics-responses-label-group ls-space padding bottom-5 top-15 ls-flex-item">
<input type='checkbox'
id='filter<?php echo $myfield; ?>'
name='summary[]'
value='<?php echo $myfield; ?>' <?php
if (isset($summary) && (array_search("{$surveyid}X{$flt[1]}X{$flt[0]}", $summary) !== FALSE
|| array_search("M{$surveyid}X{$flt[1]}X{$flt[0]}", $summary) !== FALSE
|| array_search("P{$surveyid}X{$flt[1]}X{$flt[0]}", $summary) !== FALSE
|| array_search("N{$surveyid}X{$flt[1]}X{$flt[0]}", $summary) !== FALSE))
{ echo " checked='checked'"; }
?>
/>
<label for='filter<?php echo $myfield; ?>'> <?php echo $flt[3].' - '.$oStatisticsHelper::_showSpeaker(flattenText($flt[5],true)); ?>
</label>
</div>
<?php if ($flt[2] != Question::QT_N_NUMERICAL && $flt[2] != Question::QT_VERTICAL_FILE_UPLOAD):?>
<select name='<?php
if ($flt[2] == Question::QT_M_MULTIPLE_CHOICE ) { echo Question::QT_M_MULTIPLE_CHOICE;};
if ($flt[2] == Question::QT_P_MULTIPLE_CHOICE_WITH_COMMENTS ) { echo Question::QT_P_MULTIPLE_CHOICE_WITH_COMMENTS;};
echo "{$surveyid}X{$flt[1]}X{$flt[0]}[]";?>' multiple='multiple' class='form-control'>
<?php endif; ?>
<?php endif; ?>
<!-- QUESTION TYPE = <?php echo $flt[2]; ?> -->
<?php
switch ($flt[2])
{
case Question::QT_K_MULTIPLE_NUMERICAL: // Multiple Numerical
echo '<h4 class="question-selector-title">'.$oStatisticsHelper::_showSpeaker($niceqtext).'</h4><br/>';
//go through all the (multiple) answers
foreach($result[$key1] as $row1)
{
$row1 = array_values($row1);
foreach($row1 as $row)
{
/*
* filter form for Numerical input
* - checkbox
* - greater than
* - less than
*/
$myfield1="K".$myfield.$row['title'];
$myfield2="K{$myfield}".$row['title']."G";
$myfield3="K{$myfield}".$row['title']."L";
if ($counter2 == 4) { echo "\t</tr>\n\t<tr>\n"; $counter2=0;}
//checkbox
echo '<div class="statistics-responses-label-group ls-space padding bottom-5 top-15 ls-flex-item">';
echo "<input type='checkbox' name='summary[]' value='$myfield1'";
//check SGQA -> do we want to pre-check the checkbox?
if (isset($summary) && (array_search("K{$surveyid}X{$flt[1]}X{$flt[0]}{$row['title']}", $summary) !== FALSE))
{
echo " checked='checked'";
}
echo " /> ";
//show speaker
echo $oStatisticsHelper::_showSpeaker($flt[3]." - ".flattenText($row['question'],true))
."</div>
<div class='form-group row'>
<label for='".$myfield2."' class='col-sm-4 control-label'>".gT("Number greater than:")."</label>
<div class='col-sm-6'>"
.CHtml::numberField($myfield2,$_POST[$myfield2] ?? '',array( 'class'=>'form-control', 'step'=>'any'))
."</div>
</div>
<div class='form-group row'>
<label for='N".$myfield3."' class='col-sm-4 control-label'>".gT("Number less than:")."</label>
<div class='col-sm-6'>"
.CHtml::numberField($myfield3,$_POST[$myfield3] ?? '',array( 'class'=>'form-control', 'step'=>'any'))
."</div>
</div>";
}
}
break;
case Question::QT_Q_MULTIPLE_SHORT_TEXT: // Multiple short text
echo '<h4 class="question-selector-title">'.$oStatisticsHelper::_showSpeaker($niceqtext).'</h4><br/>';
//get subqestions
$result[$key1] = Question::model()->getQuestionsForStatistics('title, question', "parent_qid='$flt[0]'", 'question_order');
//$counter2=0;
//loop through all answers
$count = 0;
foreach($result[$key1] as $row)
{
echo '<div class="row"><div class="col-sm-12">';
//we have one input field for each answer
$myfield2 = "Q".$myfield.$row['title'];
echo " <input type='checkbox' name='summary[]' value='$myfield2'";
if (isset($summary) && (array_search("Q{$surveyid}X{$flt[1]}X{$flt[0]}{$row['title']}", $summary) !== FALSE))
{
echo " checked='checked'";
}
echo " /> ";
echo $oStatisticsHelper::_showSpeaker($flt[3]." - ".flattenText($row['question'],true))
."<br /><p style='padding: 1em;'>\n"
."\t<span class='smalltext'>".gT("Responses containing").":</span><br />\n";
echo CHtml::textField($myfield2,$_POST[$myfield2] ?? '',array('class'=>'form-control'));
echo "</p>";
echo '</div></div>';
}
break;
/*
* all "free text" types (T, U, S) get the same prefix ("T")
*/
case Question::QT_T_LONG_FREE_TEXT: // Long free text
case Question::QT_U_HUGE_FREE_TEXT: // Huge free text
echo '<div class="statistics-responses-label-group ls-space padding bottom-5 top-15 ls-flex-item">';
$myfield2="T$myfield";
echo "\t<input type='checkbox' name='summary[]' value='$myfield2'";
if (isset($summary) && (array_search("T{$surveyid}X{$flt[1]}X{$flt[0]}", $summary) !== FALSE))
{echo " checked='checked'";}
echo " /> "
." ".$oStatisticsHelper::_showSpeaker($niceqtext)
."<br />\n"
."\t<span class='smalltext'>".gT("Responses containing").":</span>
</div>\n"
.CHtml::textArea($myfield2,$_POST[$myfield2] ?? '',array('rows'=>'3','cols'=>'40'));
break;
case Question::QT_S_SHORT_FREE_TEXT: // Short free text
echo '<div class="statistics-responses-label-group ls-space padding bottom-5 top-15 ls-flex-item">';
$myfield2="T$myfield";
echo "<input type='checkbox' name='summary[]' value='$myfield2'";
if (isset($summary) && (array_search("T{$surveyid}X{$flt[1]}X{$flt[0]}", $summary) !== FALSE))
{echo " checked='checked'";}
echo " /> "
." ".$oStatisticsHelper::_showSpeaker($niceqtext)
."<br />\n"
."\t<span class='smalltext'>".gT("Responses containing").":</span>
</div>\n"
.CHtml::textField($myfield2,$_POST[$myfield2] ?? '',array('class'=>'form-control'));
break;
case Question::QT_N_NUMERICAL: // Numerical
//textfields for greater and less than X
?>
<div class="statistics-responses-label-group ls-space padding bottom-5 top-15 ls-flex-item">
<input type='checkbox'
id='filter<?php echo $myfield; ?>'
name='summary[]'
value='N<?php echo $myfield; ?>' <?php
if (isset($summary) && (array_search("{$surveyid}X{$flt[1]}X{$flt[0]}", $summary) !== FALSE
|| array_search("M{$surveyid}X{$flt[1]}X{$flt[0]}", $summary) !== FALSE
|| array_search("P{$surveyid}X{$flt[1]}X{$flt[0]}", $summary) !== FALSE
|| array_search("N{$surveyid}X{$flt[1]}X{$flt[0]}", $summary) !== FALSE))
{ echo " checked='checked'"; }
?>
/>
<label for='filter<?php echo $myfield; ?>'> <?php echo $flt[3].' - '.$oStatisticsHelper::_showSpeaker(flattenText($flt[5],true)); ?>
</label>
</div>
<?php
$myfield2="N{$myfield}G";
$myfield3="N{$myfield}L";
echo "
<div class='form-group row'>
<label for='".$myfield2."' class='col-sm-4 control-label'>".gT("Number greater than:")."</label>
<div class='col-sm-6'>"
.CHtml::numberField($myfield2,$_POST[$myfield2] ?? '',array( 'class'=>'form-control', 'step'=>'any'))
."</div>
</div>
<div class='form-group row'>
<label for='N".$myfield3."' class='col-sm-4 control-label'>".gT("Number less than:")."</label>
<div class='col-sm-6'>"
.CHtml::numberField($myfield3,$_POST[$myfield3] ?? '',array( 'class'=>'form-control', 'step'=>'any'))
."</div>
</div>";
break;
case Question::QT_VERTICAL_FILE_UPLOAD: // File Upload
// Number of files uploaded for greater and less than X
$myfield2 = "{$myfield}G";
$myfield3 = "{$myfield}L";
echo"
<div class='form-group row'>
<label for='".$myfield2."' class='col-sm-4 control-label'>".gT("Number of files greater than:")."</label>
<div class='col-sm-6'>"
.CHtml::numberField($myfield2,$_POST[$myfield2] ?? '',array( 'class'=>'form-control', 'step'=>'any'))
."</div>
</div>
<div class='form-group row'>
<label for='N".$myfield3."' class='col-sm-4 control-label'>".gT("Number of files less than:")."</label>
<div class='col-sm-6'>"
.CHtml::numberField($myfield3,$_POST[$myfield3] ?? '',array( 'class'=>'form-control', 'step'=>'any'))
."</div>
</div>";
break;
/*
* DON'T show any statistics for date questions
* because there aren't any statistics implemented yet!
*
* Only filtering by date is possible.
*
* See bug report #2539 and
* feature request #2620
*/
case Question::QT_D_DATE: // Date
/*
* - input name
* - date equals
* - date less than
* - date greater than
*/
$myfield2="D$myfield";
$myfield3=$myfield2."eq";
$myfield4=$myfield2."more";
$myfield5=$myfield2."less";
echo '<div class="statistics-responses-label-group ls-space padding bottom-5 top-15 ls-flex-item">';
echo "<input type='checkbox' name='summary[]' value='$myfield2'";
if (isset($summary) && (array_search("D{$surveyid}X{$flt[1]}X{$flt[0]}", $summary) !== FALSE))
{echo " checked='checked'";}
echo " />";
echo $oStatisticsHelper::_showSpeaker($niceqtext)."
<div class='form-group row' style='margin-top:1em;'>
<label for='".$myfield3."' class='col-sm-4 col-form-label smalltext'>".gT("Date equals:")."</label>
<div class='col-sm-8'>";
Yii::app()->getController()->widget('yiiwheels.widgets.datetimepicker.WhDateTimePicker', array(
'name' => $myfield3,
'id' => $myfield3,
'value' => $_POST[$myfield3] ?? '',
'pluginOptions' => array(
'format' => $dateformatdetails['jsdate'],
'allowInputToggle' =>true,
'showClear' => true,
'tooltips' => array(
'clear'=> gT('Clear selection'),
'prevMonth'=> gT('Previous month'),
'nextMonth'=> gT('Next month'),
'selectYear'=> gT('Select year'),
'prevYear'=> gT('Previous year'),
'nextYear'=> gT('Next year'),
'selectDecade'=> gT('Select decade'),
'prevDecade'=> gT('Previous decade'),
'nextDecade'=> gT('Next decade'),
'prevCentury'=> gT('Previous century'),
'nextCentury'=> gT('Next century'),
'selectTime'=> gT('Select time')
),
'locale' => convertLStoDateTimePickerLocale(Yii::app()->session['adminlang'])
)
));
echo "
</div>
</div>
<div class='form-group row'>
<label for='".$myfield4."' class='col-sm-4 col-form-label smalltext'>".gT("Date is >= :")."</label>
<div class='col-sm-8'>";
Yii::app()->getController()->widget('yiiwheels.widgets.datetimepicker.WhDateTimePicker', array(
'name' => $myfield4,
'id' => $myfield4,
'value' => $_POST[$myfield4] ?? '',
'pluginOptions' => array(
'format' => $dateformatdetails['jsdate'] . " HH:mm",
'allowInputToggle' =>true,
'showClear' => true,
'tooltips' => array(
'clear'=> gT('Clear selection'),
'prevMonth'=> gT('Previous month'),
'nextMonth'=> gT('Next month'),
'selectYear'=> gT('Select year'),
'prevYear'=> gT('Previous year'),
'nextYear'=> gT('Next year'),
'selectDecade'=> gT('Select decade'),
'prevDecade'=> gT('Previous decade'),
'nextDecade'=> gT('Next decade'),
'prevCentury'=> gT('Previous century'),
'nextCentury'=> gT('Next century'),
'selectTime'=> gT('Select time')
),
'locale' => convertLStoDateTimePickerLocale(Yii::app()->session['adminlang'])
)
));
echo "
</div>
</div>
<div class='form-group row'>
<label for='".$myfield5."' class='col-sm-4 col-form-label smalltext'>".gT("And/or Date is <= :")."</label>
<div class='col-sm-8'>";
Yii::app()->getController()->widget('yiiwheels.widgets.datetimepicker.WhDateTimePicker', array(
'name' => $myfield5,
'id' => $myfield5,
'value' => $_POST[$myfield5] ?? '',
'pluginOptions' => array(
'format' => $dateformatdetails['jsdate'] . " HH:mm",
'allowInputToggle' =>true,
'showClear' => true,
'tooltips' => array(
'clear'=> gT('Clear selection'),
'prevMonth'=> gT('Previous month'),
'nextMonth'=> gT('Next month'),
'selectYear'=> gT('Select year'),
'prevYear'=> gT('Previous year'),
'nextYear'=> gT('Next year'),
'selectDecade'=> gT('Select decade'),
'prevDecade'=> gT('Previous decade'),
'nextDecade'=> gT('Next decade'),
'prevCentury'=> gT('Previous century'),
'nextCentury'=> gT('Next century'),
'selectTime'=> gT('Select time')
),
'locale' => convertLStoDateTimePickerLocale(Yii::app()->session['adminlang'])
)
));
echo "
</div>
</div>";
echo '</div>';
break;
case Question::QT_5_POINT_CHOICE: // 5 point choice
//we need a list of 5 entries
for ($i=1; $i<=5; $i++)
{
echo "\t<option value='$i'";
//pre-select values which were marked before
if (isset($_POST[$myfield]) && is_array($_POST[$myfield]) && in_array($i, $_POST[$myfield]))
{echo " selected='selected' ";}
echo ">$i</option>\n";
}
//End the select which starts before the CASE statement (around line 411)
echo"\t</select>\n";
break;
case Question::QT_G_GENDER: // Gender
echo "\t<option value='F'";
//pre-select values which were marked before
if (isset($_POST[$myfield]) && is_array($_POST[$myfield]) && in_array("F", $_POST[$myfield])) {echo " selected='selected' ";}
echo ">".gT("Female")."</option>\n";
echo "\t<option value='M'";
//pre-select values which were marked before
if (isset($_POST[$myfield]) && is_array($_POST[$myfield]) && in_array("M", $_POST[$myfield])) {echo " selected='selected' ";}
echo ">".gT("Male")."</option>\n\t</select>\n";
break;
case Question::QT_Y_YES_NO_RADIO: // Yes\No
echo "\t<option value='Y'";
//pre-select values which were marked before
if (isset($_POST[$myfield]) && is_array($_POST[$myfield]) && in_array("Y", $_POST[$myfield])) {echo " selected='selected' ";}
echo ">".gT("Yes")."</option>\n"
."\t<option value='N'";
//pre-select values which were marked before
if (isset($_POST[$myfield]) && is_array($_POST[$myfield]) && in_array("N", $_POST[$myfield])) {echo " selected='selected' ";}
echo ">".gT("No")."</option></select>\n";
break;
case Question::QT_I_LANGUAGE: // Language
$survlangs = Survey::model()->findByPk($surveyid)->additionalLanguages;
$survlangs[] = Survey::model()->findByPk($surveyid)->language;
foreach ($survlangs as $availlang)
{
echo "\t<option value='".$availlang."'";
//pre-select values which were marked before
if (isset($_POST[$myfield]) && is_array($_POST[$myfield]) && in_array($availlang, $_POST[$myfield]))
{echo " selected='selected' ";}
echo ">".getLanguageNameFromCode($availlang,false)."</option>\n";
}
echo "</select>";
break;
//----------------------- ARRAYS --------------------------
case Question::QT_A_ARRAY_5_POINT: // Array of 5 point choice questions
echo '<h4 class="question-selector-title">'.$oStatisticsHelper::_showSpeaker($niceqtext).'</h4><br/>';
//get answers
$result[$key1] = Question::model()->getQuestionsForStatistics('title, question', "parent_qid='$flt[0]' AND language = '{$language}'", 'question_order');
//$counter2=0;
//check all the results
foreach($result[$key1] as $row)
{
$row = array_values($row);
$myfield2 = $myfield.$row[4];
echo "<!-- $myfield2 - ";
if (isset($_POST[$myfield2])) {echo htmlspecialchars($_POST[$myfield2]);}
echo " -->\n";
echo '<div class="statistics-responses-label-group ls-space padding bottom-5 top-15 ls-flex-item">';
echo "<input type='checkbox' name='summary[]' value='$myfield2'";
//pre-check
if (isset($summary) && array_search($myfield2, $summary)!== FALSE) {echo " checked='checked'";}
echo " /> "
.$oStatisticsHelper::_showSpeaker($niceqtext." ".str_replace("'", "`", $row[15])." - # ".$flt[3])
."</div>\n"
."\t<select name='{$surveyid}X{$flt[1]}X{$flt[0]}{$row[0]}[]' multiple='multiple' class='form-control'>\n";
//there are always exactly 5 values which have to be listed
for ($i=1; $i<=5; $i++)
{
echo "\t<option value='$i'";
//pre-select
if (isset($_POST[$myfield2]) && is_array($_POST[$myfield2]) && in_array($i, $_POST[$myfield2])) {echo " selected='selected' ";}
if (isset($_POST[$myfield2]) && $_POST[$myfield2] == $i) {echo " selected='selected' ";}
echo ">$i</option>\n";
}
echo "\t</select>\n\t";
//add this to all the other fields
}
break;
//just like above only a different loop
case Question::QT_B_ARRAY_10_CHOICE_QUESTIONS: // Array of 10 point choice questions
echo '<h4 class="question-selector-title">'.$oStatisticsHelper::_showSpeaker($niceqtext).'</h4><br/>';
foreach($result[$key1] as $row)
{
$myfield2 = $myfield . $row['title'];
echo "<!-- $myfield2 - ";
if (isset($_POST[$myfield2])) {echo htmlspecialchars($_POST[$myfield2]);}
echo " -->\n";
echo '<div class="statistics-responses-label-group ls-space padding bottom-5 top-15 ls-flex-item">';
echo "<input type='checkbox' name='summary[]' value='$myfield2'";
if (isset($summary) && array_search($myfield2, $summary)!== FALSE) {echo " checked='checked'";}
echo " /> "
.$oStatisticsHelper::_showSpeaker($niceqtext." ".str_replace("'", "`", $row['question'])." - # ".$flt[3])
."</div>\n"
."\t<select name='{$surveyid}X{$flt[1]}X{$flt[0]}{$row['title']}[]' multiple='multiple' class='form-control'>\n";
//here wo loop through 10 entries to create a larger output form
for ($i=1; $i<=10; $i++)
{
echo "\t<option value='$i'";
if (isset($_POST[$myfield2]) && is_array($_POST[$myfield2]) && in_array($i, $_POST[$myfield2])) {echo " selected='selected' ";}
if (isset($_POST[$myfield2]) && $_POST[$myfield2] == $i) {echo " selected='selected' ";}
echo ">$i</option>\n";
}
echo "\t</select>\n\t";
}
break;
case Question::QT_C_ARRAY_YES_UNCERTAIN_NO: // ARRAY OF YES\No\gT("Uncertain") QUESTIONS
echo '<h4 class="question-selector-title">'.$oStatisticsHelper::_showSpeaker($niceqtext).'</h4><br/>';
//loop answers
foreach($result[$key1] as $row)
{
$row=array_values($row);
$myfield2 = $myfield . "$row[4]";
echo "<!-- $myfield2 - ";
if (isset($_POST[$myfield2])) {echo htmlspecialchars($_POST[$myfield2]);}
echo " -->\n";
echo '<div class="statistics-responses-label-group ls-space padding bottom-5 top-15 ls-flex-item">';
echo "<input type='checkbox' name='summary[]' value='$myfield2'";
if (isset($summary) && array_search($myfield2, $summary)!== FALSE)
{echo " checked='checked'";}
echo " /> "
.$oStatisticsHelper::_showSpeaker($niceqtext." ".str_replace("'", "`", $row[15])." - # ".$flt[3])
."\n"
."</div>\n"
."\t<select name='{$surveyid}X{$flt[1]}X{$flt[0]}{$row[0]}[]' multiple='multiple' class='form-control'>\n"
."\t<option value='Y'";
//pre-select "yes"
if (isset($_POST[$myfield2]) && is_array($_POST[$myfield2]) && in_array("Y", $_POST[$myfield2])) {echo " selected='selected' ";}
echo ">".gT("Yes")."</option>\n"
."\t<option value='U'";
//pre-select "uncertain"
if (isset($_POST[$myfield2]) && is_array($_POST[$myfield2]) && in_array("U", $_POST[$myfield2])) {echo " selected='selected' ";}
echo ">".gT("Uncertain")."</option>\n"
."\t<option value='N'";
//pre-select "no"
if (isset($_POST[$myfield2]) && is_array($_POST[$myfield2]) && in_array("N", $_POST[$myfield2])) {echo " selected='selected' ";}
echo ">".gT("No")."</option>\n"
."\t</select>";
//add to array
}
break;
//similiar to the above one
case Question::QT_E_ARRAY_INC_SAME_DEC: // Array of Increase/Same/Decrease questions
echo '<h4 class="question-selector-title">'.$oStatisticsHelper::_showSpeaker($niceqtext).'</h4><br/>';
foreach($result[$key1] as $row)
{
$row=array_values($row);
$myfield2 = $myfield . "$row[4]";
echo "<!-- $myfield2 - ";
if (isset($_POST[$myfield2])) {echo htmlspecialchars($_POST[$myfield2]);}
echo " -->\n";
echo '<div class="statistics-responses-label-group ls-space padding bottom-5 top-15 ls-flex-item">';
echo "<input type='checkbox' name='summary[]' value='$myfield2'";
if (isset($summary) && array_search($myfield2, $summary)!== FALSE) {echo " checked='checked'";}
echo " /> "
.$oStatisticsHelper::_showSpeaker($niceqtext." ".str_replace("'", "`", $row[15])." - # ".$flt[3])
."\n"
."</div>\n"
."\t<select name='{$surveyid}X{$flt[1]}X{$flt[0]}{$row[0]}[]' multiple='multiple' class='form-control'>\n"
."\t<option value='I'";
if (isset($_POST[$myfield2]) && is_array($_POST[$myfield2]) && in_array("I", $_POST[$myfield2])) {echo " selected='selected' ";}
echo ">".gT("Increase")."</option>\n"
."\t<option value='S'";
if (isset($_POST[$myfield]) && is_array($_POST[$myfield2]) && in_array("S", $_POST[$myfield2])) {echo " selected='selected' ";}
echo ">".gT("Same")."</option>\n"
."\t<option value='D'";
if (isset($_POST[$myfield]) && is_array($_POST[$myfield2]) && in_array("D", $_POST[$myfield2])) {echo " selected='selected' ";}
echo ">".gT("Decrease")."</option>\n"
."\t</select>";
}
$counter=0;
break;
case Question::QT_SEMICOLON_ARRAY_TEXT: // Array (Text)
echo '<h4 class="question-selector-title">'.$oStatisticsHelper::_showSpeaker($niceqtext).'</h4><br/>';
foreach($result[$key1] as $key => $row)
{
$fresult = $fresults[$key1][$key];
foreach($fresult as $frow)
{
$myfield2 = "T".$myfield . $row['title'] . "_" . $frow['title'];
echo "<!-- $myfield2 - ";
if (isset($_POST[$myfield2])) {echo htmlspecialchars($_POST[$myfield2]);}
echo " -->\n";
echo "<input type='checkbox' name='summary[]' value='$myfield2'";
if (isset($summary) && array_search($myfield2, $summary)!== FALSE) {echo " checked='checked'";}
echo " /> "
.$oStatisticsHelper::_showSpeaker($niceqtext." ".str_replace("'", "`", $row['question']." [".$frow['question']."]")." - ".$row['title']."/".$frow['title'])
."<br />\n";
echo "\t<span class='smalltext'>".gT("Responses containing").":</span><br />\n"
.CHtml::textField($myfield2,$_POST[$myfield2] ?? '',array('class'=>'form-control') );
echo "<hr/>";
$counter2++;
}
}
$counter=0;
break;
case Question::QT_COLON_ARRAY_NUMBERS: // Array (Numbers)
//Get qidattributes for this question
echo '<h4 class="question-selector-title">'.$oStatisticsHelper::_showSpeaker($niceqtext).'</h4><br/>';
$qidattributes=QuestionAttribute::model()->getQuestionAttributes($flt[0]);
$minvalue = 1;
$maxvalue = 10;
if (trim($qidattributes['multiflexible_max']) != '' && trim($qidattributes['multiflexible_min']) == '') {
$maxvalue = $qidattributes['multiflexible_max'];
$minvalue = 1;
}
if (trim($qidattributes['multiflexible_min']) != '' && trim($qidattributes['multiflexible_max']) == '') {
$minvalue = $qidattributes['multiflexible_min'];
$maxvalue = $qidattributes['multiflexible_min'] + 10;
}
if (trim($qidattributes['multiflexible_min']) != '' && trim($qidattributes['multiflexible_max']) != '') {
if ($qidattributes['multiflexible_min'] < $qidattributes['multiflexible_max']) {
$minvalue = $qidattributes['multiflexible_min'];
$maxvalue = $qidattributes['multiflexible_max'];
}
}
$stepvalue = (trim($qidattributes['multiflexible_step']) != '' && $qidattributes['multiflexible_step'] > 0) ? $qidattributes['multiflexible_step'] : 1;
if ($qidattributes['reverse'] == 1) {
$tmp = $minvalue;
$minvalue = $maxvalue;
$maxvalue = $tmp;
$reverse = true;
$stepvalue = -$stepvalue;
} else {
$reverse = false;
}
if ($qidattributes['multiflexible_checkbox']!=0)
{
$minvalue=0;
$maxvalue=1;
$stepvalue=1;
}
foreach($result[$key1] as $row)
{
//$fresult = Question::model()->getQuestionsForStatistics('*', "parent_qid='{$row->qid}' AND language = '{$language}' AND scale_id = 1", 'question_order, title');
$fresult = Question::model()->with('questionl10ns')->findAll(array('condition' =>'parent_qid = ' . $row['parent_qid'] . ' AND scale_id = 1', 'order' => 'question_order ASC'));
foreach ($fresult as $frow) {
$myfield2 = $myfield . $row['title'] . "_" . $frow['title'];
echo "<!-- MyField2: $myfield2 - ";
if (isset($_POST[$myfield2])) {echo htmlspecialchars($_POST[$myfield2]);}
echo " -->\n";
echo '<div class="statistics-responses-label-group ls-space padding bottom-5 top-15 ls-flex-item">';
if ($counter2 == 4) {echo "\t</tr>\n\t<tr>\n"; $counter2=0;}
echo "<input type='checkbox' name='summary[]' value='$myfield2'";
if (isset($summary) && array_search($myfield2, $summary)!== FALSE) {echo " checked='checked'";}
echo " /> "
.$oStatisticsHelper::_showSpeaker($niceqtext." ".str_replace("'", "`", $row['question']." [".$frow->questionl10ns[$language]->question."]")." - ".$row['title']."/".$frow['title'])
."\n"
."</div>\n";
echo "\t<select name='{$myfield2}[]' multiple='multiple' rows='5' cols='5' class='form-control'>\n";
for($ii=$minvalue; $ii<=$maxvalue; $ii+=$stepvalue)
{
echo "\t<option value='$ii'";
if (isset($_POST[$myfield2]) && is_array($_POST[$myfield2]) && in_array($frow['code'], $_POST[$myfield2])) {echo " selected='selected' ";}
echo ">$ii</option>\n";
}
echo "\t</select>";
}
}
break;
/*
* For question type "F" and "H" you can use labels.
* The only difference is that the labels are applied to column heading
* or rows respectively
*/
case Question::QT_F_ARRAY: // Array
case Question::QT_H_ARRAY_COLUMN: // Array (By Column)
//Get answers. We always use the answer code because the label might be too long elsewise
echo '<h4 class="question-selector-title">'.$oStatisticsHelper::_showSpeaker($niceqtext).'</h4><br/>';
//check all the answers
foreach($result[$key1] as $key=>$row)
{
$myfield2 = $myfield . $row['title'];
echo "<!-- $myfield2 -->\n";
if ($counter2 == 4)
{
echo "\t</tr>\n\t<tr>\n";
$counter2=0;
}
echo '<div class="statistics-responses-label-group ls-space padding bottom-5 top-15 ls-flex-item">';
echo "<input type='checkbox' name='summary[]' value='$myfield2'";
if (isset($summary) && array_search($myfield2, $summary)!== FALSE) {echo " checked='checked'";}
echo " /> "
.$oStatisticsHelper::_showSpeaker($niceqtext." ".str_replace("'", "`", $row['question'])." - # ".$flt[3])
."</div>\n";
/*
* when hoovering the speaker symbol we show the whole question
*
* flt[6] is the label ID
*
* table "labels" contains
* - lid
* - code
* - title
* - sortorder
* - language
*/
$fresult = $fresults[$key1];
//for debugging only:
//creating form
echo "\t<select name='{$surveyid}X{$flt[1]}X{$flt[0]}{$row['title']}[]' multiple='multiple' class='form-control'>\n";
//loop through all possible answers
foreach($fresult as $frow)
{
echo "\t<option value='{$frow['code']}'";
//pre-select
if (isset($_POST[$myfield2]) && is_array($_POST[$myfield2]) && in_array($frow['code'], $_POST[$myfield2])) {echo " selected='selected' ";}
echo ">({$frow['code']}) ".flattenText($frow->answerl10ns[$language]->answer,true)."</option>\n";
}
echo "\t</select>";
//add fields to main array
}
break;
case Question::QT_R_RANKING: // Ranking
//get some answers
//get number of columns
$answersCount = count($result[$key1]);
$maxDbAnswer=QuestionAttribute::model()->find("qid = :qid AND attribute = 'max_subquestions'",array(':qid' => $flt[0]));
$columnsCount=(!$maxDbAnswer || intval($maxDbAnswer->value)<1) ? $answersCount : intval($maxDbAnswer->value); // If max_subquestions is not set or is invalid : get the answer count
$columnsCount = min($columnsCount,$answersCount); // Can not be upper than current answers #14899
//lets put the answer code and text into the answers array
foreach($result[$key1] as $row)
{
$answers[]=array($row->code, $row->answerl10ns[$language]->answer);
}
//loop through all answers. if there are 3 items to rate there will be 3 statistics
for ($i=1; $i<=$columnsCount; $i++)
{
//adjust layout depending on counter
//if ($counter2 == 4) {echo "\t</tr>\n\t<tr>\n"; $counter2=0;}
//myfield is the SGQ identifier
//myfield2 is just used as comment in HTML like "R40X34X1721-1"
$myfield2 = "R" . $myfield . $i . "-" . strlen($i);
$myfield3 = $myfield . $i;
echo "<!-- $myfield2 --> ";
echo '<div class="statistics-responses-label-group ls-space padding bottom-5 top-15 ls-flex-item">';
if (isset($_POST[$myfield2])) {echo htmlspecialchars($_POST[$myfield2]);}
echo "<input type='checkbox' name='summary[]' value='$myfield2'";
//pre-check
if (isset($summary) && array_search($myfield2, $summary) !== FALSE) {echo " checked='checked'";}
echo " /> "
.$oStatisticsHelper::_showSpeaker($niceqtext." ".str_replace("'", "`", $row->answerl10ns[$language]->answer)." - # ".$flt[3])
."</div>\n"
."\t<select name='{$surveyid}X{$flt[1]}X{$flt[0]}{$i}[]' multiple='multiple' class='form-control'>\n";
//output lists of ranking items
foreach ($answers as $ans)
{
echo "\t<option value='$ans[0]'";
//pre-select
if (isset($_POST[$myfield3]) && is_array($_POST[$myfield3]) && in_array("$ans[0]", $_POST[$myfield3])) {echo " selected='selected' ";}
echo ">".flattenText($ans[1])."</option>\n";
}
echo "\t</select>";
//add averything to main array
}
//Link to rankwinner script - awaiting completion - probably never gonna happen. Mystery creator.
// echo "\t</tr>\n\t<tr bgcolor='#DDDDDD'>\n"
// ."<td colspan=$count align=center>"
// ."<input type='button' value='Show Rank Summary' onclick=\"window.open('rankwinner.php?sid=$surveyid&qid=$flt[0]', '_blank', 'toolbar=no, directories=no, location=no, status=yes, menubar=no, resizable=no, scrollbars=no, width=400, height=300, left=100, top=100')\">"
// ."</td></tr>\n\t<tr>\n";
$counter=0;
unset($answers);
break;
case Question::QT_1_ARRAY_DUAL: // Dual scale
//special dual scale counter
echo '<h4 class="question-selector-title">'.$oStatisticsHelper::_showSpeaker($niceqtext).'</h4><br/>';
//loop through answers
foreach($result[$key1] as $row)
{
$row=array_values($row);
//----------------- LABEL 1 ---------------------
//myfield2 = answer code.
$myfield2 = $myfield . "$row[4]#0";
//3 lines of debugging output
echo "<!-- $myfield2 - ";
if (isset($_POST[$myfield2]))
{
echo htmlspecialchars(implode(',',$_POST[$myfield2]));
}
echo " -->\n";
echo '<div class="statistics-responses-label-group ls-space padding bottom-5 top-15 ls-flex-item">';
//output checkbox and question/label text
echo "<input type='checkbox' name='summary[]' value='$myfield2'";
//pre-check
if (isset($summary) && array_search($myfield2, $summary)!== FALSE) {echo " checked='checked'";}
//check if there is a dualscale_headerA/B
$dshresult = $dshresults[$key1][0];
//get header
foreach($dshresult as $dshrow)
{
$dshrow=array_values($dshrow);
$dualscaleheadera = $dshrow[0];
}
if(isset($dualscaleheadera) && $dualscaleheadera != "")
{
$labeltitle = $dualscaleheadera;
}
else
{
$labeltitle='';
}
echo " /> "
.$oStatisticsHelper::_showSpeaker($niceqtext." [".str_replace("'", "`", $row[15])."] - ".gT("Label").": ".$labeltitle)
."</div>\n";
/* get labels
* table "labels" contains
* - lid
* - code
* - title
* - sortorder
* - language
*/
$fresult = Answer::model()->getQuestionsForStatistics('*', "qid='$flt[0]' AND language = '{$language}' AND scale_id = 0", 'sortorder, code');
//this is for debugging only
echo "\t<select name='{$surveyid}X{$flt[1]}X{$flt[0]}{$row[4]}#0[]' multiple='multiple' class='form-control'>\n";
//list answers
foreach($fresult as $frow)
{
echo "\t<option value='{$frow['code']}'";
//pre-check
if (isset($_POST[$myfield2]) && is_array($_POST[$myfield2]) && in_array($frow['code'], $_POST[$myfield2])) {echo " selected='selected' ";}
echo ">({$frow['code']}) ".flattenText($frow['answer'],true)."</option>\n";
}
echo "\t</select>";
//----------------- LABEL 2 ---------------------
//myfield2 = answer code
$myfield2 = $myfield . "$row[4]#1";
//3 lines of debugging output
echo "<!-- $myfield2 - ";
if (isset($_POST[$myfield2]))
{
echo htmlspecialchars(implode(',',$_POST[$myfield2]));
}
echo " -->\n";
echo '<div class="statistics-responses-label-group ls-space padding bottom-5 top-15 ls-flex-item">';
echo "<input type='checkbox' name='summary[]' value='$myfield2'";
//pre-check
if (isset($summary) && array_search($myfield2, $summary)!== FALSE) {echo " checked='checked'";}
//check if there is a dualsclae_headerA/B
$dshresult2 = $dshresults2[$key1][0];
//get header
foreach($dshresult2 as $dshrow2)
{
$dshrow2=array_values($dshrow2);
$dualscaleheaderb = $dshrow2[0];
}
if(isset($dualscaleheaderb) && $dualscaleheaderb != "")
{
$labeltitle2 = $dualscaleheaderb;
}
else
{
//get label text
$labeltitle2 = '';
}
echo " /> "
.$oStatisticsHelper::_showSpeaker($niceqtext." [".str_replace("'", "`", $row[15])."] - ".gT("Label").": ".$labeltitle2)
."</div>\n";
$fresult = Answer::model()->getQuestionsForStatistics('*', "qid='$flt[0]' AND language = '$language' AND scale_id = 1", 'sortorder, code');
//this is for debugging only
echo "\t<select name='{$surveyid}X{$flt[1]}X{$flt[0]}{$row[4]}#1[]' multiple='multiple' class='form-control'>\n";
//list answers
foreach($fresult as $frow)
{
echo "\t<option value='{$frow['code']}'";
//pre-check
if (isset($_POST[$myfield2]) && is_array($_POST[$myfield2]) && in_array($frow['code'], $_POST[$myfield2])) {echo " selected='selected' ";}
echo ">({$frow['code']}) ".flattenText($frow['answer'],true)."</option>\n";
}
echo "\t</select>";
} //end WHILE -> loop through all answers
break;
case Question::QT_P_MULTIPLE_CHOICE_WITH_COMMENTS: //P - Multiple choice with comments
case Question::QT_M_MULTIPLE_CHOICE: //M - Multiple choice
echo '<h4 class="question-selector-title">'.$oStatisticsHelper::_showSpeaker($niceqtext).'</h4><br/>';
//loop through answers
foreach($result[$key1] as $row)
{
echo "\t<option value='{$row['title']}'";
//pre-check
if (isset($_POST[$myfield]) && is_array($_POST[$myfield]) && in_array($row['title'], $_POST[$myfield])) {echo " selected='selected' ";}
echo '>'.flattenText($row['question'],true)."</option>\n";
}
echo "\t</select>";
break;
/*
* This question types use the default settings:
* L - List (Radio)