Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 190 | Rev 192 | 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();
538
                $('#form-main #form-id').val(response['id']),
539
                    $('#form-main #form-continue').val('0');
540
                $('#form-main #form-name').val(response['name']),
541
                    instanceName = 'form-description';
542
                let editor = CKEDITOR.instances[instanceName];
543
                editor.setData(response['description'], function() {
544
                    editor.focus();
545
                });
191 efrain 546
 
547
 
548
console.log(response['content']);
549
 
167 geraldo 550
                instanceName = 'form-text';
551
                CKEDITOR.instances[instanceName].setData(response['text']);
552
                $('#form-main #form-language').val(response['language']),
553
                    $('#form-main #form-status').val(response['status']);
554
                objFormGenerator.clear();
190 efrain 555
                objFormGenerator.sections = response['content'] || [];
167 geraldo 556
                objFormGenerator.render();
557
                $('#row-forms').hide();
558
                $('#row-edit').show();
559
                $('#form-main #form-name').focus();
560
            } else {
561
                $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
562
            }
563
        }).fail(function(jqXHR, textStatus, errorThrown) {
564
            $.fn.showError(textStatus);
565
        });
566
    });
567
    $(document).on('click', '[data-type="select_all"]', function() {
568
        if ($('input[name="select_all"]:checked').val() == 'all') {
569
            $('[data-type="select"]').prop('checked', true);
570
            $('[data-action="delete"]').removeClass('hide');
571
        } else {
572
            $('[data-type="select"]').prop('checked', false);
573
            $('[data-action="delete"]').addClass('hide');
574
        }
575
    });
118 steven 576
 
167 geraldo 577
    function getLength() {
578
        return $('[data-type="select"]').length;
579
    }
118 steven 580
 
167 geraldo 581
    function currentSelected() {
582
        var selected = [];
583
        $.each($("input[name='select[]']:checked"), function() {
584
            selected.push($(this).val());
585
        });
586
        return selected;
587
    }
588
    $(document).on('change', "input[name='select[]']", function() {
589
        var c = currentSelected();
590
        var cc = getLength();
591
        if (c.length == cc) {
592
            if ($('[data-action="delete"]').hasClass('hide')) {
593
                $('[data-action="delete"]').removeClass('hide');
594
            }
595
            return true;
596
        } else {
597
            $('input[name="select_all"]').prop('checked', false);
598
        }
599
        if (c.length > 0) {
600
            if ($('[data-action="delete"]').hasClass('hide')) {
601
                $('[data-action="delete"]').removeClass('hide');
602
            }
603
        } else {
604
            if (!$('[data-action="delete"]').hasClass('hide')) {
605
                $('[data-action="delete"]').addClass('hide');
606
            }
607
        }
118 steven 608
    });
167 geraldo 609
    var form3 = $('#form_sample_3');
610
    var error3 = $('.alert-danger', form3);
611
    var success3 = $('.alert-success', form3);
612
    //IMPORTANT: update CKEDITOR textarea with actual content before submit
613
    $("#form-main").on('submit', function() {
614
        for (var instanceName in CKEDITOR.instances) {
615
            CKEDITOR.instances[instanceName].updateElement();
616
        }
617
    })
