/
editQuestion_view.php
381 lines (353 loc) · 24.1 KB
/
editQuestion_view.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
<?php
/* @var $this AdminController */
/* @var QuestionGroup $oQuestionGroup */
/* @var Survey $oSurvey */
/* @var Question $oQuestion */
/* @var array $ajaxDatas */
/* @var boolean $copying */
/* @var boolean $adding */
/* @var Question[] $aqresult */
// DO NOT REMOVE This is for automated testing to validate we see that page
echo viewHelper::getViewTestTag('addQuestion');
?>
<?php
$aQuestionTypeGroups = array();
$aQuestionTypeList = Question::typeList();
$question_template_preview = '';
foreach ( $aQuestionTypeList as $key=> $questionType)
{
$htmlReadyGroup = str_replace(' ', '_', strtolower($questionType['group']));
if (!isset($aQuestionTypeGroups[$htmlReadyGroup]))
{
$aQuestionTypeGroups[$htmlReadyGroup] = array(
'questionGroupName' => $questionType['group']
);
}
$aQuestionTypeGroups[$htmlReadyGroup]['questionTypes'][$key] = $questionType;
}
?>
<?php PrepareEditorScript(true, $this); ?>
<?php $this->renderPartial("./survey/Question/question_subviews/_ajax_variables", $ajaxDatas); ?>
<div id='edit-question-body' class='side-body <?php echo getSideBodyClass(false); ?>'>
<!-- Page Title-->
<div class="pagetitle h3">
<?php
if ($adding) {
eT("Add a new question");
} elseif ($copying) {
eT("Copy question");
} else {
eT("Edit question");
echo ': <em>'.$oQuestion->title.'</em> (ID:'.$oQuestion->qid.')';
}
?>
</div>
<div class="row">
<!-- Form for the whole page-->
<?php echo CHtml::form(array("admin/database/index"), 'post',array('class'=>'form30 ','id'=>'frmeditquestion','name'=>'frmeditquestion')); ?>
<!-- The tabs & tab-fanes -->
<div class="col-sm-12 col-md-7 content-right">
<?php if($adding):?>
<?php
$this->renderPartial(
'./survey/Question/question_subviews/_tabs',
array(
'oSurvey'=>$oSurvey,
'oQuestion'=>$oQuestion,
'surveyid'=>$oSurvey->sid,
'gid'=>$oQuestion->gid,
'qid'=>NULL,
'adding'=>$adding,
'aqresult'=>$aqresult,
'action'=>$action
)
); ?>
<?php else:?>
<?php
$this->renderPartial(
'./survey/Question/question_subviews/_tabs',
array(
'oSurvey'=>$oSurvey,
'oQuestion'=>$oQuestion,
'surveyid'=>$oSurvey->sid,
'gid'=>$oQuestion->gid,
'qid'=>$oQuestion->qid,
'adding'=>$adding,
'aqresult'=>$aqresult,
'action'=>$action
)
); ?>
<?php endif;?>
</div>
<!-- The Accordion -->
<div class="col-sm-12 col-md-5" id="accordion-container" style="background-color: #fff; z-index: 2;">
<?php // TODO : find why the $groups can't be generated from controller?>
<div id='questionbottom'>
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<!-- Copy options -->
<?php if ($copying): ?>
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="heading-copy">
<div class="panel-title h4">
<a class="btn btn-default btn-xs hide-button hidden-xs opened handleAccordion">
<span class="fa fa-chevron-left"></span>
<span class="sr-only"><?php eT("Expand/Collapse");?></span>
</a>
<a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse-copy" aria-expanded="false" aria-controls="collapse-copy">
<?php eT("Copy options"); ?>
</a>
</div>
</div>
<div id="collapse-copy" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="heading-copy">
<div class="panel-body">
<div class="form-group">
<label class=" control-label" for='copysubquestions'><?php eT("Copy subquestions?"); ?></label>
<div class="">
<?php $this->widget('yiiwheels.widgets.switch.WhSwitch', array(
'name' => 'copysubquestions',
'id'=>'copysubquestions',
'value' => 'Y',
'onLabel' =>gT('Yes'),
'offLabel' => gT('No')));
?>
</div>
</div>
<div class="form-group">
<label class=" control-label" for='copyanswers'><?php eT("Copy answer options?"); ?></label>
<div class="">
<?php $this->widget('yiiwheels.widgets.switch.WhSwitch', array(
'name' => 'copyanswers',
'id'=>'copyanswers',
'value' => 'Y',
'onLabel' =>gT('Yes'),
'offLabel' => gT('No')));
?>
</div>
</div>
<div class="form-group">
<label class=" control-label" for='copyattributes'><?php eT("Copy advanced settings?"); ?></label>
<div class="">
<?php $this->widget('yiiwheels.widgets.switch.WhSwitch', array(
'name' => 'copyattributes',
'id' => 'copyattributes',
'value' => 'Y',
'onLabel' => gT('Yes'),
'offLabel' => gT('No')));
?>
</div>
</div>
</div>
</div>
</div>
<?php endif; // Copying ?>
<!-- General Options -->
<div class="panel panel-default" id="questionTypeContainer">
<!-- General Options : Header -->
<div class="panel-heading" role="tab" id="headingOne">
<div class="panel-title h4">
<a class="btn btn-default btn-xs hide-button hidden-xs opened handleAccordion">
<span class="fa fa-chevron-left"></span>
<span class="sr-only"><?php eT("Expand/Collapse");?></span>
</a>
<a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse-question" aria-expanded="true" aria-controls="collapse-question">
<?php eT("General options");?>
</a>
</div>
</div>
<div id="collapse-question" class="panel-collapse collapse <?php if (!$copying){echo ' in '; } ?>" role="tabpanel" aria-labelledby="headingOne">
<div class="panel-body">
<!-- Question selector start -->
<div class="form-group">
<input type="hidden" id="question_type" name="type" value="<?php echo $oQuestion->type; ?>" />
<?php if( !$oSurvey->isActive && isset($selectormodeclass) && $selectormodeclass != "none"): ?>
<label class=" control-label" for="question_type_button" title="<?php eT("Question type");?>" data-gethelp='{ "title":"Get help", "text" : "More on questions", "href":"https://manual.limesurvey.org/Questions_-_introduction" }' data-help="<?=gT("Select the question type here.")?>">
<?php
eT("Question type:");
?>
</label>
<div class=" btn-group" id="question_type_button">
<button type="button" class="btn btn-default " data-target="#selector__modal_select-question-type" data-toggle="modal" aria-haspopup="true" aria-expanded="false" >
<span class="buttontext" id="selector__editView_question_type_description">
<?=Question::getQuestionTypeName($oQuestion->type); ?>
<?php if(YII_DEBUG):?>
<em class="small">
Type code: <?php echo $oQuestion->type; ?>
</em>
<?php endif;?>
</span>
<i class="fa fa-folder-open"></i>
</button>
</div>
<?php elseif(!$oSurvey->isActive && (isset($selectormodeclass) && $selectormodeclass == "none")): ?>
<label class=" control-label" for="question_type" title="<?php eT("Question type");?>">
<?php
eT("Question type:");
?>
</label>
<select id="question_type" name="type" class="form-control">
<?php
foreach ($aQuestionTypeGroups as $sGroupHTMLConformString => $aQuestionTypeGroup) {
echo sprintf("<optgroup label='%s'>", $aQuestionTypeGroup['questionGroupName']);
foreach ($aQuestionTypeGroup['questionTypes'] as $sQuestionTypeKey => $aQuestionType) {
$selected = $oQuestion->type == $sQuestionTypeKey ? 'selected' : '';
if(YII_DEBUG) {
echo sprintf("<option value='%s' %s>%s (%s)</option>", $sQuestionTypeKey, $selected, $aQuestionType['description'], $sQuestionTypeKey);
} else {
echo sprintf("<option value='%s' %s>%s</option>", $sQuestionTypeKey, $selected, $aQuestionType['description']);
}
}
echo "</optgroup>";
}
?>
</select>
<?php elseif($oSurvey->isActive) : ?>
<input type="hidden" id="question_type" name="type" value="<?php echo $oQuestion->type; ?>" />
<!-- TODO : control if we can remove, disable update type must be done by PHP -->
<label class=" control-label" for="question_type_button" title="<?php eT("Question type");?>">
<?php
eT("Question type:");
?>
</label>
<div class=" btn-group" id="question_type_button">
<button type="button" class="btn btn-default" disabled aria-haspopup="true" aria-expanded="false" >
<span class="buttontext" id="selector__editView_question_type_description">
<?=Question::getQuestionTypeName($oQuestion->type); ?>
<?php if(YII_DEBUG):?>
<em class="small">
Type code: <?php echo $oQuestion->type; ?>
</em>
<?php endif;?>
</span>
<i class="fa fa-lock"></i>
</button>
</div>
<?php endif; ?>
</div>
<!-- Question selector end -->
<div class="form-group" id="QuestionTemplateSelection">
<label class=" control-label" for='gid' title="<?php eT("Use a customized question theme for this question");?>"><?php eT("Question theme:"); ?></label>
<div class="">
<select id="question_template" name="question_template" class="form-control">
<?php
foreach ($aQuestionTemplateList as $code => $value) {
$selected = $aQuestionTemplateAttributes['value'] == $code ? 'selected' : '';
$question_template_preview = $aQuestionTemplateAttributes['value'] == $code ? $value['preview'] : '';
if(YII_DEBUG) {
echo sprintf("<option value='%s' %s>%s (code: %s)</option>", $code, $selected, $value['title'], $code);
} else {
echo sprintf("<option value='%s' %s>%s</option>", $code, $selected, $value['title']);
}
}
?>
</select>
<?php if ($activated == "Y"): ?>
<input type='hidden' name='gid' value='<?php echo $eqrow['gid'];?>' />
<?php endif; ?>
</div>
</div>
<div class="form-group" id="QuestionTemplatePreview">
<label class=" control-label" for='gid' title="<?php eT("Question theme preview");?>"><?php eT("Question theme preview:"); ?></label>
<div class="">
<img src="<?php echo $question_template_preview; ?>" style="border: 1px solid gray; padding: 10px; max-width: 100%;">
</div>
</div>
<div class="form-group">
<label class=" control-label" for='gid' title="<?php eT("Set question group");?>"><?php eT("Question group:"); ?></label>
<div class="">
<select name='gid' id='gid' class="form-control" <?php if ($oSurvey->isActive){echo " disabled ";} ?> >
<?php echo getGroupList3($oQuestion->gid,$oSurvey->sid); ?>
</select>
<?php if ($oSurvey->isActive): ?>
<input type='hidden' name='gid' value='<?php echo $oQuestion->gid;?>' />
<?php endif; ?>
</div>
</div>
<div class="form-group" id="OtherSelection">
<label class=" control-label" title="<?php eT("Option 'Other':");?>"><?php eT("Option 'Other':"); ?></label>
<?php if (!$oSurvey->isActive): ?>
<div class="">
<?php $this->widget('yiiwheels.widgets.switch.WhSwitch', array('name' => 'other', 'value'=> $oQuestion->other === "Y", 'onLabel'=>gT('On'),'offLabel'=>gT('Off')));?>
</div>
<?php else:?>
<?php eT("Cannot be changed (survey is active)");?>
<input type='hidden' name='other' value="<?php echo ($oQuestion->other=='Y' ? 1 : 0); ?>" />
<?php endif;?>
</div>
<div id='MandatorySelection' class="form-group">
<label class=" control-label" title="<?php eT("Set \"Mandatory\" state");?>"><?php eT("Mandatory:"); ?></label>
<div class="">
<!-- Todo : replace by direct use of bootstrap switch. See statistics -->
<?php $this->widget('yiiwheels.widgets.switch.WhSwitch', array('name' => 'mandatory', 'value'=> $oQuestion->mandatory === "Y", 'onLabel'=>gT('On'),'offLabel'=>gT('Off')));?>
</div>
</div>
<div class="form-group">
<label class=" control-label" for='relevance' title="<?php eT("Relevance equation");?>" data-gethelp='{ "title":"Get help", "text" : "More on relevance and the EM", "href":"https://manual.limesurvey.org/Expression_Manager" }' data-help="<?=gT("The relevance equation can be used to add branching logic. This is a rather advanced topic. If you are unsure, just leave it be.")?>"><?php eT("Relevance equation:"); ?></label>
<div class="">
<div class="input-group">
<div class="input-group-addon">{</div>
<textarea class="form-control" rows='1' id='relevance' name='relevance' <?php if (count($oQuestion->conditions)>0) {?> readonly='readonly'<?php } ?> ><?php echo $oQuestion->relevance; ?></textarea>
<div class="input-group-addon">}</div>
</div>
<?php if (count($oQuestion->conditions)>0) :?>
<div class='help-block text-warning'> <?php eT("Note: You can't edit the relevance equation because there are currently conditions set for this question."); ?></div>
<?php endif; ?>
</div>
</div>
<div id='Validation' class="form-group">
<label class=" control-label" for='preg' title="<?php eT("Validation:");?>"><?php eT("Validation:"); ?></label>
<div class="">
<input class="form-control" type='text' id='preg' name='preg' size='50' value="<?php echo $oQuestion->preg; ?>" />
</div>
</div>
<?php if ($adding || $copying ): ?>
<!-- Rendering position widget -->
<?php $this->widget('ext.admin.survey.question.PositionWidget.PositionWidget', array(
'display' => 'ajax_form_group',
'oQuestionGroup' => $oQuestionGroup,
));
?>
<?php endif; ?>
</div>
</div>
</div>
<hr/>
<?php if (!$copying): ?>
<div id="container-advanced-question-settings" class="custom custom-margin top-5">
<!-- Advanced settings -->
</div>
<div class="loader-advancedquestionsettings text-center">
<span class="fa fa-refresh" style="font-size:3em;" aria-hidden='true'></span>
</div>
<?php endif; ?>
</div>
</div>
</div>
<?php if ($adding): ?>
<input type='hidden' name='action' value='insertquestion' />
<input type='hidden' id='sid' name='sid' value='<?= $oSurvey->sid; ?>' />
<p><input type='submit' class="hidden" value='<?php eT("Add question"); ?>' /></p>
<?php elseif ($copying): ?>
<input type='hidden' name='action' value='copyquestion' />
<input type='hidden' id='oldqid' name='oldqid' value='<?= $oQuestion->qid; ?>' />
<p><input type='submit' class="hidden" value='<?php eT("Copy question"); ?>' /></p>
<?php else: ?>
<input type='hidden' name='action' value='updatequestion' />
<input type='hidden' id='qid' name='qid' value='<?= $oQuestion->qid; ?>' />
<p><button type='submit' class="saveandreturn hidden" name="redirection" value="edit"><?php eT("Save") ?> </button></p>
<input type='submit' class="hidden" value='<?php eT("Save and close"); ?>' />
<?php endif; ?>
<input type='hidden' name='sid' value='<?= $oSurvey->sid; ?>' />
<?= CHtml::endForm() ?>
</div>
</div>
<?php if(isset($selectormodeclass) && $selectormodeclass != "none" && !$oSurvey->isActive): ?>
<div class="modal fade" tabindex="-1" role="dialog" id="selector__modal_select-question-type" style="z-index: 1250">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<?php Yii::app()->getController()->renderPartial('/admin/survey/Question/question_subviews/_question_type_select', ['currentType' => $oQuestion->type, 'aQuestionTypeGroups' => $aQuestionTypeGroups]); ?>
</div>
</div>
</div>
<?php endif; ?>