Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 88 | Rev 90 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
66 efrain 1
<?php
2
use LeadersLinked\Model\CompanyService;
3
use LeadersLinked\Model\Company;
4
 
5
 
6
//$this->headLink()->appendStylesheet($this->basePath('plugins/nprogress/nprogress.css'));
7
//$this->inlineScript()->appendFile($this->basePath('plugins/nprogress/nprogress.js'));
8
 
86 steven 9
$this->headLink()->appendStylesheet($this->basePath('plugins/datatables-bs4/css/dataTables.bootstrap4.min.css'));
10
$this->headLink()->appendStylesheet($this->basePath('plugins/datatables-responsive/css/responsive.bootstrap4.min.css'));
66 efrain 11
 
86 steven 12
$this->inlineScript()->appendFile($this->basePath('plugins/datatables/jquery.dataTables.min.js'));
13
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-bs4/js/dataTables.bootstrap4.min.js'));
14
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-responsive/js/dataTables.responsive.min.js'));
15
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-responsive/js/responsive.bootstrap4.min.js'));
88 steven 16
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/jquery.validate.js'));
17
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/additional-methods.js'));
18
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/localization/messages_es.js'));
89 steven 19
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-input-number/input-number-format.jquery.js'));
20
 
66 efrain 21
$this->inlineScript()->captureStart();
22
echo <<<JS
84 steven 23
		const classFormGenerator = function() {
24
			this.id 				= 0,
25
			this.table				= '',
26
			this.name 				= '',
27
			this.text 				= '',
28
			this.status				= 'a',
29
			this.sections 			= [],
30
			this.clear = function()
31
			{
32
				this.sections = [];
33
				this.render();
34
			},
35
			this.renderSection = function(section_slug)
36
			{
37
 
38
				var s = '';
39
				for(i = 0; i < this.sections.length; i++)
40
				{
41
					if(section_slug !=  this.sections[i].slug) {
42
						continue;
43
					}
44
 
45
					$('span.section-name' + section_slug).html(this.sections[i].name);
46
 
47
					let table = 'table-section-question-option' + this.sections[i].slug;
48
					$('#' + table  + ' tbody').empty();
49
 
50
					s = '<tr class="tr-section" data-slug="' + this.sections[i].slug + '">';
51
					s = s  + '<td class="text-left">Section</td>';
52
					s = s  + '<td class="text-left">' + this.sections[i].name +  '</td>';
53
					s = s  + '<td class="text-right">' + this.sections[i].value + '</td>';
54
					s = s  + '<td>&nbsp</td>';
55
					s = s  + '<td>';
56
					s = s  + '<button class="btn btn-default btn-edit-section" data-slug="' + this.sections[i].slug + '" data-toggle="tooltip" title="Edit Section"><i class="fa fa-edit" aria-hidden="true"></i> Edit section </button>&nbsp';
57
					s = s  + '<button class="btn btn-default btn-delete-section" data-slug="' + this.sections[i].slug + '" data-toggle="tooltip" title="Delete Section"><i class="fa fa-ban" aria-hidden="true"></i> Delete section </button>&nbsp';
58
					s = s  + '<button class="btn btn-default btn-add-question" data-slug="' + this.sections[i].slug + '" data-toggle="tooltip" title="Add Question"><i class="fa fa-plus" aria-hidden="true"></i> Add question </button>&nbsp';
59
					s = s  + '</td>';
60
					s = s  + '</tr>';
61
					$('#' + table + ' tbody').append(s);
62
 
63
 
64
 
65
					for(j = 0; j < this.sections[i].questions.length; j++)
66
					{
67
						this.sections[i].questions[j].position = j;
68
 
69
						this.drawQuestion( this.sections[i].slug, this.sections[i].questions[j].slug, this.sections[i].questions[j].text, this.sections[i].questions[j].value , this.sections[i].questions[j].type);
70
						if(this.sections[i].questions[j].type == 'simple' || this.sections[i].questions[j].type == 'multiple'|| this.sections[i].questions[j].type == 'rating-open') {
71
 
72
 
73
							this.sections[i].questions[j].options.sort(function(a, b) {
74
										if (a.position > b.position) {
75
												return 1;
76
										}
77
										if (a.position < b.position) {
78
											return -1;
79
										}
80
										return 0;
81
									});
82
 
83
 
84
							for(k = 0; k < this.sections[i].questions[j].options.length; k++)
85
							{
86
								this.sections[i].questions[j].options[k].position = j;
87
								this.drawOption(
88
									this.sections[i].slug,
89
									this.sections[i].questions[j].slug,
90
									this.sections[i].questions[j].type,
91
									this.sections[i].questions[j].options[k].slug,
92
									this.sections[i].questions[j].options[k].text,
93
									this.sections[i].questions[j].options[k].type,
94
									this.sections[i].questions[j].options[k].correct,
95
									this.sections[i].questions[j].options[k].value
96
								);
97
							}
98
						}
99
					}
100
				}
101
 
102
				$('[data-toggle="tooltip"]').tooltip();
103
			},
104
			this.drawSection = function(section_slug, section_name, section_value)
105
			{
106
				let table = 'table-section-question-option' + section_slug;
107
				let collapse = 'collapse-' + section_slug;
108
 
109
				s = '<div class="panel panel-default" id="panel' + section_slug + '">';
110
				s = s + '	<div class="panel-heading">';
111
				s = s + '		<h4 class="panel-title">';
112
				s = s + '			<a class="accordion-toggle collapsed" data-toggle="collapse" data-parent="#accordion" href="#' + collapse + '"><span class="section-name' + section_slug + '">' + section_name + '</span></a>';
113
				s = s + '		</h4>';
114
				s = s + '	</div>';
115
				s = s + '	<div id="' + collapse + '" class="panel-collapse collapse">';
116
				s = s + '		<div class="panel-body">';
117
				s = s + '			<div class="table-responsive">';
118
				s = s + '				<table class="table table-bordered" id="' + table + '">';
119
				s = s + '					<thead>';
120
				s = s + '						<tr>';
121
				s = s + '							<th>Element</th>';
122
				s = s + '							<th>Text</th>';
123
				s = s + '							<th>Value</th>';
124
				s = s + '							<th>Type</th>';
125
				s = s + '							<th>Actions</th>';
126
				s = s + '						</tr>';
127
				s = s + '					</thead>';
128
				s = s + '					<tbody>';
129
				s = s + '					</tbody>';
130
				s = s + '				</table>';
131
				s = s + '			</div>';
132
				s = s + '		</div>';
133
				s = s + '	</div>';
134
				s = s + '</div>';
135
 
136
				$('#accordion').append(s);
137
 
138
 
139
				s = '<tr class="tr-section" data-slug="' + section_slug + '">';
140
				s = s  + '<td class="text-left">Section</td>';
141
				s = s  + '<td class="text-left">' + section_name +  '</td>';
142
				s = s  + '<td class="text-right">' + section_value + '</td>';
143
				s = s  + '<td>&nbsp</td>';
144
				s = s  + '<td>';
145
				s = s  + '<button class="btn btn-default btn-edit-section" data-slug="' + section_slug + '" data-toggle="tooltip" title="Edit Section"><i class="fa fa-edit" aria-hidden="true"></i> Edit section</button>&nbsp';
146
				s = s  + '<button class="btn btn-default btn-delete-section" data-slug="' + section_slug + '" data-toggle="tooltip" title="Delete Section"><i class="fa fa-ban" aria-hidden="true"></i> Delete section</button>&nbsp';
147
				s = s  + '<button class="btn btn-default btn-add-question" data-slug="' + section_slug + '" data-toggle="tooltip" title="Add Question"><i class="fa fa-plus" aria-hidden="true"></i> Add question</button>&nbsp';
148
				s = s  + '</td>';
149
				s = s  + '</tr>';
150
				$('#' + table + ' tbody').append(s);
151
			},
152
 
153
			this.drawQuestion = function(section_slug, question_slug, question_text, question_value, question_type)
154
			{
155
 
156
 
157
				s = '<tr class="tr-question" data-slug="' + question_slug + '">';
158
				s = s  + '<td class="text-left">--Question</td>';
159
				s = s  + '<td class="text-left">' + question_text +  '</td>';
160
				s = s  + '<td class="text-right"><font color="red">' + question_value + '</font></td>';
161
				s = s  + '<td>' + question_type.substr(0,1).toUpperCase() + question_type.substr(1) +  '</td>';
162
				s = s  + '<td>';
163
				s = s  + '<button class="btn btn-default btn-edit-question" data-section="' + section_slug + '" data-slug="' + question_slug + '" data-toggle="tooltip" title="Edit Question"><i class="fa fa-edit" aria-hidden="true"></i> Edit question</button>&nbsp';
164
				s = s  + '<button class="btn btn-default btn-delete-question" data-section="' + section_slug + '" data-slug="' + question_slug + '" data-toggle="tooltip" title="Delete Question"><i class="fa fa-ban" aria-hidden="true"></i> Delete question</button>&nbsp';
165
				if(question_type == 'simple' || question_type == 'multiple' || question_type == 'rating-open') {
166
					s = s  + '<button class="btn btn-default btn-add-option" data-section="' + section_slug + '" data-slug="' + question_slug + '" data-toggle="tooltip" title="Add Option"><i class="fa fa-plus" aria-hidden="true"></i> Add option</button>&nbsp';
167
				}
168
 
169
				s = s  + '</td>';
170
 
171
				let table = 'table-section-question-option' + section_slug;
172
				$('#' + table + ' tbody').append(s);
173
			},
174
 
175
			this.drawOption = function(section_slug, question_slug,  question_type, option_slug, option_text, option_type, option_correct, option_value)
176
			{
177
 
178
 
179
				s = '<tr class="tr-option" data-slug="' + option_slug + '">';
180
				s = s  + '<td class="text-left">---Option</td>';
181
				s = s  + '<td class="text-left">' + option_text +  '</td>';
182
				if(question_type == 'multiple' || question_type == 'rating-open') {
183
 
184
					if(question_type == 'multiple') {
185
						if(option_correct == 1) {
186
							s = s  + '<td class="text-right">' + option_value + '</td>';
187
						} else {
188
							s = s  + '<td>&nbsp</td>';
189
						}
190
					} else {
191
						s = s  + '<td class="text-right">' + option_value + '</td>';
192
					}
193
				} else {
194
					s = s  + '<td>&nbsp</td>';
195
				}
196
 
197
				if(question_type == 'simple' || question_type == 'multiple') {
198
					if(option_correct == 1) {
199
						s = s  + '<td class="text-left"><font color="green">Correct</font></td>';
200
					} else {
201
						s = s  + '<td class="text-left"><font color="red">Fail</font></td>';
202
 
203
					}
204
				} else {
205
					s = s  + '<td>&nbsp</td>';
206
				}
207
 
208
 
209
				s = s  + '<td>';
210
				s = s  + '<button class="btn btn-default btn-edit-option" data-section="' + section_slug + '" data-question="' + question_slug + '" data-slug="' + option_slug + '" data-toggle="tooltip" title="Edit Option"><i class="fa fa-edit" aria-hidden="true"></i></button>&nbsp';
211
				s = s  + '<button class="btn btn-default btn-delete-option" data-section="' + section_slug + '" data-question="' + question_slug + '" data-slug="' + option_slug + '" data-toggle="tooltip" title="Delete Option"><i class="fa fa-ban" aria-hidden="true"></i></button>&nbsp';
212
				s = s  + '</td>';
213
 
214
				let table = 'table-section-question-option' + section_slug;
215
				$('#' + table + ' tbody').append(s);
216
 
217
			},
218
 
219
			this.render = function()
220
			{
221
				$('#accordion').empty();
222
 
223
				this.sections.sort(function(a, b) {
224
					if (a.position > b.position) {
225
							return 1;
226
					}
227
					if (a.position < b.position) {
228
						return -1;
229
					}
230
					return 0;
231
				});
232
 
233
				var s = '';
234
				for(i = 0; i < this.sections.length; i++)
235
				{
236
					this.sections[i].position = i;
237
 
238
 
239
					this.drawSection(this.sections[i].slug, this.sections[i].name, this.sections[i].value);
240
 
241
 
242
					this.sections[i].questions.sort(function(a, b) {
243
						if (a.position > b.position) {
244
								return 1;
245
						}
246
						if (a.position < b.position) {
247
							return -1;
248
						}
249
						return 0;
250
					});
251
 
252
 
253
					for(j = 0; j < this.sections[i].questions.length; j++)
254
					{
255
						this.sections[i].questions[j].position = j;
256
 
257
						this.drawQuestion( this.sections[i].slug, this.sections[i].questions[j].slug, this.sections[i].questions[j].text, this.sections[i].questions[j].value , this.sections[i].questions[j].type);
258
						if(this.sections[i].questions[j].type == 'simple' || this.sections[i].questions[j].type == 'multiple'|| this.sections[i].questions[j].type == 'rating-open') {
259
 
260
 
261
							this.sections[i].questions[j].options.sort(function(a, b) {
262
										if (a.position > b.position) {
263
												return 1;
264
										}
265
										if (a.position < b.position) {
266
											return -1;
267
										}
268
										return 0;
269
									});
270
 
271
 
272
							for(k = 0; k < this.sections[i].questions[j].options.length; k++)
273
							{
274
								this.sections[i].questions[j].options[k].position = j;
275
								this.drawOption(
276
									this.sections[i].slug,
277
									this.sections[i].questions[j].slug,
278
									this.sections[i].questions[j].type,
279
									this.sections[i].questions[j].options[k].slug,
280
									this.sections[i].questions[j].options[k].text,
281
									this.sections[i].questions[j].options[k].type,
282
									this.sections[i].questions[j].options[k].correct,
283
									this.sections[i].questions[j].options[k].value
284
								);
285
							}
286
						}
287
 
288
					}
289
 
290
 
291
				}
292
 
293
 
294
				$('[data-toggle="tooltip"]').tooltip();
295
 
296
			},
297
 
298
			this.addSection = function (name, text, value)
299
			{
300
				var d = new Date();
301
					var slug = 'section' + d.getTime();
302
 
303
					var position = 0;
304
					$.each(this.sections, function(index, section) {
305
						if(position < section.position) {
306
							position = section.position;
307
						}
308
					});
309
					position++;
310
 
311
				var section = {
312
					'slug' 		: slug,
313
					'name' 		: name,
314
					'text' 		: text,
315
					'value' 	: value,
316
					'position' 	: position,
317
					'questions' : [],
318
				}
319
 
320
				this.sections.push(section);
321
				this.drawSection(slug, name, text);
322
			},
323
			this.editSection = function (slug, name, text, value)
324
			{
325
				var renderTable = false;
326
				for(i = 0; i < this.sections.length; i++)
327
				{
328
						if(slug == this.sections[i].slug) {
329
							this.sections[i].name = name;
330
							this.sections[i].text = text;
331
							this.sections[i].value = value;
332
							renderTable = true;
333
 
334
							break;
335
						}
336
				}
337
				if(renderTable) {
338
					this.renderSection(slug);
339
				}
340
 
341
 
342
			},
343
			this.deleteSection = function(slug)
344
			{
345
				var renderTable = false;
346
				for(i = 0; i < this.sections.length; i++)
347
				{
348
						if(slug == this.sections[i].slug) {
349
							this.sections.splice(i, 1);
350
 
351
							renderTable = true;
352
							break;
353
					}
354
 
355
 
356
				}
357
				if(renderTable) {
358
					$('#panel' + slug).remove();
359
				}
360
			},
361
			this.addQuestion = function (section_slug, text, value, type, maxlength, multiline, range)
362
			{
363
				var d = new Date();
364
				var slug = 'question' + d.getTime();
365
 
366
				var position = 0;
367
				var renderTable = false;
368
				for(i = 0; i < this.sections.length; i++)
369
				{
370
					if(section_slug == this.sections[i].slug) {
371
						$.each(this.sections[i].questions, function(index, question) {
372
							if(position < question.position) {
373
								position = question.position;
374
							}
375
						});
376
						position++;
377
 
378
						var question = {
379
							'slug' : slug,
380
								'text' : text,
381
								'value' : value,
382
								'type' : type,
383
								'position' : position,
384
								'maxlength' :maxlength,
385
								'multiline' : multiline,
386
								'range' : range,
387
								'options' : [],
388
							}
389
 
390
						this.sections[i].questions.push(question);
391
						renderTable = true;
392
						break;
393
					}
394
				}
395
 
396
				if(renderTable) {
397
					this.renderSection(section_slug);
398
				}
399
			},
400
			this.editQuestion = function(section_slug, question_slug, text, value, type, maxlength, multiline, range)
401
			{
402
				var renderTable = false;
403
				for(i = 0; i < this.sections.length; i++)
404
				{
405
					if(section_slug == this.sections[i].slug) {
406
						for(j = 0; j < this.sections[i].questions.length; j++) {
407
							if(question_slug == this.sections[i].questions[j].slug) {
408
								this.sections[i].questions[j].text 	= text,
409
								this.sections[i].questions[j].value	= value,
410
								this.sections[i].questions[j].type 	= type;
411
 
412
								if(type == 'open') {
413
									this.sections[i].questions[j].maxlength	= maxlength;
414
									this.sections[i].questions[j].multiline	= multiline;
415
									this.sections[i].questions[j].options	= [];
416
								} else {
417
									this.sections[i].questions[j].maxlength	= 0;
418
									this.sections[i].questions[j].multiline	= 0;
419
								}
420
 
421
									if(type == 'rating-range') {
422
										this.sections[i].questions[j].range = range;
423
									} else {
424
										this.sections[i].questions[j].range = 0;
425
									}
426
								renderTable = true;
427
								break;
428
							}
429
						}
430
					}
431
					if(renderTable) {
432
						break;
433
					}
434
				}
435
				if(renderTable) {
436
					this.renderSection(section_slug);
437
				}
438
			},
439
			this.deleteQuestion = function(section_slug, question_slug)
440
			{
441
				var renderTable = false;
442
				for(i = 0; i < this.sections.length; i++)
443
				{
444
						if(section_slug == this.sections[i].slug) {
445
							for(j = 0; j < this.sections[i].questions.length; j++) {
446
							if(question_slug == this.sections[i].questions[j].slug) {
447
									this.sections[i].questions.splice(j, 1);
448
										renderTable = true;
449
										break;
450
							}
451
						}
452
					}
453
 
454
					if(renderTable) {
455
						break;
456
					}
457
				}
458
				if(renderTable) {
459
					this.renderSection(section_slug);
460
				}
461
			},
462
			this.addOption = function (section_slug, question_slug, text, correct, value)
463
			{
464
				var d = new Date();
465
				var slug = 'option' + d.getTime();
466
 
467
				var position = 0;
468
				var renderTable = false;
469
				for(i = 0; i < this.sections.length; i++)
470
				{
471
					if(section_slug == this.sections[i].slug) {
472
						for(j = 0; j < this.sections[i].questions.length; j++) {
473
							if(question_slug == this.sections[i].questions[j].slug) {
474
								$.each(this.sections[i].questions[j].options, function(index, option) {
475
										if(position < option.position) {
476
											position = option.position;
477
										}
478
									});
479
									position++;
480
 
481
									var option = {
482
										'slug' : slug,
483
											'text' : text,
484
											'correct' : correct,
485
											'value' : value
486
										}
487
 
488
										this.sections[i].questions[j].options.push(option);
489
									renderTable = true;
490
									break;
491
							}
492
 
493
									if(renderTable) {
494
								break;
495
							}
496
						}
497
					}
498
				}
499
				if(renderTable) {
500
					this.renderSection(section_slug);
501
				}
502
			},
503
			this.editOption = function(section_slug, question_slug, option_slug, text, correct, value)
504
			{
505
				var renderTable = false;
506
				for(i = 0; i < this.sections.length; i++)
507
				{
508
					if(section_slug == this.sections[i].slug) {
509
						for(j = 0; j < this.sections[i].questions.length; j++) {
510
							if(question_slug == this.sections[i].questions[j].slug) {
511
								for(k = 0; k < this.sections[i].questions[j].options.length; k++) {
512
									if(option_slug == this.sections[i].questions[j].options[k].slug) {
513
										this.sections[i].questions[j].options[k].text = text;
514
										this.sections[i].questions[j].options[k].correct = correct;
515
										this.sections[i].questions[j].options[k].value = value;
516
										renderTable = true;
517
												break;
518
									}
519
								}
520
							}
521
									if(renderTable) {
522
								break;
523
							}
524
						}
525
					}
526
						if(renderTable) {
527
							break;
528
						}
529
				}
530
 
531
				if(renderTable) {
532
					this.renderSection(section_slug);
533
				}
534
			},
535
			this.deleteOption = function(section_slug, question_slug, option_slug)
536
			{
537
				var renderTable = false;
538
				for(i = 0; i < this.sections.length; i++)
539
				{
540
						if(section_slug == this.sections[i].slug) {
541
							for(j = 0; j < this.sections[i].questions.length; j++) {
542
							if(question_slug == this.sections[i].questions[j].slug) {
543
								for(k = 0; k < this.sections[i].questions[j].options.length; k++) {
544
									if(option_slug == this.sections[i].questions[j].options[k].slug) {
545
										this.sections[i].questions[j].options.splice(k, 1);
546
										renderTable = true;
547
												break;
548
									}
549
								}
550
							}
551
									if(renderTable) {
552
								break;
553
							}
554
						}
555
					}
556
 
557
					if(renderTable) {
558
						break;
559
					}
560
				}
561
				if(renderTable) {
562
					this.renderSection(section_slug);
563
				}
564
			}
565
		}
