Proyectos de Subversion LeadersLinked - Backend

Rev

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