618
    var validatorForm = $("#form-main").validate({
118 steven 619
        ignore: [],
620
        errorClass: 'help-block',
621
        errorElement: 'span',
167 geraldo 622
        rules: {
623
            'form-name': {
624
                required: true,
625
                minlength: 2,
626
                maxlength: 50
627
            },
628
            'form-description': {
629
                required: true,
630
            },
631
            'form-text': {
632
                required: true,
633
            },
634
            'form-language': {
635
                required: true,
636
            },
637
            'forrm-status': {
638
                required: true,
639
            },
640
        },
641
        highlight: function(element) {
118 steven 642
            $(element).closest('.form-group').addClass('has-error');
643
        },
167 geraldo 644
        unhighlight: function(element) {
118 steven 645
            $(element).closest('.form-group').removeClass('has-error');
646
        },
167 geraldo 647
        errorPlacement: function(error, element) {
118 steven 648
            if (element.attr("data-error-container")) {
649
                error.appendTo(element.attr("data-error-container"));
650
            } else {
651
                error.insertAfter(element);
652
            }
653
        },
654
        invalidHandler: function(form, validator) {
655
            if (!validator.numberOfInvalids())
656
                return;
657
            $('html, body').animate({
658
                scrollTop: $(validator.errorList[0].element).offset().top - 100
659
            }, 1000);
660
        },
167 geraldo 661
        submitHandler: function(form) {
662
            var error = false;
663
            if (objFormGenerator.sections.length == 0) {
664
                $.fn.showError('ERROR_SECCTIONS');
665
                error = true;
666
            } else {
667
                for (i = 0; i < objFormGenerator.sections.length; i++) {
668
                    if (objFormGenerator.sections[i].questions.length == 0) {
669
                        $.fn.showError('ERROR_QUESTIONS'.replace('%s', objFormGenerator.sections[i].name));
670
                        break;
671
                    }
672
                    var valueSection = parseInt(objFormGenerator.sections[i].value);
673
                    var totalValueQuestion = 0;
674
                    for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
675
                        valueQuestion = parseInt(objFormGenerator.sections[i].questions[j].value);
676
                        totalValueQuestion = totalValueQuestion + valueQuestion;
677
                        if (objFormGenerator.sections[i].questions[j].type == 'simple' ||
678
                            objFormGenerator.sections[i].questions[j].type == 'multiple' ||
679
                            objFormGenerator.sections[i].questions[j].type == 'rating-open') {
680
                            var questionNumber = j + 1;
681
                            var numberCorrect = 0;
682
                            if (objFormGenerator.sections[i].questions[j].options.length == 0) {
683
                                $.fn.showError('ERROR_OPTIONS'.replace('%s', objFormGenerator.sections[i].name).replace('%n', questionNumber));
684
                                error = true;
685
                                return false;
686
                                break;
687
                            }
688
                            var totalOption = 0;
689
                            var maxOption = 0;
690
                            for (k = 0; k < objFormGenerator.sections[i].questions[j].options.length; k++) {
691
                                if (objFormGenerator.sections[i].questions[j].type == 'simple' || objFormGenerator.sections[i].questions[j].type == 'multiple') {
692
                                    if (objFormGenerator.sections[i].questions[j].options[k].correct == 1) {
693
                                        numberCorrect++;
694
                                    }
695
                                }
696
                                if (objFormGenerator.sections[i].questions[j].type == 'multiple' && objFormGenerator.sections[i].questions[j].options[k].correct == 1) {
697
                                    totalOption = totalOption + parseInt(objFormGenerator.sections[i].questions[j].options[k].value);
698
                                }
699
                                if (objFormGenerator.sections[i].questions[j].type == 'rating-open') {
700
                                    if (parseInt(objFormGenerator.sections[i].questions[j].options[k].value) > maxOption) {
701
                                        maxOption = parseInt(objFormGenerator.sections[i].questions[j].options[k].value);
702
                                    }
703
                                }
704
                            }
705
                            if (objFormGenerator.sections[i].questions[j].type == 'simple' || objFormGenerator.sections[i].questions[j].type == 'multiple') {
706
                                if (numberCorrect == 0) {
707
                                    $.fn.showError('ERROR_OPTIONS_CORRECT'.replace('%s', objFormGenerator.sections[i].name).replace('%n', questionNumber));
708
                                    error = true;
709
                                    return false;
710
                                    break;
711
                                }
712
                                if (objFormGenerator.sections[i].questions[j].type == 'simple' && numberCorrect > 1) {
713
                                    $.fn.showError('ERROR_OPTIONS_DUPLICATE_CORRECT'.replace('%s', objFormGenerator.sections[i].name).replace('%n', questionNumber));
714
                                    error = true;
715
                                    return false;
716
                                    break;
717
                                }
718
                                if (objFormGenerator.sections[i].questions[j].type == 'multiple' && numberCorrect == 1) {
719
                                    $.fn.showError('ERROR_OPTIONS_ONE_CORRECT'.replace('%s', objFormGenerator.sections[i].name).replace('%n', questionNumber));
720
                                    error = true;
721
                                    return false;
722
                                    break;
723
                                }
724
                            }
725
                            if (objFormGenerator.sections[i].questions[j].type == 'multiple' && totalOption > valueQuestion) {
726
                                $.fn.showError('ERROR_OPTIONS_SUM_VALUES'.replace('%s', objFormGenerator.sections[i].name).replace('%n', questionNumber));
727
                                error = true;
728
                                return false;
729
                                break;
730
                            }
731
                            if (objFormGenerator.sections[i].questions[j].type == 'rating-open' && maxOption > valueQuestion) {
732
                                $.fn.showError('ERROR_OPTIONS_MAX_OPTION'.replace('%s', objFormGenerator.sections[i].name).replace('%n', questionNumber));
733
                                error = true;
734
                                return false;
735
                                break;
736
                            }
737
                        }
738
                    }
739
                    if (valueSection != totalValueQuestion) {
740
                        $.fn.showError('ERROR_VALUE_SECTIONS'.replace('%s', objFormGenerator.sections[i].name));
741
                        error = true;
742
                        return false;
743
                        break;
744
                    }
745
                }
746
                if (error) {
747
                    return false;
748
                } else {
749
                    var formId = parseInt($('#form-main #form-id').val());
750
                    var formContinue = parseInt($('#form-main #form-continue').val());
751
                    var data = {
752
                        'id': formId,
753
                        'name': $('#form-main #form-name').val(),
754
                        'description': $('#form-main #form-description').val(),
755
                        'text': $('#form-main #form-text').val(),
756
                        'language': $('#form-main #form-language').val(),
757
                        'status': $('#form-main #form-status').val(),
187 efrain 758
                        'content': JSON.stringify(objFormGenerator.sections)
167 geraldo 759
                    }
760
                    $.ajax({
761
                        'dataType': 'json',
762
                        'method': 'post',
763
                        'url': '$routeAdd',
764
                        'data': data,
765
                    }).done(function(response) {
766
                        if (response['success']) {
767
                            $.fn.showSuccess(response['message']);
768
                            if (formContinue == 1) {
769
                                $('#form-main #form-id').val(response['form-id']);
770
                                $('#form-main #form-continue').val(0);
771
                            } else {
772
                                $('#row-edit').hide();
773
                                $('#row-forms').show();
774
                            }
775
                            tableForm.fnDraw();
776
                        } else {
777
                            $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
778
                        }
779
                    }).fail(function(jqXHR, textStatus, errorThrown) {
780
                        $.fn.showError(textStatus);
781
                    });
782
                    return false;
783
                }
784
            }
785
        }
786
    });
787
    //IMPORTANT: update CKEDITOR textarea with actual content before submit
788
    $("#form-section").on('submit', function() {
789
        for (var instanceName in CKEDITOR.instances) {
790
            CKEDITOR.instances[instanceName].updateElement();
791
        }
792
    })
793
    var validatorFormSection = $("#form-section").validate({
118 steven 794
        ignore: [],
795
        errorClass: 'help-block',
796
        errorElement: 'span',
167 geraldo 797
        rules: {
798
            'section-name': {
799
                required: true,
800
                minlength: 2,
801
                maxlength: 50
802
            },
803
            'section-text': {
804
                required: false,
805
            },
806
            'section-value': {
807
                required: true,
808
                number: true,
809
                min: 1
810
            },
811
        },
812
        highlight: function(element) {
118 steven 813
            $(element).closest('.form-group').addClass('has-error');
814
        },
167 geraldo 815
        unhighlight: function(element) {
118 steven 816
            $(element).closest('.form-group').removeClass('has-error');
817
        },
167 geraldo 818
        errorPlacement: function(error, element) {
118 steven 819
            if (element.attr("data-error-container")) {
820
                error.appendTo(element.attr("data-error-container"));
821
            } else {
822
                error.insertAfter(element);
823
            }
824
        },
825
        invalidHandler: function(form, validator) {
826
            if (!validator.numberOfInvalids())
827
                return;
828
            $('html, body').animate({
829
                scrollTop: $(validator.errorList[0].element).offset().top - 100
830
            }, 1000);
831
        },
167 geraldo 832
        submitHandler: function(form) {
833
            // do other things for a valid form
834
            //form.submit();
835
            var slug = $('#form-section #section-slug').val();
836
            if (slug) {
837
                objFormGenerator.editSection(
838
                    $('#form-section #section-slug').val(),
839
                    $('#form-section #section-name').val(),
840
                    $('#form-section #section-text').val(),
841
                    $('#form-section #section-value').val()
842
                );
843
            } else {
844
                objFormGenerator.addSection(
845
                    $('#form-section #section-name').val(),
846
                    $('#form-section #section-text').val(),
847
                    $('#form-section #section-value').val()
848
                );
849
            }
850
            renderData(objFormGenerator.sections);
851
            $('#modal-section').modal('hide');
852
            return false;
853
        }
854
    });
