Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 193 | Rev 196 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
135 geraldo 1
<?php
2
$acl = $this->viewModel()->getRoot()->getVariable('acl');
3
$currentUser = $this->currentUserHelper();
115 efrain 4
 
5
$roleName = $currentUser->getUserTypeId();
6
 
135 geraldo 7
$routeAdd = $this->url('self-evaluation/forms/add');
115 efrain 8
$routeDatatable = $this->url('self-evaluation/forms');
9
$routeDashboard = $this->url('dashboard');
10
 
135 geraldo 11
$allowAdd = $acl->isAllowed($roleName, 'self-evaluation/forms/add') ? 1 : 0;
12
$allowEdit = $acl->isAllowed($roleName, 'self-evaluation/forms/edit') ? 1 : 0;
13
$allowDelete = $acl->isAllowed($roleName, 'self-evaluation/forms/delete') ? 1 : 0;
115 efrain 14
 
15
 
16
$this->inlineScript()->appendFile($this->basePath('plugins/ckeditor/ckeditor.js'));
17
 
18
 
19
$this->headLink()->appendStylesheet($this->basePath('plugins/nprogress/nprogress.css'));
20
$this->inlineScript()->appendFile($this->basePath('plugins/nprogress/nprogress.js'));
21
 
22
 
23
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/jquery.validate.js'));
24
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/additional-methods.js'));
25
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/localization/messages_es.js'));
26
 
27
$this->headLink()->appendStylesheet($this->basePath('plugins/datatables-bs4/css/dataTables.bootstrap4.min.css'));
28
$this->headLink()->appendStylesheet($this->basePath('plugins/datatables-responsive/css/responsive.bootstrap4.min.css'));
29
 
30
$this->inlineScript()->appendFile($this->basePath('plugins/datatables/jquery.dataTables.min.js'));
31
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-bs4/js/dataTables.bootstrap4.min.js'));
32
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-responsive/js/dataTables.responsive.min.js'));
33
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-responsive/js/responsive.bootstrap4.min.js'));
34
 
35
 
36
$this->headLink()->appendStylesheet($this->basePath('plugins/select2/css/select2.min.css'));
37
$this->headLink()->appendStylesheet($this->basePath('plugins/select2-bootstrap4-theme/select2-bootstrap4.min.css'));
38
 
39
$this->inlineScript()->appendFile($this->basePath('plugins/select2/js/select2.full.min.js'));
40
 
41
$this->inlineScript()->appendFile($this->basePath('plugins/moment/moment-with-locales.min.js'));
42
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-datetimepicker/css/bootstrap-datetimepicker.css'));
43
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js'));
44
 
45
 
46
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap4-toggle/css/bootstrap4-toggle.min.css'));
47
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap4-toggle/js/bootstrap4-toggle.min.js'));
48
 
49
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-confirmation/dist/bootstrap-confirmation.js'));
50
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-checkbox/awesome-bootstrap-checkbox.css'));
120 steven 51
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-input-number/input-number-format.jquery.js'));
115 efrain 52
 
137 geraldo 53
// bootbox Alert //
54
$this->inlineScript()->appendFile($this->basePath('plugins/bootbox/bootbox.min.js'));
55
 
158 geraldo 56
// JsRender //
57
$this->inlineScript()->appendFile($this->basePath('plugins/jsrender/jsrender.min.js'));
58
 
115 efrain 59
$status_active = \LeadersLinked\Model\CompanySelfEvaluationForm::STATUS_ACTIVE;
144 geraldo 60
$status_inactive = \LeadersLinked\Model\CompanySelfEvaluationForm::STATUS_INACTIVE;
115 efrain 61
 
144 geraldo 62
$lang_es = \LeadersLinked\Model\CompanySelfEvaluationForm::LANGUAGE_SPANISH;
63
$lang_en = \LeadersLinked\Model\CompanySelfEvaluationForm::LANGUAGE_ENGLISH;
153 geraldo 64
 
167 geraldo 65
 
