| Línea 147... |
Línea 147... |
| 147 |
$('[data-toggle="tooltip"]').tooltip();
|
147 |
$('[data-toggle="tooltip"]').tooltip();
|
| 148 |
},
|
148 |
},
|
| 149 |
/**
|
149 |
/**
|
| 150 |
* Add element to section array
|
150 |
* Add element to section array
|
| 151 |
*/
|
151 |
*/
|
| 152 |
this.addSection = function(name, text, value) {
|
152 |
this.addSection = function(name, text) {
|
| 153 |
var d = new Date();
|
153 |
var d = new Date();
|
| 154 |
var slug = 'section' + d.getTime();
|
154 |
var slug = 'section' + d.getTime();
|
| 155 |
var position = 0;
|
155 |
var position = 0;
|
| 156 |
$.each(this.sections, function(index, section) {
|
156 |
$.each(this.sections, function(index, section) {
|
| 157 |
if (position < section.position) {
|
157 |
if (position < section.position) {
|
| Línea 161... |
Línea 161... |
| 161 |
position++;
|
161 |
position++;
|
| 162 |
var section = {
|
162 |
var section = {
|
| 163 |
'slug_section': slug,
|
163 |
'slug_section': slug,
|
| 164 |
'name': name,
|
164 |
'name': name,
|
| 165 |
'text': text,
|
165 |
'text': text,
|
| 166 |
'value': value,
|
- |
|
| 167 |
'position': position,
|
166 |
'position': position,
|
| 168 |
'questions': [],
|
167 |
'questions': [],
|
| 169 |
'status': 0
|
168 |
'status': 0
|
| 170 |
}
|
169 |
}
|
| 171 |
this.sections.push(section);
|
170 |
this.sections.push(section);
|
| 172 |
},
|
171 |
},
|
| 173 |
/**
|
172 |
/**
|
| 174 |
* Edit element to section array
|
173 |
* Edit element to section array
|
| 175 |
*/
|
174 |
*/
|
| 176 |
this.editSection = function(slug, name, text, value) {
|
175 |
this.editSection = function(slug, name, text) {
|
| 177 |
var renderTable = false;
|
176 |
var renderTable = false;
|
| 178 |
for (i = 0; i < this.sections.length; i++) {
|
177 |
for (i = 0; i < this.sections.length; i++) {
|
| 179 |
if (slug == this.sections[i].slug_section) {
|
178 |
if (slug == this.sections[i].slug_section) {
|
| 180 |
this.sections[i].name = name;
|
179 |
this.sections[i].name = name;
|
| 181 |
this.sections[i].text = text;
|
180 |
this.sections[i].text = text;
|
| 182 |
this.sections[i].value = value;
|
- |
|
| 183 |
renderTable = true;
|
181 |
renderTable = true;
|
| 184 |
break;
|
182 |
break;
|
| 185 |
}
|
183 |
}
|
| 186 |
}
|
184 |
}
|
| 187 |
if (renderTable) {
|
185 |
if (renderTable) {
|
| Línea 205... |
Línea 203... |
| 205 |
}
|
203 |
}
|
| 206 |
},
|
204 |
},
|
| 207 |
/**
|
205 |
/**
|
| 208 |
* Add element to question array
|
206 |
* Add element to question array
|
| 209 |
*/
|
207 |
*/
|
| 210 |
this.addQuestion = function(slug_section, text, value, type, maxlength, multiline, range) {
|
208 |
this.addQuestion = function(slug_section, text, type, maxlength, multiline, range) {
|
| 211 |
var d = new Date();
|
209 |
var d = new Date();
|
| 212 |
var slug_question = 'question' + d.getTime();
|
210 |
var slug_question = 'question' + d.getTime();
|
| 213 |
var position = 0;
|
211 |
var position = 0;
|
| 214 |
var renderTable = false;
|
212 |
var renderTable = false;
|
| 215 |
for (i = 0; i < this.sections.length; i++) {
|
213 |
for (i = 0; i < this.sections.length; i++) {
|
| Línea 222... |
Línea 220... |
| 222 |
position++;
|
220 |
position++;
|
| 223 |
var question = {
|
221 |
var question = {
|
| 224 |
'slug_section': slug_section,
|
222 |
'slug_section': slug_section,
|
| 225 |
'slug_question': slug_question,
|
223 |
'slug_question': slug_question,
|
| 226 |
'text': text,
|
224 |
'text': text,
|
| 227 |
'value': value,
|
- |
|
| 228 |
'type': type,
|
225 |
'type': type,
|
| 229 |
'position': position,
|
226 |
'position': position,
|
| 230 |
'maxlength': maxlength,
|
227 |
'maxlength': maxlength,
|
| 231 |
'multiline': multiline,
|
228 |
'multiline': multiline,
|
| 232 |
'range': range,
|
229 |
'range': range,
|
| Línea 243... |
Línea 240... |
| 243 |
}
|
240 |
}
|
| 244 |
},
|
241 |
},
|
| 245 |
/**
|
242 |
/**
|
| 246 |
* Add element to question array
|
243 |
* Add element to question array
|
| 247 |
*/
|
244 |
*/
|
| 248 |
this.editQuestion = function(slug_section, slug_question, text, value, type, maxlength, multiline, range) {
|
245 |
this.editQuestion = function(slug_section, slug_question, text, type, maxlength, multiline, range) {
|
| 249 |
var renderTable = false;
|
246 |
var renderTable = false;
|
| 250 |
for (i = 0; i < this.sections.length; i++) {
|
247 |
for (i = 0; i < this.sections.length; i++) {
|
| 251 |
if (slug_section == this.sections[i].slug_section) {
|
248 |
if (slug_section == this.sections[i].slug_section) {
|
| 252 |
for (j = 0; j < this.sections[i].questions.length; j++) {
|
249 |
for (j = 0; j < this.sections[i].questions.length; j++) {
|
| 253 |
if (slug_question == this.sections[i].questions[j].slug_question) {
|
250 |
if (slug_question == this.sections[i].questions[j].slug_question) {
|
| 254 |
this.sections[i].questions[j].text = text,
|
251 |
this.sections[i].questions[j].text = text,
|
| 255 |
this.sections[i].questions[j].value = value,
|
- |
|
| 256 |
this.sections[i].questions[j].type = type;
|
252 |
this.sections[i].questions[j].type = type;
|
| 257 |
if (type == 'open') {
|
253 |
if (type == 'open') {
|
| 258 |
this.sections[i].questions[j].maxlength = maxlength;
|
254 |
this.sections[i].questions[j].maxlength = maxlength;
|
| 259 |
this.sections[i].questions[j].multiline = multiline;
|
255 |
this.sections[i].questions[j].multiline = multiline;
|
| 260 |
this.sections[i].questions[j].options = [];
|
256 |
this.sections[i].questions[j].options = [];
|
| Línea 311... |
Línea 307... |
| 311 |
}
|
307 |
}
|
| 312 |
},
|
308 |
},
|
| 313 |
/**
|
309 |
/**
|
| 314 |
* Add element to option array
|
310 |
* Add element to option array
|
| 315 |
*/
|
311 |
*/
|
| 316 |
this.addOption = function(slug_section, slug_question, text, correct, value) {
|
312 |
this.addOption = function(slug_section, slug_question, text, correct) {
|
| 317 |
var d = new Date();
|
313 |
var d = new Date();
|
| 318 |
var slug_option = 'option' + d.getTime();
|
314 |
var slug_option = 'option' + d.getTime();
|
| 319 |
var position = 0;
|
315 |
var position = 0;
|
| 320 |
var renderTable = false;
|
316 |
var renderTable = false;
|
| 321 |
for (i = 0; i < this.sections.length; i++) {
|
317 |
for (i = 0; i < this.sections.length; i++) {
|
| Línea 332... |
Línea 328... |
| 332 |
'slug_section': slug_section,
|
328 |
'slug_section': slug_section,
|
| 333 |
'slug_question': slug_question,
|
329 |
'slug_question': slug_question,
|
| 334 |
'slug_option': slug_option,
|
330 |
'slug_option': slug_option,
|
| 335 |
'text': text,
|
331 |
'text': text,
|
| 336 |
'correct': correct,
|
332 |
'correct': correct,
|
| 337 |
'value': value,
|
- |
|
| 338 |
'checked': false
|
333 |
'checked': false
|
| 339 |
}
|
334 |
}
|
| 340 |
this.sections[i].questions[j].options.push(option);
|
335 |
this.sections[i].questions[j].options.push(option);
|
| 341 |
renderTable = true;
|
336 |
renderTable = true;
|
| 342 |
break;
|
337 |
break;
|
| Línea 352... |
Línea 347... |
| 352 |
}
|
347 |
}
|
| 353 |
},
|
348 |
},
|
| 354 |
/**
|
349 |
/**
|
| 355 |
* Edit element to option array
|
350 |
* Edit element to option array
|
| 356 |
*/
|
351 |
*/
|
| 357 |
this.editOption = function(slug_section, slug_question, option_slug, text, correct, value) {
|
352 |
this.editOption = function(slug_section, slug_question, option_slug, text, correct) {
|
| 358 |
var renderTable = false;
|
353 |
var renderTable = false;
|
| 359 |
for (i = 0; i < this.sections.length; i++) {
|
354 |
for (i = 0; i < this.sections.length; i++) {
|
| 360 |
if (slug_section == this.sections[i].slug_section) {
|
355 |
if (slug_section == this.sections[i].slug_section) {
|
| 361 |
for (j = 0; j < this.sections[i].questions.length; j++) {
|
356 |
for (j = 0; j < this.sections[i].questions.length; j++) {
|
| 362 |
if (slug_question == this.sections[i].questions[j].slug_question) {
|
357 |
if (slug_question == this.sections[i].questions[j].slug_question) {
|
| 363 |
for (k = 0; k < this.sections[i].questions[j].options.length; k++) {
|
358 |
for (k = 0; k < this.sections[i].questions[j].options.length; k++) {
|
| 364 |
if (option_slug == this.sections[i].questions[j].options[k].slug_option) {
|
359 |
if (option_slug == this.sections[i].questions[j].options[k].slug_option) {
|
| 365 |
this.sections[i].questions[j].options[k].text = text;
|
360 |
this.sections[i].questions[j].options[k].text = text;
|
| 366 |
this.sections[i].questions[j].options[k].correct = correct;
|
361 |
this.sections[i].questions[j].options[k].correct = correct;
|
| 367 |
this.sections[i].questions[j].options[k].value = value;
|
- |
|
| 368 |
renderTable = true;
|
362 |
renderTable = true;
|
| 369 |
break;
|
363 |
break;
|
| 370 |
}
|
364 |
}
|
| 371 |
}
|
365 |
}
|
| 372 |
}
|
366 |
}
|
| Línea 712... |
Línea 706... |
| 712 |
for (i = 0; i < objFormGenerator.sections.length; i++) {
|
706 |
for (i = 0; i < objFormGenerator.sections.length; i++) {
|
| 713 |
if (objFormGenerator.sections[i].questions.length == 0) {
|
707 |
if (objFormGenerator.sections[i].questions.length == 0) {
|
| 714 |
$.fn.showError('ERROR_QUESTIONS'.replace('%s', objFormGenerator.sections[i].name));
|
708 |
$.fn.showError('ERROR_QUESTIONS'.replace('%s', objFormGenerator.sections[i].name));
|
| 715 |
return false;
|
709 |
return false;
|
| 716 |
}
|
710 |
}
|
| 717 |
var valueSection = parseInt(objFormGenerator.sections[i].value);
|
- |
|
| 718 |
var totalValueQuestion = 0;
|
- |
|
| 719 |
for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
|
711 |
for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
|
| 720 |
valueQuestion = parseInt(objFormGenerator.sections[i].questions[j].value);
|
- |
|
| 721 |
totalValueQuestion = totalValueQuestion + valueQuestion;
|
- |
|
| 722 |
if (objFormGenerator.sections[i].questions[j].type == 'simple' ||
|
712 |
if (objFormGenerator.sections[i].questions[j].type == 'simple' ||
|
| 723 |
objFormGenerator.sections[i].questions[j].type == 'multiple' ||
|
713 |
objFormGenerator.sections[i].questions[j].type == 'multiple' ||
|
| 724 |
objFormGenerator.sections[i].questions[j].type == 'rating-open') {
|
714 |
objFormGenerator.sections[i].questions[j].type == 'rating-open') {
|
| 725 |
var questionNumber = j + 1;
|
715 |
var questionNumber = j + 1;
|
| 726 |
var numberCorrect = 0;
|
716 |
var numberCorrect = 0;
|
| Línea 734... |
Línea 724... |
| 734 |
if (objFormGenerator.sections[i].questions[j].type == 'simple' || objFormGenerator.sections[i].questions[j].type == 'multiple') {
|
724 |
if (objFormGenerator.sections[i].questions[j].type == 'simple' || objFormGenerator.sections[i].questions[j].type == 'multiple') {
|
| 735 |
if (objFormGenerator.sections[i].questions[j].options[k].correct == 1) {
|
725 |
if (objFormGenerator.sections[i].questions[j].options[k].correct == 1) {
|
| 736 |
numberCorrect++;
|
726 |
numberCorrect++;
|
| 737 |
}
|
727 |
}
|
| 738 |
}
|
728 |
}
|
| 739 |
if (objFormGenerator.sections[i].questions[j].type == 'multiple' && objFormGenerator.sections[i].questions[j].options[k].correct == 1) {
|
- |
|
| 740 |
totalOption = totalOption + parseInt(objFormGenerator.sections[i].questions[j].options[k].value);
|
- |
|
| 741 |
}
|
- |
|
| 742 |
if (objFormGenerator.sections[i].questions[j].type == 'rating-open') {
|
- |
|
| 743 |
if (parseInt(objFormGenerator.sections[i].questions[j].options[k].value) > maxOption) {
|
- |
|
| 744 |
maxOption = parseInt(objFormGenerator.sections[i].questions[j].options[k].value);
|
- |
|
| 745 |
}
|
- |
|
| 746 |
}
|
- |
|
| 747 |
}
|
729 |
}
|
| 748 |
if (objFormGenerator.sections[i].questions[j].type == 'simple' || objFormGenerator.sections[i].questions[j].type == 'multiple') {
|
730 |
if (objFormGenerator.sections[i].questions[j].type == 'simple' || objFormGenerator.sections[i].questions[j].type == 'multiple') {
|
| 749 |
if (numberCorrect == 0) {
|
731 |
if (numberCorrect == 0) {
|
| 750 |
$.fn.showError('ERROR_OPTIONS_CORRECT'.replace('%s', objFormGenerator.sections[i].name).replace('%n', questionNumber));
|
732 |
$.fn.showError('ERROR_OPTIONS_CORRECT'.replace('%s', objFormGenerator.sections[i].name).replace('%n', questionNumber));
|
| 751 |
return false;
|
733 |
return false;
|
| Línea 758... |
Línea 740... |
| 758 |
if (objFormGenerator.sections[i].questions[j].type == 'multiple' && numberCorrect == 1) {
|
740 |
if (objFormGenerator.sections[i].questions[j].type == 'multiple' && numberCorrect == 1) {
|
| 759 |
$.fn.showError('ERROR_OPTIONS_ONE_CORRECT'.replace('%s', objFormGenerator.sections[i].name).replace('%n', questionNumber));
|
741 |
$.fn.showError('ERROR_OPTIONS_ONE_CORRECT'.replace('%s', objFormGenerator.sections[i].name).replace('%n', questionNumber));
|
| 760 |
return false;
|
742 |
return false;
|
| 761 |
}
|
743 |
}
|
| 762 |
}
|
744 |
}
|
| 763 |
if (objFormGenerator.sections[i].questions[j].type == 'multiple' && totalOption != valueQuestion) {
|
- |
|
| 764 |
$.fn.showError('ERROR_OPTIONS_SUM_VALUES'.replace('%s', objFormGenerator.sections[i].name).replace('%n', questionNumber));
|
- |
|
| 765 |
return false;
|
- |
|
| 766 |
}
|
- |
|
| 767 |
if (objFormGenerator.sections[i].questions[j].type == 'rating-open' && maxOption > valueQuestion) {
|
- |
|
| 768 |
$.fn.showError('ERROR_OPTIONS_MAX_OPTION'.replace('%s', objFormGenerator.sections[i].name).replace('%n', questionNumber));
|
- |
|
| 769 |
return false;
|
- |
|
| 770 |
}
|
- |
|
| 771 |
}
|
745 |
}
|
| 772 |
}
|
746 |
}
|
| 773 |
if (valueSection != totalValueQuestion) {
|
- |
|
| 774 |
$.fn.showError('ERROR_VALUE_SECTIONS'.replace('%s', objFormGenerator.sections[i].name));
|
- |
|
| 775 |
return false;
|
- |
|
| 776 |
}
|
- |
|
| 777 |
}
|
747 |
}
|
| 778 |
var formContinue = parseInt($('#form-main #form-continue').val());
|
748 |
var formContinue = parseInt($('#form-main #form-continue').val());
|
| 779 |
var data = {
|
749 |
var data = {
|
| 780 |
'name': $('#form-main #name').val(),
|
750 |
'name': $('#form-main #name').val(),
|
| 781 |
'description': $('#form-main #description').val(),
|
751 |
'description': $('#form-main #description').val(),
|
| Línea 839... |
Línea 809... |
| 839 |
maxlength: 50
|
809 |
maxlength: 50
|
| 840 |
},
|
810 |
},
|
| 841 |
'section-text': {
|
811 |
'section-text': {
|
| 842 |
required: false,
|
812 |
required: false,
|
| 843 |
},
|
813 |
},
|
| 844 |
'section-value': {
|
- |
|
| 845 |
required: true,
|
- |
|
| 846 |
number: true,
|
- |
|
| 847 |
min: 1
|
- |
|
| 848 |
},
|
- |
|
| 849 |
},
|
814 |
},
|
| 850 |
highlight: function(element) {
|
815 |
highlight: function(element) {
|
| 851 |
$(element).closest('.form-group').addClass('has-error');
|
816 |
$(element).closest('.form-group').addClass('has-error');
|
| 852 |
},
|
817 |
},
|
| 853 |
unhighlight: function(element) {
|
818 |
unhighlight: function(element) {
|
| Línea 874... |
Línea 839... |
| 874 |
if (slug) {
|
839 |
if (slug) {
|
| 875 |
objFormGenerator.editSection(
|
840 |
objFormGenerator.editSection(
|
| 876 |
$('#form-section #section-slug').val(),
|
841 |
$('#form-section #section-slug').val(),
|
| 877 |
$('#form-section #section-name').val(),
|
842 |
$('#form-section #section-name').val(),
|
| 878 |
$('#form-section #section-text').val(),
|
843 |
$('#form-section #section-text').val(),
|
| 879 |
$('#form-section #section-value').val()
|
- |
|
| 880 |
);
|
844 |
);
|
| 881 |
} else {
|
845 |
} else {
|
| 882 |
objFormGenerator.addSection(
|
846 |
objFormGenerator.addSection(
|
| 883 |
$('#form-section #section-name').val(),
|
847 |
$('#form-section #section-name').val(),
|
| 884 |
$('#form-section #section-text').val(),
|
848 |
$('#form-section #section-text').val()
|
| 885 |
$('#form-section #section-value').val()
|
- |
|
| 886 |
);
|
849 |
);
|
| 887 |
}
|
850 |
}
|
| 888 |
renderSectionData(objFormGenerator.sections);
|
851 |
renderSectionData(objFormGenerator.sections);
|
| 889 |
$('#modal-section').modal('hide');
|
852 |
$('#modal-section').modal('hide');
|
| 890 |
return false;
|
853 |
return false;
|
| Línea 905... |
Línea 868... |
| 905 |
errorElement: 'span',
|
868 |
errorElement: 'span',
|
| 906 |
rules: {
|
869 |
rules: {
|
| 907 |
'question-text': {
|
870 |
'question-text': {
|
| 908 |
required: true,
|
871 |
required: true,
|
| 909 |
},
|
872 |
},
|
| 910 |
'question-value': {
|
- |
|
| 911 |
required: true,
|
- |
|
| 912 |
number: true,
|
- |
|
| 913 |
min: 1
|
- |
|
| 914 |
},
|
- |
|
| 915 |
'question-type': {
|
873 |
'question-type': {
|
| 916 |
required: true,
|
874 |
required: true,
|
| 917 |
},
|
875 |
},
|
| 918 |
'question-max-length': {
|
876 |
'question-max-length': {
|
| 919 |
required: true,
|
877 |
required: true,
|
| Línea 950... |
Línea 908... |
| 950 |
if ($('#form-question #question-slug').val()) {
|
908 |
if ($('#form-question #question-slug').val()) {
|
| 951 |
objFormGenerator.editQuestion(
|
909 |
objFormGenerator.editQuestion(
|
| 952 |
$('#form-question #question-section').val(),
|
910 |
$('#form-question #question-section').val(),
|
| 953 |
$('#form-question #question-slug').val(),
|
911 |
$('#form-question #question-slug').val(),
|
| 954 |
$('#form-question #question-text').val(),
|
912 |
$('#form-question #question-text').val(),
|
| 955 |
$('#form-question #question-value').val(),
|
- |
|
| 956 |
$('#form-question #question-type').val(),
|
913 |
$('#form-question #question-type').val(),
|
| 957 |
$('#form-question #question-max-length').val(),
|
914 |
$('#form-question #question-max-length').val(),
|
| 958 |
$('#form-question #question-multiline').val(),
|
915 |
$('#form-question #question-multiline').val(),
|
| 959 |
$('#form-question #question-range').val()
|
916 |
$('#form-question #question-range').val()
|
| 960 |
);
|
917 |
);
|
| 961 |
} else {
|
918 |
} else {
|
| 962 |
objFormGenerator.addQuestion(
|
919 |
objFormGenerator.addQuestion(
|
| 963 |
$('#form-question #question-section').val(),
|
920 |
$('#form-question #question-section').val(),
|
| 964 |
$('#form-question #question-text').val(),
|
921 |
$('#form-question #question-text').val(),
|
| 965 |
$('#form-question #question-value').val(),
|
- |
|
| 966 |
$('#form-question #question-type').val(),
|
922 |
$('#form-question #question-type').val(),
|
| 967 |
$('#form-question #question-max-length').val(),
|
923 |
$('#form-question #question-max-length').val(),
|
| 968 |
$('#form-question #question-multiline').val(),
|
924 |
$('#form-question #question-multiline').val(),
|
| 969 |
$('#form-question #question-range').val()
|
925 |
$('#form-question #question-range').val()
|
| 970 |
);
|
926 |
);
|
| Línea 988... |
Línea 944... |
| 988 |
errorClass: 'help-block',
|
944 |
errorClass: 'help-block',
|
| 989 |
errorElement: 'span',
|
945 |
errorElement: 'span',
|
| 990 |
rules: {
|
946 |
rules: {
|
| 991 |
'option-text': {
|
947 |
'option-text': {
|
| 992 |
required: true,
|
948 |
required: true,
|
| 993 |
},
|
- |
|
| 994 |
'option-value': {
|
- |
|
| 995 |
required: true,
|
- |
|
| 996 |
number: true,
|
- |
|
| 997 |
min: 1
|
- |
|
| 998 |
}
|
949 |
}
|
| - |
|
950 |
|
| 999 |
},
|
951 |
},
|
| 1000 |
highlight: function(element) {
|
952 |
highlight: function(element) {
|
| 1001 |
$(element).closest('.form-group').addClass('has-error');
|
953 |
$(element).closest('.form-group').addClass('has-error');
|
| 1002 |
},
|
954 |
},
|
| 1003 |
unhighlight: function(element) {
|
955 |
unhighlight: function(element) {
|
| Línea 1022... |
Línea 974... |
| 1022 |
objFormGenerator.editOption(
|
974 |
objFormGenerator.editOption(
|
| 1023 |
$('#form-option #option-section').val(),
|
975 |
$('#form-option #option-section').val(),
|
| 1024 |
$('#form-option #option-question').val(),
|
976 |
$('#form-option #option-question').val(),
|
| 1025 |
$('#form-option #option-slug').val(),
|
977 |
$('#form-option #option-slug').val(),
|
| 1026 |
$('#form-option #option-text').val(),
|
978 |
$('#form-option #option-text').val(),
|
| 1027 |
$('#form-option #option-correct').val(),
|
979 |
$('#form-option #option-correct').val()
|
| 1028 |
$('#form-option #option-value').val()
|
- |
|
| 1029 |
);
|
980 |
);
|
| 1030 |
} else {
|
981 |
} else {
|
| 1031 |
objFormGenerator.addOption(
|
982 |
objFormGenerator.addOption(
|
| 1032 |
$('#form-option #option-section').val(),
|
983 |
$('#form-option #option-section').val(),
|
| 1033 |
$('#form-option #option-question').val(),
|
984 |
$('#form-option #option-question').val(),
|
| 1034 |
$('#form-option #option-text').val(),
|
985 |
$('#form-option #option-text').val(),
|
| 1035 |
$('#form-option #option-correct').val(),
|
986 |
$('#form-option #option-correct').val()
|
| 1036 |
$('#form-option #option-value').val()
|
- |
|
| 1037 |
);
|
987 |
);
|
| 1038 |
}
|
988 |
}
|
| 1039 |
renderSectionData(objFormGenerator.sections);
|
989 |
renderSectionData(objFormGenerator.sections);
|
| 1040 |
$('#modal-option').modal('hide');
|
990 |
$('#modal-option').modal('hide');
|
| 1041 |
return false;
|
991 |
return false;
|
| Línea 1048... |
Línea 998... |
| 1048 |
e.preventDefault();
|
998 |
e.preventDefault();
|
| 1049 |
validatorFormSection.resetForm();
|
999 |
validatorFormSection.resetForm();
|
| 1050 |
$('#form-section #section-slug').val('');
|
1000 |
$('#form-section #section-slug').val('');
|
| 1051 |
$('#form-section #section-name').val('');
|
1001 |
$('#form-section #section-name').val('');
|
| 1052 |
CKEDITOR.instances['section-text'].setData('');
|
1002 |
CKEDITOR.instances['section-text'].setData('');
|
| 1053 |
$('#form-section #section-value').val('0');
|
- |
|
| 1054 |
$('#modal-section h4[class="modal-title"]').html('LABEL_ADD LABEL_SECTION');
|
1003 |
$('#modal-section h4[class="modal-title"]').html('LABEL_ADD LABEL_SECTION');
|
| 1055 |
$('#modal-section').modal('show');
|
1004 |
$('#modal-section').modal('show');
|
| 1056 |
});
|
1005 |
});
|
| 1057 |
/**
|
1006 |
/**
|
| 1058 |
* Clicked on edit section
|
1007 |
* Clicked on edit section
|
| Línea 1067... |
Línea 1016... |
| 1067 |
if (slug == section.slug_section) {
|
1016 |
if (slug == section.slug_section) {
|
| 1068 |
validatorFormSection.resetForm();
|
1017 |
validatorFormSection.resetForm();
|
| 1069 |
$('#form-section #section-slug').val(section.slug_section);
|
1018 |
$('#form-section #section-slug').val(section.slug_section);
|
| 1070 |
$('#form-section #section-name').val(section.name);
|
1019 |
$('#form-section #section-name').val(section.name);
|
| 1071 |
CKEDITOR.instances['section-text'].setData(section.text);
|
1020 |
CKEDITOR.instances['section-text'].setData(section.text);
|
| 1072 |
$('#form-section #section-value').val(section.value);
|
- |
|
| 1073 |
showForm = true;
|
1021 |
showForm = true;
|
| 1074 |
break;
|
1022 |
break;
|
| 1075 |
}
|
1023 |
}
|
| 1076 |
}
|
1024 |
}
|
| 1077 |
if (showForm) {
|
1025 |
if (showForm) {
|
| Línea 1112... |
Línea 1060... |
| 1112 |
validatorFormQuestion.resetForm();
|
1060 |
validatorFormQuestion.resetForm();
|
| 1113 |
var slug = $(this).data('section');
|
1061 |
var slug = $(this).data('section');
|
| 1114 |
$('#form-question #question-section').val(slug);
|
1062 |
$('#form-question #question-section').val(slug);
|
| 1115 |
$('#form-question #question-slug').val('');
|
1063 |
$('#form-question #question-slug').val('');
|
| 1116 |
CKEDITOR.instances['question-text'].setData('');
|
1064 |
CKEDITOR.instances['question-text'].setData('');
|
| 1117 |
$('#form-question #question-value').val('0');
|
- |
|
| 1118 |
$('#form-question #question-type').val($('#form-question #question-type option:first').val());
|
1065 |
$('#form-question #question-type').val($('#form-question #question-type option:first').val());
|
| 1119 |
$('#form-question #question-max-length').val('0');
|
1066 |
$('#form-question #question-max-length').val('0');
|
| 1120 |
$('#form-question #question-max-length').parent().show();
|
1067 |
$('#form-question #question-max-length').parent().show();
|
| 1121 |
$('#form-question #question-multiline').val('0');
|
1068 |
$('#form-question #question-multiline').val('0');
|
| 1122 |
$('#form-question #question-multiline').parent().show();
|
1069 |
$('#form-question #question-multiline').parent().show();
|
| Línea 1139... |
Línea 1086... |
| 1139 |
if (slug == objFormGenerator.sections[i].questions[j].slug_question) {
|
1086 |
if (slug == objFormGenerator.sections[i].questions[j].slug_question) {
|
| 1140 |
validatorFormQuestion.resetForm();
|
1087 |
validatorFormQuestion.resetForm();
|
| 1141 |
$('#form-question #question-section').val(objFormGenerator.sections[i].slug_section);
|
1088 |
$('#form-question #question-section').val(objFormGenerator.sections[i].slug_section);
|
| 1142 |
$('#form-question #question-slug').val(objFormGenerator.sections[i].questions[j].slug_question);
|
1089 |
$('#form-question #question-slug').val(objFormGenerator.sections[i].questions[j].slug_question);
|
| 1143 |
CKEDITOR.instances['question-text'].setData(objFormGenerator.sections[i].questions[j].text);
|
1090 |
CKEDITOR.instances['question-text'].setData(objFormGenerator.sections[i].questions[j].text);
|
| 1144 |
$('#form-question #question-value').val(objFormGenerator.sections[i].questions[j].value);
|
- |
|
| 1145 |
$('#form-question #question-type').val(objFormGenerator.sections[i].questions[j].type);
|
1091 |
$('#form-question #question-type').val(objFormGenerator.sections[i].questions[j].type);
|
| 1146 |
if (objFormGenerator.sections[i].questions[j].type == 'open') {
|
1092 |
if (objFormGenerator.sections[i].questions[j].type == 'open') {
|
| 1147 |
$('#form-question #question-max-length').val(objFormGenerator.sections[i].questions[j].maxlength);
|
1093 |
$('#form-question #question-max-length').val(objFormGenerator.sections[i].questions[j].maxlength);
|
| 1148 |
$('#form-question #question-max-length').parent().show();
|
1094 |
$('#form-question #question-max-length').parent().show();
|
| 1149 |
$('#form-question #question-multiline').val(objFormGenerator.sections[i].questions[j].multiline);
|
1095 |
$('#form-question #question-multiline').val(objFormGenerator.sections[i].questions[j].multiline);
|
| Línea 1222... |
Línea 1168... |
| 1222 |
if (objFormGenerator.sections[i].questions[j].type == 'rating-open') {
|
1168 |
if (objFormGenerator.sections[i].questions[j].type == 'rating-open') {
|
| 1223 |
$('#form-option #option-correct').parent().hide();
|
1169 |
$('#form-option #option-correct').parent().hide();
|
| 1224 |
} else {
|
1170 |
} else {
|
| 1225 |
$('#form-option #option-correct').parent().show();
|
1171 |
$('#form-option #option-correct').parent().show();
|
| 1226 |
}
|
1172 |
}
|
| 1227 |
if (objFormGenerator.sections[i].questions[j].type == 'multiple' || objFormGenerator.sections[i].questions[j].type == 'rating-open') {
|
- |
|
| 1228 |
$('#form-option #option-value').val('0');
|
- |
|
| 1229 |
$('#form-option #option-value').parent().show();
|
- |
|
| 1230 |
} else {
|
- |
|
| 1231 |
$('#form-option #option-value').val('1');
|
- |
|
| 1232 |
$('#form-option #option-value').parent().hide();
|
- |
|
| 1233 |
}
|
- |
|
| 1234 |
renderSectionData(objFormGenerator.sections);
|
1173 |
renderSectionData(objFormGenerator.sections);
|
| 1235 |
$('#modal-option h4[class="modal-title"]').html('LABEL_ADD LABEL_OPTION');
|
1174 |
$('#modal-option h4[class="modal-title"]').html('LABEL_ADD LABEL_OPTION');
|
| 1236 |
$('#modal-option').modal('show');
|
1175 |
$('#modal-option').modal('show');
|
| 1237 |
return true;
|
1176 |
return true;
|
| 1238 |
}
|
1177 |
}
|
| Línea 1267... |
Línea 1206... |
| 1267 |
if (objFormGenerator.sections[i].questions[j].type == 'multiple' || objFormGenerator.sections[i].questions[j].type == 'simple') {
|
1206 |
if (objFormGenerator.sections[i].questions[j].type == 'multiple' || objFormGenerator.sections[i].questions[j].type == 'simple') {
|
| 1268 |
$('#form-option #option-correct').parent().show();
|
1207 |
$('#form-option #option-correct').parent().show();
|
| 1269 |
} else {
|
1208 |
} else {
|
| 1270 |
$('#form-option #option-correct').parent().hide();
|
1209 |
$('#form-option #option-correct').parent().hide();
|
| 1271 |
}
|
1210 |
}
|
| 1272 |
$('#form-option #option-value').val(objFormGenerator.sections[i].questions[j].options[k].value);
|
- |
|
| 1273 |
if (objFormGenerator.sections[i].questions[j].type == 'multiple' || objFormGenerator.sections[i].questions[j].type == 'rating-open') {
|
- |
|
| 1274 |
$('#form-option #option-value').parent().show();
|
- |
|
| 1275 |
} else {
|
- |
|
| 1276 |
$('#form-option #option-value').parent().hide();
|
- |
|
| 1277 |
}
|
- |
|
| 1278 |
showForm = true;
|
1211 |
showForm = true;
|
| 1279 |
break;
|
1212 |
break;
|
| 1280 |
}
|
1213 |
}
|
| 1281 |
}
|
1214 |
}
|
| 1282 |
}
|
1215 |
}
|
| Línea 1319... |
Línea 1252... |
| 1319 |
renderSectionData(objFormGenerator.sections);
|
1252 |
renderSectionData(objFormGenerator.sections);
|
| 1320 |
}
|
1253 |
}
|
| 1321 |
}
|
1254 |
}
|
| 1322 |
});
|
1255 |
});
|
| 1323 |
})
|
1256 |
})
|
| 1324 |
/**
|
- |
|
| 1325 |
* Format input number (Form Section)
|
- |
|
| 1326 |
*/
|
- |
|
| 1327 |
$('#form-section #section-value').inputNumberFormat({
|
- |
|
| 1328 |
'decimal': 2
|
- |
|
| 1329 |
});
|
- |
|
| 1330 |
/**
|
1257 |
|
| 1331 |
* Format input number (Form Question)
|
- |
|
| 1332 |
*/
|
- |
|
| 1333 |
$('#form-question #question-value').inputNumberFormat({
|
- |
|
| 1334 |
'decimal': 2
|
- |
|
| 1335 |
});
|
- |
|
| 1336 |
/**
|
1258 |
/**
|
| 1337 |
* Format input number (Form Question)
|
1259 |
* Format input number (Form Question)
|
| 1338 |
*/
|
1260 |
*/
|
| 1339 |
$('#form-question #question-max-length').inputNumberFormat({
|
1261 |
$('#form-question #question-max-length').inputNumberFormat({
|
| 1340 |
'decimal': 0
|
1262 |
'decimal': 0
|
| 1341 |
});
|
1263 |
});
|
| 1342 |
/**
|
1264 |
/**
|
| 1343 |
* Format input number (Form Option)
|
- |
|
| 1344 |
*/
|
- |
|
| 1345 |
$('#form-option #option-value').inputNumberFormat({
|
- |
|
| 1346 |
'decimal': 2
|
- |
|
| 1347 |
});
|
- |
|
| 1348 |
/**
|
- |
|
| 1349 |
* Detect when updating question status and hide/Show options
|
1265 |
* Detect when updating question status and hide/Show options
|
| 1350 |
*/
|
1266 |
*/
|
| 1351 |
$('#form-question #question-type').change(function(e) {
|
1267 |
$('#form-question #question-type').change(function(e) {
|
| 1352 |
e.preventDefault();
|
1268 |
e.preventDefault();
|
| 1353 |
if ($('#form-question #question-type').val() == 'open') {
|
1269 |
if ($('#form-question #question-type').val() == 'open') {
|
| Línea 1601... |
Línea 1517... |
| 1601 |
<div class="form-group">
|
1517 |
<div class="form-group">
|
| 1602 |
<label for="section-text">LABEL_TEXT</label>
|
1518 |
<label for="section-text">LABEL_TEXT</label>
|
| 1603 |
<!-- ckeditor -->
|
1519 |
<!-- ckeditor -->
|
| 1604 |
<textarea name="section-text" id="section-text" rows="5" class="ckeditor form-control"></textarea>
|
1520 |
<textarea name="section-text" id="section-text" rows="5" class="ckeditor form-control"></textarea>
|
| 1605 |
</div>
|
1521 |
</div>
|
| 1606 |
<div class="form-group">
|
- |
|
| 1607 |
<label for="section-value">LABEL_VALUE</label>
|
- |
|
| 1608 |
<input type="text" name="section-value" id="section-value" class="form-control" value="0" />
|
- |
|
| 1609 |
</div>
|
- |
|
| 1610 |
</div>
|
1522 |
</div>
|
| 1611 |
<div class="modal-footer">
|
1523 |
<div class="modal-footer">
|
| 1612 |
<button type="submit" class="btn btn-primary">LABEL_SAVE</button>
|
1524 |
<button type="submit" class="btn btn-primary">LABEL_SAVE</button>
|
| 1613 |
<button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
|
1525 |
<button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
|
| 1614 |
</div>
|
1526 |
</div>
|
| Línea 1637... |
Línea 1549... |
| 1637 |
<label for="question-text">LABEL_TEXT</label>
|
1549 |
<label for="question-text">LABEL_TEXT</label>
|
| 1638 |
<!-- ckeditor -->
|
1550 |
<!-- ckeditor -->
|
| 1639 |
<textarea name="question-text" id="question-text" rows="5" class="ckeditor form-control"></textarea>
|
1551 |
<textarea name="question-text" id="question-text" rows="5" class="ckeditor form-control"></textarea>
|
| 1640 |
</div>
|
1552 |
</div>
|
| 1641 |
<div class="form-group">
|
1553 |
<div class="form-group">
|
| 1642 |
<label for="question-value">LABEL_VALUE</label>
|
- |
|
| 1643 |
<input type="text" name="question-value" id="question-value" class="form-control" />
|
- |
|
| 1644 |
</div>
|
- |
|
| 1645 |
<div class="form-group">
|
- |
|
| 1646 |
<label for="question-type">LABEL_TYPE</label>
|
1554 |
<label for="question-type">LABEL_TYPE</label>
|
| 1647 |
<select name="question-type" id="question-type" class="form-control">
|
1555 |
<select name="question-type" id="question-type" class="form-control">
|
| 1648 |
<option value="open">LABEL_OPEN</option>
|
1556 |
<option value="open">LABEL_OPEN</option>
|
| 1649 |
<option value="simple">Simple</option>
|
1557 |
<option value="simple">Simple</option>
|
| 1650 |
<option value="multiple">Multiple</option>
|
1558 |
<option value="multiple">Multiple</option>
|
| Línea 1709... |
Línea 1617... |
| 1709 |
<select name="option-correct" id="option-correct" class="form-control">
|
1617 |
<select name="option-correct" id="option-correct" class="form-control">
|
| 1710 |
<option value="1">LABEL_YES</option>
|
1618 |
<option value="1">LABEL_YES</option>
|
| 1711 |
<option value="0">LABEL_NOT</option>
|
1619 |
<option value="0">LABEL_NOT</option>
|
| 1712 |
</select>
|
1620 |
</select>
|
| 1713 |
</div>
|
1621 |
</div>
|
| 1714 |
<div class="form-group">
|
- |
|
| 1715 |
<label for="option-value">LABEL_VALUE</label>
|
- |
|
| 1716 |
<input type="text" name="option-value" id="option-value" class="form-control" />
|
- |
|
| 1717 |
</div>
|
- |
|
| 1718 |
</div>
|
1622 |
</div>
|
| 1719 |
<div class="modal-footer">
|
1623 |
<div class="modal-footer">
|
| 1720 |
<button type="submit" class="btn btn-primary">LABEL_SAVE</button>
|
1624 |
<button type="submit" class="btn btn-primary">LABEL_SAVE</button>
|
| 1721 |
<button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
|
1625 |
<button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
|
| 1722 |
</div>
|
1626 |
</div>
|
| Línea 1745... |
Línea 1649... |
| 1745 |
<table class="table table-bordered">
|
1649 |
<table class="table table-bordered">
|
| 1746 |
<thead>
|
1650 |
<thead>
|
| 1747 |
<tr>
|
1651 |
<tr>
|
| 1748 |
<th style="width: 10%;">LABEL_ELEMENT</th>
|
1652 |
<th style="width: 10%;">LABEL_ELEMENT</th>
|
| 1749 |
<th style="width: 50%;">LABEL_TEXT</th>
|
1653 |
<th style="width: 50%;">LABEL_TEXT</th>
|
| 1750 |
<th style="width: 10%;">LABEL_VALUE</th>
|
- |
|
| 1751 |
<th style="width: 10%;">LABEL_TYPE</th>
|
1654 |
<th style="width: 10%;">LABEL_TYPE</th>
|
| 1752 |
<th style="width: 20%;">LABEL_ACTIONS</th>
|
1655 |
<th style="width: 20%;">LABEL_ACTIONS</th>
|
| 1753 |
</tr>
|
1656 |
</tr>
|
| 1754 |
</thead>
|
1657 |
</thead>
|
| 1755 |
<tbody>
|
1658 |
<tbody>
|
| 1756 |
<tr class="tr-section">
|
1659 |
<tr class="tr-section">
|
| 1757 |
<td class="text-left">LABEL_SECTION</td>
|
1660 |
<td class="text-left">LABEL_SECTION</td>
|
| 1758 |
<td class="text-left">{{:name}}</td>
|
1661 |
<td class="text-left">{{:name}}</td>
|
| 1759 |
<td>{{:value}}</td>
|
- |
|
| 1760 |
<td></td>
|
1662 |
<td></td>
|
| 1761 |
<td>
|
1663 |
<td>
|
| 1762 |
<button class="btn btn-default btn-edit-section" data-section="{{:slug_section}}" data-toggle="tooltip" data-original-title="LABEL_EDIT LABEL_SECTION"><i class="fa fa-edit" aria-hidden="true"></i> LABEL_EDIT LABEL_SECTION </button>
|
1664 |
<button class="btn btn-default btn-edit-section" data-section="{{:slug_section}}" data-toggle="tooltip" data-original-title="LABEL_EDIT LABEL_SECTION"><i class="fa fa-edit" aria-hidden="true"></i> LABEL_EDIT LABEL_SECTION </button>
|
| 1763 |
<button class="btn btn-default btn-delete-section" data-section="{{:slug_section}}" data-toggle="tooltip" data-original-title="LABEL_DELETE LABEL_SECTION"><i class="fa fa-ban" aria-hidden="true"></i> LABEL_DELETE LABEL_SECTION </button>
|
1665 |
<button class="btn btn-default btn-delete-section" data-section="{{:slug_section}}" data-toggle="tooltip" data-original-title="LABEL_DELETE LABEL_SECTION"><i class="fa fa-ban" aria-hidden="true"></i> LABEL_DELETE LABEL_SECTION </button>
|
| 1764 |
<button class="btn btn-default btn-add-question" data-section="{{:slug_section}}" data-toggle="tooltip" data-original-title="LABEL_ADD LABEL_QUESTION"><i class="fa fa-plus" aria-hidden="true"></i> LABEL_ADD LABEL_QUESTION </button>
|
1666 |
<button class="btn btn-default btn-add-question" data-section="{{:slug_section}}" data-toggle="tooltip" data-original-title="LABEL_ADD LABEL_QUESTION"><i class="fa fa-plus" aria-hidden="true"></i> LABEL_ADD LABEL_QUESTION </button>
|
| Línea 1768... |
Línea 1670... |
| 1768 |
<tr class="tr-question">
|
1670 |
<tr class="tr-question">
|
| 1769 |
<td class="text-left">--LABEL_QUESTION</td>
|
1671 |
<td class="text-left">--LABEL_QUESTION</td>
|
| 1770 |
<td class="text-left">
|
1672 |
<td class="text-left">
|
| 1771 |
{{:~removeTags(text)}}
|
1673 |
{{:~removeTags(text)}}
|
| 1772 |
</td>
|
1674 |
</td>
|
| 1773 |
<td><font color="red">{{:value}}</font></td>
|
- |
|
| 1774 |
<td class="text-capitalize">
|
1675 |
<td class="text-capitalize">
|
| 1775 |
{{if type == 'open'}} LABEL_OPEN {{/if}}
|
1676 |
{{if type == 'open'}} LABEL_OPEN {{/if}}
|
| 1776 |
{{if type == 'simple'}} Simple {{/if}}
|
1677 |
{{if type == 'simple'}} Simple {{/if}}
|
| 1777 |
{{if type == 'multiple'}} Multiple {{/if}}
|
1678 |
{{if type == 'multiple'}} Multiple {{/if}}
|
| 1778 |
{{if type == 'rating-open'}} LABEL_RATING_OPEN {{/if}}
|
1679 |
{{if type == 'rating-open'}} LABEL_RATING_OPEN {{/if}}
|
| Línea 1795... |
Línea 1696... |
| 1795 |
{{:~removeTags(text)}}
|
1696 |
{{:~removeTags(text)}}
|
| 1796 |
</td>
|
1697 |
</td>
|
| 1797 |
<td>
|
1698 |
<td>
|
| Línea 1798... |
Línea 1699... |
| 1798 |
|
1699 |
|
| 1799 |
{{if ~getType( slug_section, slug_question) == 'multiple' || ~getType( slug_section, slug_question) == 'rating-open' }}
|
- |
|
| 1800 |
{{:value}}
|
1700 |
{{if ~getType( slug_section, slug_question) == 'multiple' || ~getType( slug_section, slug_question) == 'rating-open' }}
|
| 1801 |
{{/if}}
|
1701 |
{{/if}}
|
| 1802 |
</td>
|
1702 |
</td>
|
| 1803 |
<td class="text-left">
|
1703 |
<td class="text-left">
|
| 1804 |
{{if ~getType( slug_section, slug_question) != 'rating-open'}}
|
1704 |
{{if ~getType( slug_section, slug_question) != 'rating-open'}}
|