/
editQuestion_view.php
325 lines (289 loc) · 23.5 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
<?php $this->renderPartial("./survey/Question/question_subviews/_ajax_variables", $ajaxDatas); ?>
<?php if(isset($qTypeOutput)): ?>
<script type='text/javascript'><?php echo $qTypeOutput; ?></script>
<?php PrepareEditorScript(true, $this); ?>
<?php endif; ?>
<div class="side-body" id="edit-question-body">
<!-- Page Title-->
<h3>
<?php
if ($adding)
{
eT("Add a new question");
}
elseif ($copying)
{
eT("Copy question");
}
else
{
eT("Edit question");
}
?>
</h3>
<div class="row">
<!-- Form for the whole page-->
<?php echo CHtml::form(array("admin/database/index"), 'post',array('class'=>'form30 form-horizontal','id'=>'frmeditquestion','name'=>'frmeditquestion')); ?>
<?php // if(!$adding):?>
<!-- The tabs & tab-fanes -->
<div class="col-lg-8 col-md-6 col-sm-5 content-right">
<?php $this->renderPartial('./survey/Question/question_subviews/_tabs',array('eqrow'=>$eqrow,'addlanguages'=>$addlanguages, 'surveyid'=>$surveyid, 'gid'=>NULL, 'qid'=>NULL, 'adding'=>$adding, 'aqresult'=>$aqresult, 'action'=>$action )); ?>
</div>
<!-- The Accordion -->
<div class="col-lg-4 col-md-6 col-sm-7" id="accordion-container" style="background-color: #fff;">
<?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="headingZero">
<h4 class="panel-title">
<a class="btn btn-default btn-xs hide-button hidden-xs opened handleAccordion">
<span class="glyphicon glyphicon-chevron-left"></span>
</a>
<a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseZero" aria-expanded="false" aria-controls="collapseZero">
<?php eT("Copy options"); ?>
</a>
</h4>
</div>
<div id="collapseZero" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingTwo">
<div class="panel-body">
<div class="form-group">
<label class="col-sm-4 control-label" for='copysubquestions'><?php eT("Copy subquestions?"); ?></label>
<div class="col-sm-8">
<input type='checkbox' class='checkboxbtn' checked='checked' id='copysubquestions' name='copysubquestions' value='Y' />
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label" for='copyanswers'><?php eT("Copy answer options?"); ?></label>
<div class="col-sm-8">
<input type='checkbox' class='checkboxbtn' checked='checked' id='copyanswers' name='copyanswers' value='Y' />
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label" for='copyattributes'><?php eT("Copy advanced settings?"); ?></label>
<div class="col-sm-8">
<input type='checkbox' class='checkboxbtn' checked='checked' id='copyattributes' name='copyattributes' value='Y' />
</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">
<h4 class="panel-title">
<a class="btn btn-default btn-xs hide-button hidden-xs handleAccordion">
<span class="glyphicon glyphicon-chevron-left"></span>
</a>
<a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
<?php eT("General options");?>
</a>
</h4>
</div>
<div id="collapseOne" class="panel-collapse collapse <?php if (!$copying){echo ' in '; } ?>" role="tabpanel" aria-labelledby="headingOne">
<div class="panel-body">
<div>
<div class="form-group">
<label class="col-sm-4 control-label" for="question_type_button">
<?php
eT("Question type:");
?>
</label>
<?php $modulename = (isset($eqrow['modulename']))?$eqrow['modulename']:false;?>
<input type="hidden" id="question_type" name="type" value="<?php echo $eqrow['type']; ?>" />
<input type="hidden" id="question_module_name" name="module_name" value="<?php echo $modulename; ?>" />
<?php
foreach (getQuestionTypeList($eqrow['type'], 'array') as $key=> $questionType)
{
if (!isset($groups[$questionType['group']]))
{
$groups[$questionType['group']] = array();
}
$groups[$questionType['group']][$key] = $questionType['description'];
}
?>
<?php if(isset($selectormodeclass) && $selectormodeclass != "none" && $activated != "Y"): ?>
<div class="col-sm-8 btn-group" id="question_type_button" style="z-index: 1000">
<button type="button" class="btn btn-default dropdown-toggle " <?php if ($activated == "Y"){echo " disabled ";} ?> data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style="z-index: 1000">
<?php if(!$modulename):?>
<?php foreach($groups as $name => $group):?>
<?php foreach($group as $type => $option):?>
<?php if($type == $eqrow['type']){echo '<span class="buttontext">' . $option . '</span>';}?>
<?php endforeach;?>
<?php endforeach;?>
<?php else:?>
<span class="buttontext"><?php echo $eqrow['moduletitle'];?></span>
<?php endif; ?>
<span class="caret"></span>
</button>
<ul class="dropdown-menu" style="z-index: 1000">
<?php foreach($groups as $name => $group):?>
<small><?php echo $name;?></small>
<?php foreach($group as $type => $option):?>
<li>
<a href="#" class="questionType" data-value="<?php echo $type; ?>" <?php if($type == $eqrow['type']){echo 'active';}?>><?php echo $option;?></a>
</li>
<?php endforeach;?>
<li role="separator" class="divider"></li>
<?php endforeach;?>
<small><?php eT('Question modules')?></small>
<?php foreach (getQuestionModuleList($eqrow['type'], 'array') as $key => $oQuestionType):?>
<li>
<!-- MODULE -->
<a href="#" class="questionType" data-module='1' data-modulename="<?php echo $oQuestionType->modulename; ?>" data-value="<?php echo $oQuestionType->basetype; ?>" <?php if($oQuestionType->typeid == $eqrow['modulename']){echo 'active';}?>><?php echo $oQuestionType->title; ?></a>
</li>
<?php endforeach;?>
</ul>
</div>
<?php elseif(isset($selectormodeclass) && $selectormodeclass == "none" && $activated != "Y"): ?>
<div class="col-sm-8 btn-group" id="question_type_button" style="z-index: 1000">
<?php
$aQtypeData=array();
foreach (getQuestionTypeList($eqrow['type'], 'array') as $key=> $questionType)
{
$aQtypeData[]=array('code'=>$key,'description'=>$questionType['description'],'group'=>$questionType['group']);
}
echo CHtml::dropDownList(
'type',
'category',
CHtml::listData($aQtypeData,'code','description','group'),
array(
'class' => 'form-control',
'id'=>'question_type',
'options' => array($eqrow['type']=>array('selected'=>true))
)
);
?>
</div>
<?php else: ?>
<div class="col-sm-8 ">
<p style="padding-top: 7px;">
<?php if(!$modulename):?>
<?php foreach($groups as $name => $group):?>
<?php foreach($group as $type => $option):?>
<?php if($type == $eqrow['type']){echo '' . $option . '';}?>
<?php endforeach;?>
<?php endforeach;?>
<?php else:?>
<span class="buttontext"><?php echo $eqrow['moduletitle'];?></span>
<?php endif; ?>
</p>
</div>
<?php endif; ?>
</div>
<div class="form-group">
<label class="col-sm-4 control-label" for='gid'><?php eT("Question group:"); ?></label>
<div class="col-sm-8">
<select name='gid' id='gid' class="form-control" <?php if ($activated == "Y"){echo " disabled ";} ?> >
<?php echo getGroupList3($eqrow['gid'],$surveyid); ?>
</select>
<?php if ($activated == "Y"): ?>
<input type='hidden' name='gid' value='<?php echo $eqrow['gid'];?>' />
<?php endif; ?>
</div>
</div>
<div class="form-group" id="OtherSelection">
<label class="col-sm-4 control-label"><?php eT("Option 'Other':"); ?></label>
<?php if ($activated != "Y"): ?>
<div class="col-sm-8">
<?php $this->widget('yiiwheels.widgets.switch.WhSwitch', array('name' => 'other', 'value'=> $eqrow['other'] === "Y"));?>
</div>
<?php else:?>
<?php eT("Cannot be changed (survey is active)");?>
<input type='hidden' name='other' value="<?php echo $eqrow['other']; ?>" />
<?php endif;?>
</div>
<div id='MandatorySelection' class="form-group">
<label class="col-sm-4 control-label"><?php eT("Mandatory:"); ?></label>
<div class="col-sm-8">
<!-- Todo : replace by direct use of bootstrap switch. See statistics -->
<?php $this->widget('yiiwheels.widgets.switch.WhSwitch', array('name' => 'mandatory', 'value'=> $eqrow['mandatory'] === "Y"));?>
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label" for='relevance'><?php eT("Relevance equation:"); ?></label>
<div class="col-sm-8">
<textarea class="form-control" rows='1' id='relevance' name='relevance' <?php if ($eqrow['conditions_number']) {?> readonly='readonly'<?php } ?> ><?php echo $eqrow['relevance']; ?></textarea>
<?php if ($eqrow['conditions_number']) :?>
<span class='annotation'> <?php eT("Note: You can't edit the relevance equation because there are currently conditions set for this question."); ?></span>
<?php endif; ?>
</div>
</div>
<div id='Validation' class="form-group">
<label class="col-sm-4 control-label" for='preg'><?php eT("Validation:"); ?></label>
<div class="col-sm-8">
<input class="form-control" type='text' id='preg' name='preg' size='50' value="<?php echo $eqrow['preg']; ?>" />
</div>
</div>
<?php if ($adding): ?>
<div id='Position' class='form-group'>
<label class="col-sm-4 control-label" for='pos'><?php eT("Position:"); ?></label>
<div class="col-sm-8">
<select class='form-control' name='questionposition' id='questionposition'>
<option value=''><?php eT("At end"); ?></option>
<option value='0'><?php eT("At beginning"); ?></option>
<?php foreach ($oqresult as $oq): ?>
<option value='<?php echo $oq->attributes['question_order'] + 1; ?>'><?php eT("After"); ?>: <?php echo $oq->attributes['title']; ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<?php endif; ?>
</div>
</div>
</div>
</div>
<!-- Advanced settings -->
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingTwo">
<h4 class="panel-title">
<a class="btn btn-default btn-xs hide-button hidden-xs opened handleAccordion">
<span class="glyphicon glyphicon-chevron-left"></span>
</a>
<a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
<?php eT("Advanced settings"); ?>
</a>
</h4>
</div>
<div id="collapseTwo" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingTwo">
<div class="panel-body">
<div id="advancedquestionsettingswrapper" >
<div class="loader">
<?php eT("Loading..."); ?>
</div>
<div id="advancedquestionsettings">
<!-- Content append via ajax -->
</div>
</div>
<br />
<br/>
</div>
</div>
</div>
</div>
</div>
</div>
<?php if ($adding): ?>
<input type='hidden' name='action' value='insertquestion' />
<input type='hidden' id='sid' name='sid' value='<?php echo $surveyid; ?>' />
<p><input type='submit' class="hidden" value='<?php eT("Add question"); ?>' />
<?php elseif ($copying): ?>
<input type='hidden' name='action' value='copyquestion' />
<input type='hidden' id='oldqid' name='oldqid' value='<?php echo $qid; ?>' />
<p><input type='submit' class="hidden" value='<?php eT("Copy question"); ?>' />
<?php else: ?>
<input type='hidden' name='action' value='updatequestion' />
<input type='hidden' id='qid' name='qid' value='<?php echo $qid; ?>' />
<p><button type='submit' class="saveandreturn hidden" name="redirection" value="edit"><?php eT("Save") ?> </button>
<input type='submit' class="hidden" value='<?php eT("Save and close"); ?>' />
<?php endif; ?>
<input type='hidden' id='sid' name='sid' value='<?php echo $surveyid; ?>' />
<?php // endif;?>
</form>
</div>
</div>