115 efrain 66
$this->inlineScript()->captureStart();
67
echo <<<JS
167 geraldo 68
    const classFormGenerator = function() {
69
    this.id = 0,
70
        this.table = '',
71
        this.name = '',
72
        this.text = '',
73
        this.status = 'a',
74
        this.sections = [],
75
        this.clear = function() {
76
            this.sections = [];
77
            this.render();
78
        },
171 geraldo 79
        this.renderSection = function(slug_section) {
167 geraldo 80
            var s = '';
81
            for (i = 0; i < this.sections.length; i++) {
171 geraldo 82
                if (slug_section != this.sections[i].slug_section) {
167 geraldo 83
                    continue;
84
                }
85
                for (j = 0; j < this.sections[i].questions.length; j++) {
86
                    this.sections[i].questions[j].position = j;
87
                    if (this.sections[i].questions[j].type == 'simple' || this.sections[i].questions[j].type == 'multiple' || this.sections[i].questions[j].type == 'rating-open') {
88
                        this.sections[i].questions[j].options.sort(function(a, b) {
89
                            if (a.position > b.position) {
90
                                return 1;
91
                            }
92
                            if (a.position < b.position) {
93
                                return -1;
94
                            }
95
                            return 0;
96
                        });
97
                        for (k = 0; k < this.sections[i].questions[j].options.length; k++) {
98
                            this.sections[i].questions[j].options[k].position = j;
99
                        }
100
                    }
101
                }
102
            }
103
            $('[data-toggle="tooltip"]').tooltip();
104
        },
105
        this.render = function() {
106
            this.sections.sort(function(a, b) {
107
                if (a.position > b.position) {
108
                    return 1;
109
                }
110
                if (a.position < b.position) {
111
                    return -1;
112
                }
113
                return 0;
114
            });
115
            var s = '';
116
            for (i = 0; i < this.sections.length; i++) {
117
                this.sections[i].position = i;
118
                this.sections[i].questions.sort(function(a, b) {
119
                    if (a.position > b.position) {
120
                        return 1;
121
                    }
122
                    if (a.position < b.position) {
123
                        return -1;
124
                    }
125
                    return 0;
126
                });
127
                for (j = 0; j < this.sections[i].questions.length; j++) {
128
                    this.sections[i].questions[j].position = j;
129
                    if (this.sections[i].questions[j].type == 'simple' || this.sections[i].questions[j].type == 'multiple' || this.sections[i].questions[j].type == 'rating-open') {
130
                        this.sections[i].questions[j].options.sort(function(a, b) {
131
                            if (a.position > b.position) {
132
                                return 1;
133
                            }
134
                            if (a.position < b.position) {
135
                                return -1;
136
                            }
137
                            return 0;
138
                        });
139
                        for (k = 0; k < this.sections[i].questions[j].options.length; k++) {
140
                            this.sections[i].questions[j].options[k].position = j;
141
                        }
142
                    }
143
                }
144
            }
145
            $('[data-toggle="tooltip"]').tooltip();
146
        },
147
        this.addSection = function(name, text, value) {
148
            var d = new Date();
149
            var slug = 'section' + d.getTime();
150
            var position = 0;
151
            $.each(this.sections, function(index, section) {
152
                if (position < section.position) {
153
                    position = section.position;
154
                }
155
            });
156
            position++;
157
            var section = {
158
                'slug_section': slug,
159
                'name': name,
160
                'text': text,
161
                'value': value,
162
                'position': position,
163
                'questions': [],
164
            }
165
            this.sections.push(section);
166
        },
167
        this.editSection = function(slug, name, text, value) {
168
            var renderTable = false;
169
            for (i = 0; i < this.sections.length; i++) {
170
                if (slug == this.sections[i].slug_section) {
171
                    this.sections[i].name = name;
172
                    this.sections[i].text = text;
173
                    this.sections[i].value = value;
174
                    renderTable = true;
175
                    break;
176
                }
177
            }
178
            if (renderTable) {
179
                this.renderSection(slug);
180
            }
181
        },
182
        this.deleteSection = function(slug) {
183
            var renderTable = false;
184
            for (i = 0; i < this.sections.length; i++) {
185
                if (slug == this.sections[i].slug_section) {
186
                    this.sections.splice(i, 1);
187
                    renderTable = true;
188
                    break;
189
                }
190
            }
191
            if (renderTable) {
192
                $('#panel' + slug).remove();
193
            }
194
        },
171 geraldo 195
        this.addQuestion = function(slug_section, text, value, type, maxlength, multiline, range) {
167 geraldo 196
            var d = new Date();
197
            var slug_question = 'question' + d.getTime();
198
            var position = 0;
199
            var renderTable = false;
200
            for (i = 0; i < this.sections.length; i++) {
171 geraldo 201
                if (slug_section == this.sections[i].slug_section) {
167 geraldo 202
                    $.each(this.sections[i].questions, function(index, question) {
203
                        if (position < question.position) {
204
                            position = question.position;
205
                        }
206
                    });
207
                    position++;
208
                    var question = {
171 geraldo 209
                        'slug_section': slug_section,
167 geraldo 210
                        'slug_question': slug_question,
211
                        'text': text,
212
                        'value': value,
213
                        'type': type,
214
                        'position': position,
215
                        'maxlength': maxlength,
216
                        'multiline': multiline,
217
                        'range': range,
218
                        'options': [],
219
                    }
220
                    this.sections[i].questions.push(question);
221
                    renderTable = true;
222
                    break;
223
                }
224
            }
225
            if (renderTable) {
171 geraldo 226
                this.renderSection(slug_section);
167 geraldo 227
            }
228
        },
172 geraldo 229
        this.editQuestion = function(slug_section, slug_question, text, value, type, maxlength, multiline, range) {
167 geraldo 230
            var renderTable = false;
231
            for (i = 0; i < this.sections.length; i++) {
171 geraldo 232
                if (slug_section == this.sections[i].slug_section) {
167 geraldo 233
                    for (j = 0; j < this.sections[i].questions.length; j++) {
172 geraldo 234
                        if (slug_question == this.sections[i].questions[j].slug_question) {
167 geraldo 235
                            this.sections[i].questions[j].text = text,
236
                                this.sections[i].questions[j].value = value,
237
                                this.sections[i].questions[j].type = type;
238
                            if (type == 'open') {
239
                                this.sections[i].questions[j].maxlength = maxlength;
240
                                this.sections[i].questions[j].multiline = multiline;
241
                                this.sections[i].questions[j].options = [];
242
                            } else {
243
                                this.sections[i].questions[j].maxlength = 0;
244
                                this.sections[i].questions[j].multiline = 0;
245
                            }
246
                            if (type == 'rating-range') {
247
                                this.sections[i].questions[j].range = range;
248
                            } else {
249
                                this.sections[i].questions[j].range = 0;
250
                            }
251
                            renderTable = true;
252
                            break;
253
                        }
254
                    }
255
                }
256
                if (renderTable) {
257
                    break;
258
                }
259
            }
260
            if (renderTable) {
171 geraldo 261
                this.renderSection(slug_section);
167 geraldo 262
            }
263
        },
172 geraldo 264
        this.deleteQuestion = function(slug_section, slug_question) {
167 geraldo 265
            var renderTable = false;
266
            for (i = 0; i < this.sections.length; i++) {
171 geraldo 267
                if (slug_section == this.sections[i].slug_section) {
167 geraldo 268
                    for (j = 0; j < this.sections[i].questions.length; j++) {
172 geraldo 269
                        if (slug_question == this.sections[i].questions[j].slug_question) {
167 geraldo 270
                            this.sections[i].questions.splice(j, 1);
271
                            renderTable = true;
272
                            break;
273
                        }
274
                    }
275
                }
276
                if (renderTable) {
277
                    break;
278
                }
279
            }
280
            if (renderTable) {
171 geraldo 281
                this.renderSection(slug_section);
167 geraldo 282
            }
283
        },
183 geraldo 284
        this.addOption = function(slug_section, slug_question, text, correct, value) {
167 geraldo 285
            var d = new Date();
286
            var slug_option = 'option' + d.getTime();
287
            var position = 0;
288
            var renderTable = false;
289
            for (i = 0; i < this.sections.length; i++) {
171 geraldo 290
                if (slug_section == this.sections[i].slug_section) {
167 geraldo 291
                    for (j = 0; j < this.sections[i].questions.length; j++) {
172 geraldo 292
                        if (slug_question == this.sections[i].questions[j].slug_question) {
167 geraldo 293
                            $.each(this.sections[i].questions[j].options, function(index, option) {
294
                                if (position < option.position) {
295
                                    position = option.position;
296
                                }
297
                            });
298
                            position++;
299
                            var option = {
300
                                'slug_section': slug_section,
301
                                'slug_question': slug_question,
302
                                'slug_option': slug_option,
303
                                'text': text,
304
                                'correct': correct,
183 geraldo 305
                                'value': value
167 geraldo 306
                            }
307
                            this.sections[i].questions[j].options.push(option);
308
                            renderTable = true;
309
                            break;
310
                        }
311
                        if (renderTable) {
312
                            break;
313
                        }
314
                    }
315
                }
316
            }
317
            if (renderTable) {
171 geraldo 318
                this.renderSection(slug_section);
167 geraldo 319
            }
320
        },
183 geraldo 321
        this.editOption = function(slug_section, slug_question, option_slug, text, correct, value) {
167 geraldo 322
            var renderTable = false;
323
            for (i = 0; i < this.sections.length; i++) {
171 geraldo 324
                if (slug_section == this.sections[i].slug_section) {
167 geraldo 325
                    for (j = 0; j < this.sections[i].questions.length; j++) {
172 geraldo 326
                        if (slug_question == this.sections[i].questions[j].slug_question) {
167 geraldo 327
                            for (k = 0; k < this.sections[i].questions[j].options.length; k++) {
328
                                if (option_slug == this.sections[i].questions[j].options[k].slug_option) {
329
                                    this.sections[i].questions[j].options[k].text = text;
330
                                    this.sections[i].questions[j].options[k].correct = correct;
331
                                    this.sections[i].questions[j].options[k].value = value;
332
                                    renderTable = true;
333
                                    break;
334
                                }
335
                            }
336
                        }
337
                        if (renderTable) {
338
                            break;
339
                        }
340
                    }
341
                }
342
                if (renderTable) {
343
                    break;
344
                }
345
            }
346
            if (renderTable) {
171 geraldo 347
                this.renderSection(slug_section);
167 geraldo 348
            }
349
        },
172 geraldo 350
        this.deleteOption = function(slug_section, slug_question, option_slug) {
167 geraldo 351
            var renderTable = false;
352
            for (i = 0; i < this.sections.length; i++) {
171 geraldo 353
                if (slug_section == this.sections[i].slug_section) {
167 geraldo 354
                    for (j = 0; j < this.sections[i].questions.length; j++) {
172 geraldo 355
                        if (slug_question == this.sections[i].questions[j].slug_question) {
167 geraldo 356
                            for (k = 0; k < this.sections[i].questions[j].options.length; k++) {
357
                                if (option_slug == this.sections[i].questions[j].options[k].slug_option) {
358
                                    this.sections[i].questions[j].options.splice(k, 1);
359
                                    renderTable = true;
360
                                    break;
361
                                }
362
                            }
363
                        }
364
                        if (renderTable) {
365
                            break;
366
                        }
367
                    }
368
                }
369
                if (renderTable) {
370
                    break;
371
                }
372
            }
373
            if (renderTable) {
171 geraldo 374
                this.renderSection(slug_section);
167 geraldo 375
            }
376
        }
377
}
164 geraldo 378
 