566
 
567
		function htmlEntities(str) {
568
				return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
569
		}
66 efrain 570
    jQuery( document ).ready(function( $ ) {
84 steven 571
			var objFormGenerator = new classFormGenerator();
572
	objFormGenerator.render();
66 efrain 573
 
84 steven 574
 
575
	var tableForm = $('#table-form').dataTable({
576
		select :true,
577
        bProcessing: true,
578
        bServerSide: true,
579
        sAjaxSource: "ajax.<?php echo $this->module; ?>.php?action=gridview",
580
        fnServerData: function (sSource, aoData, fnCallback) {
581
         	$.ajax({
582
               	dataType: 'json',
583
                type: "POST",
584
                url: sSource,
585
                data: aoData,
586
                success: fnCallback
587
          	});
588
        },
589
        aaSorting : [],
590
        aoColumns: [
85 steven 591
					{sName: "checkbox", sTitle : '<input type="checkbox" value="all" data-type="select_all" name="select_all" id="select_all">',bSortable:false,bSearchable:false},
592
					{sName: "name", sTitle: 'Name'},
593
					{sName: "language", sTitle: 'Language'},
594
					{sName: "added_on", sTitle : 'Added on'},
595
					{sName: "status", sTitle: 'Status', bSortable:false, bSearchable:false},
596
					{sName: "operation", sTitle: 'Operation', bSortable: false, bSearchable: false},
84 steven 597
         ],
87 steven 598
        //  fnServerParams: function(aoData){
599
        //  	setTitle(aoData, this)
600
        //  },
84 steven 601
         fnDrawCallback: function(oSettings) {
85 steven 602
         		$('.make-switch-form').bootstrapSwitch();
84 steven 603
            $('.make-switch-form').bootstrapSwitch('setOnClass', 'success');
604
            $('.make-switch-form').bootstrapSwitch('setOffClass', 'danger');
605
         }
606
	});
66 efrain 607
 
84 steven 608
	$('body').on('click', 'a.btn-delete-form',function(e) {
609
		e.preventDefault();
610
		form_id =  $(this).data('id')
611
 
612
		bootbox.confirm({
613
		    title: "Delete Form",
614
		    message: "Are you sure?",
615
		    buttons: {
616
		        cancel: {
617
		            label: '<i class="fa fa-times"></i> Cancel'
618
		        },
619
		        confirm: {
620
		            label: '<i class="fa fa-check"></i> Confirm'
621
		        }
622
		    },
623
		    callback: function (result) {
624
			    if(result) {
625
    		    	$.ajax({
626
    	                'dataType': 'json',
627
    	                'method': 'post',
628
    	                'url' :  'ajax.<?php echo $this->module; ?>.php?action=delete',
629
    	                'data' :{
630
    	                    'form-id' : form_id
631
    	                },
632
    	            }).done(function(response) {
633
 
634
    	                if(response['success']) {
635
    	                	toastr['success'](response['message']);
636
    	                	tableForm.fnDraw();
637
    	                } else {
638
    	                	toastr['error'](response['message']);
639
    	                }
640
    	            }).fail(function( jqXHR, textStatus, errorThrown) {
641
    					toastr['error'](textStatus);
642
    	            });
643
			    }
644
		    }
645
		});
646
 
66 efrain 647
 
84 steven 648
    });
66 efrain 649
 
84 steven 650
    $(document).on('click','[data-action="delete"]',function(){
651
 
652
    	bootbox.confirm({
653
		    title: "Delete Forms",
654
		    message: "Are you sure?",
655
		    buttons: {
656
		        cancel: {
657
		            label: '<i class="fa fa-times"></i> Cancel'
658
		        },
659
		        confirm: {
660
		            label: '<i class="fa fa-check"></i> Confirm'
661
		        }
662
		    },
663
		    callback: function (result) {
664
			    if(result) {
665
			    	var d = currentSelected();
666
    		    	$.ajax({
667
    	                'dataType': 'json',
668
    	                'method': 'post',
669
    	                'url' :  'ajax.<?php echo $this->module; ?>.php?action=delete-selected',
670
    	                'data' :{
671
    	                	 selected : d
672
    	                },
673
    	            }).done(function(response) {
674
 
675
    	                if(response['success']) {
676
    	                	toastr['success'](response['message']);
677
    	                	tableForm.fnDraw();
678
    	                } else {
679
    	                	toastr['error'](response['message']);
680
    	                }
681
    	            }).fail(function( jqXHR, textStatus, errorThrown) {
682
    					toastr['error'](textStatus);
683
    	            });
684
			    }
685
		    }
686
		});
687
 
66 efrain 688
    });
84 steven 689
 
690
 
691
    $('body').on('switch-change', 'input[type="checkbox"].make-switch-form', function(e) {
692
		e.preventDefault();
693
		e.stopPropagation();
694
 
695
		form_id =  $(this).data('id')
696
		form_status = $(this).prop('checked') ? 'A' : 'D';
697
 
698
 
699
		$.ajax({
700
        	'dataType': 'json',
701
            'method': 'post',
702
            'url' :  'ajax.<?php echo $this->module; ?>.php?action=status',
703
            'data' :{
704
            	'form-id' : form_id,
705
            	'form-status' : form_status
706
            },
707
        }).done(function(response) {
708
	        if(response['success']) {
709
	        	toastr['success'](response['message']);
710
	       } else {
711
    	       	toastr['error'](response['message']);
712
            }
713
         }).fail(function( jqXHR, textStatus, errorThrown) {
714
			toastr['error'](textStatus);
715
        })
716
    });
717
 
718
	$('body').on('click', 'a.btn-edit-form',function(e) {
719
		e.preventDefault();
720
		form_id =  $(this).data('id')
721
 
722
		$.ajax({
723
        	'dataType': 'json',
724
            'method': 'post',
725
            'url' :  'ajax.<?php echo $this->module; ?>.php?action=edit',
726
            'data' :{
727
            	'form-id' : form_id
728
            },
729
        }).done(function(response) {
730
	        if(response['success']) {
731
	    		validatorForm.resetForm();
732
 
733
	    		$('#form-main #form-id' ).val(response['id']),
734
	    		$('#form-main #form-continue').val('0');
735
	    		$('#form-main #form-name' ).val(response['name']),
736
 
737
 
738
	    		instanceName = 'form-description';
739
	    		let editor = CKEDITOR.instances[instanceName ];
740
	    		editor.setData(response['description'], function() {
741
	    		    editor.focus();
742
	    		});
743
 
744
 
745
	    		instanceName = 'form-text';
746
	    		CKEDITOR.instances[instanceName ].setData(response['text']);
747
 
748
	    		$( '#form-main #form-language' ).val(response['language']),
749
	    		$( '#form-main #form-status' ).val(response['status']);
750
 
751
	    		objFormGenerator.clear();
752
	    		objFormGenerator.sections = response['sections'];
753
	    		objFormGenerator.render();
754
	    		$('#row-forms').hide();
755
	    		$('#row-edit').show();
756
 
757
	    		$('#form-main #form-name').focus();
758
 
759
            } else {
760
    	       	toastr['error'](response['message']);
761
            }
762
         }).fail(function( jqXHR, textStatus, errorThrown) {
763
			toastr['error'](textStatus);
764
        });
765
 
766
 
767
    });
768
 
769
	 $(document).on('click','[data-type="select_all"]',function(){
770
 
771
	        if($('input[name="select_all"]:checked').val() == 'all'){
772
	            $('[data-type="select"]').prop('checked', true);
773
	            $('[data-action="delete"]').removeClass('hide');
774
	        }else{
775
	            $('[data-type="select"]').prop('checked', false);
776
	            $('[data-action="delete"]').addClass('hide');
777
	        }
778
	    });
779
 
780
	    function getLength(){
781
	        return $('[data-type="select"]').length;
782
	    }
783
 
784
	    function currentSelected(){
785
	        var selected = [];
786
	        $.each($("input[name='select[]']:checked"), function(){
787
	            selected.push($(this).val());
788
	        });
789
 
790
	        return selected;
791
	    }
792
 
793
	    $(document).on('change',"input[name='select[]']",function(){
794
	        var c = currentSelected();
795
	        var cc = getLength();
796
 
797
 
798
	        if(c.length == cc){
799
	            if($('[data-action="delete"]').hasClass('hide')){
800
	                $('[data-action="delete"]').removeClass('hide');
801
	            }
802
	            return true;
803
	        }else{
804
	            $('input[name="select_all"]').prop('checked', false);
805
	        }
806
 
807
	        if(c.length > 0){
808
	            if($('[data-action="delete"]').hasClass('hide')){
809
	                $('[data-action="delete"]').removeClass('hide');
810
	            }
811
	        }else{
812
	            if(!$('[data-action="delete"]').hasClass('hide')){
813
	                $('[data-action="delete"]').addClass('hide');
814
	            }
815
	        }
816
	    });
817
 
818
	    var form3 = $('#form_sample_3');
819
        var error3 = $('.alert-danger', form3);
820
        var success3 = $('.alert-success', form3);
821
 
822
	//IMPORTANT: update CKEDITOR textarea with actual content before submit
823
 	$( "#form-main" ).on('submit', function() {
824
		for(var instanceName in CKEDITOR.instances) {
825
			CKEDITOR.instances[instanceName].updateElement();
826
		}
827
	})
828
 
829
	var validatorForm = $( "#form-main" ).validate( {
830
        ignore: [],
831
        errorClass: 'help-block',
832
        errorElement: 'span',
833
		rules: {
834
			'form-name':  {
835
				required: true,
836
				minlength: 2,
837
				maxlength: 50
838
			},
839
			'form-description' : {
840
				required: true,
841
			},
842
			'form-text' : {
843
				required: true,
844
			},
845
			'form-language' : {
846
				required: true,
847
			},
848
			'forrm-status' : {
849
				required: true,
850
			},
851
		},
852
        highlight: function (element) {
853
            $(element).closest('.form-group').addClass('has-error');
854
        },
855
        unhighlight: function (element) {
856
            $(element).closest('.form-group').removeClass('has-error');
857
        },
858
        errorPlacement: function (error, element) {
859
            if (element.attr("data-error-container")) {
860
                error.appendTo(element.attr("data-error-container"));
861
            } else {
862
                error.insertAfter(element);
863
            }
864
        },
865
        invalidHandler: function(form, validator) {
866
            if (!validator.numberOfInvalids())
867
                return;
868
            $('html, body').animate({
869
                scrollTop: $(validator.errorList[0].element).offset().top - 100
870
            }, 1000);
871
        },
872
		submitHandler: function(form) {
873
		    // do other things for a valid form
874
		    //form.submit();
875
 
876
 
877
		    var error = false;
878
		    if(objFormGenerator.sections.length == 0) {
879
		    	toastr['error']('There are no sections');
880
		    	error = true;
881
		    } else {
882
 
883
		    	for(i = 0; i < objFormGenerator.sections.length; i++)
884
		    	{
885
 
886
		    		if(objFormGenerator.sections[i].questions.length == 0) {
887
		    			toastr['error']('The "' + objFormGenerator.sections[i].name + '" section has no questions');
888
		    			break;
889
		    		}
890
 
891
		    		var valueSection = parseInt(objFormGenerator.sections[i].value);
892
		    		var totalValueQuestion = 0;
893
 
894
 
895
		    		for(j = 0; j < objFormGenerator.sections[i].questions.length; j++)
896
		    		{
897
		    			valueQuestion = parseInt(objFormGenerator.sections[i].questions[j].value);
898
		    			totalValueQuestion = totalValueQuestion + valueQuestion;
899
		    			if(objFormGenerator.sections[i].questions[j].type == 'simple'
900
			    			|| objFormGenerator.sections[i].questions[j].type == 'multiple'
901
			    			|| objFormGenerator.sections[i].questions[j].type == 'rating-open' ) {
902
 
903
		    				var questionNumber = j + 1;
904
		    				var numberCorrect = 0;
905
 
906
 
907
		    				if(objFormGenerator.sections[i].questions[j].options.length == 0) {
908
		    					toastr['error']('The "' + objFormGenerator.sections[i].name + '" section, questions #' + questionNumber + ' has no options');
909
								error = true;
910
								break;
911
		    				}
912
 
913
 
914
		    				var totalOption = 0;
915
		    				var maxOption = 0;
916
		    				for(k = 0;  k < objFormGenerator.sections[i].questions[j].options.length; k++)
917
		    				{
918
		    					if(objFormGenerator.sections[i].questions[j].type == 'simple' || objFormGenerator.sections[i].questions[j].type == 'multiple' ) {
919
    		    					if(objFormGenerator.sections[i].questions[j].options[k].correct == 1) {
920
    		    						numberCorrect++;
921
    		    					}
922
		    					}
923
 
924
		    					if(objFormGenerator.sections[i].questions[j].type == 'multiple' && objFormGenerator.sections[i].questions[j].options[k].correct == 1) {
925
		    						totalOption = totalOption + parseInt(objFormGenerator.sections[i].questions[j].options[k].value);
926
			    				}
927
 
928
		    					if(objFormGenerator.sections[i].questions[j].type == 'rating-open') {
929
		    						if(parseInt(objFormGenerator.sections[i].questions[j].options[k].value) > maxOption) {
930
										maxOption = parseInt(objFormGenerator.sections[i].questions[j].options[k].value);
931
					    			}
932
			    				}
933
 
934
		    				}
935
 
936
		    				if(objFormGenerator.sections[i].questions[j].type == 'simple' || objFormGenerator.sections[i].questions[j].type == 'multiple' ) {
937
 
938
    		    				if(numberCorrect == 0) {
939
    		    					toastr['error']('The "' + objFormGenerator.sections[i].name + '" section, questions #' + questionNumber + '  has no correct option');
940
    		    					error = true;
941
    		    					break;
942
    		    				}
943
    		    				if(objFormGenerator.sections[i].questions[j].type == 'simple' && numberCorrect > 1) {
944
    		    					toastr['error']('The "' + objFormGenerator.sections[i].name + '" section, questions #' + questionNumber + '   has more than one correct option');
945
    		    					error = true;
946
    		    					break;
947
    		    				}
948
    		    				if(objFormGenerator.sections[i].questions[j].type == 'multiple' && numberCorrect == 1) {
949
    		    					toastr['error']('The "' + objFormGenerator.sections[i].name + '" section, questions #' + questionNumber + '    has only one correct option');
950
    		    					error = true;
951
    		    					break;
952
    		    				}
953
		    				}
954
 
955
			    			//console.log('totalOption = ' + totalOption + ' valueQuestion = ' + valueQuestion );
956
 
957
			 				if(objFormGenerator.sections[i].questions[j].type == 'multiple' && totalOption > valueQuestion ) {
958
		     					toastr['error']('The "' + objFormGenerator.sections[i].name + '" section, questions #' + questionNumber + ' the sum of the values of the options is greater than the value of the question');
959
		    					error = true;
960
		    					break;
961
			    			}
962
 
963
							//console.log('maxOption = ' + maxOption + ' valueQuestion = ' + valueQuestion );
964
 
965
		    				if(objFormGenerator.sections[i].questions[j].type == 'rating-open' && maxOption > valueQuestion ) {
966
		     					toastr['error']('The "' + objFormGenerator.sections[i].name + '" section, questions #' + questionNumber + ' the value of an option is greater than the value of the question');
967
		    					error = true;
968
		    					break;
969
			    			}
970
						}
971
 
972
 
973
		    		}
974
 
975
		    		if(valueSection != totalValueQuestion) {
976
		    			toastr['error']('The values of the "' + objFormGenerator.sections[i].name + '" section and the questions are not the same');
977
		    			error = true;
978
		    			break;
979
					}
980
				}
981
 
982
 
983
 
984
    			if(error) {
985
    				return false;
986
    			} else {
987
 
988
 
989
    				var formId		= parseInt($( '#form-main #form-id' ).val());
990
    				var formContinue = parseInt($( '#form-main #form-continue' ).val());
991
 
992
    				var data = {
993
    	    			'form-id'	: formId,
994
        				'form-name' : $( '#form-main #form-name' ).val(),
995
        				'form-description' : $( '#form-main #form-description' ).val(),
996
        				'form-text' : $( '#form-main #form-text' ).val(),
997
        				'form-language' : $( '#form-main #form-language' ).val(),
998
        				'form-status' : $( '#form-main #form-status' ).val(),
999
        				'sections' : objFormGenerator.sections
1000
    				}
1001
 
1002
 
1003
    				$.ajax({
1004
                        'dataType': 'json',
1005
                        'method': 'post',
1006
                        'url' :  'ajax.<?php echo $this->module; ?>.php?action=save',
1007
                        'data' : data,
1008
                    }).done(function(response) {
1009
 
1010
                        if(response['success']) {
1011
                        	toastr['success'](response['message']);
1012
							if(formContinue == 1) {
1013
								$('#form-main #form-id').val(response['form-id']);
1014
								$('#form-main #form-continue').val(0);
1015
							} else {
1016
								$('#row-edit').hide();
1017
                        		$('#row-forms').show();
1018
							}
1019
 
1020
 
1021
							tableForm.fnDraw();
1022
 
1023
                        } else {
1024
                        	toastr['error'](response['message']);
1025
                        }
1026
                    }).fail(function( jqXHR, textStatus, errorThrown) {
1027
						toastr['error'](textStatus);
1028
                    });
1029
 
1030
                    return false;
1031
 
1032
 
1033
    			}
1034
			}
1035
 
1036
 
1037
		}
1038
	});
1039
 
1040
	//IMPORTANT: update CKEDITOR textarea with actual content before submit
1041
 	$( "#form-section" ).on('submit', function() {
1042
		for(var instanceName in CKEDITOR.instances) {
1043
			CKEDITOR.instances[instanceName].updateElement();
1044
		}
1045
	})
1046
 
1047
	var validatorFormSection = $( "#form-section" ).validate( {
1048
        ignore: [],
1049
        errorClass: 'help-block',
1050
        errorElement: 'span',
1051
		rules: {
1052
			'section-name':  {
1053
				required: true,
1054
				minlength: 2,
1055
				maxlength: 50
1056
			},
1057
			'section-text' : {
1058
				required: false,
1059
			},
1060
			'section-value' : {
1061
				required: true,
1062
				number: true,
1063
				min: 1
1064
			},
1065
		},
1066
        highlight: function (element) {
1067
            $(element).closest('.form-group').addClass('has-error');
1068
        },
1069
        unhighlight: function (element) {
1070
            $(element).closest('.form-group').removeClass('has-error');
1071
        },
1072
        errorPlacement: function (error, element) {
1073
            if (element.attr("data-error-container")) {
1074
                error.appendTo(element.attr("data-error-container"));
1075
            } else {
1076
                error.insertAfter(element);
1077
            }
1078
        },
1079
        invalidHandler: function(form, validator) {
1080
            if (!validator.numberOfInvalids())
1081
                return;
1082
            $('html, body').animate({
1083
                scrollTop: $(validator.errorList[0].element).offset().top - 100
1084
            }, 1000);
1085
        },
1086
		submitHandler: function(form) {
1087
		    // do other things for a valid form
1088
		    //form.submit();
1089
 
1090
		    var slug = $('#form-section #section-slug').val();
1091
		    if(slug) {
1092
		    	objFormGenerator.editSection(
1093
		    		$('#form-section #section-slug').val(),
1094
			    	$('#form-section #section-name').val(),
1095
			    	$('#form-section #section-text').val(),
1096
			    	$('#form-section #section-value').val()
1097
			  	);
1098
		    } else {
1099
		    	objFormGenerator.addSection(
1100
		    		$('#form-section #section-name').val(),
1101
		    		$('#form-section #section-text').val(),
1102
		    		$('#form-section #section-value').val()
1103
		    	);
1104
		    }
1105
 
1106
 
1107
 
1108
			$('#modal-section').modal('hide');
1109
			return false;
1110
		  }
1111
	} );
1112
 
1113
	//IMPORTANT: update CKEDITOR textarea with actual content before submit
1114
 	$( "#form-question" ).on('submit', function() {
1115
		for(var instanceName in CKEDITOR.instances) {
1116
			CKEDITOR.instances[instanceName].updateElement();
1117
		}
1118
	})
1119
 
1120
 
1121
	var validatorFormQuestion = $( "#form-question" ).validate( {
1122
        ignore: [],
1123
        errorClass: 'help-block',
1124
        errorElement: 'span',
1125
		rules: {
1126
			'question-text' : {
1127
				required: true,
1128
			},
1129
			'question-value' : {
1130
				required: true,
1131
				number: true,
1132
				min: 1
1133
			},
1134
			'question-type':  {
1135
				required: true,
1136
			},
1137
			'question-max-length' : {
1138
				required: true,
1139
				digits: true,
1140
				min: 0
1141
			},
1142
			'question-range' : {
1143
				required: true,
1144
				number: true,
1145
				min: 1
1146
			},
1147
		},
1148
        highlight: function (element) {
1149
            $(element).closest('.form-group').addClass('has-error');
1150
        },
1151
        unhighlight: function (element) {
1152
            $(element).closest('.form-group').removeClass('has-error');
1153
        },
1154
        errorPlacement: function (error, element) {
1155
            if (element.attr("data-error-container")) {
1156
                error.appendTo(element.attr("data-error-container"));
1157
            } else {
1158
                error.insertAfter(element);
1159
            }
1160
        },
1161
        invalidHandler: function(form, validator) {
1162
 
1163
			//console.log(validator);
1164
 
1165
            if (!validator.numberOfInvalids())
1166
                return;
1167
            $('html, body').animate({
1168
                scrollTop: $(validator.errorList[0].element).offset().top - 100
1169
            }, 1000);
1170
        },
1171
		submitHandler: function(form) {
1172
		    // do other things for a valid form
1173
		    //form.submit();
1174
 
1175
		    /*console.log('submitHandler');
1176
		    console.log('question-section = ' + $('#form-question #question-section').val());
1177
		    console.log('question-text = ' + $('#form-question #question-text').val());
1178
		    console.log('question-value = ' + $('#form-question #question-value').val());
1179
		    console.log('question-type = ' + $('#form-question #question-type').val());
1180
		    console.log('question-max-length = ' + $('#form-question #question-max-length').val());
1181
		    console.log('question-multiline = ' + $('#form-question #question-multiline').val());
1182
		    console.log('question-range = ' + $('#form-question #question-range').val());*/
1183
 
1184
 
1185
 
1186
		    if($('#form-question #question-slug').val()) {
1187
		    	console.log('editQuestion');
1188
 
1189
		    	objFormGenerator.editQuestion(
1190
		    		$('#form-question #question-section').val(),
1191
		    		$('#form-question #question-slug').val(),
1192
		    		$('#form-question #question-text').val(),
1193
		    		$('#form-question #question-value').val(),
1194
			    	$('#form-question #question-type').val(),
1195
			    	$('#form-question #question-max-length').val(),
1196
	    			$('#form-question #question-multiline').val(),
1197
	    			$('#form-question #question-range').val()
1198
			  	);
1199
		    } else {
1200
		    	console.log('addQuestion');
1201
 
1202
		    	objFormGenerator.addQuestion(
1203
			    	$('#form-question #question-section').val(),
1204
			    	$('#form-question #question-text').val(),
1205
			    	$('#form-question #question-value').val(),
1206
				    $('#form-question #question-type').val(),
1207
				    $('#form-question #question-max-length').val(),
1208
		    		$('#form-question #question-multiline').val(),
1209
		    		$('#form-question #question-range').val()
1210
		    	);
1211
		    }
1212
 
1213
			$('#modal-question').modal('hide');
1214
			return false;
1215
		  }
1216
	} );
1217
 
1218
	//IMPORTANT: update CKEDITOR textarea with actual content before submit
1219
 	$( "#form-option" ).on('submit', function() {
1220
		for(var instanceName in CKEDITOR.instances) {
1221
			CKEDITOR.instances[instanceName].updateElement();
1222
		}
1223
	})
1224
 
1225
	var validatorFormOption = $( "#form-option" ).validate( {
1226
        ignore: [],
1227
        errorClass: 'help-block',
1228
        errorElement: 'span',
1229
		rules: {
1230
			'option-text' : {
1231
				required: true,
1232
			},
1233
        	'option-value' : {
1234
				required: true,
1235
				number: true,
1236
				min: 1
1237
        	}
1238
		},
1239
        highlight: function (element) {
1240
            $(element).closest('.form-group').addClass('has-error');
1241
        },
1242
        unhighlight: function (element) {
1243
            $(element).closest('.form-group').removeClass('has-error');
1244
        },
1245
        errorPlacement: function (error, element) {
1246
            if (element.attr("data-error-container")) {
1247
                error.appendTo(element.attr("data-error-container"));
1248
            } else {
1249
                error.insertAfter(element);
1250
            }
1251
        },
1252
        invalidHandler: function(form, validator) {
1253
            if (!validator.numberOfInvalids())
1254
                return;
1255
            $('html, body').animate({
1256
                scrollTop: $(validator.errorList[0].element).offset().top - 100
1257
            }, 1000);
1258
        },
1259
		submitHandler: function(form) {
1260
		    // do other things for a valid form
1261
		    //form.submit();
1262
 
1263
 
1264
		    if($('#form-option #option-slug').val()) {
1265
		    	objFormGenerator.editOption(
1266
		    		$('#form-option #option-section').val(),
1267
		    		$('#form-option #option-question').val(),
1268
		    		$('#form-option #option-slug').val(),
1269
		    		$('#form-option #option-text').val(),
1270
		    		$('#form-option #option-correct').val(),
1271
		    		$('#form-option #option-value').val()
1272
			  	);
1273
		    } else {
1274
		    	objFormGenerator.addOption(
1275
			    	$('#form-option #option-section').val(),
1276
			    	$('#form-option #option-question').val(),
1277
			    	$('#form-option #option-text').val(),
1278
			    	$('#form-option #option-correct').val(),
1279
			    	$('#form-option #option-value').val()
1280
		    	);
1281
		    }
1282
 
1283
 
1284
 
1285
 
1286
			$('#modal-option').modal('hide');
1287
			return false;
1288
		  }
1289
	} );
1290
 
1291
	$('body').on('click', 'button[id="btn-add-section"]', function(e){
1292
		e.preventDefault();
1293
 
1294
		validatorFormSection.resetForm();
1295
		$('#form-section #section-slug').val('');
1296
		$('#form-section #section-name').val('');
1297
 
1298
		instanceName = 'section-text';
1299
		let editor = CKEDITOR.instances[instanceName ];
1300
		editor.setData( '', function() {
1301
		    editor.focus();
1302
		});
1303
 
1304
 
1305
		$('#form-section #section-value').val('0');
1306
		$('#modal-section h4[class="modal-title"]').html('New Section');
1307
		$('#modal-section').modal('show');
1308
	});
1309
 
1310
	$('body').on('click', 'button.btn-edit-section', function(e){
1311
	    e.preventDefault();
1312
 
1313
	    var slug = $(this).data('slug');
1314
	    var section;
1315
	    var showForm = false;
1316
 
1317
	    for(i = 0; i < objFormGenerator.sections.length; i++) {
1318
	        section = objFormGenerator.sections[i];
1319
 
1320
	    	if(slug == section.slug) {
1321
 
1322
		    	//console.log('btn-edit-section');
1323
		    	//console.log(section);
1324
 
1325
				validatorFormSection.resetForm();
1326
	    		$('#form-section #section-slug').val(section.slug);
1327
	    		$('#form-section #section-name').val(section.name);
1328
 
1329
	    		instanceName = 'section-text';
1330
	    		let editor = CKEDITOR.instances[instanceName ];
1331
	    		editor.setData( section.text, function() {
1332
	    		    editor.focus();
1333
	    		});
1334
 
1335
				$('#form-section #section-value').val(section.value);
1336
 
1337
				showForm = true;
1338
				break;
1339
	    	}
1340
	    }
1341
 
1342
	    if(showForm) {
1343
	    	$('#modal-section h4[class="modal-title"]').html('Edit Section');
1344
			$('#modal-section').modal('show');
1345
	    }
1346
 
1347
	});
1348
 
1349
	$('body').on('click', 'button.btn-delete-section', function(e){
1350
		e.preventDefault();
1351
		var slug = $(this).data('slug');
1352
 
1353
		bootbox.confirm({
1354
		    title: "Delete Section?",
1355
		    message: "Are you sure?",
1356
		    buttons: {
1357
		        cancel: {
1358
		            label: '<i class="fa fa-times"></i> Cancel'
1359
		        },
1360
		        confirm: {
1361
		            label: '<i class="fa fa-check"></i> Confirm'
1362
		        }
1363
		    },
1364
		    callback: function (result) {
1365
		    	if (result) {
1366
					objFormGenerator.deleteSection(slug);
1367
				}
1368
		    }
1369
		});
1370
 
1371
 
1372
 
1373
	});
1374
 
1375
 
1376
	$('body').on('click', 'button.btn-add-question', function(e){
1377
		e.preventDefault();
1378
 
1379
		validatorFormQuestion.resetForm();
1380
		var slug = $(this).data('slug');
1381
 
1382
		$('#form-question #question-section').val(slug);
1383
		$('#form-question #question-slug').val('');
1384
 
1385
		instanceName = 'question-text';
1386
		let editor = CKEDITOR.instances[instanceName ];
1387
		editor.setData( '', function() {
1388
		    editor.focus();
1389
		});
1390
 
1391
 
1392
		$('#form-question #question-value').val('0');
1393
		$('#form-question #question-type').val($('#form-question #question-type option:first').val());
1394
 
1395
		$('#form-question #question-max-length').val('0');
1396
		$('#form-question #question-max-length').parent().show();
1397
 
1398
		$('#form-question #question-multiline').val('0');
1399
		$('#form-question #question-multiline').parent().show();
1400
 
1401
		$('#form-question #question-range').val('10');
1402
		$('#form-question #question-range').parent().hide();
1403
 
1404
		$('#modal-question h4[class="modal-title"]').html('New Question');
1405
		$('#modal-question').modal('show');
1406
 
1407
	});
1408
 
1409
 
1410
 
1411
	$('body').on('click', 'button.btn-edit-question', function(e){
1412
	    e.preventDefault();
1413
 
1414
	    var slug_section	= $(this).data('section');
1415
	    var slug 			= $(this).data('slug');
1416
	    var showForm 		= false;
1417
 
1418
	    for(i = 0; i < objFormGenerator.sections.length; i++) {
1419
 
1420
	    	if(slug_section == objFormGenerator.sections[i].slug) {
1421
 
1422
	    		for(j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
1423
 
1424
	    			if(slug == objFormGenerator.sections[i].questions[j].slug) {
1425
	    				validatorFormQuestion.resetForm();
1426
 
1427
	    				$('#form-question #question-section').val(objFormGenerator.sections[i].slug);
1428
	    				$('#form-question #question-slug').val(objFormGenerator.sections[i].questions[j].slug);
1429
 
1430
	    	    		instanceName = 'question-text';
1431
	    	    		let editor = CKEDITOR.instances[instanceName ];
1432
	    	    		editor.setData( objFormGenerator.sections[i].questions[j].text, function() {
1433
	    	    		    editor.focus();
1434
	    	    		});
1435
 
1436
 
1437
	        			$('#form-question #question-value').val(objFormGenerator.sections[i].questions[j].value);
1438
	        			$('#form-question #question-type').val(objFormGenerator.sections[i].questions[j].type);
1439
 
1440
 
1441
 
1442
	        			if(objFormGenerator.sections[i].questions[j].type == 'open') {
1443
		        			$('#form-question #question-max-length').val(objFormGenerator.sections[i].questions[j].maxlength);
1444
		        			$('#form-question #question-max-length').parent().show();
1445
 
1446
		        			$('#form-question #question-multiline').val(objFormGenerator.sections[i].questions[j].multiline);
1447
							$('#form-question #question-multiline').parent().show();
1448
	        			} else {
1449
		        			$('#form-question #question-max-length').val('0');
1450
		        			$('#form-question #question-max-length').parent().hide();
1451
 
1452
		        			$('#form-question #question-multiline').val('0');
1453
							$('#form-question #question-multiline').parent().hide();
1454
	        			}
1455
 
1456
	        			if(objFormGenerator.sections[i].questions[j].type == 'rating-range') {
1457
	            			$('#form-question #question-range').val(objFormGenerator.sections[i].questions[j].range);
1458
		        			$('#form-question #question-range').parent().show();
1459
 
1460
	        			} else {
1461
	            			$('#form-question #question-range').val('10');
1462
		        			$('#form-question #question-range').parent().hide();
1463
		        		}
1464
 
1465
    					showForm = true;
1466
    					break;
1467
 
1468
	    			}
1469
 
1470
	    		}
1471
 
1472
	    		break;
1473
	    	}
1474
	    }
1475
 
1476
	    if(showForm) {
1477
	    	$('#modal-question h4[class="modal-title"]').html('Edit Question');
1478
			$('#modal-question').modal('show');
1479
	    }
1480
 
1481
	});
1482
 
1483
 
1484
 
1485
 
1486
	$('body').on('click', 'button.btn-delete-question', function(e){
1487
		e.preventDefault();
1488
 
1489
		var slug_section	= $(this).data('section');
1490
		var slug 			= $(this).data('slug');
1491
 
1492
		bootbox.confirm({
1493
			title: "Delete Question?",
1494
			message: "Are you sure?",
1495
			buttons: {
1496
				cancel: {
1497
   					label: '<i class="fa fa-times"></i> Cancel'
1498
    			},
1499
			    confirm: {
1500
			    	label: '<i class="fa fa-check"></i> Confirm'
1501
			    }
1502
			},
1503
			callback: function (result) {
1504
				if (result) {
1505
					objFormGenerator.deleteQuestion(slug_section, slug);
1506
				}
1507
			}
1508
		});
1509
	});
1510
 
1511
 
1512
	$('body').on('click', 'button.btn-add-option', function(e){
1513
		e.preventDefault();
1514
	    var slug_section	= $(this).data('section');
1515
		var slug_question 	= $(this).data('slug');
1516
		var showForm 		= false;
1517
 
1518
	    for(i = 0; i < objFormGenerator.sections.length; i++) {
1519
	    	if(slug_section == objFormGenerator.sections[i].slug) {
1520
	    		for(j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
1521
	    			if(slug_question == objFormGenerator.sections[i].questions[j].slug) {
1522
 
1523
                		validatorFormOption.resetForm();
1524
                		$('#form-option #option-section').val(slug_section);
1525
                		$('#form-option #option-question').val(slug_question);
1526
                		$('#form-option #option-slug').val('');
1527
 
1528
                		instanceName = 'option-text';
1529
	    	    		let editor = CKEDITOR.instances[instanceName ];
1530
	    	    		editor.setData( '', function() {
1531
	    	    		    editor.focus();
1532
	    	    		});
1533
 
1534
 
1535
	    	    		$('#form-option #option-correct').val('0');
1536
                		if(objFormGenerator.sections[i].questions[j].type == 'rating-open') {
1537
                    		$('#form-option #option-correct').parent().hide();
1538
                        } else {
1539
                    		$('#form-option #option-correct').parent().show();
1540
                        }
1541
 
1542
                		if(objFormGenerator.sections[i].questions[j].type == 'multiple' || objFormGenerator.sections[i].questions[j].type == 'rating-open') {
1543
                			$('#form-option #option-value').val('0');
1544
                			$('#form-option #option-value').parent().show();
1545
                		} else {
1546
                			$('#form-option #option-value').val('1');
1547
                			$('#form-option #option-value').parent().hide();
1548
 
1549
                       	}
1550
                		showForm = true;
1551
	    			}
1552
	    		}
1553
	    	}
1554
	    }
1555
 
1556
		if(showForm) {
1557
    		$('#modal-option h4[class="modal-title"]').html('New Option');
1558
    		$('#modal-option').modal('show');
1559
		}
1560
 
1561
	});
1562
 
1563
 
1564
 
1565
	$('body').on('click', 'button.btn-edit-option', function(e){
1566
	    e.preventDefault();
1567
 
1568
	    var slug_section	= $(this).data('section');
1569
	    var slug_question	= $(this).data('question');
1570
	    var slug 			= $(this).data('slug');
1571
	    var showForm 		= false;
1572
 
1573
	    for(i = 0; i < objFormGenerator.sections.length; i++) {
1574
	    	if(slug_section == objFormGenerator.sections[i].slug) {
1575
	    		for(j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
1576
	    			if(slug_question == objFormGenerator.sections[i].questions[j].slug) {
1577
	    				for(k = 0; k < objFormGenerator.sections[i].questions[j].options.length; k++) {
1578
	    					if(slug == objFormGenerator.sections[i].questions[j].options[k].slug) {
1579
	    						validatorFormOption.resetForm();
1580
	    						$('#form-option #option-section').val(objFormGenerator.sections[i].slug);
1581
	    						$('#form-option #option-question').val(objFormGenerator.sections[i].questions[j].slug);
1582
    		    				$('#form-option #option-slug').val(objFormGenerator.sections[i].questions[j].options[k].slug);
1583
 
1584
    		    				instanceName = 'option-text';
1585
    		    	    		let editor = CKEDITOR.instances[instanceName ];
1586
    		    	    		editor.setData( objFormGenerator.sections[i].questions[j].options[k].text, function() {
1587
    		    	    		    editor.focus();
1588
    		    	    		});
1589
 
1590
 
1591
    		    				$('#form-option #option-correct').val(objFormGenerator.sections[i].questions[j].options[k].correct);
1592
    		    				if(objFormGenerator.sections[i].questions[j].type == 'multiple' || objFormGenerator.sections[i].questions[j].type == 'simple') {
1593
    		    					$('#form-option #option-correct').parent().show();
1594
    		    				} else {
1595
    		    					$('#form-option #option-correct').parent().hide();
1596
            		    		}
1597
 
1598
    		    				$('#form-option #option-value').val(objFormGenerator.sections[i].questions[j].options[k].value);
1599
 
1600
								if(objFormGenerator.sections[i].questions[j].type == 'multiple' || objFormGenerator.sections[i].questions[j].type == 'rating-open') {
1601
    		    					$('#form-option #option-value').parent().show();
1602
								} else {
1603
									$('#form-option #option-value').parent().hide();
1604
								}
1605
 
1606
 
1607
 
1608
    		    				showForm = true;
1609
    	    					break;
1610
	    					}
1611
	    				}
1612
	    			}
1613
	    			if(showForm) {
1614
		    			break;
1615
		    		}
1616
	    		}
1617
	    	}
1618
			if(showForm) {
1619
    			break;
1620
    		}
1621
	    }
1622
 
1623
	    if(showForm) {
1624
	    	$('#modal-option h4[class="modal-title"]').html('Edit Option');
1625
			$('#modal-option').modal('show');
1626
	    }
1627
	});
1628
 
1629
	$('body').on('click', 'button.btn-delete-option', function(e){
1630
		e.preventDefault();
1631
		var slug_section	= $(this).data('section');
1632
		var slug_question	= $(this).data('question');
1633
		    var slug 			= $(this).data('slug');
1634
 
1635
 
1636
		bootbox.confirm({
1637
			title: "Delete Option?",
1638
			message: "Are you sure?",
1639
			buttons: {
1640
				cancel: {
1641
	   				label: '<i class="fa fa-times"></i> Cancel'
1642
	    		},
1643
				confirm: {
1644
					label: '<i class="fa fa-check"></i> Confirm'
1645
				}
1646
			},
1647
			callback: function (result) {
1648
				if (result) {
1649
					objFormGenerator.deleteOption(slug_section, slug_question, slug);
1650
				}
1651
			}
1652
		});
1653
	})
1654
 
1655
	$('#form-section #section-value').inputNumberFormat({'decimal' : 2});
1656
 
1657
	$('#form-question #question-value').inputNumberFormat({'decimal' : 2});
1658
	$('#form-question #question-max-length').inputNumberFormat({'decimal' : 0});
1659
 
1660
	$('#form-option #option-value').inputNumberFormat({'decimal' : 2});
1661
 
1662
	$('#form-question #question-type').change(function(e) {
1663
		e.preventDefault();
1664
 
1665
		if($('#form-question #question-type').val() == 'open') {
1666
			$('#form-question #question-max-length').parent().show();
1667
			$('#form-question #question-multiline').parent().show();
1668
 
1669
		} else {
1670
			$('#form-question #question-max-length').val('0');
1671
			$('#form-question #question-max-length').parent().hide();
1672
 
1673
			$('#form-question #question-multiline').val('0');
1674
			$('#form-question #question-multiline').parent().hide();
1675
		}
1676
 
1677
		$('#form-question #question-range').val('10');
1678
		if($('#form-question #question-type').val() == 'rating-range') {
1679
			$('#form-question #question-range').parent().show();
1680
		} else {
1681
			$('#form-question #question-range').parent().hide();
1682
		}
1683
 
1684
 
1685
 
1686
	});
1687
 
1688
	$('button.btn-add-form').click(function(e) {
1689
		e.preventDefault();
1690
 
1691
		objFormGenerator.clear();
1692
		objFormGenerator.render();
1693
		validatorForm.resetForm();
1694
 
1695
		$('#form-main #form-id').val('0');
1696
		$('#form-main #form-continue').val('0');
1697
		$('#form-main #form-name').val('');
1698
 
1699
		instanceName = 'form-text';
1700
		let editor = CKEDITOR.instances[instanceName ];
1701
		editor.setData('', function() {
1702
		    editor.focus();
1703
		});
1704
 
1705
 
1706
		instanceName = 'form-description';
1707
		CKEDITOR.instances[instanceName ].setData('');
1708
 
1709
		$( '#form-main #form-language' ).val('EN'),
1710
		$( '#form-main #form-status' ).val('D');
1711
 
1712
		$('#row-forms').hide();
1713
		$('#row-edit').show();
1714
		$('#form-main #form-name').focus();
1715
 
1716
        /*$('html, body').animate({
1717
            scrollTop: $('#form-main #form-name').offset().top - 100
1718
        }, 1000);*/
1719
	});
1720
 
1721
	$('button.btn-edit-cancel').click(function(e) {
1722
		e.preventDefault();
1723
		$('#row-edit').hide();
1724
		$('#row-forms').show();
1725
 
1726
	});
1727
 
1728
 
1729
	$('button.btn-form-save-continue').click(function(e) {
1730
		e.preventDefault();
1731
		$('#form-main #form-continue').val('1')
1732
		$('#form-main').submit();
1733
	});
1734
 
1735
	$('button.btn-form-save-close').click(function(e) {
1736
		e.preventDefault();
1737
		$('#form-main #form-continue').val('0')
1738
		$('#form-main').submit();
1739
 
1740
	});
1741
 
1742
	$('#modal-section, #modal-question, #modal-option').modal({
1743
	    backdrop: 'static',
1744
	    keyboard: false,
1745
	    show: false
1746
	});
1747
    });