855
    //IMPORTANT: update CKEDITOR textarea with actual content before submit
856
    $("#form-question").on('submit', function() {
857
        for (var instanceName in CKEDITOR.instances) {
858
            CKEDITOR.instances[instanceName].updateElement();
859
        }
860
    })
861
    var validatorFormQuestion = $("#form-question").validate({
118 steven 862
        ignore: [],
863
        errorClass: 'help-block',
864
        errorElement: 'span',
167 geraldo 865
        rules: {
866
            'question-text': {
867
                required: true,
868
            },
869
            'question-value': {
870
                required: true,
871
                number: true,
872
                min: 1
873
            },
874
            'question-type': {
875
                required: true,
876
            },
877
            'question-max-length': {
878
                required: true,
879
                digits: true,
880
                min: 0
881
            },
882
            'question-range': {
883
                required: true,
884
                number: true,
885
                min: 1
886
            },
887
        },
888
        highlight: function(element) {
118 steven 889
            $(element).closest('.form-group').addClass('has-error');
890
        },
167 geraldo 891
        unhighlight: function(element) {
118 steven 892
            $(element).closest('.form-group').removeClass('has-error');
893
        },
167 geraldo 894
        errorPlacement: function(error, element) {
118 steven 895
            if (element.attr("data-error-container")) {
896
                error.appendTo(element.attr("data-error-container"));
897
            } else {
898
                error.insertAfter(element);
899
            }
900
        },
901
        invalidHandler: function(form, validator) {
902
            if (!validator.numberOfInvalids())
903
                return;
904
            $('html, body').animate({
905
                scrollTop: $(validator.errorList[0].element).offset().top - 100
906
            }, 1000);
907
        },
167 geraldo 908
        submitHandler: function(form) {
909
            if ($('#form-question #question-slug').val()) {
910
                objFormGenerator.editQuestion(
911
                    $('#form-question #question-section').val(),
912
                    $('#form-question #question-slug').val(),
913
                    $('#form-question #question-text').val(),
914
                    $('#form-question #question-value').val(),
915
                    $('#form-question #question-type').val(),
916
                    $('#form-question #question-max-length').val(),
917
                    $('#form-question #question-multiline').val(),
918
                    $('#form-question #question-range').val()
919
                );
920
            } else {
921
                objFormGenerator.addQuestion(
922
                    $('#form-question #question-section').val(),
923
                    $('#form-question #question-text').val(),
924
                    $('#form-question #question-value').val(),
925
                    $('#form-question #question-type').val(),
926
                    $('#form-question #question-max-length').val(),
927
                    $('#form-question #question-multiline').val(),
928
                    $('#form-question #question-range').val()
929
                );
930
            }
931
            renderData(objFormGenerator.sections);
932
            $('#modal-question').modal('hide');
933
            return false;
934
        }
935
    });
936
    //IMPORTANT: update CKEDITOR textarea with actual content before submit
937
    $("#form-option").on('submit', function() {
938
        for (var instanceName in CKEDITOR.instances) {
939
            CKEDITOR.instances[instanceName].updateElement();
940
        }
941
    })
942
    var validatorFormOption = $("#form-option").validate({
118 steven 943
        ignore: [],
944
        errorClass: 'help-block',
945
        errorElement: 'span',
167 geraldo 946
        rules: {
947
            'option-text': {
948
                required: true,
949
            },
950
            'option-value': {
951
                required: true,
952
                number: true,
953
                min: 1
954
            }
955
        },
956
        highlight: function(element) {
118 steven 957
            $(element).closest('.form-group').addClass('has-error');
958
        },
167 geraldo 959
        unhighlight: function(element) {
118 steven 960
            $(element).closest('.form-group').removeClass('has-error');
961
        },
167 geraldo 962
        errorPlacement: function(error, element) {
118 steven 963
            if (element.attr("data-error-container")) {
964
                error.appendTo(element.attr("data-error-container"));
965
            } else {
966
                error.insertAfter(element);
967
            }
968
        },
969
        invalidHandler: function(form, validator) {
970
            if (!validator.numberOfInvalids())
971
                return;
972
            $('html, body').animate({
973
                scrollTop: $(validator.errorList[0].element).offset().top - 100
974
            }, 1000);
975
        },
167 geraldo 976
        submitHandler: function(form) {
977
            if ($('#form-option #option-slug').val()) {
978
                objFormGenerator.editOption(
979
                    $('#form-option #option-section').val(),
980
                    $('#form-option #option-question').val(),
981
                    $('#form-option #option-slug').val(),
982
                    $('#form-option #option-text').val(),
983
                    $('#form-option #option-correct').val(),
184 geraldo 984
                    $('#form-option #option-value').val()
167 geraldo 985
                );
986
            } else {
987
                objFormGenerator.addOption(
988
                    $('#form-option #option-section').val(),
989
                    $('#form-option #option-question').val(),
990
                    $('#form-option #option-text').val(),
991
                    $('#form-option #option-correct').val(),
184 geraldo 992
                    $('#form-option #option-value').val()
167 geraldo 993
                );
994
            }
995
            renderData(objFormGenerator.sections);
996
            $('#modal-option').modal('hide');
997
            return false;
998
        }
999
    });
1000
    $('body').on('click', 'button[id="btn-add-section"]', function(e) {
1001
        e.preventDefault();
1002
        validatorFormSection.resetForm();
1003
        $('#form-section #section-slug').val('');
1004
        $('#form-section #section-name').val('');
1005
        instanceName = 'section-text';
1006
        let editor = CKEDITOR.instances[instanceName];
1007
        editor.setData('', function() {
1008
            editor.focus();
1009
        });
1010
        $('#form-section #section-value').val('0');
1011
        $('#modal-section h4[class="modal-title"]').html('LABEL_ADD LABEL_SECTION');
1012
        $('#modal-section').modal('show');
1013
    });