167 geraldo 379
function htmlEntities(str) {
380
    return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
381
}
382
jQuery(document).ready(function($) {
383
    var objFormGenerator = new classFormGenerator();
384
    objFormGenerator.render();
385
    var allowEdit = $allowEdit;
386
    var allowDelete = $allowDelete;
387
    var tableForm = $('#gridTable').dataTable({
388
        'processing': true,
389
        'serverSide': true,
390
        'searching': true,
391
        'order': [
392
            [0, 'asc']
393
        ],
394
        'ordering': true,
395
        'ordenable': true,
396
        'responsive': true,
397
        'select': false,
398
        'paging': true,
399
        'pagingType': 'simple_numbers',
400
        'ajax': {
401
            'url': '$routeDatatable',
402
            'type': 'get',
403
            'beforeSend': function(request) {
404
                NProgress.start();
405
            },
406
            'dataFilter': function(response) {
407
                var response = jQuery.parseJSON(response);
408
                var json = {};
409
                json.recordsTotal = 0;
410
                json.recordsFiltered = 0;
411
                json.data = [];
412
                if (response.success) {
413
                    json.recordsTotal = response.data.total;
414
                    json.recordsFiltered = response.data.total;
415
                    json.data = response.data.items;
416
                } else {
417
                    $.fn.showError(response.data)
418
                }
419
                return JSON.stringify(json);
420
            }
421
        },
422
        'language': {
423
            'sProcessing': 'LABEL_DATATABLE_SPROCESSING',
424
            'sLengthMenu': 'LABEL_DATATABLE_SLENGTHMENU',
425
            'sZeroRecords': 'LABEL_DATATABLE_SZERORECORDS',
426
            'sEmptyTable': 'LABEL_DATATABLE_SEMPTYTABLE',
427
            'sInfo': 'LABEL_DATATABLE_SINFO',
428
            'sInfoEmpty': 'LABEL_DATATABLE_SINFOEMPTY',
429
            'sInfoFiltered': 'LABEL_DATATABLE_SINFOFILTERED',
430
            'sInfoPostFix': '',
431
            'sSearch': 'LABEL_DATATABLE_SSEARCH',
432
            'sUrl': '',
433
            'sInfoThousands': ',',
434
            'sLoadingRecords': 'LABEL_DATATABLE_SLOADINGRECORDS',
435
            'oPaginate': {
436
                'sFirst': 'LABEL_DATATABLE_SFIRST',
437
                'sLast': 'LABEL_DATATABLE_SLAST',
438
                'sNext': 'LABEL_DATATABLE_SNEXT',
439
                'sPrevious': 'LABEL_DATATABLE_SPREVIOUS'
440
            },
441
            'oAria': {
442
                'sSortAscending': ': LABEL_DATATABLE_SSORTASCENDING',
443
                'sSortDescending': ':LABEL_DATATABLE_SSORTDESCENDING'
444
            },
445
        },
446
        'drawCallback': function(settings) {
447
            NProgress.done();
448
            $('button.btn-delete').confirmation({
449
                rootSelector: 'button.btn-delete',
450
                title: 'LABEL_ARE_YOU_SURE',
451
                singleton: true,
452
                btnOkLabel: 'LABEL_YES',
453
                btnCancelLabel: 'LABEL_NO',
454
                onConfirm: function(value) {
455
                    action = $(this).data('href');
456
                    NProgress.start();
457
                    $.ajax({
458
                        'dataType': 'json',
459
                        'accept': 'application/json',
460
                        'method': 'post',
461
                        'url': action,
462
                    }).done(function(response) {
463
                        if (response['success']) {
464
                            $.fn.showSuccess(response['data']);
465
                            gridTable.api().ajax.reload(null, false);
466
                        } else {
467
                            $.fn.showError(response['data']);
468
                        }
469
                    }).fail(function(jqXHR, textStatus, errorThrown) {
470
                        $.fn.showError(textStatus);
471
                    }).always(function() {
472
                        NProgress.done();
473
                    });
474
                },
475
            });
476
        },
477
        'aoColumns': [{
478
                'mDataProp': 'name'
479
            },
480
            {
481
                'mDataProp': 'language'
482
            },
483
            {
484
                'mDataProp': 'status'
485
            },
486
            {
487
                'mDataProp': 'actions'
488
            },
489
        ],
490
        'columnDefs': [{
491
                'targets': 0,
492
                'className': 'text-vertical-middle',
493
            },
494
            {
495
                'targets': 1,
496
                'className': 'text-vertical-middle',
497
            },
498
            {
499
                'targets': -2,
500
                'orderable': false,
501
                'className': 'text-center',
502
                'render': function(data, type, row) {
503
                    checked = data == 'a' ? ' checked="checked" ' : '';
504
                    return '<div class="checkbox checkbox-success">' +
505
                        '<input class="styled" type="checkbox" ' + checked + ' disabled="disabled">' +
506
                        '<label ></label></div>';
507
                }
508
            },
509
            {
510
                'targets': -1,
511
                'orderable': false,
512
                'render': function(data, type, row) {
513
                    s = '';
514
                    if (allowEdit) {
515
                        s = s + '<button class="btn btn-primary btn-edit-form" data-href="' + data['link_edit'] + '" data-toggle="tooltip" title="LABEL_EDIT"><i class="fa fa-pencil"></i> LABEL_EDIT </button>&nbsp;';
516
                    }
517
                    if (allowDelete) {
518
                        s = s + '<button class="btn btn-danger btn-delete" data-href="' + data['link_delete'] + '" data-toggle="tooltip" title="LABEL_DELETE"><i class="fa fa-trash"></i> LABEL_DELETE </button>&nbsp;';
519
                    }
520
                    return s;
521
                }
522
            }
523
        ],
118 steven 524
    });
187 efrain 525
 
167 geraldo 526
    $('body').on('click', 'button.btn-edit-form', function(e) {
527
        e.preventDefault();
528
        form_id = $(this).data('id')
529
        var action = $(this).data('href');
530
        $.ajax({
531
            'dataType': 'json',
532
            'accept': 'application/json',
533
            'method': 'get',
534
            'url': action,
535
        }).done(function(response) {
536
            if (response['success']) {
537
                validatorForm.resetForm();
192 efrain 538
                $('#form-main #form-id').val(response['data']['id']),
167 geraldo 539
                    $('#form-main #form-continue').val('0');
194 efrain 540
                $('#form-main #form-name').val(response['data']['name']),
167 geraldo 541
                    instanceName = 'form-description';
542
                let editor = CKEDITOR.instances[instanceName];
192 efrain 543
                editor.setData(response['data']['description'], function() {
167 geraldo 544
                    editor.focus();
545
                });
191 efrain 546
 
547
 
548
 
193 efrain 549
                console.log(response['data'])
550
 
167 geraldo 551
                instanceName = 'form-text';
192 efrain 552
                CKEDITOR.instances[instanceName].setData(response['data']['text']);
553
                $('#form-main #form-language').val(response['data']['language']),
554
                    $('#form-main #form-status').val(response['data']['status']);
167 geraldo 555
                objFormGenerator.clear();
192 efrain 556
                objFormGenerator.sections = response['data']['content'] || [];
167 geraldo 557
                objFormGenerator.render();
558
                $('#row-forms').hide();
559
                $('#row-edit').show();
560
                $('#form-main #form-name').focus();
561
            } else {
562
                $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
563
            }
564
        }).fail(function(jqXHR, textStatus, errorThrown) {
565
            $.fn.showError(textStatus);
566
        });
567
    });
568
    $(document).on('click', '[data-type="select_all"]', function() {
569
        if ($('input[name="select_all"]:checked').val() == 'all') {
570
            $('[data-type="select"]').prop('checked', true);
571
            $('[data-action="delete"]').removeClass('hide');
572
        } else {
573
            $('[data-type="select"]').prop('checked', false);
574
            $('[data-action="delete"]').addClass('hide');
575
        }
576
    });
118 steven 577
 
167 geraldo 578
    function getLength() {
579
        return $('[data-type="select"]').length;
580
    }
118 steven 581
 
167 geraldo 582
    function currentSelected() {
583
        var selected = [];
584
        $.each($("input[name='select[]']:checked"), function() {
585
            selected.push($(this).val());
586
        });
587
        return selected;
588
    }
589
    $(document).on('change', "input[name='select[]']", function() {
590
        var c = currentSelected();
591
        var cc = getLength();
592
        if (c.length == cc) {
593
            if ($('[data-action="delete"]').hasClass('hide')) {
594
                $('[data-action="delete"]').removeClass('hide');
595
            }
596
            return true;
597
        } else {
598
            $('input[name="select_all"]').prop('checked', false);
599
        }
600
        if (c.length > 0) {
601
            if ($('[data-action="delete"]').hasClass('hide')) {
602
                $('[data-action="delete"]').removeClass('hide');
603
            }
604
        } else {
605
            if (!$('[data-action="delete"]').hasClass('hide')) {
606
                $('[data-action="delete"]').addClass('hide');
607
            }
608
        }
118 steven 609
    });
167 geraldo 610
    var form3 = $('#form_sample_3');
611
    var error3 = $('.alert-danger', form3);
612
    var success3 = $('.alert-success', form3);
613
    //IMPORTANT: update CKEDITOR textarea with actual content before submit
614
    $("#form-main").on('submit', function() {
615
        for (var instanceName in CKEDITOR.instances) {
616
            CKEDITOR.instances[instanceName].updateElement();
617
        }
618
    })
619
    var validatorForm = $("#form-main").validate({
118 steven 620
        ignore: [],
621
        errorClass: 'help-block',
622
        errorElement: 'span',
167 geraldo 623
        rules: {
624
            'form-name': {
625
                required: true,
626
                minlength: 2,
627
                maxlength: 50
628
            },
629
            'form-description': {
630
                required: true,
631
            },
632
            'form-text': {
633
                required: true,
634
            },
635
            'form-language': {
636
                required: true,
637
            },
638
            'forrm-status': {
639
                required: true,
640
            },
641
        },
642
        highlight: function(element) {
118 steven 643
            $(element).closest('.form-group').addClass('has-error');
644
        },
167 geraldo 645
        unhighlight: function(element) {
118 steven 646
            $(element).closest('.form-group').removeClass('has-error');
647
        },
167 geraldo 648
        errorPlacement: function(error, element) {
118 steven 649
            if (element.attr("data-error-container")) {
650
                error.appendTo(element.attr("data-error-container"));
651
            } else {
652
                error.insertAfter(element);
653
            }
654
        },
655
        invalidHandler: function(form, validator) {
656
            if (!validator.numberOfInvalids())
657
                return;
658
            $('html, body').animate({
659
                scrollTop: $(validator.errorList[0].element).offset().top - 100
660
            }, 1000);
661
        },
167 geraldo 662
        submitHandler: function(form) {
663
            var error = false;
664
            if (objFormGenerator.sections.length == 0) {
665
                $.fn.showError('ERROR_SECCTIONS');
666
                error = true;
667
            } else {
668
                for (i = 0; i < objFormGenerator.sections.length; i++) {
669
                    if (objFormGenerator.sections[i].questions.length == 0) {
670
                        $.fn.showError('ERROR_QUESTIONS'.replace('%s', objFormGenerator.sections[i].name));
671
                        break;
672
                    }
673
                    var valueSection = parseInt(objFormGenerator.sections[i].value);
674
                    var totalValueQuestion = 0;
675
                    for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
676
                        valueQuestion = parseInt(objFormGenerator.sections[i].questions[j].value);
677
                        totalValueQuestion = totalValueQuestion + valueQuestion;
678
                        if (objFormGenerator.sections[i].questions[j].type == 'simple' ||
679
                            objFormGenerator.sections[i].questions[j].type == 'multiple' ||
680
                            objFormGenerator.sections[i].questions[j].type == 'rating-open') {
681
                            var questionNumber = j + 1;
682
                            var numberCorrect = 0;
683
                            if (objFormGenerator.sections[i].questions[j].options.length == 0) {
684
                                $.fn.showError('ERROR_OPTIONS'.replace('%s', objFormGenerator.sections[i].name).replace('%n', questionNumber));
685
                                error = true;
686
                                return false;
687
                                break;
688
                            }
689
                            var totalOption = 0;
690
                            var maxOption = 0;
691
                            for (k = 0; k < objFormGenerator.sections[i].questions[j].options.length; k++) {
692
                                if (objFormGenerator.sections[i].questions[j].type == 'simple' || objFormGenerator.sections[i].questions[j].type == 'multiple') {
693
                                    if (objFormGenerator.sections[i].questions[j].options[k].correct == 1) {
694
                                        numberCorrect++;
695
                                    }
696
                                }
697
                                if (objFormGenerator.sections[i].questions[j].type == 'multiple' && objFormGenerator.sections[i].questions[j].options[k].correct == 1) {
698
                                    totalOption = totalOption + parseInt(objFormGenerator.sections[i].questions[j].options[k].value);
699
                                }
700
                                if (objFormGenerator.sections[i].questions[j].type == 'rating-open') {
701
                                    if (parseInt(objFormGenerator.sections[i].questions[j].options[k].value) > maxOption) {
702
                                        maxOption = parseInt(objFormGenerator.sections[i].questions[j].options[k].value);
703
                                    }
704
                                }
705
                            }
706
                            if (objFormGenerator.sections[i].questions[j].type == 'simple' || objFormGenerator.sections[i].questions[j].type == 'multiple') {
707
                                if (numberCorrect == 0) {
708
                                    $.fn.showError('ERROR_OPTIONS_CORRECT'.replace('%s', objFormGenerator.sections[i].name).replace('%n', questionNumber));
709
                                    error = true;
710
                                    return false;
711
                                    break;
712
                                }
713
                                if (objFormGenerator.sections[i].questions[j].type == 'simple' && numberCorrect > 1) {
714
                                    $.fn.showError('ERROR_OPTIONS_DUPLICATE_CORRECT'.replace('%s', objFormGenerator.sections[i].name).replace('%n', questionNumber));
715
                                    error = true;
716
                                    return false;
717
                                    break;
718
                                }
719
                                if (objFormGenerator.sections[i].questions[j].type == 'multiple' && numberCorrect == 1) {
720
                                    $.fn.showError('ERROR_OPTIONS_ONE_CORRECT'.replace('%s', objFormGenerator.sections[i].name).replace('%n', questionNumber));
721
                                    error = true;
722
                                    return false;
723
                                    break;
724
                                }
725
                            }
726
                            if (objFormGenerator.sections[i].questions[j].type == 'multiple' && totalOption > valueQuestion) {
727
                                $.fn.showError('ERROR_OPTIONS_SUM_VALUES'.replace('%s', objFormGenerator.sections[i].name).replace('%n', questionNumber));
728
                                error = true;
729
                                return false;
730
                                break;
731
                            }
732
                            if (objFormGenerator.sections[i].questions[j].type == 'rating-open' && maxOption > valueQuestion) {
733
                                $.fn.showError('ERROR_OPTIONS_MAX_OPTION'.replace('%s', objFormGenerator.sections[i].name).replace('%n', questionNumber));
734
                                error = true;
735
                                return false;
736
                                break;
737
                            }
738
                        }
739
                    }
740
                    if (valueSection != totalValueQuestion) {
741
                        $.fn.showError('ERROR_VALUE_SECTIONS'.replace('%s', objFormGenerator.sections[i].name));
742
                        error = true;
743
                        return false;
744
                        break;
745
                    }
746
                }
747
                if (error) {
748
                    return false;
749
                } else {
750
                    var formId = parseInt($('#form-main #form-id').val());
751
                    var formContinue = parseInt($('#form-main #form-continue').val());
752
                    var data = {
753
                        'id': formId,
754
                        'name': $('#form-main #form-name').val(),
755
                        'description': $('#form-main #form-description').val(),
756
                        'text': $('#form-main #form-text').val(),
757
                        'language': $('#form-main #form-language').val(),
758
                        'status': $('#form-main #form-status').val(),
187 efrain 759
                        'content': JSON.stringify(objFormGenerator.sections)
167 geraldo 760
                    }
761
                    $.ajax({
762
                        'dataType': 'json',
763
                        'method': 'post',
764
                        'url': '$routeAdd',
765
                        'data': data,
766
                    }).done(function(response) {
767
                        if (response['success']) {
768
                            $.fn.showSuccess(response['message']);
769
                            if (formContinue == 1) {
770
                                $('#form-main #form-id').val(response['form-id']);
771
                                $('#form-main #form-continue').val(0);
772
                            } else {
773
                                $('#row-edit').hide();
774
                                $('#row-forms').show();
775
                            }
776
                            tableForm.fnDraw();
777
                        } else {
778
                            $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
779
                        }
780
                    }).fail(function(jqXHR, textStatus, errorThrown) {
781
                        $.fn.showError(textStatus);
782
                    });
783
                    return false;
784
                }
785
            }
786
        }
787
    });
788
    //IMPORTANT: update CKEDITOR textarea with actual content before submit
789
    $("#form-section").on('submit', function() {
790
        for (var instanceName in CKEDITOR.instances) {
791
            CKEDITOR.instances[instanceName].updateElement();
792
        }
793
    })
794
    var validatorFormSection = $("#form-section").validate({
118 steven 795
        ignore: [],
796
        errorClass: 'help-block',
797
        errorElement: 'span',
167 geraldo 798
        rules: {
799
            'section-name': {
800
                required: true,
801
                minlength: 2,
802
                maxlength: 50
803
            },
804
            'section-text': {
805
                required: false,
806
            },
807
            'section-value': {
808
                required: true,
809
                number: true,
810
                min: 1
811
            },
812
        },
813
        highlight: function(element) {
118 steven 814
            $(element).closest('.form-group').addClass('has-error');
815
        },
167 geraldo 816
        unhighlight: function(element) {
118 steven 817
            $(element).closest('.form-group').removeClass('has-error');
818
        },
167 geraldo 819
        errorPlacement: function(error, element) {
118 steven 820
            if (element.attr("data-error-container")) {
821
                error.appendTo(element.attr("data-error-container"));
822
            } else {
823
                error.insertAfter(element);
824
            }
825
        },
826
        invalidHandler: function(form, validator) {
827
            if (!validator.numberOfInvalids())
828
                return;
829
            $('html, body').animate({
830
                scrollTop: $(validator.errorList[0].element).offset().top - 100
831
            }, 1000);
832
        },
167 geraldo 833
        submitHandler: function(form) {
834
            // do other things for a valid form
835
            //form.submit();
836
            var slug = $('#form-section #section-slug').val();
837
            if (slug) {
838
                objFormGenerator.editSection(
839
                    $('#form-section #section-slug').val(),
840
                    $('#form-section #section-name').val(),
841
                    $('#form-section #section-text').val(),
842
                    $('#form-section #section-value').val()
843
                );
844
            } else {
845
                objFormGenerator.addSection(
846
                    $('#form-section #section-name').val(),
847
                    $('#form-section #section-text').val(),
848
                    $('#form-section #section-value').val()
849
                );
850
            }
851
            renderData(objFormGenerator.sections);
852
            $('#modal-section').modal('hide');
853
            return false;
854
        }
855
    });
856
    //IMPORTANT: update CKEDITOR textarea with actual content before submit
857
    $("#form-question").on('submit', function() {
858
        for (var instanceName in CKEDITOR.instances) {
859
            CKEDITOR.instances[instanceName].updateElement();
860
        }
861
    })
862
    var validatorFormQuestion = $("#form-question").validate({
118 steven 863
        ignore: [],
864
        errorClass: 'help-block',
865
        errorElement: 'span',
167 geraldo 866
        rules: {
867
            'question-text': {
868
                required: true,
869
            },
870
            'question-value': {
871
                required: true,
872
                number: true,
873
                min: 1
874
            },
875
            'question-type': {
876
                required: true,
877
            },
878
            'question-max-length': {
879
                required: true,
880
                digits: true,
881
                min: 0
882
            },
883
            'question-range': {
884
                required: true,
885
                number: true,
886
                min: 1
887
            },
888
        },
889
        highlight: function(element) {
118 steven 890
            $(element).closest('.form-group').addClass('has-error');
891
        },
167 geraldo 892
        unhighlight: function(element) {
118 steven 893
            $(element).closest('.form-group').removeClass('has-error');
894
        },
167 geraldo 895
        errorPlacement: function(error, element) {
118 steven 896
            if (element.attr("data-error-container")) {
897
                error.appendTo(element.attr("data-error-container"));
898
            } else {
899
                error.insertAfter(element);
900
            }
901
        },
902
        invalidHandler: function(form, validator) {
903
            if (!validator.numberOfInvalids())
904
                return;
905
            $('html, body').animate({
906
                scrollTop: $(validator.errorList[0].element).offset().top - 100
907
            }, 1000);
908
        },
167 geraldo 909
        submitHandler: function(form) {
910
            if ($('#form-question #question-slug').val()) {
911
                objFormGenerator.editQuestion(
912
                    $('#form-question #question-section').val(),
913
                    $('#form-question #question-slug').val(),
914
                    $('#form-question #question-text').val(),
915
                    $('#form-question #question-value').val(),
916
                    $('#form-question #question-type').val(),
917
                    $('#form-question #question-max-length').val(),
918
                    $('#form-question #question-multiline').val(),
919
                    $('#form-question #question-range').val()
920
                );
921
            } else {
922
                objFormGenerator.addQuestion(
923
                    $('#form-question #question-section').val(),
924
                    $('#form-question #question-text').val(),
925
                    $('#form-question #question-value').val(),
926
                    $('#form-question #question-type').val(),
927
                    $('#form-question #question-max-length').val(),
928
                    $('#form-question #question-multiline').val(),
929
                    $('#form-question #question-range').val()
930
                );
931
            }
932
            renderData(objFormGenerator.sections);
933
            $('#modal-question').modal('hide');
934
            return false;
935
        }
936
    });
937
    //IMPORTANT: update CKEDITOR textarea with actual content before submit
938
    $("#form-option").on('submit', function() {
939
        for (var instanceName in CKEDITOR.instances) {
940
            CKEDITOR.instances[instanceName].updateElement();
941
        }
942
    })
943
    var validatorFormOption = $("#form-option").validate({
118 steven 944
        ignore: [],
945
        errorClass: 'help-block',
946
        errorElement: 'span',
167 geraldo 947
        rules: {
948
            'option-text': {
949
                required: true,
950
            },
951
            'option-value': {
952
                required: true,
953
                number: true,
954
                min: 1
955
            }
956
        },
957
        highlight: function(element) {
118 steven 958
            $(element).closest('.form-group').addClass('has-error');
959
        },
167 geraldo 960
        unhighlight: function(element) {
118 steven 961
            $(element).closest('.form-group').removeClass('has-error');
962
        },
167 geraldo 963
        errorPlacement: function(error, element) {
118 steven 964
            if (element.attr("data-error-container")) {
965
                error.appendTo(element.attr("data-error-container"));
966
            } else {
967
                error.insertAfter(element);
968
            }
969
        },
970
        invalidHandler: function(form, validator) {
971
            if (!validator.numberOfInvalids())
972
                return;
973
            $('html, body').animate({
974
                scrollTop: $(validator.errorList[0].element).offset().top - 100
975
            }, 1000);
976
        },
167 geraldo 977
        submitHandler: function(form) {
978
            if ($('#form-option #option-slug').val()) {
979
                objFormGenerator.editOption(
980
                    $('#form-option #option-section').val(),
981
                    $('#form-option #option-question').val(),
982
                    $('#form-option #option-slug').val(),
983
                    $('#form-option #option-text').val(),
984
                    $('#form-option #option-correct').val(),
184 geraldo 985
                    $('#form-option #option-value').val()
167 geraldo 986
                );
987
            } else {
988
                objFormGenerator.addOption(
989
                    $('#form-option #option-section').val(),
990
                    $('#form-option #option-question').val(),
991
                    $('#form-option #option-text').val(),
992
                    $('#form-option #option-correct').val(),
184 geraldo 993
                    $('#form-option #option-value').val()
167 geraldo 994
                );
995
            }
996
            renderData(objFormGenerator.sections);
997
            $('#modal-option').modal('hide');
998
            return false;
999
        }
1000
    });
1001
    $('body').on('click', 'button[id="btn-add-section"]', function(e) {
1002
        e.preventDefault();
1003
        validatorFormSection.resetForm();
1004
        $('#form-section #section-slug').val('');
1005
        $('#form-section #section-name').val('');
1006
        instanceName = 'section-text';
1007
        let editor = CKEDITOR.instances[instanceName];
1008
        editor.setData('', function() {
1009
            editor.focus();
1010
        });
1011
        $('#form-section #section-value').val('0');
1012
        $('#modal-section h4[class="modal-title"]').html('LABEL_ADD LABEL_SECTION');
1013
        $('#modal-section').modal('show');
1014
    });
1015
    $('body').on('click', 'button.btn-edit-section', function(e) {
1016
        e.preventDefault();
169 geraldo 1017
        var slug = $(this).data('section');
167 geraldo 1018
        var section;
1019
        var showForm = false;
1020
        for (i = 0; i < objFormGenerator.sections.length; i++) {
1021
            section = objFormGenerator.sections[i];
171 geraldo 1022
            if (slug == section.slug_section) {
167 geraldo 1023
                validatorFormSection.resetForm();
171 geraldo 1024
                $('#form-section #section-slug').val(section.slug_section);
167 geraldo 1025
                $('#form-section #section-name').val(section.name);
1026
                instanceName = 'section-text';
1027
                let editor = CKEDITOR.instances[instanceName];
1028
                editor.setData(section.text, function() {
1029
                    editor.focus();
1030
                });
1031
                $('#form-section #section-value').val(section.value);
1032
                showForm = true;
1033
                break;
1034
            }
1035
        }
1036
        if (showForm) {
1037
            $('#modal-section h4[class="modal-title"]').html('LABEL_EDIT LABEL_SECTION');
1038
            $('#modal-section').modal('show');
1039
        }
1040
    });
1041
    $('body').on('click', 'button.btn-delete-section', function(e) {
1042
        e.preventDefault();
169 geraldo 1043
        var slug = $(this).data('section');
167 geraldo 1044
        bootbox.confirm({
1045
            title: "LABEL_DELETE LABEL_SECTION",
1046
            message: "LABEL_QUESTION_DELETE",
1047
            buttons: {
1048
                cancel: {
1049
                    label: '<i class="fa fa-times"></i> LABEL_CANCEL'
1050
                },
1051
                confirm: {
1052
                    label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
1053
                }
1054
            },
1055
            callback: function(result) {
1056
                if (result) {
1057
                    objFormGenerator.deleteSection(slug);
1058
                    renderData(objFormGenerator.sections);
1059
                }
1060
            }
1061
        });
1062
    });
1063
    $('body').on('click', 'button.btn-add-question', function(e) {
1064
        e.preventDefault();
1065
        validatorFormQuestion.resetForm();
169 geraldo 1066
        var slug = $(this).data('section');
167 geraldo 1067
        $('#form-question #question-section').val(slug);
1068
        $('#form-question #question-slug').val('');
1069
        instanceName = 'question-text';
1070
        let editor = CKEDITOR.instances[instanceName];
1071
        editor.setData('', function() {
1072
            editor.focus();
1073
        });
1074
        $('#form-question #question-value').val('0');
1075
        $('#form-question #question-type').val($('#form-question #question-type option:first').val());
1076
        $('#form-question #question-max-length').val('0');
1077
        $('#form-question #question-max-length').parent().show();
1078
        $('#form-question #question-multiline').val('0');
1079
        $('#form-question #question-multiline').parent().show();
1080
        $('#form-question #question-range').val('10');
1081
        $('#form-question #question-range').parent().hide();
1082
        $('#modal-question h4[class="modal-title"]').html('LABEL_ADD LABEL_QUESTION');
1083
        $('#modal-question').modal('show');
1084
    });
1085
    $('body').on('click', 'button.btn-edit-question', function(e) {
1086
        e.preventDefault();
1087
        var slug_section = $(this).data('section');
170 geraldo 1088
        var slug = $(this).data('question');
167 geraldo 1089
        var showForm = false;
1090
        for (i = 0; i < objFormGenerator.sections.length; i++) {
1091
            if (slug_section == objFormGenerator.sections[i].slug_section) {
1092
                for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
1093
                    if (slug == objFormGenerator.sections[i].questions[j].slug_question) {
1094
                        validatorFormQuestion.resetForm();
1095
                        $('#form-question #question-section').val(objFormGenerator.sections[i].slug_section);
1096
                        $('#form-question #question-slug').val(objFormGenerator.sections[i].questions[j].slug_question);
1097
                        instanceName = 'question-text';
1098
                        let editor = CKEDITOR.instances[instanceName];
1099
                        editor.setData(objFormGenerator.sections[i].questions[j].text, function() {
1100
                            editor.focus();
1101
                        });
1102
                        $('#form-question #question-value').val(objFormGenerator.sections[i].questions[j].value);
1103
                        $('#form-question #question-type').val(objFormGenerator.sections[i].questions[j].type);
1104
                        if (objFormGenerator.sections[i].questions[j].type == 'open') {
1105
                            $('#form-question #question-max-length').val(objFormGenerator.sections[i].questions[j].maxlength);
1106
                            $('#form-question #question-max-length').parent().show();
1107
                            $('#form-question #question-multiline').val(objFormGenerator.sections[i].questions[j].multiline);
1108
                            $('#form-question #question-multiline').parent().show();
118 steven 1109
                        } else {
167 geraldo 1110
                            $('#form-question #question-max-length').val('0');
1111
                            $('#form-question #question-max-length').parent().hide();
1112
                            $('#form-question #question-multiline').val('0');
1113
                            $('#form-question #question-multiline').parent().hide();
118 steven 1114
                        }
167 geraldo 1115
                        if (objFormGenerator.sections[i].questions[j].type == 'rating-range') {
1116
                            $('#form-question #question-range').val(objFormGenerator.sections[i].questions[j].range);
1117
                            $('#form-question #question-range').parent().show();
1118
                        } else {
1119
                            $('#form-question #question-range').val('10');
1120
                            $('#form-question #question-range').parent().hide();
1121
                        }
1122
                        showForm = true;
1123
                        break;
1124
                    }
1125
                }
1126
                break;
1127
            }
1128
        }
1129
        if (showForm) {
1130
            $('#modal-question h4[class="modal-title"]').html('LABEL_EDIT LABEL_QUESTION');
1131
            $('#modal-question').modal('show');
1132
        }
1133
    });
