Proyectos de Subversion LeadersLinked - Backend

Rev

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