1014
    $('body').on('click', 'button.btn-edit-section', function(e) {
1015
        e.preventDefault();
169 geraldo 1016
        var slug = $(this).data('section');
167 geraldo 1017
        var section;
1018
        var showForm = false;
1019
        for (i = 0; i < objFormGenerator.sections.length; i++) {
1020
            section = objFormGenerator.sections[i];
171 geraldo 1021
            if (slug == section.slug_section) {
167 geraldo 1022
                validatorFormSection.resetForm();
171 geraldo 1023
                $('#form-section #section-slug').val(section.slug_section);
167 geraldo 1024
                $('#form-section #section-name').val(section.name);
1025
                instanceName = 'section-text';
1026
                let editor = CKEDITOR.instances[instanceName];
1027
                editor.setData(section.text, function() {
1028
                    editor.focus();
1029
                });
1030
                $('#form-section #section-value').val(section.value);
1031
                showForm = true;
1032
                break;
1033
            }
1034
        }
1035
        if (showForm) {
1036
            $('#modal-section h4[class="modal-title"]').html('LABEL_EDIT LABEL_SECTION');
1037
            $('#modal-section').modal('show');
1038
        }
1039
    });
1040
    $('body').on('click', 'button.btn-delete-section', function(e) {
1041
        e.preventDefault();
169 geraldo 1042
        var slug = $(this).data('section');
167 geraldo 1043
        bootbox.confirm({
1044
            title: "LABEL_DELETE LABEL_SECTION",
1045
            message: "LABEL_QUESTION_DELETE",
1046
            buttons: {
1047
                cancel: {
1048
                    label: '<i class="fa fa-times"></i> LABEL_CANCEL'
1049
                },
1050
                confirm: {
1051
                    label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
1052
                }
1053
            },
1054
            callback: function(result) {
1055
                if (result) {
1056
                    objFormGenerator.deleteSection(slug);
1057
                    renderData(objFormGenerator.sections);
1058
                }
1059
            }
1060
        });
1061
    });
1062
    $('body').on('click', 'button.btn-add-question', function(e) {
1063
        e.preventDefault();
1064
        validatorFormQuestion.resetForm();
169 geraldo 1065
        var slug = $(this).data('section');
167 geraldo 1066
        $('#form-question #question-section').val(slug);
1067
        $('#form-question #question-slug').val('');
1068
        instanceName = 'question-text';
1069
        let editor = CKEDITOR.instances[instanceName];
1070
        editor.setData('', function() {
1071
            editor.focus();
1072
        });
1073
        $('#form-question #question-value').val('0');
1074
        $('#form-question #question-type').val($('#form-question #question-type option:first').val());
1075
        $('#form-question #question-max-length').val('0');
1076
        $('#form-question #question-max-length').parent().show();
1077
        $('#form-question #question-multiline').val('0');
1078
        $('#form-question #question-multiline').parent().show();
1079
        $('#form-question #question-range').val('10');
1080
        $('#form-question #question-range').parent().hide();
1081
        $('#modal-question h4[class="modal-title"]').html('LABEL_ADD LABEL_QUESTION');
1082
        $('#modal-question').modal('show');
1083
    });
1084
    $('body').on('click', 'button.btn-edit-question', function(e) {
1085
        e.preventDefault();
1086
        var slug_section = $(this).data('section');
170 geraldo 1087
        var slug = $(this).data('question');
167 geraldo 1088
        var showForm = false;
1089
        for (i = 0; i < objFormGenerator.sections.length; i++) {
1090
            if (slug_section == objFormGenerator.sections[i].slug_section) {
1091
                for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
1092
                    if (slug == objFormGenerator.sections[i].questions[j].slug_question) {
1093
                        validatorFormQuestion.resetForm();
1094
                        $('#form-question #question-section').val(objFormGenerator.sections[i].slug_section);
1095
                        $('#form-question #question-slug').val(objFormGenerator.sections[i].questions[j].slug_question);
1096
                        instanceName = 'question-text';
1097
                        let editor = CKEDITOR.instances[instanceName];
1098
                        editor.setData(objFormGenerator.sections[i].questions[j].text, function() {
1099
                            editor.focus();
1100
                        });
1101
                        $('#form-question #question-value').val(objFormGenerator.sections[i].questions[j].value);
1102
                        $('#form-question #question-type').val(objFormGenerator.sections[i].questions[j].type);
1103
                        if (objFormGenerator.sections[i].questions[j].type == 'open') {
1104
                            $('#form-question #question-max-length').val(objFormGenerator.sections[i].questions[j].maxlength);
1105
                            $('#form-question #question-max-length').parent().show();
1106
                            $('#form-question #question-multiline').val(objFormGenerator.sections[i].questions[j].multiline);
1107
                            $('#form-question #question-multiline').parent().show();
118 steven 1108
                        } else {
167 geraldo 1109
                            $('#form-question #question-max-length').val('0');
1110
                            $('#form-question #question-max-length').parent().hide();
1111
                            $('#form-question #question-multiline').val('0');
1112
                            $('#form-question #question-multiline').parent().hide();
118 steven 1113
                        }
167 geraldo 1114
                        if (objFormGenerator.sections[i].questions[j].type == 'rating-range') {
1115
                            $('#form-question #question-range').val(objFormGenerator.sections[i].questions[j].range);
1116
                            $('#form-question #question-range').parent().show();
1117
                        } else {
1118
                            $('#form-question #question-range').val('10');
1119
                            $('#form-question #question-range').parent().hide();
1120
                        }
1121
                        showForm = true;
1122
                        break;
1123
                    }
1124
                }
1125
                break;
1126
            }
1127
        }
1128
        if (showForm) {
1129
            $('#modal-question h4[class="modal-title"]').html('LABEL_EDIT LABEL_QUESTION');
1130
            $('#modal-question').modal('show');
1131
        }
1132
    });
1133
    $('body').on('click', 'button.btn-delete-question', function(e) {
1134
        e.preventDefault();
1135
        var slug_section = $(this).data('section');
170 geraldo 1136
        var slug = $(this).data('question');
167 geraldo 1137
        bootbox.confirm({
1138
            title: "LABEL_DELETE LABEL_QUESTION",
1139
            message: "LABEL_QUESTION_DELETE",
1140
            buttons: {
1141
                cancel: {
1142
                    label: '<i class="fa fa-times"></i> LABEL_CANCEL'
1143
                },
1144
                confirm: {
1145
                    label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
1146
                }
1147
            },
1148
            callback: function(result) {
1149
                if (result) {
1150
                    objFormGenerator.deleteQuestion(slug_section, slug);
1151
                    renderData(objFormGenerator.sections);
1152
                }
1153
            }
1154
        });
1155
    });
172 geraldo 1156
 
180 geraldo 1157
     /**
1158
      * Get Question type
1159
      */