1134
    $('body').on('click', 'button.btn-delete-question', function(e) {
1135
        e.preventDefault();
1136
        var slug_section = $(this).data('section');
170 geraldo 1137
        var slug = $(this).data('question');
167 geraldo 1138
        bootbox.confirm({
1139
            title: "LABEL_DELETE LABEL_QUESTION",
1140
            message: "LABEL_QUESTION_DELETE",
1141
            buttons: {
1142
                cancel: {
1143
                    label: '<i class="fa fa-times"></i> LABEL_CANCEL'
1144
                },
1145
                confirm: {
1146
                    label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
1147
                }
1148
            },
1149
            callback: function(result) {
1150
                if (result) {
1151
                    objFormGenerator.deleteQuestion(slug_section, slug);
1152
                    renderData(objFormGenerator.sections);
1153
                }
1154
            }
1155
        });
1156
    });
172 geraldo 1157
 
180 geraldo 1158
     /**
1159
      * Get Question type
1160
      */
181 geraldo 1161
     const getQuestionTypeBySlug = (slug_section, slug_question) => {
180 geraldo 1162
         for (i = 0; i < objFormGenerator.sections.length; i++) {
1163
             if (slug_section == objFormGenerator.sections[i].slug_section) {
1164
                 for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
1165
                     if (slug_question == objFormGenerator.sections[i].questions[j].slug_question) {
1166
                         return objFormGenerator.sections[i].questions[j].type;
1167
                     }
1168
                 }
1169
             }
1170
         }
