Proyectos de Subversion LeadersLinked - Backend

Rev

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

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