181 geraldo 1160
     const getQuestionTypeBySlug = (slug_section, slug_question) => {
180 geraldo 1161
         for (i = 0; i < objFormGenerator.sections.length; i++) {
1162
             if (slug_section == objFormGenerator.sections[i].slug_section) {
1163
                 for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
1164
                     if (slug_question == objFormGenerator.sections[i].questions[j].slug_question) {
1165
                         return objFormGenerator.sections[i].questions[j].type;
1166
                     }
1167
                 }
1168
             }
1169
         }
1170
     }
1171
 
1172
     /**
1173
      * Render Sections data
1174
      */
1175
     const renderData = (data) => $("#rows").html($("#sectionTemplate").render(data, {
1176
         getType: getQuestionTypeBySlug
1177
     }));
1178
 
167 geraldo 1179
    $('body').on('click', 'button.btn-add-option', function(e) {
1180
        e.preventDefault();
1181
        var slug_section = $(this).data('section');
1182
        var slug_question = $(this).data('question');
1183
        var showForm = false;
1184
        for (i = 0; i < objFormGenerator.sections.length; i++) {
1185
            if (slug_section == objFormGenerator.sections[i].slug_section) {
1186
                for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
1187
                    if (slug_question == objFormGenerator.sections[i].questions[j].slug_question) {
1188
                        validatorFormOption.resetForm();
1189
                        $('#form-option #option-section').val(slug_section);
1190
                        $('#form-option #option-question').val(slug_question);
1191
                        $('#form-option #option-slug').val('');
1192
                        instanceName = 'option-text';
1193
                        let editor = CKEDITOR.instances[instanceName];
1194
                        editor.setData('', function() {
1195
                            editor.focus();
1196
                        });
1197
                        $('#form-option #option-correct').val('0');
1198
                        if (objFormGenerator.sections[i].questions[j].type == 'rating-open') {
1199
                            $('#form-option #option-correct').parent().hide();
1200
                        } else {
1201
                            $('#form-option #option-correct').parent().show();
1202
                        }
1203
                        if (objFormGenerator.sections[i].questions[j].type == 'multiple' || objFormGenerator.sections[i].questions[j].type == 'rating-open') {
1204
                            $('#form-option #option-value').val('0');
1205
                            $('#form-option #option-value').parent().show();
1206
                        } else {
1207
                            $('#form-option #option-value').val('1');
1208
                            $('#form-option #option-value').parent().hide();
1209
                        }
1210
                        renderData(objFormGenerator.sections);
1211
                        showForm = true;
1212
                    }
1213
                }
1214
            }
1215
        }
1216
        if (showForm) {
1217
            $('#modal-option h4[class="modal-title"]').html('LABEL_ADD LABEL_OPTION');
1218
            $('#modal-option').modal('show');
1219
        }
1220
    });
171 geraldo 1221
 
167 geraldo 1222
    $('body').on('click', 'button.btn-edit-option', function(e) {
1223
        e.preventDefault();
1224
        var slug_section = $(this).data('section');
1225
        var slug_question = $(this).data('question');
1226
        var slug = $(this).data('slug');
1227
        var showForm = false;
1228
        for (i = 0; i < objFormGenerator.sections.length; i++) {
1229
            if (slug_section == objFormGenerator.sections[i].slug_section) {
1230
                for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
1231
                    if (slug_question == objFormGenerator.sections[i].questions[j].slug_question) {
1232
                        for (k = 0; k < objFormGenerator.sections[i].questions[j].options.length; k++) {
1233
                            if (slug == objFormGenerator.sections[i].questions[j].options[k].slug_option) {
1234
                                validatorFormOption.resetForm();
1235
                                $('#form-option #option-section').val(objFormGenerator.sections[i].slug_section);
1236
                                $('#form-option #option-question').val(objFormGenerator.sections[i].questions[j].slug_question);
1237
                                $('#form-option #option-slug').val(objFormGenerator.sections[i].questions[j].options[k].slug_option);
1238
                                instanceName = 'option-text';
1239
                                let editor = CKEDITOR.instances[instanceName];
1240
                                editor.setData(objFormGenerator.sections[i].questions[j].options[k].text, function() {
1241
                                    editor.focus();
1242
                                });
1243
                                $('#form-option #option-correct').val(objFormGenerator.sections[i].questions[j].options[k].correct);
1244
                                if (objFormGenerator.sections[i].questions[j].type == 'multiple' || objFormGenerator.sections[i].questions[j].type == 'simple') {
1245
                                    $('#form-option #option-correct').parent().show();
1246
                                } else {
1247
                                    $('#form-option #option-correct').parent().hide();
1248
                                }
1249
                                $('#form-option #option-value').val(objFormGenerator.sections[i].questions[j].options[k].value);
1250
                                if (objFormGenerator.sections[i].questions[j].type == 'multiple' || objFormGenerator.sections[i].questions[j].type == 'rating-open') {
1251
                                    $('#form-option #option-value').parent().show();
1252
                                } else {
1253
                                    $('#form-option #option-value').parent().hide();
1254
                                }
1255
                                showForm = true;
1256
                                break;
1257
                            }
1258
                        }
1259
                    }
1260
                    if (showForm) {
1261
                        break;
1262
                    }
1263
                }
1264
            }
1265
            if (showForm) {
1266
                break;
1267
            }
1268
        }
1269
        if (showForm) {
1270
            $('#modal-option h4[class="modal-title"]').html('LABEL_EDIT LABEL_OPTION');
1271
            $('#modal-option').modal('show');
1272
        }
1273
    });
1274
    $('body').on('click', 'button.btn-delete-option', function(e) {
1275
        e.preventDefault();
1276
        var slug_section = $(this).data('section');
1277
        var slug_question = $(this).data('question');
1278
        var slug = $(this).data('slug');
1279
        bootbox.confirm({
1280
            title: "LABEL_DELETE LABEL_OPTION",
1281
            message: "LABEL_QUESTION_DELETE",
1282
            buttons: {
1283
                cancel: {
1284
                    label: '<i class="fa fa-times"></i> LABEL_CANCEL'
1285
                },
1286
                confirm: {
1287
                    label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
1288
                }
1289
            },
1290
            callback: function(result) {
1291
                if (result) {
1292
                    objFormGenerator.deleteOption(slug_section, slug_question, slug);
1293
                    renderData(objFormGenerator.sections);
1294
                }
1295
            }
1296
        });
1297
    })
1298
    $('#form-section #section-value').inputNumberFormat({
1299
        'decimal': 2
1300
    });