1171
     }
1172
 
1173
     /**
1174
      * Render Sections data
1175
      */
1176
     const renderData = (data) => $("#rows").html($("#sectionTemplate").render(data, {
1177
         getType: getQuestionTypeBySlug
1178
     }));
1179
 
167 geraldo 1180
    $('body').on('click', 'button.btn-add-option', function(e) {
1181
        e.preventDefault();
1182
        var slug_section = $(this).data('section');
1183
        var slug_question = $(this).data('question');
1184
        var showForm = false;
1185
        for (i = 0; i < objFormGenerator.sections.length; i++) {
1186
            if (slug_section == objFormGenerator.sections[i].slug_section) {
1187
                for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
1188
                    if (slug_question == objFormGenerator.sections[i].questions[j].slug_question) {
1189
                        validatorFormOption.resetForm();
1190
                        $('#form-option #option-section').val(slug_section);
1191
                        $('#form-option #option-question').val(slug_question);
1192
                        $('#form-option #option-slug').val('');
1193
                        instanceName = 'option-text';
1194
                        let editor = CKEDITOR.instances[instanceName];
1195
                        editor.setData('', function() {
1196
                            editor.focus();
1197
                        });
1198
                        $('#form-option #option-correct').val('0');
1199
                        if (objFormGenerator.sections[i].questions[j].type == 'rating-open') {
1200
                            $('#form-option #option-correct').parent().hide();
1201
                        } else {
1202
                            $('#form-option #option-correct').parent().show();
1203
                        }
1204
                        if (objFormGenerator.sections[i].questions[j].type == 'multiple' || objFormGenerator.sections[i].questions[j].type == 'rating-open') {
1205
                            $('#form-option #option-value').val('0');
1206
                            $('#form-option #option-value').parent().show();
1207
                        } else {
1208
                            $('#form-option #option-value').val('1');
1209
                            $('#form-option #option-value').parent().hide();
1210
                        }
1211
                        renderData(objFormGenerator.sections);
1212
                        showForm = true;
1213
                    }
1214
                }
1215
            }
1216
        }
1217
        if (showForm) {
1218
            $('#modal-option h4[class="modal-title"]').html('LABEL_ADD LABEL_OPTION');
1219
            $('#modal-option').modal('show');
1220
        }
1221
    });