66 efrain 1748
JS;
1749
$this->inlineScript()->captureEnd();
1750
?>
83 steven 1751
<style type="text/css">
1752
    /*#uniform-select_all{0
1753
        margin-left: 15px;
1754
    }*/
66 efrain 1755
 
83 steven 1756
    tbody input[type="checkbox"]{
1757
        margin-left: 14px;
1758
    }
1759
 
1760
   .panel-heading .accordion-toggle:after {
1761
        /* symbol for "opening" panels */
1762
        font-family: 'Glyphicons Halflings';  /* essential for enabling glyphicon */
1763
        content: "\e114";    /* adjust as needed, taken from bootstrap.css */
1764
        float: right;        /* adjust as needed */
1765
        color: grey;         /* adjust as needed */
1766
    }
1767
    .panel-heading .accordion-toggle.collapsed:after {
1768
        /* symbol for "collapsed" panels */
1769
        content: "\e080";    /* adjust as needed, taken from bootstrap.css */
1770
    }
1771
 
1772
 
1773
</style>
66 efrain 1774
<!-- Content Header (Page header) -->
1775
<section class="content-header">
1776
	<div class="container-fluid">
1777
    	<div class="row mb-2">
1778
        	<div class="col-sm-12">
1779
            	<h1>LABEL_TEST</h1>