1301
    $('#form-question #question-value').inputNumberFormat({
1302
        'decimal': 2
1303
    });
1304
    $('#form-question #question-max-length').inputNumberFormat({
1305
        'decimal': 0
1306
    });
1307
    $('#form-option #option-value').inputNumberFormat({
1308
        'decimal': 2
1309
    });
1310
    $('#form-question #question-type').change(function(e) {
1311
        e.preventDefault();
1312
        if ($('#form-question #question-type').val() == 'open') {
1313
            $('#form-question #question-max-length').parent().show();
1314
            $('#form-question #question-multiline').parent().show();
1315
        } else {
1316
            $('#form-question #question-max-length').val('0');
1317
            $('#form-question #question-max-length').parent().hide();
1318
            $('#form-question #question-multiline').val('0');
1319
            $('#form-question #question-multiline').parent().hide();
1320
        }
1321
        $('#form-question #question-range').val('10');
1322
        if ($('#form-question #question-type').val() == 'rating-range') {
1323
            $('#form-question #question-range').parent().show();
1324
        } else {
1325
            $('#form-question #question-range').parent().hide();
1326
        }
1327
    });
1328
    $('button.btn-add-form').click(function(e) {
1329
        e.preventDefault();
1330
        objFormGenerator.clear();
1331
        objFormGenerator.render();
1332
        validatorForm.resetForm();
1333
        $('#form-main #form-id').val('0');
1334
        $('#form-main #form-continue').val('0');
1335
        $('#form-main #form-name').val('');
1336
        instanceName = 'form-text';
1337
        let editor = CKEDITOR.instances[instanceName];
1338
        editor.setData('', function() {
1339
            editor.focus();
1340
        });
1341
        instanceName = 'form-description';
1342
        CKEDITOR.instances[instanceName].setData('');
1343
        $('#form-main #form-language').val('$lang_es'),
1344
            $('#form-main #form-status').val('$status_inactive');
1345
        $('#row-forms').hide();
1346
        $('#row-edit').show();
1347
        $('#form-main #form-name').focus();
1348
    });
1349
    $('button.btn-edit-cancel').click(function(e) {
1350
        e.preventDefault();
1351
        $('#row-edit').hide();
1352
        $('#row-forms').show();
1353
    });
1354
    $('button.btn-form-save-continue').click(function(e) {
1355
        e.preventDefault();
1356
        $('#form-main #form-continue').val('1')
1357
        $('#form-main').submit();
1358
    });
1359
    $('button.btn-form-save-close').click(function(e) {
1360
        e.preventDefault();
1361
        $('#form-main #form-continue').val('0')
1362
        $('#form-main').submit();
1363
    });
1364
    $('#modal-section, #modal-question, #modal-option').modal({
1365
        backdrop: 'static',
1366
        keyboard: false,
1367
        show: false
1368
    });
1369
});
118 steven 1370
JS;
115 efrain 1371
$this->inlineScript()->captureEnd();
1372
?>
118 steven 1373
 
121 steven 1374
<style type="text/css">
135 geraldo 1375
    tbody input[type="checkbox"]{
1376
        margin-left: 14px;
1377
    }
1378
    .panel-heading .accordion-toggle:after {
1379
        /* symbol for "opening" panels */
1380
        display: inline-block;
1381
        font: normal normal normal 14px/1 FontAwesome;
1382
        font-size: inherit;
1383
        content: "\f077" ;
1384
        float: right;        /* adjust as needed */
1385
        color: grey;         /* adjust as needed */
1386
        text-rendering: auto;
1387
        -webkit-font-smoothing: antialiased;
1388
    }
1389
    .panel-heading .accordion-toggle.collapsed:after {
1390
        /* symbol for "collapsed" panels */
1391
        content: "\f078";    /* adjust as needed, taken from bootstrap.css */
1392
    }
121 steven 1393
</style>
115 efrain 1394
<!-- Content Header (Page header) -->
1395
<section class="content-header">
135 geraldo 1396
    <div class="container-fluid">
1397
        <div class="row mb-2">
1398
            <div class="col-sm-12">
1399
                <h1>LABEL_SELF_EVALUATION_FORMS</h1>
1400
            </div>
1401
        </div>
145 geraldo 1402
    </div>
1403
    <!-- /.container-fluid -->
115 efrain 1404
</section>
1405
<section class="content">
135 geraldo 1406
    <div class="container-fluid" id="row-forms">
1407
        <div class="row">
1408
            <div class="col-12">
145 geraldo 1409
                <div class="card">
135 geraldo 1410
                    <div class="card-body">
153 geraldo 1411
                        <table id="gridTable" class="table   table-hover">
1412
                            <thead>
1413
                                <tr>
1414
                                    <th>LABEL_NAME</th>
1415
                                    <th>LABEL_LANGUAGE</th>
1416
                                    <th>LABEL_ACTIVE</th>
1417
                                    <th>LABEL_ACTIONS</th>
1418
                                </tr>
1419
                            </thead>
155 geraldo 1420
                            <tbody></tbody>
153 geraldo 1421
                        </table>
135 geraldo 1422
                    </div>
1423
                    <div class="card-footer clearfix">
1424
                        <div style="float:right;">
1425
                            <button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH </button>
1426
                            <?php if ($allowAdd) : ?>
1427
                                <button type="button" class="btn btn-primary btn-add-form"><i class="fa fa-plus"></i> LABEL_ADD </button>
1428
                            <?php endif; ?>
1429
                        </div>
1430
                    </div>
1431
                </div>
145 geraldo 1432
            </div>
1433
        </div>
135 geraldo 1434
    </div>
154 geraldo 1435
 
155 geraldo 1436
    <!-- Create/Edit Form -->
174 geraldo 1437
 
1438
    <div class="row" id="row-edit" style="display: none">
1439
        <div class="col-xs-12 col-md-12">
1440
            <form action="#" name="form-main" id="form-main">
1441
                <input type="hidden" name="form-id" id="form-id" value="0" />
1442
                <input type="hidden" name="form-continue" id="form-continue" value="0" />
1443
                <div class="form-group">
1444
                    <label for="form-name">LABEL_FIRST_NAME</label>
1445
                    <input type="text" name="form-name" id="form-name" class="form-control" maxlength="50" />
1446
                </div>
1447
                <div class="form-group">
1448
                    <label for="form-description">LABEL_DESCRIPTION</label>
1449
                    <!--  ckeditor -->
