/
answerOptionsEdit_view.twig
232 lines (204 loc) · 13.5 KB
/
answerOptionsEdit_view.twig
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
<input type='hidden' name='sid' value='{{ surveyid }}' />
<input type='hidden' name='gid' value='{{ gid }}' />
<input type='hidden' name='qid' value='{{ qid }}' />
{% if viewType=='subQuestions' %}
<input type='hidden' id='action' name='action' value='updatesubquestions' />
{% elseif viewType=='answerOptions' %}
<input type='hidden' name='action' value='updateansweroptions' />
{% endif %}
<input type='hidden' name='sortorder' value='' />
<input type='hidden' id='deletedqids' name='deletedqids' value='' />
{% set first=true %}
<!-- Tabs -->
<ul class="nav nav-tabs">
{% for i, anslang in anslangs %}
<li role="presentation" {% if i==0 %}class="active"{% endif %}>
<a data-toggle="tab" href='#tabpage_{{ anslang }}'>
{{ base_language[i] }}
</a>
</li>
{% endfor %}
</ul>
{% set sortorderids='' %}
{% set codeids='' %}
{% set scale_id = 0 %}
<!-- Tab content -->
<div class="tab-content">
{% for i, anslang in anslangs %}
<div id='tabpage_{{ anslang }}' class='tab-page tab-pane fade in {% if i==0 %}active{% endif %}'>
{% for scale_id in range(0,scalecount-1) %}
{% set result = results[anslang][scale_id] %}
{% set anscount = result|length %}
{# TODO : check the rendering of XSCALES / Y SCALES #}
{# For subQuestions #}
{% if viewType=='subQuestions' %}
{% set position=0 %}
{% if scalecount>1 %}
{% if scale_id==0 %}
<div class='header ui-widget-header'>
{{ gT("Y-Scale") }}
</div>
{% else %}
<div class='header ui-widget-header'>
{{ gT("X-Scale") }}
</div>
{% endif %}
{% endif %}
{# For answers #}
{% elseif viewType=='answerOptions' %}
{% set position=1 %}
{% if scalecount>1 %}
<div class='header ui-widget-header' style='margin-top:5px;'>
{{ sprintf(gT("Answer scale %s"),scale_id+1) }}
</div>
{% endif %}
{% endif %}
<!-- Answers/Subquestions Table -->
<table class='answertable table table-responsive' id='{{ tableId[anslang][scale_id] }}' data-scaleid='{{ scale_id }}'>
<!-- Headers -->
<thead>
<tr>
<th class="col-md-1">
{% if first and activated != 'Y' %}
{{ gT("Position") }}
{% else %}
{% endif %}
</th>
<th class='col-md-1'>{{ gT("Code") }}</th>
<!-- subQuestions headers -->
{% if viewType=='subQuestions' %}
<th>
{{ gT("Subquestion") }}
</th>
{% if first %}
{% if scale_id == 0 %}
<th id='rel-eq-th' class='col-md-1'>
{{ gT("Relevance equation") }}
</th>
{% endif %}
<th class="col-md-1">
{{ gT("Action") }}
</th>
{% endif %}
<!-- answer Options header-->
{% elseif viewType=='answerOptions' %}
{% if assessmentvisible %}
<th class='col-md-1'>
{{ gT("Assessment value") }}
</th>
{% else %}
<th style='display:none;'>
</th>
{% endif %}
<th class='col-md-8'>
{{ gT("Answer options") }}
</th>
<th class='col-md-1'>
{% if first %}
{{ gT("Actions") }}
{% endif %}
</th>
{% endif %}
</tr>
</thead>
<!-- Body -->
<tbody id="rowcontainer">
{% for row in result %}
<!-- Line tag -->
{% if viewType=='subQuestions' %}
{% include '/admin/survey/Question/subquestionsAndAnswers/_subquestion.twig' with {
'position' : position,
'scale_id' : scale_id,
'activated' : activated,
'first' : first,
'surveyid' : surveyid,
'gid' : gid,
'qid' : row.qid,
'language' : row.language,
'title' : row.title,
'question' : row.question,
'relevance' : row.relevance,
'oldCode' : true,
} %}
{% elseif viewType=='answerOptions' %}
{% include '/admin/survey/Question/subquestionsAndAnswers/_answer_option.twig' with {
'position' : position,
'first' : first,
'assessmentvisible' : assessmentvisible,
'scale_id' : scale_id,
'title' : row.code,
'surveyid' : surveyid,
'gid' : gid,
'qid' : qid,
'language' : row.language,
'assessment_value' : row.assessment_value,
'sortorder' : row.sortorder,
'answer' : row.answer,
'oldCode' : true,
} %}
{% endif %}
{% set position = position + 1 %}
{% endfor %}
</tbody>
</table>
<div class="action-buttons">
{% if viewType=='subQuestions' %}
{% if activated == 'Y' %}
{% set disabled = 'disabled="disabled"' %}
{% else %}
{% set disabled = '' %}
{% endif %}
{% elseif viewType=='answerOptions' %}
{% if first %}
<input type='hidden' id='answercount_{{ scale_id }}' name='answercount_{{ scale_id }}' value='{{ anscount }}' />
{% set disabled="" %}
{% endif %}
<br/>
{% endif %}
<button {{ disabled }} id='btnlsbrowser_{{ anslang }}_{{ scale_id }}' data-scale-id="{{ scale_id }}" class='btnlsbrowser btn btn-default' type='button' data-toggle="modal" data-target="#labelsetbrowserModal">
{{ gT('Predefined label sets…') }}
</button>
<button {{ disabled }} id='btnquickadd_{{ anslang }}_{{ scale_id }}' data-scale-id="{{ scale_id }}" class='btn btn-default btnquickadd' type='button' data-toggle="modal" data-target="#quickaddModal" data-scale-id="{{ scale_id }}">
{{ gT('Quick add...') }}
</button>
{% if has_permissions %}
<button class='bthsaveaslabel btn btn-default' id='bthsaveaslabel_{{ scale_id }}' type='button' data-toggle="modal" data-target="#saveaslabelModal">
{{ gT('Save as label set') }}
</button>
{% endif %}
</div>
{% set position=sprintf("%05d", position) %}
{% endfor %}
</div>
{% set first=false %}
{% endfor %}
<!-- Modals -->
{% include 'admin/survey/Question/question_subviews/_modals.twig' %}
<p>
<input type='submit' class="hidden" id='saveallbtn_{{ anslang }}' name='method' value='{{ gT("Save changes") }}' />
<!-- For javascript -->
<input
type="hidden"
id="add-input-javascript-datas"
data-url="{{ createUrl('/admin/questions/sa/getSubquestionRowForAllLanguages/') }}"
data-quickurl="{{ createUrl(
'/admin/questions/',
({
'sa' : 'getSubquestionRowQuickAdd',
'surveyid' : surveyid,
'gid' : gid
})
) }}"
data-assessmentvisible="{% if assessmentvisible|length and assessmentvisible==true%}1{% else %}0{% endif %}"
data-errormessage="An error occured while processing the ajax request."
data-surveyid="{{ surveyid }}"
data-languages='{{ json_encode(all_languages) }}'
data-gid="{{ gid }}"
data-qid="{{ qid }}"
data-scale-id="{{ scale_id }}" {# -1 : because it's incremented via < #}
/>
</p>
</div>
<input type='hidden' id='bFullPOST' name='bFullPOST' value='1' />