1780
			</div>
1781
		</div>
1782
	</div><!-- /.container-fluid -->
1783
</section>
1784
 
1785
<section class="content">
1786
	<div class="container-fluid">
1787
		<div class="row">
1788
			<div class="col-md-12 col-sm-12">
79 steven 1789
				<!-- Content -->
1790
				<div class="row" id="row-forms">
1791
					<div class="col-md-12">
1792
							<!-- Begin: life time stats -->
80 steven 1793
						<div class="portlet box blue-dark">
1794
								<div class="portlet-title ">
1795
										<div class="caption">
1796
												<i class="fa fa-dot-circle-o"></i>AutoEvaluacion
1797
										</div>
1798
										<div class="actions portlet-toggler">
1799
												<button class="btn blue btn-add-form"  data-toggle="tooltip" title="Add Form">
1800
													<i class="fa fa-plus"></i> Add
1801
													</button>
1802
												<button class="btn red hide btn-delete-forms" data-action="delete" data-toggle="tooltip" title="Delete Selected"><i class="fa fa-minus"></i> Delete Selected</button>
1803
												<div class="btn-group"></div>
1804
										</div>
79 steven 1805
 
80 steven 1806
								</div>
1807
								<div class="portlet-body portlet-toggler">
1808
									<table id="table-form" class="table table-striped table-bordered table-hover">
