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