| 66 | efrain | 1 | <?php
 | 
        
           |  |  | 2 | use LeadersLinked\Model\CompanyMicrolearningQuiz;
 | 
        
           |  |  | 3 |   | 
        
           |  |  | 4 | $acl            = $this->viewModel()->getRoot()->getVariable('acl');
 | 
        
           |  |  | 5 | $currentUser    = $this->currentUserHelper();
 | 
        
           |  |  | 6 | $roleName       = $currentUser->getUserTypeId();
 | 
        
           |  |  | 7 |   | 
        
           |  |  | 8 | $params = [
 | 
        
           |  |  | 9 |     'quiz_id' => $quiz_uuid,
 | 
        
           |  |  | 10 | ];
 | 
        
           |  |  | 11 |   | 
        
           |  |  | 12 | $routeAdd       = $this->url('microlearning/content/quizzes/questions/add', $params);
 | 
        
           |  |  | 13 | $routeDatatable  = $this->url('microlearning/content/quizzes/questions', $params);
 | 
        
           |  |  | 14 |   | 
        
           |  |  | 15 | $allowAdd       = $acl->isAllowed($roleName, 'microlearning/content/quizzes/questions/add') ? 1 : 0;
 | 
        
           |  |  | 16 | $allowEdit      = $acl->isAllowed($roleName, 'microlearning/content/quizzes/questions/edit') ? 1 : 0;
 | 
        
           |  |  | 17 | $allowDelete    = $acl->isAllowed($roleName, 'microlearning/content/quizzes/questions/delete') ? 1 : 0;
 | 
        
           |  |  | 18 | $allowAnswer    = $acl->isAllowed($roleName, 'microlearning/content/quizzes/questions/answers') ? 1 : 0;
 | 
        
           |  |  | 19 |   | 
        
           |  |  | 20 | $this->headLink()->appendStylesheet($this->basePath('plugins/nprogress/nprogress.css'));
 | 
        
           |  |  | 21 | $this->inlineScript()->appendFile($this->basePath('plugins/nprogress/nprogress.js'));
 | 
        
           |  |  | 22 |   | 
        
           |  |  | 23 | $this->headLink()->appendStylesheet($this->basePath('plugins/datatables-bs4/css/dataTables.bootstrap4.min.css'));
 | 
        
           |  |  | 24 | $this->headLink()->appendStylesheet($this->basePath('plugins/datatables-responsive/css/responsive.bootstrap4.min.css'));
 | 
        
           |  |  | 25 |   | 
        
           |  |  | 26 | $this->inlineScript()->appendFile($this->basePath('plugins/datatables/jquery.dataTables.min.js'));
 | 
        
           |  |  | 27 | $this->inlineScript()->appendFile($this->basePath('plugins/datatables-bs4/js/dataTables.bootstrap4.min.js'));
 | 
        
           |  |  | 28 | $this->inlineScript()->appendFile($this->basePath('plugins/datatables-responsive/js/dataTables.responsive.min.js'));
 | 
        
           |  |  | 29 | $this->inlineScript()->appendFile($this->basePath('plugins/datatables-responsive/js/responsive.bootstrap4.min.js'));
 | 
        
           |  |  | 30 |   | 
        
           |  |  | 31 |   | 
        
           |  |  | 32 | $this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap4-toggle/css/bootstrap4-toggle.min.css'));
 | 
        
           |  |  | 33 | $this->inlineScript()->appendFile($this->basePath('plugins/bootstrap4-toggle/js/bootstrap4-toggle.min.js'));
 | 
        
           |  |  | 34 |   | 
        
           |  |  | 35 | $this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-confirmation/dist/bootstrap-confirmation.js'));
 | 
        
           |  |  | 36 | $this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-checkbox/awesome-bootstrap-checkbox.css'));
 | 
        
           |  |  | 37 |   | 
        
           |  |  | 38 |   | 
        
           |  |  | 39 |   | 
        
           |  |  | 40 |   | 
        
           |  |  | 41 | $this->inlineScript()->appendFile($this->basePath('plugins/ckeditor/ckeditor.js'));
 | 
        
           |  |  | 42 | $this->inlineScript()->appendFile($this->basePath('plugins/jquery-input-number/input-number-format.jquery.js'));
 | 
        
           |  |  | 43 |   | 
        
           |  |  | 44 | $this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-confirmation/dist/bootstrap-confirmation.js'));
 | 
        
           |  |  | 45 |   | 
        
           |  |  | 46 |   | 
        
           |  |  | 47 | $this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/jquery.validate.js'));
 | 
        
           |  |  | 48 | $this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/additional-methods.js'));
 | 
        
           |  |  | 49 | $this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/localization/messages_es.js'));
 | 
        
           |  |  | 50 |   | 
        
           |  |  | 51 |   | 
        
           |  |  | 52 | $this->inlineScript()->captureStart();
 | 
        
           |  |  | 53 | echo <<<JS
 | 
        
           |  |  | 54 |   | 
        
           |  |  | 55 | var allowAdd = $allowAdd;
 | 
        
           |  |  | 56 | var allowEdit = $allowEdit;
 | 
        
           |  |  | 57 | var allowDelete = $allowDelete;
 | 
        
           |  |  | 58 | var allowAnswer = $allowAnswer;
 | 
        
           |  |  | 59 |   | 
        
           |  |  | 60 | jQuery( document ).ready(function( $ ) {
 | 
        
           |  |  | 61 |   | 
        
           |  |  | 62 |     var gridTable = $('#gridTable').dataTable( {
 | 
        
           |  |  | 63 |             'processing': true,
 | 
        
           |  |  | 64 |             'serverSide': true,
 | 
        
           |  |  | 65 |             'searching': true,
 | 
        
           |  |  | 66 |             'order': [[ 0, 'asc' ]],
 | 
        
           |  |  | 67 |             'ordering':  true,
 | 
        
           |  |  | 68 |             'ordenable' : true,
 | 
        
           |  |  | 69 |             'responsive': true,
 | 
        
           |  |  | 70 |             'select' : false,
 | 
        
           |  |  | 71 |         	'paging': true,
 | 
        
           |  |  | 72 |             'pagingType': 'simple_numbers',
 | 
        
           |  |  | 73 |     		'ajax': {
 | 
        
           |  |  | 74 |     			'url' : '$routeDatatable',
 | 
        
           |  |  | 75 |     			'type' : 'get',
 | 
        
           |  |  | 76 |                 'beforeSend': function (request) {
 | 
        
           |  |  | 77 |                   NProgress.start();
 | 
        
           |  |  | 78 |                 },
 | 
        
           |  |  | 79 |                 'dataFilter': function(response) {
 | 
        
           |  |  | 80 |                     var response = jQuery.parseJSON( response );
 | 
        
           |  |  | 81 |   | 
        
           |  |  | 82 |                     var json                = {};
 | 
        
           |  |  | 83 |                     json.recordsTotal       = 0;
 | 
        
           |  |  | 84 |                     json.recordsFiltered    = 0;
 | 
        
           |  |  | 85 |                     json.data               = [];
 | 
        
           |  |  | 86 |   | 
        
           |  |  | 87 |   | 
        
           |  |  | 88 |                     if(response.success) {
 | 
        
           |  |  | 89 |                         json.recordsTotal       = response.data.total;
 | 
        
           |  |  | 90 |                         json.recordsFiltered    = response.data.total;
 | 
        
           |  |  | 91 |                         json.data               = response.data.items;
 | 
        
           |  |  | 92 |                     } else {
 | 
        
           |  |  | 93 |                         $.fn.showError(response.data)
 | 
        
           |  |  | 94 |                     }
 | 
        
           |  |  | 95 |   | 
        
           |  |  | 96 |                     return JSON.stringify( json );
 | 
        
           |  |  | 97 |                 }
 | 
        
           |  |  | 98 |     		},
 | 
        
           |  |  | 99 |             'language' : {
 | 
        
           |  |  | 100 |                 'sProcessing':     'LABEL_DATATABLE_SPROCESSING',
 | 
        
           |  |  | 101 |                 'sLengthMenu':     'LABEL_DATATABLE_SLENGTHMENU',
 | 
        
           |  |  | 102 |                 'sZeroRecords':    'LABEL_DATATABLE_SZERORECORDS',
 | 
        
           |  |  | 103 |                 'sEmptyTable':     'LABEL_DATATABLE_SEMPTYTABLE',
 | 
        
           |  |  | 104 |                 'sInfo':           'LABEL_DATATABLE_SINFO',
 | 
        
           |  |  | 105 |                 'sInfoEmpty':      'LABEL_DATATABLE_SINFOEMPTY',
 | 
        
           |  |  | 106 |                 'sInfoFiltered':   'LABEL_DATATABLE_SINFOFILTERED',
 | 
        
           |  |  | 107 |                 'sInfoPostFix':    '',
 | 
        
           |  |  | 108 |                 'sSearch':         'LABEL_DATATABLE_SSEARCH',
 | 
        
           |  |  | 109 |                 'sUrl':            '',
 | 
        
           |  |  | 110 |                 'sInfoThousands':  ',',
 | 
        
           |  |  | 111 |                 'sLoadingRecords': 'LABEL_DATATABLE_SLOADINGRECORDS',
 | 
        
           |  |  | 112 |                 'oPaginate': {
 | 
        
           |  |  | 113 |                     'sFirst':    'LABEL_DATATABLE_SFIRST',
 | 
        
           |  |  | 114 |                     'sLast':     'LABEL_DATATABLE_SLAST',
 | 
        
           |  |  | 115 |                     'sNext':     'LABEL_DATATABLE_SNEXT',
 | 
        
           |  |  | 116 |                     'sPrevious': 'LABEL_DATATABLE_SPREVIOUS'
 | 
        
           |  |  | 117 |                 },
 | 
        
           |  |  | 118 |                 'oAria': {
 | 
        
           |  |  | 119 |                     'sSortAscending':  ': LABEL_DATATABLE_SSORTASCENDING',
 | 
        
           |  |  | 120 |                     'sSortDescending': ':LABEL_DATATABLE_SSORTDESCENDING'
 | 
        
           |  |  | 121 |                 },
 | 
        
           |  |  | 122 |             },
 | 
        
           |  |  | 123 |             'drawCallback': function( settings ) {
 | 
        
           |  |  | 124 |                 NProgress.done();
 | 
        
           |  |  | 125 |                 $('button.btn-delete').confirmation({
 | 
        
           |  |  | 126 |                     rootSelector: 'button.btn-delete',
 | 
        
           |  |  | 127 |                     title : 'LABEL_ARE_YOU_SURE',
 | 
        
           |  |  | 128 |                     singleton : true,
 | 
        
           |  |  | 129 |                     btnOkLabel: 'LABEL_YES',
 | 
        
           |  |  | 130 |                     btnCancelLabel: 'LABEL_NO',
 | 
        
           |  |  | 131 |                     onConfirm: function(value) {
 | 
        
           |  |  | 132 |                         action = $(this).data('href');
 | 
        
           |  |  | 133 |                         NProgress.start();
 | 
        
           |  |  | 134 |                         $.ajax({
 | 
        
           |  |  | 135 |                             'dataType'  : 'json',
 | 
        
           |  |  | 136 |                             'accept'    : 'application/json',
 | 
        
           |  |  | 137 |                             'method'    : 'post',
 | 
        
           |  |  | 138 |                             'url'       :  action,
 | 
        
           |  |  | 139 |                         }).done(function(response) {
 | 
        
           |  |  | 140 |                             if(response['success']) {
 | 
        
           |  |  | 141 |                                 $.fn.showSuccess(response['data']);
 | 
        
           |  |  | 142 |                                 gridTable.api().ajax.reload(null, false);
 | 
        
           |  |  | 143 |                             } else {
 | 
        
           |  |  | 144 |                                 $.fn.showError(response['data']);
 | 
        
           |  |  | 145 |                             }
 | 
        
           |  |  | 146 |                         }).fail(function( jqXHR, textStatus, errorThrown) {
 | 
        
           |  |  | 147 |                             $.fn.showError(textStatus);
 | 
        
           |  |  | 148 |                         }).always(function() {
 | 
        
           |  |  | 149 |                             NProgress.done();
 | 
        
           |  |  | 150 |                         });
 | 
        
           |  |  | 151 |                     },
 | 
        
           |  |  | 152 |                 });
 | 
        
           |  |  | 153 |             },
 | 
        
           |  |  | 154 |             'aoColumns': [
 | 
        
           |  |  | 155 |                 { 'mDataProp': 'text' },
 | 
        
           |  |  | 156 |                 { 'mDataProp': 'details' },
 | 
        
           |  |  | 157 |                 { 'mDataProp': 'actions' },
 | 
        
           |  |  | 158 |     	    ],
 | 
        
           |  |  | 159 |             'columnDefs': [
 | 
        
           |  |  | 160 |                 {
 | 
        
           |  |  | 161 |                     'targets': 0,
 | 
        
           |  |  | 162 |                     'className' : 'text-vertical-middle',
 | 
        
           |  |  | 163 |                     'render' : function ( data, type, row ) {
 | 
        
           |  |  | 164 |                         var s = data;
 | 
        
           |  |  | 165 |                         if(allowAnswer && row['actions']['link_answer']  ) {
 | 
        
           |  |  | 166 |                             s = s + '<br><button class="btn btn-info btn-sm btn-answer" data-href="' + row['actions']['link_answer']+ '" data-toggle="tooltip" title="LABEL_ANSWERS"><i class="fa fa-external-link"></i> LABEL_ANSWERS </button';
 | 
        
           |  |  | 167 |                         }
 | 
        
           |  |  | 168 |   | 
        
           |  |  | 169 |                         return s;
 | 
        
           |  |  | 170 |                      }
 | 
        
           |  |  | 171 |                 },
 | 
        
           |  |  | 172 |                 {
 | 
        
           |  |  | 173 |                     'targets': 1,
 | 
        
           |  |  | 174 |                     'orderable': false,
 | 
        
           |  |  | 175 |                     'render' : function ( data, type, row ) {
 | 
        
           |  |  | 176 |                         var s = 'LABEL_VERIFICATION : ' + row['details']['check'] + '<br>';
 | 
        
           |  |  | 177 |                         s = s + 'LABEL_POINTS : ' + row['details']['points'] + '<br>';
 | 
        
           |  |  | 178 |                         s = s + 'LABEL_TYPE : ' + row['details']['type'] + '<br>';
 | 
        
           |  |  | 179 |   | 
        
           |  |  | 180 |                         return s;
 | 
        
           |  |  | 181 |                     }
 | 
        
           |  |  | 182 |                 },
 | 
        
           |  |  | 183 |                 {
 | 
        
           |  |  | 184 |                     'targets': -1,
 | 
        
           |  |  | 185 |                     'orderable': false,
 | 
        
           |  |  | 186 |                     'render' : function ( data, type, row ) {
 | 
        
           |  |  | 187 |                         s = '';
 | 
        
           |  |  | 188 |   | 
        
           |  |  | 189 |                         if(allowEdit && data['link_edit']  ) {
 | 
        
           |  |  | 190 |                             s = s + '<button class="btn btn-info btn-sm btn-edit" data-href="' + data['link_edit']+ '" data-toggle="tooltip" title="LABEL_EDIT"><i class="fa fa-pencil"></i> LABEL_EDIT </button> ';
 | 
        
           |  |  | 191 |                         }
 | 
        
           |  |  | 192 |                         if(allowDelete && data['link_delete']  ) {
 | 
        
           |  |  | 193 |                             s = s + '<button class="btn btn-danger btn-sm btn-delete" data-href="' + data['link_delete']+ '" data-toggle="tooltip" title="LABEL_DELETE"><i class="fa fa-trash"></i> LABEL_DELETE </button> ';
 | 
        
           |  |  | 194 |                         }
 | 
        
           |  |  | 195 |   | 
        
           |  |  | 196 |   | 
        
           |  |  | 197 |   | 
        
           |  |  | 198 |                         return s;
 | 
        
           |  |  | 199 |                     }
 | 
        
           |  |  | 200 |                 }
 | 
        
           |  |  | 201 |               ],
 | 
        
           |  |  | 202 |         });
 | 
        
           |  |  | 203 |   | 
        
           |  |  | 204 |   | 
        
           |  |  | 205 |   | 
        
           |  |  | 206 |   | 
        
           |  |  | 207 |   | 
        
           |  |  | 208 |         $.validator.setDefaults({
 | 
        
           |  |  | 209 |             debug: true,
 | 
        
           |  |  | 210 |             highlight: function(element) {
 | 
        
           |  |  | 211 |                 $(element).addClass('is-invalid');
 | 
        
           |  |  | 212 |             },
 | 
        
           |  |  | 213 |             unhighlight: function(element) {
 | 
        
           |  |  | 214 |                 $(element).removeClass('is-invalid');
 | 
        
           |  |  | 215 |             },
 | 
        
           |  |  | 216 |             errorElement: 'span',
 | 
        
           |  |  | 217 |             errorClass: 'error invalid-feedback',
 | 
        
           |  |  | 218 |             errorPlacement: function(error, element) {
 | 
        
           |  |  | 219 |                 if(element.parent('.btn-file').length) {
 | 
        
           |  |  | 220 |                     error.insertAfter(element.parent().parent());
 | 
        
           |  |  | 221 |                 } else if(element.parent('.toggle').length) {
 | 
        
           |  |  | 222 |                     error.insertAfter(element.parent().parent());
 | 
        
           |  |  | 223 |                 } else {
 | 
        
           |  |  | 224 |                     error.insertAfter(element.parent());
 | 
        
           |  |  | 225 |                 }
 | 
        
           |  |  | 226 |             }
 | 
        
           |  |  | 227 |         });
 | 
        
           |  |  | 228 |   | 
        
           |  |  | 229 |   | 
        
           |  |  | 230 |         $.fn.showFormErrorValidator = function(fieldname, errors) {
 | 
        
           |  |  | 231 |             var field = $(fieldname);
 | 
        
           |  |  | 232 |             if(field) {
 | 
        
           |  |  | 233 |                 $(field).addClass('is-invalid');
 | 
        
           |  |  | 234 |   | 
        
           |  |  | 235 |   | 
        
           |  |  | 236 |                 var error = $('<span id="' + fieldname +'-error" class="error invalid-feedback">' + errors + '</div>');
 | 
        
           |  |  | 237 |                 if(element.parent('.btn-file').length) {
 | 
        
           |  |  | 238 |                     error.insertAfter(element.parent().parent());
 | 
        
           |  |  | 239 |                 } else if(element.parent('.toggle').length) {
 | 
        
           |  |  | 240 |                     error.insertAfter(element.parent().parent());
 | 
        
           |  |  | 241 |                 } else {
 | 
        
           |  |  | 242 |                     error.insertAfter(element.parent());
 | 
        
           |  |  | 243 |                 }
 | 
        
           |  |  | 244 |             }
 | 
        
           |  |  | 245 |         };
 | 
        
           |  |  | 246 |   | 
        
           |  |  | 247 |   | 
        
           |  |  | 248 |     var validator = $('#form').validate({
 | 
        
           |  |  | 249 |         debug: true,
 | 
        
           |  |  | 250 |         onclick: false,
 | 
        
           |  |  | 251 |         onkeyup: false,
 | 
        
           |  |  | 252 |         ignore: [],
 | 
        
           |  |  | 253 |         rules: {
 | 
        
           |  |  | 254 |             'text': {
 | 
        
           |  |  | 255 |                 updateCkeditor:function() {
 | 
        
           |  |  | 256 |                         CKEDITOR.instances.text.updateElement();
 | 
        
           |  |  | 257 |                 },
 | 
        
           |  |  | 258 |                 required: true
 | 
        
           |  |  | 259 |             },
 | 
        
           |  |  | 260 |             'type' : {
 | 
        
           |  |  | 261 |                 required: true,
 | 
        
           |  |  | 262 |             },
 | 
        
           |  |  | 263 |             'points' : {
 | 
        
           |  |  | 264 |                 required: true,
 | 
        
           |  |  | 265 |                 digits: true,
 | 
        
           |  |  | 266 |                 min: 1,
 | 
        
           |  |  | 267 |                 max: 100
 | 
        
           |  |  | 268 |             },
 | 
        
           |  |  | 269 |         },
 | 
        
           |  |  | 270 |         submitHandler: function(form)
 | 
        
           |  |  | 271 |         {
 | 
        
           |  |  | 272 |             $('input[type="submit"]').prop('disabled', true);
 | 
        
           |  |  | 273 |   | 
        
           |  |  | 274 |             $.ajax({
 | 
        
           |  |  | 275 |                 'dataType'  : 'json',
 | 
        
           |  |  | 276 |                 'accept'    : 'application/json',
 | 
        
           |  |  | 277 |                 'method'    : 'post',
 | 
        
           |  |  | 278 |                 'url'       :  $('#form').attr('action'),
 | 
        
           |  |  | 279 |                 'data'      :  $('#form').serialize(),
 | 
        
           |  |  | 280 |             }).done(function(response) {
 | 
        
           |  |  | 281 |                 if(response['success']) {
 | 
        
           |  |  | 282 |                     $.fn.showSuccess(response['data']);
 | 
        
           |  |  | 283 |   | 
        
           |  |  | 284 |                     $('#modal-form').modal('hide');
 | 
        
           |  |  | 285 |                     gridTable.api().ajax.reload(null, false);
 | 
        
           |  |  | 286 |                 } else {
 | 
        
           |  |  | 287 |                     validator.resetForm();
 | 
        
           |  |  | 288 |                     if(jQuery.type(response['data']) == 'string') {
 | 
        
           |  |  | 289 |                         $.fn.showError(response['data']);
 | 
        
           |  |  | 290 |                     } else  {
 | 
        
           |  |  | 291 |                         $.each(response['data'], function( fieldname, errors ) {
 | 
        
           |  |  | 292 |                             $.fn.showFormErrorValidator('#form #' + fieldname, errors);
 | 
        
           |  |  | 293 |                         });
 | 
        
           |  |  | 294 |                     }
 | 
        
           |  |  | 295 |                 }
 | 
        
           |  |  | 296 |             }).fail(function( jqXHR, textStatus, errorThrown) {
 | 
        
           |  |  | 297 |                 $.fn.showError(textStatus);
 | 
        
           |  |  | 298 |             }).always(function() {
 | 
        
           |  |  | 299 |                 NProgress.done();
 | 
        
           |  |  | 300 |             });
 | 
        
           |  |  | 301 |             return false;
 | 
        
           |  |  | 302 |         },
 | 
        
           |  |  | 303 |         invalidHandler: function(form, validator) {
 | 
        
           |  |  | 304 |   | 
        
           |  |  | 305 |         }
 | 
        
           |  |  | 306 |     });
 | 
        
           |  |  | 307 |   | 
        
           |  |  | 308 |     $('body').on('click', 'button.btn-add', function(e) {
 | 
        
           |  |  | 309 |         e.preventDefault();
 | 
        
           |  |  | 310 |   | 
        
           |  |  | 311 |         $('span[id="form-title"]').html('LABEL_ADD');
 | 
        
           |  |  | 312 |         $('#form').attr('action', '$routeAdd');
 | 
        
           |  |  | 313 |         $('#form #name').val('');
 | 
        
           |  |  | 314 |         $('#form #type').val('');
 | 
        
           |  |  | 315 |         $('#form #maxlength').val('');
 | 
        
           |  |  | 316 |         $('#form #maxlength').parent().hide();
 | 
        
           |  |  | 317 |         $('#form #points').val('');
 | 
        
           |  |  | 318 |   | 
        
           |  |  | 319 |   | 
        
           |  |  | 320 |         CKEDITOR.instances['text'].setData('');
 | 
        
           |  |  | 321 |         validator.resetForm();
 | 
        
           |  |  | 322 |   | 
        
           |  |  | 323 |         $('#modal-form').modal('show');
 | 
        
           |  |  | 324 |         return false;
 | 
        
           |  |  | 325 |     });
 | 
        
           |  |  | 326 |   | 
        
           |  |  | 327 |     $('#form #type').change(function(e) {
 | 
        
           |  |  | 328 |         e.preventDefault();
 | 
        
           |  |  | 329 |   | 
        
           |  |  | 330 |         var value = $(this).val();
 | 
        
           |  |  | 331 |         if(value == 'sl' || value == 'ml') {
 | 
        
           |  |  | 332 |             $('#form #maxlength').parent().show();
 | 
        
           |  |  | 333 |         } else {
 | 
        
           |  |  | 334 |             $('#form #maxlength').val('');
 | 
        
           |  |  | 335 |             $('#form #maxlength').parent().hide();
 | 
        
           |  |  | 336 |         }
 | 
        
           |  |  | 337 |   | 
        
           |  |  | 338 |     });
 | 
        
           |  |  | 339 |   | 
        
           |  |  | 340 |     $('body').on('click', 'button.btn-answer', function(e) {
 | 
        
           |  |  | 341 |         e.preventDefault();
 | 
        
           |  |  | 342 |         var action = $(this).data('href');
 | 
        
           |  |  | 343 |         window.location.href = action;
 | 
        
           |  |  | 344 |     });
 | 
        
           |  |  | 345 |   | 
        
           |  |  | 346 |     $('body').on('click', 'button.btn-edit', function(e) {
 | 
        
           |  |  | 347 |             e.preventDefault();
 | 
        
           |  |  | 348 |             NProgress.start();
 | 
        
           |  |  | 349 |             var action = $(this).data('href');
 | 
        
           |  |  | 350 |   | 
        
           |  |  | 351 |             $.ajax({
 | 
        
           |  |  | 352 |                 'dataType'  : 'json',
 | 
        
           |  |  | 353 |                 'accept'    : 'application/json',
 | 
        
           |  |  | 354 |                 'method'    : 'get',
 | 
        
           |  |  | 355 |                 'url'       :  action,
 | 
        
           |  |  | 356 |             }).done(function(response) {
 | 
        
           |  |  | 357 |                 if(response['success']) {
 | 
        
           |  |  | 358 |   | 
        
           |  |  | 359 |                     $('span[id="form-title"]').html('LABEL_EDIT');
 | 
        
           |  |  | 360 |                     $('#form').attr('action', action);
 | 
        
           |  |  | 361 |                     $('#form #name').val(response['data']['name']);
 | 
        
           |  |  | 362 |                     $('#form #type').val(response['data']['type']);
 | 
        
           |  |  | 363 |                     $('#form #maxlength').val(response['data']['maxlength']);
 | 
        
           |  |  | 364 |   | 
        
           |  |  | 365 |                      if(response['data']['type'] == 'sl' || response['data']['type'] == 'ml') {
 | 
        
           |  |  | 366 |                         $('#form #maxlength').parent().show();
 | 
        
           |  |  | 367 |                     } else {
 | 
        
           |  |  | 368 |   | 
        
           |  |  | 369 |                         $('#form #maxlength').parent().hide();
 | 
        
           |  |  | 370 |                     }
 | 
        
           |  |  | 371 |   | 
        
           |  |  | 372 |                     $('#form #points').val(response['data']['points']);
 | 
        
           |  |  | 373 |   | 
        
           |  |  | 374 |                     CKEDITOR.instances['text'].setData(response['data']['text']);
 | 
        
           |  |  | 375 |                     validator.resetForm();
 | 
        
           |  |  | 376 |   | 
        
           |  |  | 377 |                     $('#modal-form').modal('show');
 | 
        
           |  |  | 378 |                     return false;
 | 
        
           |  |  | 379 |                 } else {
 | 
        
           |  |  | 380 |                     $.fn.showError(response['data']);
 | 
        
           |  |  | 381 |                 }
 | 
        
           |  |  | 382 |             }).fail(function( jqXHR, textStatus, errorThrown) {
 | 
        
           |  |  | 383 |                 $.fn.showError(textStatus);
 | 
        
           |  |  | 384 |             }).always(function() {
 | 
        
           |  |  | 385 |                 NProgress.done();
 | 
        
           |  |  | 386 |             });
 | 
        
           |  |  | 387 |         });
 | 
        
           |  |  | 388 |   | 
        
           |  |  | 389 |   | 
        
           |  |  | 390 |     $('#form #points').inputNumberFormat({decimal: 0});
 | 
        
           |  |  | 391 |   | 
        
           |  |  | 392 |     CKEDITOR.replace('text');
 | 
        
           |  |  | 393 |   | 
        
           |  |  | 394 | });
 | 
        
           |  |  | 395 | JS;
 | 
        
           |  |  | 396 | $this->inlineScript()->captureEnd();
 | 
        
           |  |  | 397 | ?>
 | 
        
           |  |  | 398 |   | 
        
           |  |  | 399 | <!-- Content Header (Page header) -->
 | 
        
           |  |  | 400 | <section class="content-header">
 | 
        
           |  |  | 401 | 	<div class="container-fluid">
 | 
        
           |  |  | 402 |     	<div class="row mb-2">
 | 
        
           |  |  | 403 |         	<div class="col-sm-12">
 | 
        
           |  |  | 404 |             	<h1>LABEL_QUESTIONS</h1>
 | 
        
           |  |  | 405 |             	<h2><?php echo $quiz_name ?></h2>
 | 
        
           |  |  | 406 | 			</div>
 | 
        
           |  |  | 407 | 		</div>
 | 
        
           |  |  | 408 | 	</div><!-- /.container-fluid -->
 | 
        
           |  |  | 409 | </section>
 | 
        
           |  |  | 410 |   | 
        
           |  |  | 411 | <section class="content">
 | 
        
           |  |  | 412 | 	<div class="container-fluid">
 | 
        
           |  |  | 413 |     	<div class="row">
 | 
        
           |  |  | 414 |         	<div class="col-12">
 | 
        
           |  |  | 415 | 				<div class="card">
 | 
        
           |  |  | 416 | 					<div class="card-body">
 | 
        
           |  |  | 417 |         	    		<table id="gridTable" class="table   table-hover">
 | 
        
           |  |  | 418 |                       		<thead>
 | 
        
           |  |  | 419 |         						<tr>
 | 
        
           |  |  | 420 |                                 	<th>LABEL_NAME</th>
 | 
        
           |  |  | 421 |                                   	<th>LABEL_DETAILS</th>
 | 
        
           |  |  | 422 |                                   	<th>LABEL_ACTIONS</th>
 | 
        
           |  |  | 423 |                                 </tr>
 | 
        
           |  |  | 424 |                        		</thead>
 | 
        
           |  |  | 425 |                          	<tbody>
 | 
        
           |  |  | 426 |                          	</tbody>
 | 
        
           |  |  | 427 |                     	</table>
 | 
        
           |  |  | 428 |                    	</div>
 | 
        
           |  |  | 429 |                    	<div class="card-footer clearfix">
 | 
        
           |  |  | 430 |                    		<div style="float:right;">
 | 
        
           |  |  | 431 | 							<button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH  </button>
 | 
        
           |  |  | 432 | 							<?php if($allowAdd) : ?>
 | 
        
           |  |  | 433 | 							<button type="button" class="btn btn-primary btn-add"><i class="fa fa-plus"></i> LABEL_ADD </button>
 | 
        
           |  |  | 434 | 							<?php endif; ?>
 | 
        
           |  |  | 435 | 						</div>
 | 
        
           |  |  | 436 |                  	</div>
 | 
        
           |  |  | 437 |           		</div>
 | 
        
           |  |  | 438 |            	</div>
 | 
        
           |  |  | 439 |         </div>
 | 
        
           |  |  | 440 |  	</div>
 | 
        
           |  |  | 441 | </section>
 | 
        
           |  |  | 442 |   | 
        
           |  |  | 443 |   | 
        
           |  |  | 444 | <div class="modal" tabindex="-1" role="dialog" id="modal-form">
 | 
        
           |  |  | 445 | 	<div class="modal-dialog  modal-lg">
 | 
        
           |  |  | 446 |     	<div class="modal-content">
 | 
        
           |  |  | 447 | 		<?php
 | 
        
           |  |  | 448 | 		$form = $this->formCreateOrEdit;
 | 
        
           |  |  | 449 | 	    $form->setAttributes([
 | 
        
           |  |  | 450 | 	       'method'    => 'post',
 | 
        
           |  |  | 451 | 	        'name'      => 'form',
 | 
        
           |  |  | 452 | 	        'id'        => 'form'
 | 
        
           |  |  | 453 | 	    ]);
 | 
        
           |  |  | 454 | 	    $form->prepare();
 | 
        
           |  |  | 455 | 	    echo $this->form()->openTag($form);
 | 
        
           |  |  | 456 | 	    ?>
 | 
        
           |  |  | 457 |     	<div class="modal-content">
 | 
        
           |  |  | 458 |       		<div class="modal-header">
 | 
        
           |  |  | 459 |         		<h3 class="modal-title" ><span id="form-title">LABEL_ADD</span></h3>
 | 
        
           |  |  | 460 |       		</div>
 | 
        
           |  |  | 461 |       		<div class="modal-body">
 | 
        
           |  |  | 462 |    				<div class="form-group">
 | 
        
           |  |  | 463 |                 	<?php
 | 
        
           |  |  | 464 |                     $element = $form->get('text');
 | 
        
           |  |  | 465 |                     $element->setAttributes(['id' => 'text', 'rows' => '2', 'placeholder' => '', 'class' => 'form-control']);
 | 
        
           |  |  | 466 |                     $element->setOptions(['label' => 'LABEL_TEXT']);
 | 
        
           |  |  | 467 |                     echo $this->formLabel($element);
 | 
        
           |  |  | 468 |                     echo $this->formTextArea($element);
 | 
        
           |  |  | 469 |                     ?>
 | 
        
           |  |  | 470 |    				</div>
 | 
        
           |  |  | 471 |    				<div class="form-group">
 | 
        
           |  |  | 472 |     				<?php
 | 
        
           |  |  | 473 |                         $element = $form->get('type');
 | 
        
           |  |  | 474 |                         $element->setAttributes(['class' => 'form-control']);
 | 
        
           |  |  | 475 |                         $element->setOptions(['label' => 'LABEL_TYPE']);
 | 
        
           |  |  | 476 |                         echo $this->formLabel($element);
 | 
        
           |  |  | 477 |                         echo $this->formSelect($element);
 | 
        
           |  |  | 478 |                     ?>
 | 
        
           |  |  | 479 | 				</div>
 | 
        
           |  |  | 480 |    				<div class="form-group">
 | 
        
           |  |  | 481 |     				<?php
 | 
        
           |  |  | 482 |                         $element = $form->get('maxlength');
 | 
        
           |  |  | 483 |                         $element->setAttributes(['class' => 'form-control']);
 | 
        
           |  |  | 484 |                         $element->setOptions(['label' => 'LABEL_MAXLENGTH']);
 | 
        
           |  |  | 485 |                         echo $this->formLabel($element);
 | 
        
           |  |  | 486 |                         echo $this->formText($element);
 | 
        
           |  |  | 487 |                     ?>
 | 
        
           |  |  | 488 | 				</div>
 | 
        
           |  |  | 489 | 				<div class="form-group">
 | 
        
           |  |  | 490 |     				<?php
 | 
        
           |  |  | 491 |                         $element = $form->get('points');
 | 
        
           |  |  | 492 |                         $element->setAttributes(['class' => 'form-control']);
 | 
        
           |  |  | 493 |                         $element->setOptions(['label' => 'LABEL_POINTS']);
 | 
        
           |  |  | 494 |                         echo $this->formLabel($element);
 | 
        
           |  |  | 495 |                         echo $this->formText($element);
 | 
        
           |  |  | 496 |                     ?>
 | 
        
           |  |  | 497 | 				</div>
 | 
        
           |  |  | 498 |           	</div>
 | 
        
           |  |  | 499 |   | 
        
           |  |  | 500 |          	<div class="modal-footer">
 | 
        
           |  |  | 501 |     			<button type="submit" class="btn btn-primary">LABEL_SAVE</button>
 | 
        
           |  |  | 502 |     			<button type="button" class="btn btn-danger" data-dismiss="modal">Cerrar</button>
 | 
        
           |  |  | 503 |           	</div>
 | 
        
           |  |  | 504 |       	<?php echo $this->form()->closeTag($form); ?>
 | 
        
           |  |  | 505 |     	</div>
 | 
        
           |  |  | 506 |     	</div>
 | 
        
           |  |  | 507 |     </div>
 | 
        
           |  |  | 508 | </div>
 |