1809
 
1810
									</table>
1811
								</div>
1812
								<div class="portlet-body portlet-toggler pageform" style="display:none;"></div>
1813
						</div>
1814
					</div>
1815
				</div>
1816
				<!-- End Content -->
1817
				<!-- Row Edit -->
81 steven 1818
				<div class="row" id="row-edit">
80 steven 1819
					<div class="col-xs-12 col-md-12">
1820
						<form action="#" name="form-main" id="form-main">
1821
							<input type="hidden" name="form-id" id="form-id" value="0" />
1822
							<input type="hidden" name="form-continue" id="form-continue" value="0" />
1823
									<div class="form-group">
1824
										<label for="form-name">Name</label>
1825
										<input type="text" name="form-name" id="form-name" class="form-control" maxlength="50" />
79 steven 1826
									</div>
80 steven 1827
									<div class="form-group">
1828
										<label for="form-description">Description</label>
1829
										<!--  ckeditor -->
1830
										<textarea  name="form-description" id="form-description" rows="5" class="ckeditor form-control"></textarea>
1831
									</div>
1832
									<div class="form-group">
1833
										<label for="form-text">Text</label>
1834
										<!--  ckeditor -->
1835
										<textarea  name="form-text" id="form-text" rows="5" class="ckeditor form-control"></textarea>
