Proyectos de Subversion LeadersLinked - Backend

Rev

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