171 geraldo 1222
 
167 geraldo 1223
    $('body').on('click', 'button.btn-edit-option', function(e) {
1224
        e.preventDefault();
1225
        var slug_section = $(this).data('section');
1226
        var slug_question = $(this).data('question');
1227
        var slug = $(this).data('slug');
1228
        var showForm = false;
1229
        for (i = 0; i < objFormGenerator.sections.length; i++) {
1230
            if (slug_section == objFormGenerator.sections[i].slug_section) {
1231
                for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
1232
                    if (slug_question == objFormGenerator.sections[i].questions[j].slug_question) {
1233
                        for (k = 0; k < objFormGenerator.sections[i].questions[j].options.length; k++) {
1234
                            if (slug == objFormGenerator.sections[i].questions[j].options[k].slug_option) {
1235
                                validatorFormOption.resetForm();
1236
                                $('#form-option #option-section').val(objFormGenerator.sections[i].slug_section);
1237
                                $('#form-option #option-question').val(objFormGenerator.sections[i].questions[j].slug_question);
1238
                                $('#form-option #option-slug').val(objFormGenerator.sections[i].questions[j].options[k].slug_option);
1239
                                instanceName = 'option-text';
1240
                                let editor = CKEDITOR.instances[instanceName];
1241
                                editor.setData(objFormGenerator.sections[i].questions[j].options[k].text, function() {
1242
                                    editor.focus();
1243
                                });
1244
                                $('#form-option #option-correct').val(objFormGenerator.sections[i].questions[j].options[k].correct);
1245
                                if (objFormGenerator.sections[i].questions[j].type == 'multiple' || objFormGenerator.sections[i].questions[j].type == 'simple') {
1246
                                    $('#form-option #option-correct').parent().show();
1247
                                } else {
1248
                                    $('#form-option #option-correct').parent().hide();
1249
                                }
1250
                                $('#form-option #option-value').val(objFormGenerator.sections[i].questions[j].options[k].value);
1251
                                if (objFormGenerator.sections[i].questions[j].type == 'multiple' || objFormGenerator.sections[i].questions[j].type == 'rating-open') {
1252
                                    $('#form-option #option-value').parent().show();
1253
                                } else {
1254
                                    $('#form-option #option-value').parent().hide();
1255
                                }
1256
                                showForm = true;
1257
                                break;
1258
                            }
1259
                        }
1260
                    }
1261
                    if (showForm) {
1262
                        break;
1263
                    }
1264
                }
1265
            }
1266
            if (showForm) {
1267
                break;
1268
            }
1269
        }
1270
        if (showForm) {
1271
            $('#modal-option h4[class="modal-title"]').html('LABEL_EDIT LABEL_OPTION');
1272
            $('#modal-option').modal('show');
1273
        }
1274
    });
1275
    $('body').on('click', 'button.btn-delete-option', function(e) {
1276
        e.preventDefault();
1277
        var slug_section = $(this).data('section');
1278
        var slug_question = $(this).data('question');
1279
        var slug = $(this).data('slug');
1280
        bootbox.confirm({
1281
            title: "LABEL_DELETE LABEL_OPTION",
1282
            message: "LABEL_QUESTION_DELETE",
1283
            buttons: {
1284
                cancel: {
1285
                    label: '<i class="fa fa-times"></i> LABEL_CANCEL'
1286
                },
1287
                confirm: {
1288
                    label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
1289
                }
1290
            },
1291
            callback: function(result) {
1292
                if (result) {
1293
                    objFormGenerator.deleteOption(slug_section, slug_question, slug);
1294
                    renderData(objFormGenerator.sections);
1295
                }
1296
            }
1297
        });
1298
    })
1299
    $('#form-section #section-value').inputNumberFormat({
1300
        'decimal': 2
1301
    });
1302
    $('#form-question #question-value').inputNumberFormat({
1303
        'decimal': 2
1304
    });
1305
    $('#form-question #question-max-length').inputNumberFormat({
1306
        'decimal': 0
1307
    });
1308
    $('#form-option #option-value').inputNumberFormat({
1309
        'decimal': 2
1310
    });
1311
    $('#form-question #question-type').change(function(e) {
1312
        e.preventDefault();
1313
        if ($('#form-question #question-type').val() == 'open') {
1314
            $('#form-question #question-max-length').parent().show();
1315
            $('#form-question #question-multiline').parent().show();
1316
        } else {
1317
            $('#form-question #question-max-length').val('0');
1318
            $('#form-question #question-max-length').parent().hide();
1319
            $('#form-question #question-multiline').val('0');
1320
            $('#form-question #question-multiline').parent().hide();
1321
        }
1322
        $('#form-question #question-range').val('10');
1323
        if ($('#form-question #question-type').val() == 'rating-range') {
1324
            $('#form-question #question-range').parent().show();
1325
        } else {
1326
            $('#form-question #question-range').parent().hide();
1327
        }
1328
    });
1329
    $('button.btn-add-form').click(function(e) {
1330
        e.preventDefault();
1331
        objFormGenerator.clear();
1332
        objFormGenerator.render();
1333
        validatorForm.resetForm();
1334
        $('#form-main #form-id').val('0');
1335
        $('#form-main #form-continue').val('0');
1336
        $('#form-main #form-name').val('');
1337
        instanceName = 'form-text';
1338
        let editor = CKEDITOR.instances[instanceName];
1339
        editor.setData('', function() {
1340
            editor.focus();
1341
        });
1342
        instanceName = 'form-description';
1343
        CKEDITOR.instances[instanceName].setData('');
1344
        $('#form-main #form-language').val('$lang_es'),
1345
            $('#form-main #form-status').val('$status_inactive');
1346
        $('#row-forms').hide();
1347
        $('#row-edit').show();
1348
        $('#form-main #form-name').focus();
1349
    });
1350
    $('button.btn-edit-cancel').click(function(e) {
1351
        e.preventDefault();
1352
        $('#row-edit').hide();
1353
        $('#row-forms').show();
1354
    });
1355
    $('button.btn-form-save-continue').click(function(e) {
1356
        e.preventDefault();
1357
        $('#form-main #form-continue').val('1')
1358
        $('#form-main').submit();
1359
    });
1360
    $('button.btn-form-save-close').click(function(e) {
1361
        e.preventDefault();
1362
        $('#form-main #form-continue').val('0')
1363
        $('#form-main').submit();
1364
    });
1365
    $('#modal-section, #modal-question, #modal-option').modal({
1366
        backdrop: 'static',
1367
        keyboard: false,
1368
        show: false
1369
    });
1370
});
118 steven 1371
JS;
115 efrain 1372
$this->inlineScript()->captureEnd();
1373
?>
118 steven 1374
 
