Proyectos de Subversion LeadersLinked - Backend

Rev

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

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