Proyectos de Subversion LeadersLinked - Backend

Rev

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