121 steven 1375
<style type="text/css">
135 geraldo 1376
    tbody input[type="checkbox"]{
1377
        margin-left: 14px;
1378
    }
1379
    .panel-heading .accordion-toggle:after {
1380
        /* symbol for "opening" panels */
1381
        display: inline-block;
1382
        font: normal normal normal 14px/1 FontAwesome;
1383
        font-size: inherit;
1384
        content: "\f077" ;
1385
        float: right;        /* adjust as needed */
1386
        color: grey;         /* adjust as needed */
1387
        text-rendering: auto;
1388
        -webkit-font-smoothing: antialiased;
1389
    }
1390
    .panel-heading .accordion-toggle.collapsed:after {
1391
        /* symbol for "collapsed" panels */
1392
        content: "\f078";    /* adjust as needed, taken from bootstrap.css */
1393
    }
121 steven 1394
</style>
115 efrain 1395
<!-- Content Header (Page header) -->
1396
<section class="content-header">
135 geraldo 1397
    <div class="container-fluid">
1398
        <div class="row mb-2">
1399
            <div class="col-sm-12">
1400
                <h1>LABEL_SELF_EVALUATION_FORMS</h1>
1401
            </div>
1402
        </div>
145 geraldo 1403
    </div>
1404
    <!-- /.container-fluid -->
115 efrain 1405
</section>
1406
<section class="content">
135 geraldo 1407
    <div class="container-fluid" id="row-forms">
1408
        <div class="row">
1409
            <div class="col-12">
145 geraldo 1410
                <div class="card">
135 geraldo 1411
                    <div class="card-body">
153 geraldo 1412
                        <table id="gridTable" class="table   table-hover">
1413
                            <thead>
1414
                                <tr>
1415
                                    <th>LABEL_NAME</th>
1416
                                    <th>LABEL_LANGUAGE</th>
1417
                                    <th>LABEL_ACTIVE</th>
1418
                                    <th>LABEL_ACTIONS</th>
1419
                                </tr>
1420
                            </thead>
155 geraldo 1421
                            <tbody></tbody>
153 geraldo 1422
                        </table>
135 geraldo 1423
                    </div>
1424
                    <div class="card-footer clearfix">
1425
                        <div style="float:right;">
1426
                            <button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH </button>
1427
                            <?php if ($allowAdd) : ?>
1428
                                <button type="button" class="btn btn-primary btn-add-form"><i class="fa fa-plus"></i> LABEL_ADD </button>
1429
                            <?php endif; ?>
1430
                        </div>
1431
                    </div>
1432
                </div>
145 geraldo 1433
            </div>
1434
        </div>
135 geraldo 1435
    </div>
154 geraldo 1436
 
155 geraldo 1437
    <!-- Create/Edit Form -->
174 geraldo 1438
 
1439
    <div class="row" id="row-edit" style="display: none">
1440
        <div class="col-xs-12 col-md-12">
1441
            <form action="#" name="form-main" id="form-main">
1442
                <input type="hidden" name="form-id" id="form-id" value="0" />
1443
                <input type="hidden" name="form-continue" id="form-continue" value="0" />
1444
                <div class="form-group">
1445
                    <label for="form-name">LABEL_FIRST_NAME</label>
1446
                    <input type="text" name="form-name" id="form-name" class="form-control" maxlength="50" />
1447
                </div>
1448
                <div class="form-group">
1449
                    <label for="form-description">LABEL_DESCRIPTION</label>
1450
                    <!--  ckeditor -->
1451
                    <textarea  name="form-description" id="form-description" rows="5" class="ckeditor form-control"></textarea>
1452
                </div>
1453
                <div class="form-group">
1454
                    <label for="form-text">LABEL_TEXT</label>
1455
                    <!--  ckeditor -->
1456
                    <textarea  name="form-text" id="form-text" rows="5" class="ckeditor form-control"></textarea>
1457
                </div>
1458
                <div class="form-group">
1459
                    <label for="form-language">LABEL_LANGUAGES</label>
1460
                    <select name="form-language" id="form-language" class="form-control">
176 geraldo 1461
                        <option value="<?php echo $lang_en; ?>">LABEL_ENGLISH</option>
1462
                        <option value="<?php echo $lang_es; ?>">LABEL_SPANISH</option>
174 geraldo 1463
                    </select>
1464
                </div>
1465
                <div class="form-group">
1466
                    <label for="form-status">LABEL_STATUS</label>
1467
                    <select name="form-status" id="form-status" class="form-control">
176 geraldo 1468
                        <option value="<?php echo $status_inactive; ?>">LABEL_INACTIVE</option>
1469
                        <option value="<?php echo $status_active; ?>">LABEL_ACTIVE</option>
174 geraldo 1470
                    </select>
1471
                </div>
1472
                <br/>
1473
                <div class="row">
1474
                    <div class="col-xs-12 col-md-12 text-right">
1475
                        <button class="btn btn-primary" id="btn-add-section" data-toggle="tooltip" title="LABEL_ADD LABEL_SECTION"><i class="fa fa-plus" aria-hidden="true"></i> LABEL_ADD LABEL_SECTION</button>
1476
                    </div>
1477
                </div>
1478
                <br />
1479
                <div class="row">
1480
                    <div class="col-xs-12 col-md-12">
1481
                        <div class="panel-group" id="rows"></div>
1482
                    </div>
1483
                </div>
1484
                <div class="form-group">
1485
                    <button type="submit" form="form-main" class="btn btn-info btn-form-save-continue">LABEL_SAVE & LABEL_CONTINUE</button>
1486
                    <button type="button" class="btn btn-primary btn-form-save-close">LABEL_SAVE & LABEL_CLOSE</button>
1487
                    <button type="button" class="btn btn-secondary btn-edit-cancel">LABEL_CANCEL</button>
1488
                </div>
1489
            </form>
1490
        </div>
1491
    </div>
1492
 
155 geraldo 1493
    <!-- Create/Edit Form-->
154 geraldo 1494
 
135 geraldo 1495
    <!-- Section Modal -->
174 geraldo 1496
    <div  id="modal-section" class="modal" tabindex="-1" role="dialog">
1497
        <div class="modal-dialog modal-lg" role="document">
1498
            <form action="#" name="form-section" id="form-section">
1499
                <input type="hidden" name="section-slug" id="section-slug" value="" />
1500
                <div class="modal-content">
1501
                    <div class="modal-header">
1502
                        <h4 class="modal-title">LABEL_ADD LABEL_SECTION</h4>
1503
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
1504
                            <span aria-hidden="true">&times;</span>
1505
                        </button>
1506
                    </div>
1507
                    <div class="modal-body">
1508
                        <div class="form-group">
1509
                            <label for="section-name">LABEL_FIRST_NAME</label>
1510
                            <input type="text" name="section-name" id="section-name" class="form-control" maxlength="50" value="" />
1511
                        </div>
1512
                        <div class="form-group">
1513
                            <label for="section-text">LABEL_TEXT</label>
1514
                            <!--  ckeditor -->
1515
                            <textarea  name="section-text" id="section-text" rows="5" class="ckeditor form-control"></textarea>
1516
                        </div>
1517
                        <div class="form-group">
1518
                            <label for="section-value">LABEL_VALUE</label>
1519
                            <input type="text" name="section-value" id="section-value"  class="form-control" value="0" />
1520
                        </div>
1521
                    </div>
1522
                    <div class="modal-footer">
1523
                        <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
1524
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
1525
                    </div>
1526
                </div>
1527
            </form>
1528
        </div>
1529
    </div>
135 geraldo 1530
    <!-- End Modal Section -->
153 geraldo 1531
 
135 geraldo 1532
    <!-- Question Modal -->
156 geraldo 1533
 
174 geraldo 1534
    <div  id="modal-question" class="modal" tabindex="-1" role="dialog">
1535
        <div class="modal-dialog modal-lg" role="document">
1536
            <form action="#" name="form-question" id="form-question">
1537
                <input type="hidden" name="question-section" id="question-section" />
1538
                <input type="hidden" name="question-slug" id="question-slug" />
1539
                <div class="modal-content">
1540
                    <div class="modal-header">
1541
                        <h4 class="modal-title">LABEL_ADD LABEL_QUESTION</h4>
1542
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
1543
                            <span aria-hidden="true">&times;</span>
1544
                        </button>
1545
                    </div>
1546
                    <div class="modal-body">
1547
                        <div class="form-group">
1548
                            <label for="question-text">LABEL_TEXT</label>
1549
                            <!--  ckeditor -->
1550
                            <textarea  name="question-text" id="question-text" rows="5" class="ckeditor form-control"></textarea>
1551
                        </div>
1552
                        <div class="form-group">
1553
                            <label for="question-value">LABEL_VALUE</label>
1554
                            <input type="text" name="question-value" id="question-value"  class="form-control" />
1555
                        </div>
1556
                        <div class="form-group">
1557
                            <label for="question-type">LABEL_TYPE</label>
1558
                            <select name="question-type" id="question-type" class="form-control">
1559
                                <option value="open">LABEL_OPEN</option>
1560
                                <option value="simple">Simple</option>
1561
                                <option value="multiple">Multiple</option>
1562
                                <option value="rating-open">LABEL_RATING_OPEN</option>
1563
                                <option value="rating-range">LABEL_RATING_RANGE</option>
1564
                            </select>
1565
                        </div>
1566
                        <div class="form-group">
1567
                            <label for="question-max-length">LABEL_MAXLENGTH</label>
