Proyectos de Subversion LeadersLinked - Backend

Rev

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