1450
                    <textarea  name="form-description" id="form-description" rows="5" class="ckeditor form-control"></textarea>
1451
                </div>
1452
                <div class="form-group">
1453
                    <label for="form-text">LABEL_TEXT</label>
1454
                    <!--  ckeditor -->
1455
                    <textarea  name="form-text" id="form-text" rows="5" class="ckeditor form-control"></textarea>
1456
                </div>
1457
                <div class="form-group">
1458
                    <label for="form-language">LABEL_LANGUAGES</label>
1459
                    <select name="form-language" id="form-language" class="form-control">
176 geraldo 1460
                        <option value="<?php echo $lang_en; ?>">LABEL_ENGLISH</option>
1461
                        <option value="<?php echo $lang_es; ?>">LABEL_SPANISH</option>
174 geraldo 1462
                    </select>
1463
                </div>
1464
                <div class="form-group">
1465
                    <label for="form-status">LABEL_STATUS</label>
1466
                    <select name="form-status" id="form-status" class="form-control">
176 geraldo 1467
                        <option value="<?php echo $status_inactive; ?>">LABEL_INACTIVE</option>
1468
                        <option value="<?php echo $status_active; ?>">LABEL_ACTIVE</option>
174 geraldo 1469
                    </select>
1470
                </div>
1471
                <br/>
1472
                <div class="row">
1473
                    <div class="col-xs-12 col-md-12 text-right">
1474
                        <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>
1475
                    </div>
1476
                </div>
1477
                <br />
1478
                <div class="row">
1479
                    <div class="col-xs-12 col-md-12">
1480
                        <div class="panel-group" id="rows"></div>
1481
                    </div>
1482
                </div>
1483
                <div class="form-group">
1484
                    <button type="submit" form="form-main" class="btn btn-info btn-form-save-continue">LABEL_SAVE & LABEL_CONTINUE</button>
1485
                    <button type="button" class="btn btn-primary btn-form-save-close">LABEL_SAVE & LABEL_CLOSE</button>
1486
                    <button type="button" class="btn btn-secondary btn-edit-cancel">LABEL_CANCEL</button>
1487
                </div>
1488
            </form>
1489
        </div>
1490
    </div>
1491
 
155 geraldo 1492
    <!-- Create/Edit Form-->
154 geraldo 1493
 
135 geraldo 1494
    <!-- Section Modal -->
174 geraldo 1495
    <div  id="modal-section" class="modal" tabindex="-1" role="dialog">
1496
        <div class="modal-dialog modal-lg" role="document">
1497
            <form action="#" name="form-section" id="form-section">
1498
                <input type="hidden" name="section-slug" id="section-slug" value="" />
1499
                <div class="modal-content">
1500
                    <div class="modal-header">
1501
                        <h4 class="modal-title">LABEL_ADD LABEL_SECTION</h4>
1502
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
1503
                            <span aria-hidden="true">&times;</span>
1504
                        </button>
1505
                    </div>
1506
                    <div class="modal-body">
1507
                        <div class="form-group">
1508
                            <label for="section-name">LABEL_FIRST_NAME</label>
1509
                            <input type="text" name="section-name" id="section-name" class="form-control" maxlength="50" value="" />
1510
                        </div>
1511
                        <div class="form-group">
1512
                            <label for="section-text">LABEL_TEXT</label>
1513
                            <!--  ckeditor -->
1514
                            <textarea  name="section-text" id="section-text" rows="5" class="ckeditor form-control"></textarea>
1515
                        </div>
1516
                        <div class="form-group">
1517
                            <label for="section-value">LABEL_VALUE</label>
1518
                            <input type="text" name="section-value" id="section-value"  class="form-control" value="0" />
1519
                        </div>
1520
                    </div>
1521
                    <div class="modal-footer">
1522
                        <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
1523
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
1524
                    </div>
1525
                </div>
1526
            </form>
1527
        </div>
1528
    </div>
135 geraldo 1529
    <!-- End Modal Section -->
153 geraldo 1530
 
135 geraldo 1531
    <!-- Question Modal -->
156 geraldo 1532
 
174 geraldo 1533
    <div  id="modal-question" class="modal" tabindex="-1" role="dialog">
1534
        <div class="modal-dialog modal-lg" role="document">
1535
            <form action="#" name="form-question" id="form-question">
1536
                <input type="hidden" name="question-section" id="question-section" />
1537
                <input type="hidden" name="question-slug" id="question-slug" />
1538
                <div class="modal-content">
1539
                    <div class="modal-header">
1540
                        <h4 class="modal-title">LABEL_ADD LABEL_QUESTION</h4>
1541
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
1542
                            <span aria-hidden="true">&times;</span>
1543
                        </button>
1544
                    </div>
1545
                    <div class="modal-body">
1546
                        <div class="form-group">
1547
                            <label for="question-text">LABEL_TEXT</label>
1548
                            <!--  ckeditor -->
1549
                            <textarea  name="question-text" id="question-text" rows="5" class="ckeditor form-control"></textarea>
1550
                        </div>
1551
                        <div class="form-group">
1552
                            <label for="question-value">LABEL_VALUE</label>
1553
                            <input type="text" name="question-value" id="question-value"  class="form-control" />
1554
                        </div>
1555
                        <div class="form-group">
1556
                            <label for="question-type">LABEL_TYPE</label>
1557
                            <select name="question-type" id="question-type" class="form-control">
1558
                                <option value="open">LABEL_OPEN</option>
1559
                                <option value="simple">Simple</option>
1560
                                <option value="multiple">Multiple</option>
1561
                                <option value="rating-open">LABEL_RATING_OPEN</option>
1562
                                <option value="rating-range">LABEL_RATING_RANGE</option>
1563
                            </select>
1564
                        </div>
1565
                        <div class="form-group">
1566
                            <label for="question-max-length">LABEL_MAXLENGTH</label>
1567
                            <input type="text" name="question-max-length" id="question-max-length"  class="form-control" />
1568
                        </div>
1569
                        <div class="form-group">
1570
                            <label for="question-multiline">LABEL_MULTI_LINE</label>
1571
                            <select name="question-multiline" id="question-multiline" class="form-control">
1572
                                <option value="1">LABEL_YES</option>
1573
                                <option value="0">LABEL_NOT</option>
1574
                            </select>
1575
                        </div>
1576
                        <div class="form-group">
1577
                            <label for="question-range">LABEL_RANGE</label>
1578
                            <select name="question-range" id="question-range" class="form-control">