79 steven 1836
									</div>
80 steven 1837
									<div class="form-group">
1838
										<label for="form-language">Language</label>
1839
										<select name="form-language" id="form-language" class="form-control">
1840
											<option value="EN">English</option>
1841
											<option value="SP">Spanish</option>
1842
										</select>
1843
									</div>
1844
									<div class="form-group">
1845
										<label for="form-status">Status</label>
1846
										<select name="form-status" id="form-status" class="form-control">
1847
											<option value="D">Inactive</option>
1848
											<option value="A">Active</option>
1849
										</select>
1850
									</div>
1851
									<br/>
1852
									<div class="row">
1853
								<div class="col-xs-12 col-md-12 text-right">
1854
									<button class="btn btn-primary" id="btn-add-section" data-toggle="tooltip" title="New Section"><i class="fa fa-plus" aria-hidden="true"></i> New Section</button>
1855
								</div>
79 steven 1856
							</div>
85 steven 1857
							<br />
80 steven 1858
							<div class="row">
1859
								<div class="col-xs-12 col-md-12">
1860
									<div class="panel-group" id="accordion">
1861
 
1862
 
1863
 
1864
									</div>
1865
								</div>
1866
							</div>
1867
 
1868
 
1869
							<div class="form-group">
1870
								<button type="button" class="btn btn-info btn-form-save-continue">Save & Continue</button>
