Proyectos de Subversion LeadersLinked - Backend

Rev

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