1579
                                <option value="10">1-10</option>
1580
                                <option value="6">1-6</option>
1581
                                <option value="5">1-5</option>
1582
                            </select>
1583
                        </div>
1584
                    </div>
1585
                    <div class="modal-footer">
1586
                        <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
1587
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
1588
                    </div>
1589
                </div>
1590
            </form>
1591
        </div>
1592
    </div>
156 geraldo 1593
 
167 geraldo 1594
    <!-- End Modal Question -->
153 geraldo 1595
 
1596
    <!-- Modal Options -->
156 geraldo 1597
 
174 geraldo 1598
    <div  id="modal-option" class="modal" tabindex="-1" role="dialog">
1599
        <div class="modal-dialog modal-lg" role="document">
1600
            <form action="#" name="form-option" id="form-option">
1601
                <input type="hidden" name="option-section" id="option-section" value="" />
1602
                <input type="hidden" name="option-question" id="option-question" value="" />
1603
                <input type="hidden" name="option-slug" id="option-slug" value="" />
1604
                <div class="modal-content">
1605
                    <div class="modal-header">
1606
                        <h4 class="modal-title">LABEL_OPTION</h4>
1607
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
1608
                            <span aria-hidden="true">&times;</span>
1609
                        </button>
1610
                    </div>
1611
                    <div class="modal-body">
1612
                        <div class="form-group">
1613
                            <label for="option-text">LABEL_TEXT</label>
1614
                            <!--  ckeditor -->
1615
                            <textarea  name="option-text" id="option-text" rows="5" class="ckeditor form-control"></textarea>
1616
                        </div>
1617
                        <div class="form-group">
1618
                            <label for="option-correct">LABEL_ANSWER_CORRECT</label>
1619
                            <select name="option-correct" id="option-correct" class="form-control">
1620
                                <option value="1">LABEL_YES</option>
1621
                                <option value="0">LABEL_NOT</option>
1622
                            </select>
1623
                        </div>
1624
                        <div class="form-group">
1625
                            <label for="option-value">LABEL_VALUE</label>
1626
                            <input type="text" name="option-value" id="option-value" class="form-control" />
1627
                        </div>
1628
                    </div>
1629
                    <div class="modal-footer">
1630
                        <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
1631
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
1632
                    </div>
1633
                </div>
1634
            </form>
1635
        </div>
1636
    </div>
1637
 
135 geraldo 1638
    <!-- End Modal Options -->
153 geraldo 1639
 
180 geraldo 1640
    <!---Template Sections --->
1641
    <script id="sectionTemplate" type="text/x-jsrender">
1642
    <div class="panel panel-default" id="panel-{{:slug_section}}">
1643
        <div class="panel-heading">
1644
            <h4 class="panel-title">
1645
                <a class="accordion-toggle" data-toggle="collapse" aria-expanded="true" data-parent="#panel-{{:slug_section}}" href="#collapse-{{:slug_section}}">
1646
                    <span class="section-name{{:slug_section}}">
1647
                        {{:name}}
1648
                    </span>
1649
                </a>
1650
            </h4>
1651
        </div>
1652
        <div id="collapse-{{:slug_section}}" class="panel-collapse in collapse show">
1653
            <div class="panel-body">
1654
                <div class="table-responsive">
1655
                    <table class="table table-bordered">
1656
                        <thead>
1657
                            <tr>
1658
                                <th>LABEL_ELEMENT</th>
1659
                                <th>LABEL_TEXT</th>
1660
                                <th>LABEL_VALUE</th>
1661
                                <th>LABEL_TYPE</th>
1662
                                <th>LABEL_ACTIONS</th>
1663
                            </tr>
1664
                        </thead>
1665
                        <tbody>
1666
                            <tr class="tr-section">
1667
                                <td class="text-left">LABEL_SECTION</td>
1668
                                <td class="text-left">{{:name}}</td>
1669
                                <td>{{:value}}</td>
1670
                                <td></td>
1671
                                <td>
1672
                                    <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>
1673
                                    <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>
1674
                                    <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>
1675
                                </td>
1676
                            </tr>
1677
                            {{for questions}}
1678
                            <tr class="tr-question">
1679
                                <td class="text-left">--LABEL_QUESTION</td>
1680
                                <td class="text-left">
1681
                                    {{:text}}
1682
                                </td>
1683
                                <td><font color="red">{{:value}}</font></td>
1684
                                <td class="text-capitalize">
1685
                                    {{if type == 'open'}} LABEL_OPEN {{/if}}
1686
                                    {{if type == 'simple'}} Simple {{/if}}
1687
                                    {{if type == 'multiple'}} Multiple {{/if}}
1688
                                    {{if type == 'rating-open'}} LABEL_RATING_OPEN {{/if}}
1689
                                    {{if type == 'rating-range'}} LABEL_RATING_RANGE {{/if}}
1690
                                </td>
1691
                                <td>
1692
                                    <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>
1693
                                    <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>
1694
                                    <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>
1695
                                </td>
1696
                            </tr>
1697
                            {{for options}}
1698
                            <tr class="tr-option">
1699
                                <td class="text-left">---LABEL_OPTION</td>
1700
                                <td class="text-left">
1701
                                    {{:text}}
1702
                                </td>
1703
                                <td>
153 geraldo 1704
 
186 geraldo 1705
                                    {{if ~getType( slug_section, slug_question) == 'multiple' || ~getType( slug_section, slug_question) == 'rating-open'  }}
1706
                                    {{:value}}
1707
                                    {{/if}}
180 geraldo 1708
                                </td>
1709
                                <td class="text-left">
186 geraldo 1710
                                    {{if ~getType( slug_section, slug_question) != rating-open'}}
1711
                                    {{if correct == 1}}
1712
                                    <font color="green">LABEL_CORRECT</font>
1713
                                    {{/if}}
1714
                                    {{if correct == 0}}
1715
                                    <font color="red">LABEL_FAIL</font>
1716
                                    {{/if}}
1717
                                    {{/if}}
180 geraldo 1718
                                </td>
1719
                                <td>
1720
                                    <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>
1721
                                    <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>
1722
                                </td>
1723
                            </tr>
1724
                            {{/for}}
1725
                            {{/for}}
1726
                        </tbody>
1727
                    </table>
1728
                </div>
1729
            </div>
1730
        </div>
1731
    </div>
1732
    </script>
1733
 
1734
    <!-- End Template Sections-->
1735
 
119 steven 1736
</section>