1568
                            <input type="text" name="question-max-length" id="question-max-length"  class="form-control" />
1569
                        </div>
1570
                        <div class="form-group">
1571
                            <label for="question-multiline">LABEL_MULTI_LINE</label>
1572
                            <select name="question-multiline" id="question-multiline" class="form-control">
1573
                                <option value="1">LABEL_YES</option>
1574
                                <option value="0">LABEL_NOT</option>
1575
                            </select>
1576
                        </div>
1577
                        <div class="form-group">
1578
                            <label for="question-range">LABEL_RANGE</label>
1579
                            <select name="question-range" id="question-range" class="form-control">
1580
                                <option value="10">1-10</option>
1581
                                <option value="6">1-6</option>
1582
                                <option value="5">1-5</option>
1583
                            </select>
1584
                        </div>
1585
                    </div>
1586
                    <div class="modal-footer">
1587
                        <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
1588
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
1589
                    </div>
1590
                </div>
1591
            </form>
1592
        </div>
1593
    </div>
156 geraldo 1594
 
167 geraldo 1595
    <!-- End Modal Question -->
153 geraldo 1596
 
1597
    <!-- Modal Options -->
156 geraldo 1598
 
174 geraldo 1599
    <div  id="modal-option" class="modal" tabindex="-1" role="dialog">
1600
        <div class="modal-dialog modal-lg" role="document">
1601
            <form action="#" name="form-option" id="form-option">
1602
                <input type="hidden" name="option-section" id="option-section" value="" />
1603
                <input type="hidden" name="option-question" id="option-question" value="" />
1604
                <input type="hidden" name="option-slug" id="option-slug" value="" />
1605
                <div class="modal-content">
1606
                    <div class="modal-header">
1607
                        <h4 class="modal-title">LABEL_OPTION</h4>
1608
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
1609
                            <span aria-hidden="true">&times;</span>
1610
                        </button>
1611
                    </div>
1612
                    <div class="modal-body">
1613
                        <div class="form-group">
1614
                            <label for="option-text">LABEL_TEXT</label>
1615
                            <!--  ckeditor -->
1616
                            <textarea  name="option-text" id="option-text" rows="5" class="ckeditor form-control"></textarea>
1617
                        </div>
1618
                        <div class="form-group">
1619
                            <label for="option-correct">LABEL_ANSWER_CORRECT</label>
1620
                            <select name="option-correct" id="option-correct" class="form-control">
1621
                                <option value="1">LABEL_YES</option>
1622
                                <option value="0">LABEL_NOT</option>
1623
                            </select>
1624
                        </div>
1625
                        <div class="form-group">
1626
                            <label for="option-value">LABEL_VALUE</label>
1627
                            <input type="text" name="option-value" id="option-value" class="form-control" />
1628
                        </div>
1629
                    </div>
1630
                    <div class="modal-footer">
1631
                        <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
1632
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
1633
                    </div>
1634
                </div>
1635
            </form>
1636
        </div>
1637
    </div>
1638
 
135 geraldo 1639
    <!-- End Modal Options -->
153 geraldo 1640
 
180 geraldo 1641
    <!---Template Sections --->
1642
    <script id="sectionTemplate" type="text/x-jsrender">
1643
    <div class="panel panel-default" id="panel-{{:slug_section}}">
1644
        <div class="panel-heading">
1645
            <h4 class="panel-title">
1646
                <a class="accordion-toggle" data-toggle="collapse" aria-expanded="true" data-parent="#panel-{{:slug_section}}" href="#collapse-{{:slug_section}}">
1647
                    <span class="section-name{{:slug_section}}">
1648
                        {{:name}}
1649
                    </span>
1650
                </a>
1651
            </h4>
1652
        </div>
1653
        <div id="collapse-{{:slug_section}}" class="panel-collapse in collapse show">
1654
            <div class="panel-body">
1655
                <div class="table-responsive">
1656
                    <table class="table table-bordered">
1657
                        <thead>
1658
                            <tr>
1659
                                <th>LABEL_ELEMENT</th>
1660
                                <th>LABEL_TEXT</th>
1661
                                <th>LABEL_VALUE</th>
1662
                                <th>LABEL_TYPE</th>
1663
                                <th>LABEL_ACTIONS</th>
1664
                            </tr>
1665
                        </thead>
1666
                        <tbody>
1667
                            <tr class="tr-section">
1668
                                <td class="text-left">LABEL_SECTION</td>
1669
                                <td class="text-left">{{:name}}</td>
1670
                                <td>{{:value}}</td>
1671
                                <td></td>
1672
                                <td>
1673
                                    <button class="btn btn-default btn-edit-section" data-section="{{:slug_section}}" data-toggle="tooltip"  data-original-title="LABEL_EDIT LABEL_SECTION"><i class="fa fa-edit" aria-hidden="true"></i> LABEL_EDIT LABEL_SECTION </button>
1674
                                    <button class="btn btn-default btn-delete-section" data-section="{{:slug_section}}" data-toggle="tooltip"  data-original-title="LABEL_DELETE LABEL_SECTION"><i class="fa fa-ban" aria-hidden="true"></i> LABEL_DELETE LABEL_SECTION </button>
1675
                                    <button class="btn btn-default btn-add-question" data-section="{{:slug_section}}" data-toggle="tooltip"  data-original-title="LABEL_ADD  LABEL_QUESTION"><i class="fa fa-plus" aria-hidden="true"></i> LABEL_ADD  LABEL_QUESTION </button>
1676
                                </td>
1677
                            </tr>
1678
                            {{for questions}}
1679
                            <tr class="tr-question">
1680
                                <td class="text-left">--LABEL_QUESTION</td>
1681
                                <td class="text-left">
1682
                                    {{:text}}
1683
                                </td>
1684
                                <td><font color="red">{{:value}}</font></td>
1685
                                <td class="text-capitalize">
1686
                                    {{if type == 'open'}} LABEL_OPEN {{/if}}
1687
                                    {{if type == 'simple'}} Simple {{/if}}
1688
                                    {{if type == 'multiple'}} Multiple {{/if}}
1689
                                    {{if type == 'rating-open'}} LABEL_RATING_OPEN {{/if}}
1690
                                    {{if type == 'rating-range'}} LABEL_RATING_RANGE {{/if}}
1691
                                </td>
1692
                                <td>
1693
                                    <button class="btn btn-default btn-edit-question" data-section="{{:slug_section}}" data-question="{{:slug_question}}" data-toggle="tooltip"  data-original-title="LABEL_EDIT LABEL_QUESTION"><i class="fa fa-edit" aria-hidden="true"></i> LABEL_EDIT LABEL_QUESTION</button>
1694
                                    <button class="btn btn-default btn-delete-question" data-section="{{:slug_section}}" data-question="{{:slug_question}}" data-toggle="tooltip"  data-original-title="LABEL_DELETE LABEL_QUESTION"><i class="fa fa-ban" aria-hidden="true"></i> LABEL_DELETE LABEL_QUESTION</button>
1695
                                    <button class="btn btn-default btn-add-option" data-section="{{:slug_section}}" data-question="{{:slug_question}}" data-toggle="tooltip"  data-original-title="LABEL_ADD  LABEL_OPTION"><i class="fa fa-plus" aria-hidden="true"></i> LABEL_ADD  LABEL_OPTION</button>
1696
                                </td>
1697
                            </tr>
1698
                            {{for options}}
1699
                            <tr class="tr-option">
1700
                                <td class="text-left">---LABEL_OPTION</td>
1701
                                <td class="text-left">
1702
                                    {{:text}}
1703
                                </td>
1704
                                <td>
153 geraldo 1705
 
186 geraldo 1706
                                    {{if ~getType( slug_section, slug_question) == 'multiple' || ~getType( slug_section, slug_question) == 'rating-open'  }}
1707
                                    {{:value}}
1708
                                    {{/if}}
180 geraldo 1709
                                </td>
1710
                                <td class="text-left">
186 geraldo 1711
                                    {{if ~getType( slug_section, slug_question) != rating-open'}}
1712
                                    {{if correct == 1}}
1713
                                    <font color="green">LABEL_CORRECT</font>
1714
                                    {{/if}}
1715
                                    {{if correct == 0}}
1716
                                    <font color="red">LABEL_FAIL</font>
1717
                                    {{/if}}
1718
                                    {{/if}}
180 geraldo 1719
                                </td>
1720
                                <td>
1721
                                    <button class="btn btn-default btn-edit-option" data-section="{{:slug_section}}" data-question="{{:slug_question}}" data-slug="{{:slug_option}}" data-toggle="tooltip"  data-original-title="LABEL_EDIT LABEL_OPTION"><i class="fa fa-edit" aria-hidden="true"></i> LABEL_EDIT LABEL_OPTION</button>
1722
                                    <button class="btn btn-default btn-delete-option" data-section="{{:slug_section}}" data-question="{{:slug_question}}" data-slug="{{:slug_option}}" data-toggle="tooltip"  data-original-title="LABEL_DELETE LABEL_OPTION"><i class="fa fa-ban" aria-hidden="true"></i> LABEL_DELETE LABEL_OPTION</button>
1723
                                </td>
1724
                            </tr>
1725
                            {{/for}}
1726
                            {{/for}}
1727
                        </tbody>
1728
                    </table>
1729
                </div>
1730
            </div>
1731
        </div>
1732
    </div>
1733
    </script>
1734
 
1735
    <!-- End Template Sections-->
1736
 
119 steven 1737
</section>