| 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 |   | 
        
           | 16822 | efrain | 20 | $this->headLink()->appendStylesheet($this->basePath('assets/vendors/nprogress/nprogress.css'));
 | 
        
           |  |  | 21 | $this->inlineScript()->appendFile($this->basePath('assets/vendors/nprogress/nprogress.js'));
 | 
        
           | 66 | efrain | 22 |   | 
        
           | 16822 | efrain | 23 | $this->headLink()->appendStylesheet($this->basePath('assets/vendors/datatables.net-bs5/dataTables.bootstrap5.css'));
 | 
        
           |  |  | 24 | $this->headLink()->appendStylesheet($this->basePath('assets/vendors/datatables.net-bs5-responsive/responsive.bootstrap5.css'));
 | 
        
           | 66 | efrain | 25 |   | 
        
           | 16822 | efrain | 26 | $this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net/jquery.dataTables.js'));
 | 
        
           |  |  | 27 | $this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5/dataTables.bootstrap5.js'));
 | 
        
           |  |  | 28 | $this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5-responsive/dataTables.responsive.min.js'));
 | 
        
           |  |  | 29 | $this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5-responsive/responsive.bootstrap5.min.js'));
 | 
        
           | 66 | efrain | 30 |   | 
        
           |  |  | 31 |   | 
        
           | 16822 | efrain | 32 | $this->headLink()->appendStylesheet($this->basePath('assets/vendors/bootstrap4-toggle/css/bootstrap4-toggle.min.css'));
 | 
        
           |  |  | 33 | $this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap4-toggle/js/bootstrap4-toggle.min.js'));
 | 
        
           | 66 | efrain | 34 |   | 
        
           |  |  | 35 |   | 
        
           |  |  | 36 |   | 
        
           |  |  | 37 |   | 
        
           |  |  | 38 |   | 
        
           |  |  | 39 |   | 
        
           |  |  | 40 |   | 
        
           | 16822 | efrain | 41 | $this->inlineScript()->appendFile($this->basePath('assets/vendors/ckeditor/ckeditor.js'));
 | 
        
           |  |  | 42 | $this->inlineScript()->appendFile($this->basePath('assets/vendors/jquery-input-number/input-number-format.jquery.js'));
 | 
        
           | 66 | efrain | 43 |   | 
        
           |  |  | 44 |   | 
        
           |  |  | 45 |   | 
        
           | 16822 | efrain | 46 |   | 
        
           |  |  | 47 | $this->inlineScript()->appendFile($this->basePath('assets/vendors/jquery-validation/jquery.validate.js'));
 | 
        
           |  |  | 48 | $this->inlineScript()->appendFile($this->basePath('assets/vendors/jquery-validation/additional-methods.js'));
 | 
        
           |  |  | 49 | $this->inlineScript()->appendFile($this->basePath('assets/vendors/jquery-validation/localization/messages_es.js'));
 | 
        
           |  |  | 50 |   | 
        
           |  |  | 51 |   | 
        
           | 66 | efrain | 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();
 | 
        
           | 16822 | efrain | 125 |   | 
        
           | 66 | efrain | 126 |             },
 | 
        
           |  |  | 127 |             'aoColumns': [
 | 
        
           |  |  | 128 |                 { 'mDataProp': 'text' },
 | 
        
           |  |  | 129 |                 { 'mDataProp': 'details' },
 | 
        
           |  |  | 130 |                 { 'mDataProp': 'actions' },
 | 
        
           |  |  | 131 |     	    ],
 | 
        
           |  |  | 132 |             'columnDefs': [
 | 
        
           |  |  | 133 |                 {
 | 
        
           |  |  | 134 |                     'targets': 0,
 | 
        
           |  |  | 135 |                     'className' : 'text-vertical-middle',
 | 
        
           |  |  | 136 |                     'render' : function ( data, type, row ) {
 | 
        
           |  |  | 137 |                         var s = data;
 | 
        
           |  |  | 138 |                         if(allowAnswer && row['actions']['link_answer']  ) {
 | 
        
           |  |  | 139 |                             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';
 | 
        
           |  |  | 140 |                         }
 | 
        
           |  |  | 141 |   | 
        
           |  |  | 142 |                         return s;
 | 
        
           |  |  | 143 |                      }
 | 
        
           |  |  | 144 |                 },
 | 
        
           |  |  | 145 |                 {
 | 
        
           |  |  | 146 |                     'targets': 1,
 | 
        
           |  |  | 147 |                     'orderable': false,
 | 
        
           |  |  | 148 |                     'render' : function ( data, type, row ) {
 | 
        
           |  |  | 149 |                         var s = 'LABEL_VERIFICATION : ' + row['details']['check'] + '<br>';
 | 
        
           |  |  | 150 |                         s = s + 'LABEL_POINTS : ' + row['details']['points'] + '<br>';
 | 
        
           |  |  | 151 |                         s = s + 'LABEL_TYPE : ' + row['details']['type'] + '<br>';
 | 
        
           |  |  | 152 |   | 
        
           |  |  | 153 |                         return s;
 | 
        
           |  |  | 154 |                     }
 | 
        
           |  |  | 155 |                 },
 | 
        
           |  |  | 156 |                 {
 | 
        
           |  |  | 157 |                     'targets': -1,
 | 
        
           |  |  | 158 |                     'orderable': false,
 | 
        
           |  |  | 159 |                     'render' : function ( data, type, row ) {
 | 
        
           |  |  | 160 |                         s = '';
 | 
        
           |  |  | 161 |   | 
        
           |  |  | 162 |                         if(allowEdit && data['link_edit']  ) {
 | 
        
           |  |  | 163 |                             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> ';
 | 
        
           |  |  | 164 |                         }
 | 
        
           |  |  | 165 |                         if(allowDelete && data['link_delete']  ) {
 | 
        
           |  |  | 166 |                             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> ';
 | 
        
           |  |  | 167 |                         }
 | 
        
           |  |  | 168 |   | 
        
           |  |  | 169 |   | 
        
           |  |  | 170 |   | 
        
           |  |  | 171 |                         return s;
 | 
        
           |  |  | 172 |                     }
 | 
        
           |  |  | 173 |                 }
 | 
        
           |  |  | 174 |               ],
 | 
        
           |  |  | 175 |         });
 | 
        
           |  |  | 176 |   | 
        
           |  |  | 177 |   | 
        
           |  |  | 178 |   | 
        
           |  |  | 179 |   | 
        
           |  |  | 180 |   | 
        
           |  |  | 181 |         $.validator.setDefaults({
 | 
        
           |  |  | 182 |             debug: true,
 | 
        
           |  |  | 183 |             highlight: function(element) {
 | 
        
           |  |  | 184 |                 $(element).addClass('is-invalid');
 | 
        
           |  |  | 185 |             },
 | 
        
           |  |  | 186 |             unhighlight: function(element) {
 | 
        
           |  |  | 187 |                 $(element).removeClass('is-invalid');
 | 
        
           |  |  | 188 |             },
 | 
        
           |  |  | 189 |             errorElement: 'span',
 | 
        
           |  |  | 190 |             errorClass: 'error invalid-feedback',
 | 
        
           |  |  | 191 |             errorPlacement: function(error, element) {
 | 
        
           |  |  | 192 |                 if(element.parent('.btn-file').length) {
 | 
        
           |  |  | 193 |                     error.insertAfter(element.parent().parent());
 | 
        
           |  |  | 194 |                 } else if(element.parent('.toggle').length) {
 | 
        
           |  |  | 195 |                     error.insertAfter(element.parent().parent());
 | 
        
           |  |  | 196 |                 } else {
 | 
        
           |  |  | 197 |                     error.insertAfter(element.parent());
 | 
        
           |  |  | 198 |                 }
 | 
        
           |  |  | 199 |             }
 | 
        
           |  |  | 200 |         });
 | 
        
           |  |  | 201 |   | 
        
           |  |  | 202 |   | 
        
           |  |  | 203 |         $.fn.showFormErrorValidator = function(fieldname, errors) {
 | 
        
           |  |  | 204 |             var field = $(fieldname);
 | 
        
           |  |  | 205 |             if(field) {
 | 
        
           |  |  | 206 |                 $(field).addClass('is-invalid');
 | 
        
           |  |  | 207 |   | 
        
           |  |  | 208 |   | 
        
           |  |  | 209 |                 var error = $('<span id="' + fieldname +'-error" class="error invalid-feedback">' + errors + '</div>');
 | 
        
           |  |  | 210 |                 if(element.parent('.btn-file').length) {
 | 
        
           |  |  | 211 |                     error.insertAfter(element.parent().parent());
 | 
        
           |  |  | 212 |                 } else if(element.parent('.toggle').length) {
 | 
        
           |  |  | 213 |                     error.insertAfter(element.parent().parent());
 | 
        
           |  |  | 214 |                 } else {
 | 
        
           |  |  | 215 |                     error.insertAfter(element.parent());
 | 
        
           |  |  | 216 |                 }
 | 
        
           |  |  | 217 |             }
 | 
        
           |  |  | 218 |         };
 | 
        
           |  |  | 219 |   | 
        
           |  |  | 220 |   | 
        
           |  |  | 221 |     var validator = $('#form').validate({
 | 
        
           |  |  | 222 |         debug: true,
 | 
        
           |  |  | 223 |         onclick: false,
 | 
        
           |  |  | 224 |         onkeyup: false,
 | 
        
           |  |  | 225 |         ignore: [],
 | 
        
           |  |  | 226 |         rules: {
 | 
        
           |  |  | 227 |             'text': {
 | 
        
           |  |  | 228 |                 updateCkeditor:function() {
 | 
        
           |  |  | 229 |                         CKEDITOR.instances.text.updateElement();
 | 
        
           |  |  | 230 |                 },
 | 
        
           |  |  | 231 |                 required: true
 | 
        
           |  |  | 232 |             },
 | 
        
           |  |  | 233 |             'type' : {
 | 
        
           |  |  | 234 |                 required: true,
 | 
        
           |  |  | 235 |             },
 | 
        
           |  |  | 236 |             'points' : {
 | 
        
           |  |  | 237 |                 required: true,
 | 
        
           |  |  | 238 |                 digits: true,
 | 
        
           |  |  | 239 |                 min: 1,
 | 
        
           |  |  | 240 |                 max: 100
 | 
        
           |  |  | 241 |             },
 | 
        
           |  |  | 242 |         },
 | 
        
           |  |  | 243 |         submitHandler: function(form)
 | 
        
           |  |  | 244 |         {
 | 
        
           |  |  | 245 |             $('input[type="submit"]').prop('disabled', true);
 | 
        
           |  |  | 246 |   | 
        
           |  |  | 247 |             $.ajax({
 | 
        
           |  |  | 248 |                 'dataType'  : 'json',
 | 
        
           |  |  | 249 |                 'accept'    : 'application/json',
 | 
        
           |  |  | 250 |                 'method'    : 'post',
 | 
        
           |  |  | 251 |                 'url'       :  $('#form').attr('action'),
 | 
        
           |  |  | 252 |                 'data'      :  $('#form').serialize(),
 | 
        
           |  |  | 253 |             }).done(function(response) {
 | 
        
           |  |  | 254 |                 if(response['success']) {
 | 
        
           |  |  | 255 |                     $.fn.showSuccess(response['data']);
 | 
        
           |  |  | 256 |   | 
        
           |  |  | 257 |                     $('#modal-form').modal('hide');
 | 
        
           |  |  | 258 |                     gridTable.api().ajax.reload(null, false);
 | 
        
           |  |  | 259 |                 } else {
 | 
        
           |  |  | 260 |                     validator.resetForm();
 | 
        
           |  |  | 261 |                     if(jQuery.type(response['data']) == 'string') {
 | 
        
           |  |  | 262 |                         $.fn.showError(response['data']);
 | 
        
           |  |  | 263 |                     } else  {
 | 
        
           |  |  | 264 |                         $.each(response['data'], function( fieldname, errors ) {
 | 
        
           |  |  | 265 |                             $.fn.showFormErrorValidator('#form #' + fieldname, errors);
 | 
        
           |  |  | 266 |                         });
 | 
        
           |  |  | 267 |                     }
 | 
        
           |  |  | 268 |                 }
 | 
        
           |  |  | 269 |             }).fail(function( jqXHR, textStatus, errorThrown) {
 | 
        
           |  |  | 270 |                 $.fn.showError(textStatus);
 | 
        
           |  |  | 271 |             }).always(function() {
 | 
        
           |  |  | 272 |                 NProgress.done();
 | 
        
           |  |  | 273 |             });
 | 
        
           |  |  | 274 |             return false;
 | 
        
           |  |  | 275 |         },
 | 
        
           |  |  | 276 |         invalidHandler: function(form, validator) {
 | 
        
           |  |  | 277 |   | 
        
           |  |  | 278 |         }
 | 
        
           |  |  | 279 |     });
 | 
        
           |  |  | 280 |   | 
        
           |  |  | 281 |     $('body').on('click', 'button.btn-add', function(e) {
 | 
        
           |  |  | 282 |         e.preventDefault();
 | 
        
           |  |  | 283 |   | 
        
           | 16840 | efrain | 284 |   | 
        
           | 66 | efrain | 285 |         $('#form').attr('action', '$routeAdd');
 | 
        
           |  |  | 286 |         $('#form #name').val('');
 | 
        
           |  |  | 287 |         $('#form #type').val('');
 | 
        
           |  |  | 288 |         $('#form #maxlength').val('');
 | 
        
           |  |  | 289 |         $('#form #maxlength').parent().hide();
 | 
        
           |  |  | 290 |         $('#form #points').val('');
 | 
        
           |  |  | 291 |   | 
        
           |  |  | 292 |   | 
        
           |  |  | 293 |         CKEDITOR.instances['text'].setData('');
 | 
        
           |  |  | 294 |         validator.resetForm();
 | 
        
           |  |  | 295 |   | 
        
           |  |  | 296 |         $('#modal-form').modal('show');
 | 
        
           |  |  | 297 |         return false;
 | 
        
           |  |  | 298 |     });
 | 
        
           |  |  | 299 |   | 
        
           |  |  | 300 |     $('#form #type').change(function(e) {
 | 
        
           |  |  | 301 |         e.preventDefault();
 | 
        
           |  |  | 302 |   | 
        
           |  |  | 303 |         var value = $(this).val();
 | 
        
           |  |  | 304 |         if(value == 'sl' || value == 'ml') {
 | 
        
           |  |  | 305 |             $('#form #maxlength').parent().show();
 | 
        
           |  |  | 306 |         } else {
 | 
        
           |  |  | 307 |             $('#form #maxlength').val('');
 | 
        
           |  |  | 308 |             $('#form #maxlength').parent().hide();
 | 
        
           |  |  | 309 |         }
 | 
        
           |  |  | 310 |   | 
        
           |  |  | 311 |     });
 | 
        
           |  |  | 312 |   | 
        
           |  |  | 313 |     $('body').on('click', 'button.btn-answer', function(e) {
 | 
        
           |  |  | 314 |         e.preventDefault();
 | 
        
           |  |  | 315 |         var action = $(this).data('href');
 | 
        
           |  |  | 316 |         window.location.href = action;
 | 
        
           |  |  | 317 |     });
 | 
        
           |  |  | 318 |   | 
        
           |  |  | 319 |     $('body').on('click', 'button.btn-edit', function(e) {
 | 
        
           |  |  | 320 |             e.preventDefault();
 | 
        
           |  |  | 321 |             NProgress.start();
 | 
        
           |  |  | 322 |             var action = $(this).data('href');
 | 
        
           |  |  | 323 |   | 
        
           |  |  | 324 |             $.ajax({
 | 
        
           |  |  | 325 |                 'dataType'  : 'json',
 | 
        
           |  |  | 326 |                 'accept'    : 'application/json',
 | 
        
           |  |  | 327 |                 'method'    : 'get',
 | 
        
           |  |  | 328 |                 'url'       :  action,
 | 
        
           |  |  | 329 |             }).done(function(response) {
 | 
        
           |  |  | 330 |                 if(response['success']) {
 | 
        
           |  |  | 331 |   | 
        
           | 16840 | efrain | 332 |   | 
        
           | 66 | efrain | 333 |                     $('#form').attr('action', action);
 | 
        
           |  |  | 334 |                     $('#form #name').val(response['data']['name']);
 | 
        
           |  |  | 335 |                     $('#form #type').val(response['data']['type']);
 | 
        
           |  |  | 336 |                     $('#form #maxlength').val(response['data']['maxlength']);
 | 
        
           |  |  | 337 |   | 
        
           |  |  | 338 |                      if(response['data']['type'] == 'sl' || response['data']['type'] == 'ml') {
 | 
        
           |  |  | 339 |                         $('#form #maxlength').parent().show();
 | 
        
           |  |  | 340 |                     } else {
 | 
        
           |  |  | 341 |   | 
        
           |  |  | 342 |                         $('#form #maxlength').parent().hide();
 | 
        
           |  |  | 343 |                     }
 | 
        
           |  |  | 344 |   | 
        
           |  |  | 345 |                     $('#form #points').val(response['data']['points']);
 | 
        
           |  |  | 346 |   | 
        
           |  |  | 347 |                     CKEDITOR.instances['text'].setData(response['data']['text']);
 | 
        
           |  |  | 348 |                     validator.resetForm();
 | 
        
           |  |  | 349 |   | 
        
           |  |  | 350 |                     $('#modal-form').modal('show');
 | 
        
           |  |  | 351 |                     return false;
 | 
        
           |  |  | 352 |                 } else {
 | 
        
           |  |  | 353 |                     $.fn.showError(response['data']);
 | 
        
           |  |  | 354 |                 }
 | 
        
           |  |  | 355 |             }).fail(function( jqXHR, textStatus, errorThrown) {
 | 
        
           |  |  | 356 |                 $.fn.showError(textStatus);
 | 
        
           |  |  | 357 |             }).always(function() {
 | 
        
           |  |  | 358 |                 NProgress.done();
 | 
        
           |  |  | 359 |             });
 | 
        
           |  |  | 360 |         });
 | 
        
           |  |  | 361 |   | 
        
           | 16822 | efrain | 362 |     $('body').on('click', 'button.btn-delete', function(e) {
 | 
        
           |  |  | 363 |         e.preventDefault();
 | 
        
           |  |  | 364 |         var action = $(this).data('href');
 | 
        
           | 66 | efrain | 365 |   | 
        
           | 16822 | efrain | 366 |   | 
        
           |  |  | 367 |           swal.fire({
 | 
        
           |  |  | 368 |             title: 'LABEL_ARE_YOU_SURE',
 | 
        
           |  |  | 369 |             icon: 'question',
 | 
        
           |  |  | 370 |             cancelButtonText: 'LABEL_NO',
 | 
        
           |  |  | 371 |             showCancelButton: true,
 | 
        
           |  |  | 372 |             confirmButtonText: 'LABEL_YES'
 | 
        
           |  |  | 373 |           }).then((result) => {
 | 
        
           |  |  | 374 |             if (result.isConfirmed) {
 | 
        
           |  |  | 375 |   | 
        
           |  |  | 376 |                     NProgress.start();
 | 
        
           |  |  | 377 |                     $.ajax({
 | 
        
           |  |  | 378 |                         'dataType'  : 'json',
 | 
        
           |  |  | 379 |                         'accept'    : 'application/json',
 | 
        
           |  |  | 380 |                         'method'    : 'post',
 | 
        
           |  |  | 381 |                         'url'       :  action,
 | 
        
           |  |  | 382 |                     }).done(function(response) {
 | 
        
           |  |  | 383 |                         if(response['success']) {
 | 
        
           |  |  | 384 |                             $.fn.showSuccess(response['data']);
 | 
        
           |  |  | 385 |                             gridTable.api().ajax.reload(null, false);
 | 
        
           |  |  | 386 |                         } else {
 | 
        
           |  |  | 387 |                             $.fn.showError(response['data']);
 | 
        
           |  |  | 388 |                         }
 | 
        
           |  |  | 389 |                     }).fail(function( jqXHR, textStatus, errorThrown) {
 | 
        
           |  |  | 390 |                         $.fn.showError(textStatus);
 | 
        
           |  |  | 391 |                     }).always(function() {
 | 
        
           |  |  | 392 |                         NProgress.done();
 | 
        
           |  |  | 393 |                     });
 | 
        
           |  |  | 394 |             }
 | 
        
           |  |  | 395 |        });
 | 
        
           |  |  | 396 |     });
 | 
        
           |  |  | 397 |   | 
        
           |  |  | 398 |   | 
        
           | 66 | efrain | 399 |     $('#form #points').inputNumberFormat({decimal: 0});
 | 
        
           |  |  | 400 |   | 
        
           | 8290 | stevensc | 401 |     CKEDITOR.replace('text', {
 | 
        
           |  |  | 402 |         toolbar: [
 | 
        
           |  |  | 403 |                     { name: 'editing', items: ['Scayt'] },
 | 
        
           |  |  | 404 |                     { name: 'links', items: ['Link', 'Unlink'] },
 | 
        
           |  |  | 405 |                     { name: 'paragraph', items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote'] },
 | 
        
           |  |  | 406 |                     { name: 'basicstyles', items: ['Bold', 'Italic', 'Strike', 'RemoveFormat'] },
 | 
        
           |  |  | 407 |                     '/',
 | 
        
           |  |  | 408 |                     { name: 'insert', items: ['Image', 'Table', 'HorizontalRule', 'SpecialChar'] },
 | 
        
           |  |  | 409 |                     { name: 'styles', items: ['Styles', 'Format'] },
 | 
        
           |  |  | 410 |                     { name: 'tools', items: ['Maximize'] }
 | 
        
           |  |  | 411 |                 ],
 | 
        
           |  |  | 412 |                 removePlugins: 'elementspath,Anchor',
 | 
        
           |  |  | 413 |                 heigth: 100
 | 
        
           |  |  | 414 |     });
 | 
        
           | 66 | efrain | 415 |   | 
        
           |  |  | 416 | });
 | 
        
           |  |  | 417 | JS;
 | 
        
           |  |  | 418 | $this->inlineScript()->captureEnd();
 | 
        
           |  |  | 419 | ?>
 | 
        
           |  |  | 420 |   | 
        
           |  |  | 421 | <!-- Content Header (Page header) -->
 | 
        
           |  |  | 422 | <section class="content-header">
 | 
        
           |  |  | 423 | 	<div class="container-fluid">
 | 
        
           |  |  | 424 |     	<div class="row mb-2">
 | 
        
           |  |  | 425 |         	<div class="col-sm-12">
 | 
        
           |  |  | 426 |             	<h1>LABEL_QUESTIONS</h1>
 | 
        
           |  |  | 427 |             	<h2><?php echo $quiz_name ?></h2>
 | 
        
           |  |  | 428 | 			</div>
 | 
        
           |  |  | 429 | 		</div>
 | 
        
           |  |  | 430 | 	</div><!-- /.container-fluid -->
 | 
        
           |  |  | 431 | </section>
 | 
        
           |  |  | 432 |   | 
        
           |  |  | 433 | <section class="content">
 | 
        
           |  |  | 434 | 	<div class="container-fluid">
 | 
        
           |  |  | 435 |     	<div class="row">
 | 
        
           |  |  | 436 |         	<div class="col-12">
 | 
        
           |  |  | 437 | 				<div class="card">
 | 
        
           |  |  | 438 | 					<div class="card-body">
 | 
        
           | 16845 | efrain | 439 |         	    		<table id="gridTable" class="table   table-bordered">
 | 
        
           | 66 | efrain | 440 |                       		<thead>
 | 
        
           |  |  | 441 |         						<tr>
 | 
        
           |  |  | 442 |                                 	<th>LABEL_NAME</th>
 | 
        
           |  |  | 443 |                                   	<th>LABEL_DETAILS</th>
 | 
        
           |  |  | 444 |                                   	<th>LABEL_ACTIONS</th>
 | 
        
           |  |  | 445 |                                 </tr>
 | 
        
           |  |  | 446 |                        		</thead>
 | 
        
           |  |  | 447 |                          	<tbody>
 | 
        
           |  |  | 448 |                          	</tbody>
 | 
        
           |  |  | 449 |                     	</table>
 | 
        
           |  |  | 450 |                    	</div>
 | 
        
           |  |  | 451 |                    	<div class="card-footer clearfix">
 | 
        
           |  |  | 452 |                    		<div style="float:right;">
 | 
        
           |  |  | 453 | 							<button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH  </button>
 | 
        
           |  |  | 454 | 							<?php if($allowAdd) : ?>
 | 
        
           |  |  | 455 | 							<button type="button" class="btn btn-primary btn-add"><i class="fa fa-plus"></i> LABEL_ADD </button>
 | 
        
           |  |  | 456 | 							<?php endif; ?>
 | 
        
           |  |  | 457 | 						</div>
 | 
        
           |  |  | 458 |                  	</div>
 | 
        
           |  |  | 459 |           		</div>
 | 
        
           |  |  | 460 |            	</div>
 | 
        
           |  |  | 461 |         </div>
 | 
        
           |  |  | 462 |  	</div>
 | 
        
           |  |  | 463 | </section>
 | 
        
           |  |  | 464 |   | 
        
           |  |  | 465 |   | 
        
           |  |  | 466 | <div class="modal" tabindex="-1" role="dialog" id="modal-form">
 | 
        
           |  |  | 467 | 	<div class="modal-dialog  modal-lg">
 | 
        
           |  |  | 468 |     	<div class="modal-content">
 | 
        
           |  |  | 469 | 		<?php
 | 
        
           |  |  | 470 | 		$form = $this->formCreateOrEdit;
 | 
        
           |  |  | 471 | 	    $form->setAttributes([
 | 
        
           |  |  | 472 | 	       'method'    => 'post',
 | 
        
           |  |  | 473 | 	        'name'      => 'form',
 | 
        
           |  |  | 474 | 	        'id'        => 'form'
 | 
        
           |  |  | 475 | 	    ]);
 | 
        
           |  |  | 476 | 	    $form->prepare();
 | 
        
           |  |  | 477 | 	    echo $this->form()->openTag($form);
 | 
        
           |  |  | 478 | 	    ?>
 | 
        
           |  |  | 479 |     	<div class="modal-content">
 | 
        
           |  |  | 480 |       		<div class="modal-header">
 | 
        
           |  |  | 481 |         		<h3 class="modal-title" ><span id="form-title">LABEL_ADD</span></h3>
 | 
        
           |  |  | 482 |       		</div>
 | 
        
           |  |  | 483 |       		<div class="modal-body">
 | 
        
           |  |  | 484 |    				<div class="form-group">
 | 
        
           |  |  | 485 |                 	<?php
 | 
        
           |  |  | 486 |                     $element = $form->get('text');
 | 
        
           |  |  | 487 |                     $element->setAttributes(['id' => 'text', 'rows' => '2', 'placeholder' => '', 'class' => 'form-control']);
 | 
        
           |  |  | 488 |                     $element->setOptions(['label' => 'LABEL_TEXT']);
 | 
        
           |  |  | 489 |                     echo $this->formLabel($element);
 | 
        
           |  |  | 490 |                     echo $this->formTextArea($element);
 | 
        
           |  |  | 491 |                     ?>
 | 
        
           |  |  | 492 |    				</div>
 | 
        
           |  |  | 493 |    				<div class="form-group">
 | 
        
           |  |  | 494 |     				<?php
 | 
        
           |  |  | 495 |                         $element = $form->get('type');
 | 
        
           |  |  | 496 |                         $element->setAttributes(['class' => 'form-control']);
 | 
        
           |  |  | 497 |                         $element->setOptions(['label' => 'LABEL_TYPE']);
 | 
        
           |  |  | 498 |                         echo $this->formLabel($element);
 | 
        
           |  |  | 499 |                         echo $this->formSelect($element);
 | 
        
           |  |  | 500 |                     ?>
 | 
        
           |  |  | 501 | 				</div>
 | 
        
           |  |  | 502 |    				<div class="form-group">
 | 
        
           |  |  | 503 |     				<?php
 | 
        
           |  |  | 504 |                         $element = $form->get('maxlength');
 | 
        
           |  |  | 505 |                         $element->setAttributes(['class' => 'form-control']);
 | 
        
           |  |  | 506 |                         $element->setOptions(['label' => 'LABEL_MAXLENGTH']);
 | 
        
           |  |  | 507 |                         echo $this->formLabel($element);
 | 
        
           |  |  | 508 |                         echo $this->formText($element);
 | 
        
           |  |  | 509 |                     ?>
 | 
        
           |  |  | 510 | 				</div>
 | 
        
           |  |  | 511 | 				<div class="form-group">
 | 
        
           |  |  | 512 |     				<?php
 | 
        
           |  |  | 513 |                         $element = $form->get('points');
 | 
        
           |  |  | 514 |                         $element->setAttributes(['class' => 'form-control']);
 | 
        
           |  |  | 515 |                         $element->setOptions(['label' => 'LABEL_POINTS']);
 | 
        
           |  |  | 516 |                         echo $this->formLabel($element);
 | 
        
           |  |  | 517 |                         echo $this->formText($element);
 | 
        
           |  |  | 518 |                     ?>
 | 
        
           |  |  | 519 | 				</div>
 | 
        
           |  |  | 520 |           	</div>
 | 
        
           |  |  | 521 |   | 
        
           |  |  | 522 |          	<div class="modal-footer">
 | 
        
           |  |  | 523 |     			<button type="submit" class="btn btn-primary">LABEL_SAVE</button>
 | 
        
           | 16822 | efrain | 524 |     			 <button type="button" class="btn btn-light" data-bs-dismiss="modal">LABEL_CLOSE</button>
 | 
        
           | 66 | efrain | 525 |           	</div>
 | 
        
           |  |  | 526 |       	<?php echo $this->form()->closeTag($form); ?>
 | 
        
           |  |  | 527 |     	</div>
 | 
        
           |  |  | 528 |     	</div>
 | 
        
           |  |  | 529 |     </div>
 | 
        
           |  |  | 530 | </div>
 |