1871
								<button type="button" class="btn btn-primary btn-form-save-close">Save & Close</button>
1872
								<button type="button" class="btn btn-secondary btn-edit-cancel">Cancel</button>
1873
							</div>
1874
						</form>
79 steven 1875
					</div>
1876
				</div>
80 steven 1877
				<!-- End Row Edit -->
82 steven 1878
				<!-- Modals -->
1879
					<!-- Senction Modal -->
1880
					<div  id="modal-section" class="modal" tabindex="-1" role="dialog">
1881
						<div class="modal-dialog" role="document">
1882
								<form action="#" name="form-section" id="form-section">
1883
									<input type="hidden" name="section-slug" id="section-slug" value="" />
1884
									<div class="modal-content">
1885
											<div class="modal-header">
1886
												<h4 class="modal-title">Modal title</h4>
1887
												<!-- <button type="button" class="close" data-dismiss="modal" aria-label="Close">
1888
											<span aria-hidden="true">&times;</span>
1889
												</button> -->
1890
											</div>
1891
											<div class="modal-body">
1892
										<div class="form-group">
1893
											<label for="section-name">Name</label>
1894
													<input type="text" name="section-name" id="section-name" class="form-control" maxlength="50" value="" />
1895
												</div>
1896
												<div class="form-group">
