9a342fa128d4f6b96617ef151f619df1ffc69257
[odoo/odoo.git] / addons / survey / views / survey_templates.xml
1 <?xml version="1.0" encoding="utf-8"?>
2 <openerp>
3 <data>
4     <!-- "Thank you" message when the survey is completed -->
5     <template id="sfinished" name="Survey Finished">
6         <t t-call="website.layout">
7             <div class="wrap">
8                 <div class="container">
9                     <div class="jumbotron mt32">
10                         <h1>Thank you!</h1>
11                         <div t-field="survey.thank_you_message" />
12                         <div t-if='survey.quizz_mode'>You scored <t t-esc="user_input.quizz_score" /> points.</div>
13                         <div>If you wish, you can <a t-att-href="'/survey/print/%s/%s' % (slug(survey), token)">review your answers</a>.</div>
14                     </div>
15                 </div>
16             </div>
17         </t>
18     </template>
19
20     <!-- Message when the survey is not open  -->
21     <template id="notopen" name="Survey not open">
22         <t t-call="website.layout">
23             <div class="wrap">
24                 <div class="container">
25                     <div class="jumbotron mt32">
26                         <h1>Not open</h1>
27                         <p>This survey is not open. Thank you for your interest!</p>
28                     </div>
29                 </div>
30             </div>
31         </t>
32     </template>
33
34     <!-- Message when the survey has no pages  -->
35     <template id="nopages" name="Survey has no pages">
36         <t t-call="website.layout">
37             <div class="wrap">
38                 <div class="container">
39                     <div class="jumbotron mt32">
40                         <h1>Not ready</h1>
41                         <p>This survey has no pages by now!</p>
42                     </div>
43                 </div>
44             </div>
45         </t>
46     </template>
47
48     <!-- First page of a survey -->
49     <template id="survey_init" name="Survey">
50         <t t-call="website.layout">
51             <div class="wrap">
52                 <div class="oe_structure" />
53                 <div class="container">
54                     <div groups="base.group_website_publisher" t-ignore="true" class="text-right">
55                         <a href="/web#action=survey.action_survey_form" class="btn btn-default">Go back to surveys</a>
56                     </div>
57                     <div class='jumbotron mt32'>
58                         <h1 t-field='survey.title' />
59                         <div t-field='survey.description' />
60                         <a class="btn btn-primary btn-lg" t-att-href="'/survey/fill/%s/%s' % (slug(survey), token)">
61                             Start Survey
62                         </a>
63                     </div>
64                 </div>
65                 <div class="oe_structure" />
66             </div>
67         </t>
68     </template>
69
70     <!-- A survey -->
71     <template id="survey" name="Survey">
72         <t t-call="website.layout">
73             <t t-set="head">
74                 <script type="text/javascript" src="/survey/static/src/js/survey.js" />
75             </t>
76             <div class="wrap">
77                 <div class="oe_structure"/>
78                 <div class="container">
79                     <div groups="base.group_website_publisher" t-ignore="true" class="text-right">
80                         <a href="/web#action=survey.action_survey_form" class="btn btn-default">Go back to surveys</a>
81                     </div>
82                     <t t-call="survey.page" />
83                 </div>
84                 <div class="oe_structure"/>
85             </div>
86         </t>
87     </template>
88
89     <!-- A page -->
90     <template id="page" name="Page">
91         <div class="page-header">
92             <p class="pull-right">Page <span t-raw='page_nr + 1'/> on <span t-raw="len(survey.page_ids)"/></p>
93             <h1 t-field='page.title' />
94             <div t-field='page.description'/>
95         </div>
96
97         <form role="form" method="post" class="js_surveyform" t-att-name="'%s_%s' % (survey.id, page.id)" t-att-action="'/survey/fill/%s/%s' % (slug(survey), token)" t-att-data-prefill="'/survey/prefill/%s/%s/%s' % (slug(survey), token, slug(page))" t-att-data-validate="'/survey/validate/%s' % (slug(survey))" t-att-data-submit="'/survey/submit/%s' % (slug(survey))">
98             <input type="hidden" name="page_id" t-att-value="page.id" />
99             <input type="hidden" name="token" t-att-value="token" />
100             <t t-foreach='page.question_ids' t-as='question'>
101                 <t t-set="prefix" t-value="'%s_%s_%s' % (survey.id, page.id, question.id)" />
102                 <div class="js_question-wrapper" t-att-id="prefix">
103                     <h2>
104                         <span t-field='question.question' />
105                         <span t-if="question.constr_mandatory" class="text-danger">*</span>
106                     </h2>
107                     <div t-field='question.description' class="text-muted"/>
108                     <t t-if="question.type == 'free_text'"><t t-call="survey.free_text"/></t>
109                     <t t-if="question.type == 'textbox'"><t t-call="survey.textbox"/></t>
110                     <t t-if="question.type == 'numerical_box'"><t t-call="survey.numerical_box"/></t>
111                     <t t-if="question.type == 'datetime'"><t t-call="survey.datetime"/></t>
112                     <t t-if="question.type == 'simple_choice'"><t t-call="survey.simple_choice"/></t>
113                     <t t-if="question.type == 'multiple_choice'"><t t-call="survey.multiple_choice"/></t>
114                     <t t-if="question.type == 'matrix'"><t t-call="survey.matrix"/></t>
115                     <div class="js_errzone alert alert-danger" style="display:none;"></div>
116                 </div>
117             </t>
118             <div class="text-center mt16 mb16">
119                 <button t-if="survey.users_can_go_back and page_nr > 0" type="submit" class="btn btn-default" name="button_submit" value="previous">Previous page</button>
120                 <button t-if="not last" type="submit" class="btn btn-primary" name="button_submit" value="next">Next page</button>
121                 <button t-if="last" type="submit" class="btn btn-primary" name="button_submit" value="finish">Submit survey</button>
122             </div>
123         </form>
124
125         <!-- Modal used to display error message, i.c.o. ajax error -->
126         <div class="modal fade" id="AJAXErrorModal" role="dialog" aria-labelledby="AJAXErrorModal" aria-hidden="true" >
127             <div class="modal-dialog">
128                 <div class="modal-content">
129                     <div class="modal-header">
130                         <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&amp;times;</button>
131                         <h4 class="modal-title">A problem has occured</h4>
132                     </div>
133                     <div class="modal-body"><p>Something went wrong while contacting survey server. <strong class="text-danger">Your answers have probably not been recorded.</strong> Try refreshing.</p></div>
134                     <div class="modal-footer"><button type="button" class="btn btn-primary" data-dismiss="modal">Close</button></div>
135                 </div>
136             </div>
137         </div>
138
139     </template>
140
141     <!-- Question widgets -->
142     <template id="free_text" name="Free text box">
143         <textarea class="form-control" rows="3" t-att-name="prefix"></textarea>
144     </template>
145
146     <template id="textbox" name="Text box">
147         <input type="text" class="form-control" t-att-name="prefix"/>
148     </template>
149
150     <template id="numerical_box" name="Numerical box">
151         <input type="number" step="any" class="form-control" t-att-name="prefix"/>
152     </template>
153
154     <template id="datetime" name="Datetime box">
155         <input type="text" class="form-control" t-att-name="prefix" placeholder="yyyy-mm-dd hh:mm:ss" />
156     </template>
157
158     <template id="simple_choice" name="Simple choice">
159         <div t-if="question.display_mode == 'dropdown'" class="js_drop row">
160             <div class="col-md-12">
161                 <select class="form-control" t-att-name="prefix">
162                     <option disabled="1" selected="1" value="">Choose...</option>
163                     <t t-foreach='question.labels_ids' t-as='label'>
164                         <option t-att-value='label.id'><t t-esc='label.value'/></option>
165                     </t>
166                     <t t-if='question.comments_allowed and question.comment_count_as_answer'>
167                         <option class="js_other_option" value="-1"><span t-esc="question.comments_message" /></option>
168                     </t>
169                 </select>
170             </div>
171             <div t-if='question.comments_allowed and question.comment_count_as_answer' class="col-md-6">
172                 <input type="text" class="form-control" t-att-name="'%s_%s' % (prefix, 'comment')" data-oe-survey-othert="1"/>
173             </div>
174             <div t-if='question.comments_allowed and not question.comment_count_as_answer' class="col-md-12 mt16">
175                 <span t-field="question.comments_message"/>
176                 <input type="text" class="form-control" t-att-name="'%s_%s' % (prefix, 'comment')"/>
177             </div>
178         </div>
179         <div t-if="question.display_mode == 'columns' " class="row js_radio">
180             <div t-foreach='question.labels_ids' t-as='label' t-attf-class="col-md-#{question.column_nb}">
181                 <label t-att-class="' bg-success ' if quizz_correction and label.quizz_mark > 0.0 else ''">
182                     <input type="radio" t-att-name="prefix" t-att-value='label.id' />
183                     <span t-field='label.value'/>
184                 </label>
185             </div>
186             <div t-if='question.comments_allowed and question.comment_count_as_answer' class="js_comments col-md-12" >
187                 <label>
188                     <input type="radio" t-att-name="prefix" value="-1"/>
189                     <span t-field="question.comments_message" />
190                 </label>
191                 <input type="text" class="form-control" t-att-name="'%s_%s' % (prefix, 'comment')"/>
192             </div>
193             <div t-if='question.comments_allowed and not question.comment_count_as_answer' class="col-md-12">
194                 <span t-field="question.comments_message"/>
195                 <input type="text" class="form-control" t-att-name="'%s_%s' % (prefix, 'comment')" data-oe-survey-othert="1"/>
196             </div>
197         </div>
198     </template>
199
200     <template id="multiple_choice" name="Multiple choice">
201         <div class="row">
202             <div t-foreach='question.labels_ids' t-as='label' t-attf-class="col-md-#{question.column_nb}">
203                 <label t-att-class="' bg-success ' if quizz_correction and label.quizz_mark > 0.0 else ''">
204                     <input type="checkbox" t-att-name="'%s_%s' % (prefix, label.id)" t-att-value='label.id' />
205                     <span t-field='label.value'/>
206                 </label>
207             </div>
208             <div t-if='question.comments_allowed and question.comment_count_as_answer' class="js_ck_comments col-md-12" >
209                 <label>
210                     <input type="checkbox" t-att-name="'%s_%s' % (prefix, -1)" value="-1" />
211                     <span t-field="question.comments_message" />
212                 </label>
213                 <input type="text" class="form-control" t-att-name="'%s_%s' % (prefix, 'comment')"/>
214             </div>
215             <div t-if='question.comments_allowed and not question.comment_count_as_answer' class="col-md-12">
216                 <span t-field="question.comments_message"/>
217                 <input type="text" class="form-control" t-att-name="'%s_%s' % (prefix, 'comment')" data-oe-survey-othert="1"/>
218             </div>
219         </div>
220     </template>
221
222     <template id="matrix" name="Matrix">
223         <table class="table table-hover">
224             <thead>
225                 <tr>
226                     <th> </th>
227                     <th t-foreach="question.labels_ids" t-as="col_label"><span t-field="col_label.value" /></th>
228                 </tr>
229             </thead>
230             <tbody>
231                 <tr t-foreach="question.labels_ids_2" t-as="row_label">
232                     <th><span t-field="row_label.value" /></th>
233                     <td t-foreach="question.labels_ids" t-as="col_label">
234                         <input t-if="question.matrix_subtype == 'simple'" type="radio" t-att-name="'%s_%s' % (prefix, row_label.id)" t-att-value='col_label.id' />
235                         <input t-if="question.matrix_subtype == 'multiple'" type="checkbox" t-att-name="'%s_%s_%s' % (prefix, row_label.id, col_label.id)" t-att-value='col_label.id' />
236                     </td>
237                 </tr>
238             </tbody>
239         </table>
240         <div t-if='question.comments_allowed'>
241             <span t-field="question.comments_message"/>
242             <input type="text" class="form-control" t-att-name="'%s_%s' % (prefix, 'comment')" />
243         </div>
244     </template>
245
246     <!-- Printable view of a survey (all pages) -->
247     <template id="survey_print" name="Survey">
248         <t t-call="website.layout">
249             <t t-set="head">
250                 <script type="text/javascript" src="/survey/static/src/js/survey.js" />
251             </t>
252             <div class="wrap">
253                 <div class="container">
254                     <div class="row">
255                         <div class='jumbotron mt32'>
256                             <h1><span t-field='survey.title'/></h1>
257                             <t t-if="survey.description"><div t-field='survey.description'/></t>
258                         </div>
259                         <form role="form" method="post" class="js_surveyform" t-att-name="'%s' % (survey.id)" t-att-data-prefill="'/survey/prefill/%s/%s' % (slug(survey), token)" t-att-data-scores="'/survey/scores/%s/%s' % (slug(survey), token) if quizz_correction else ''">
260                             <t t-foreach="survey.page_ids" t-as="page">
261                                 <div class="page-header">
262                                     <h1 t-field='page.title' />
263                                     <t t-if="page.description"><div t-field='page.description'/></t>
264                                 </div>
265                                 <t t-foreach='page.question_ids' t-as='question'>
266                                     <t t-set="prefix" t-value="'%s_%s_%s' % (survey.id, page.id, question.id)" />
267                                     <div class="js_question-wrapper" t-att-id="prefix">
268                                         <h2>
269                                             <span t-field='question.question' />
270                                             <span t-if="question.constr_mandatory" class="text-danger">*</span>
271                                             <span t-if="quizz_correction" class="badge" t-att-data-score-question="question.id"></span>
272                                         </h2>
273                                         <t t-if="question.description"><div class="text-muted" t-field='question.description' /></t>
274                                         <t t-if="question.type == 'free_text'"><t t-call="survey.free_text"/></t>
275                                         <t t-if="question.type == 'textbox'"><t t-call="survey.textbox"/></t>
276                                         <t t-if="question.type == 'numerical_box'"><t t-call="survey.numerical_box"/></t>
277                                         <t t-if="question.type == 'datetime'"><t t-call="survey.datetime"/></t>
278                                         <t t-if="question.type == 'simple_choice'"><t t-call="survey.simple_choice"/></t>
279                                         <t t-if="question.type == 'multiple_choice'"><t t-call="survey.multiple_choice"/></t>
280                                         <t t-if="question.type == 'matrix'"><t t-call="survey.matrix"/></t>
281                                         <div class="js_errzone alert alert-danger" style="display:none;"></div>
282                                     </div>
283                                 </t>
284                                 <hr/>
285                             </t>
286                         </form>
287                     </div>
288                 </div>
289             </div>
290         </t>
291     </template>
292 </data>
293 </openerp>