1897
													<label for="section-text">Text</label>
1898
													<!--  ckeditor -->
1899
													<textarea  name="section-text" id="section-text" rows="5" class="ckeditor form-control"></textarea>
1900
												</div>
1901
												<div class="form-group">
1902
													<label for="section-value">Value</label>
1903
													<input type="text" name="section-value" id="section-value"  class="form-control" value="0" />
1904
												</div>
1905
											</div>
1906
											<div class="modal-footer">
1907
												<button type="submit" class="btn btn-primary">Save</button>
1908
												<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
1909
											</div>
1910
									</div>
1911
								</form>
1912
						</div>
1913
					</div>
1914
					<!-- End Modal Section -->
1915
					<!-- Question Modal -->
1916
						<div  id="modal-question" class="modal" tabindex="-1" role="dialog">
1917
							<div class="modal-dialog" role="document">
1918
								<form action="#" name="form-question" id="form-question">
1919
									<input type="hidden" name="question-section" id="question-section" />
1920
									<input type="hidden" name="question-slug" id="question-slug" />
1921
										<div class="modal-content">
1922
											<div class="modal-header">
1923
													<h4 class="modal-title">Add Question</h4>
1924
													<button type="button" class="close" data-dismiss="modal" aria-label="Close">
1925
												<span aria-hidden="true">&times;</span>
1926
													</button>
1927
												</div>
1928
											<div class="modal-body">
1929
													<div class="form-group">
1930
														<label for="question-text">Text</label>
1931
														<!--  ckeditor -->
1932
														<textarea  name="question-text" id="question-text" rows="5" class="ckeditor form-control"></textarea>
1933
													</div>
1934
													<div class="form-group">
1935
														<label for="question-value">Value</label>
1936
														<input type="text" name="question-value" id="question-value"  class="form-control" />
1937
													</div>
1938
													<div class="form-group">
1939
														<label for="question-type">Type</label>
1940
														<select name="question-type" id="question-type" class="form-control">
1941
															<option value="open">Open</option>
1942
															<option value="simple">Simple</option>
1943
															<option value="multiple">Multiple</option>
1944
															<option value="rating-open">Rating Open</option>
1945
															<option value="rating-range">Rating Range</option>
1946
														</select>
1947
													</div>
1948
													<div class="form-group">
1949
														<label for="question-max-length">MaxLength</label>
1950
														<input type="text" name="question-max-length" id="question-max-length"  class="form-control" />
1951
													</div>
1952
													<div class="form-group">
1953
														<label for="question-multiline">Multiline</label>
1954
														<select name="question-multiline" id="question-multiline" class="form-control">
1955
															<option value="1">Yes</option>
1956
															<option value="0">No</option>
1957
														</select>
1958
													</div>
1959
													<div class="form-group">
1960
														<label for="question-range">Range</label>
1961
														<select name="question-range" id="question-range" class="form-control">
1962
															<option value="10">1-10</option>
1963
															<option value="6">1-6</option>
1964
															<option value="5">1-5</option>
1965
														</select>
1966
													</div>
1967
												</div>
1968
												<div class="modal-footer">
1969
													<button type="submit" class="btn btn-primary">Save</button>
1970
													<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
1971
												</div>
1972
										</div>
1973
									</form>
1974
							</div>
1975
						</div>
1976
					<!-- End Modal Question -->
83 steven 1977
					<!-- MOdal Options -->
1978
					<div  id="modal-option" class="modal" tabindex="-1" role="dialog">
1979
						<div class="modal-dialog" role="document">
1980
							<form action="#" name="form-option" id="form-option">
1981
									<input type="hidden" name="option-section" id="option-section" value="" />
1982
									<input type="hidden" name="option-question" id="option-question" value="" />
1983
									<input type="hidden" name="option-slug" id="option-slug" value="" />
1984
										<div class="modal-content">
1985
											<div class="modal-header">
1986
												<h4 class="modal-title">Modal title</h4>
1987
												<button type="button" class="close" data-dismiss="modal" aria-label="Close">
1988
											<span aria-hidden="true">&times;</span>
1989
												</button>
1990
											</div>
1991
											<div class="modal-body">
1992
												<div class="form-group">
1993
													<label for="option-text">Text</label>
1994
													<!--  ckeditor -->
1995
													<textarea  name="option-text" id="option-text" rows="5" class="ckeditor form-control"></textarea>
1996
												</div>
1997
												<div class="form-group">
1998
													<label for="option-correct">Correct</label>
1999
													<select name="option-correct" id="option-correct" class="form-control">
2000
														<option value="1">Yes</option>
2001
														<option value="0">No</option>
2002
													</select>
2003
												</div>
2004
												<div class="form-group">
2005
													<label for="option-value">Value</label>
2006
													<input type="text" name="option-value" id="option-value"  class="form-control" />
2007
												</div>
2008
											</div>
2009
											<div class="modal-footer">
2010
												<button type="submit" class="btn btn-primary">Save</button>
2011
												<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
2012
											</div>
2013
									</div>
2014
								</form>
2015
						</div>
2016
					</div>
2017
					<!-- End Modal Options -->
82 steven 2018
				<!-- End Modals -->
66 efrain 2019
			</div>
2020
		</div>
2021
 	</div>
2022
</section>