Línea 76... |
Línea 76... |
76 |
var s = '';
|
76 |
var s = '';
|
77 |
for (i = 0; i < this.sections.length; i++) {
|
77 |
for (i = 0; i < this.sections.length; i++) {
|
78 |
if (slug_section != this.sections[i].slug_section) {
|
78 |
if (slug_section != this.sections[i].slug_section) {
|
79 |
continue;
|
79 |
continue;
|
80 |
}
|
80 |
}
|
81 |
for (j = 0; j < this.sections[i].questions.length; j++) {
|
81 |
for (j = 0; j < this.sections[i].sections.length; j++) {
|
82 |
this.sections[i].questions[j].position = j;
|
82 |
this.sections[i].sections[j].position = j;
|
83 |
if (this.sections[i].questions[j].type == 'simple' || this.sections[i].questions[j].type == 'multiple' || this.sections[i].questions[j].type == 'rating-open') {
|
83 |
if (this.sections[i].sections[j].type == 'simple' || this.sections[i].sections[j].type == 'multiple' || this.sections[i].sections[j].type == 'rating-open') {
|
84 |
this.sections[i].questions[j].options.sort(function(a, b) {
|
84 |
this.sections[i].sections[j].options.sort(function(a, b) {
|
85 |
if (a.position > b.position) {
|
85 |
if (a.position > b.position) {
|
86 |
return 1;
|
86 |
return 1;
|
87 |
}
|
87 |
}
|
88 |
if (a.position < b.position) {
|
88 |
if (a.position < b.position) {
|
89 |
return -1;
|
89 |
return -1;
|
90 |
}
|
90 |
}
|
91 |
return 0;
|
91 |
return 0;
|
92 |
});
|
92 |
});
|
93 |
for (k = 0; k < this.sections[i].questions[j].options.length; k++) {
|
93 |
for (k = 0; k < this.sections[i].sections[j].options.length; k++) {
|
94 |
this.sections[i].questions[j].options[k].position = j;
|
94 |
this.sections[i].sections[j].options[k].position = j;
|
95 |
}
|
95 |
}
|
96 |
}
|
96 |
}
|
97 |
}
|
97 |
}
|
98 |
}
|
98 |
}
|
99 |
$('[data-toggle="tooltip"]').tooltip();
|
99 |
$('[data-toggle="tooltip"]').tooltip();
|
Línea 109... |
Línea 109... |
109 |
return 0;
|
109 |
return 0;
|
110 |
});
|
110 |
});
|
111 |
var s = '';
|
111 |
var s = '';
|
112 |
for (i = 0; i < this.sections.length; i++) {
|
112 |
for (i = 0; i < this.sections.length; i++) {
|
113 |
this.sections[i].position = i;
|
113 |
this.sections[i].position = i;
|
114 |
this.sections[i].questions.sort(function(a, b) {
|
114 |
this.sections[i].sections.sort(function(a, b) {
|
115 |
if (a.position > b.position) {
|
115 |
if (a.position > b.position) {
|
116 |
return 1;
|
116 |
return 1;
|
117 |
}
|
117 |
}
|
118 |
if (a.position < b.position) {
|
118 |
if (a.position < b.position) {
|
119 |
return -1;
|
119 |
return -1;
|
120 |
}
|
120 |
}
|
121 |
return 0;
|
121 |
return 0;
|
122 |
});
|
122 |
});
|
123 |
for (j = 0; j < this.sections[i].questions.length; j++) {
|
123 |
for (j = 0; j < this.sections[i].sections.length; j++) {
|
124 |
this.sections[i].questions[j].position = j;
|
124 |
this.sections[i].sections[j].position = j;
|
125 |
if (this.sections[i].questions[j].type == 'simple' || this.sections[i].questions[j].type == 'multiple' || this.sections[i].questions[j].type == 'rating-open') {
|
125 |
if (this.sections[i].sections[j].type == 'simple' || this.sections[i].sections[j].type == 'multiple' || this.sections[i].sections[j].type == 'rating-open') {
|
126 |
this.sections[i].questions[j].options.sort(function(a, b) {
|
126 |
this.sections[i].sections[j].options.sort(function(a, b) {
|
127 |
if (a.position > b.position) {
|
127 |
if (a.position > b.position) {
|
128 |
return 1;
|
128 |
return 1;
|
129 |
}
|
129 |
}
|
130 |
if (a.position < b.position) {
|
130 |
if (a.position < b.position) {
|
131 |
return -1;
|
131 |
return -1;
|
132 |
}
|
132 |
}
|
133 |
return 0;
|
133 |
return 0;
|
134 |
});
|
134 |
});
|
135 |
for (k = 0; k < this.sections[i].questions[j].options.length; k++) {
|
135 |
for (k = 0; k < this.sections[i].sections[j].options.length; k++) {
|
136 |
this.sections[i].questions[j].options[k].position = j;
|
136 |
this.sections[i].sections[j].options[k].position = j;
|
137 |
}
|
137 |
}
|
138 |
}
|
138 |
}
|
139 |
}
|
139 |
}
|
140 |
}
|
140 |
}
|
141 |
$('[data-toggle="tooltip"]').tooltip();
|
141 |
$('[data-toggle="tooltip"]').tooltip();
|
Línea 157... |
Línea 157... |
157 |
'slug_section': slug,
|
157 |
'slug_section': slug,
|
158 |
'name': name,
|
158 |
'name': name,
|
159 |
'text': text,
|
159 |
'text': text,
|
160 |
'value': value,
|
160 |
'value': value,
|
161 |
'position': position,
|
161 |
'position': position,
|
162 |
'questions': [],
|
162 |
'sections': [],
|
163 |
'status': 0
|
163 |
'status': 0
|
164 |
}
|
164 |
}
|
165 |
this.sections.push(section);
|
165 |
this.sections.push(section);
|
166 |
},
|
166 |
},
|
167 |
/**
|
167 |
/**
|
Línea 197... |
Línea 197... |
197 |
if (renderTable) {
|
197 |
if (renderTable) {
|
198 |
$('#panel' + slug).remove();
|
198 |
$('#panel' + slug).remove();
|
199 |
}
|
199 |
}
|
200 |
},
|
200 |
},
|
201 |
/**
|
201 |
/**
|
202 |
* Add element to question array
|
202 |
* Add element to section array
|
203 |
*/
|
203 |
*/
|
204 |
this.addQuestion = function(slug_section, text, value, type, maxlength, multiline, range) {
|
204 |
this.addsection = function(slug_section, text, value, type, maxlength, multiline, range) {
|
205 |
var d = new Date();
|
205 |
var d = new Date();
|
206 |
var slug_question = 'question' + d.getTime();
|
206 |
var slug_section = 'section' + d.getTime();
|
207 |
var position = 0;
|
207 |
var position = 0;
|
208 |
var renderTable = false;
|
208 |
var renderTable = false;
|
209 |
for (i = 0; i < this.sections.length; i++) {
|
209 |
for (i = 0; i < this.sections.length; i++) {
|
210 |
if (slug_section == this.sections[i].slug_section) {
|
210 |
if (slug_section == this.sections[i].slug_section) {
|
211 |
$.each(this.sections[i].questions, function(index, question) {
|
211 |
$.each(this.sections[i].sections, function(index, section) {
|
212 |
if (position < question.position) {
|
212 |
if (position < section.position) {
|
213 |
position = question.position;
|
213 |
position = section.position;
|
214 |
}
|
214 |
}
|
215 |
});
|
215 |
});
|
216 |
position++;
|
216 |
position++;
|
217 |
var question = {
|
217 |
var section = {
|
- |
|
218 |
'slug_section': slug_section,
|
218 |
'slug_section': slug_section,
|
219 |
'slug_section': slug_section,
|
219 |
'slug_question': slug_question,
|
- |
|
220 |
'text': text,
|
220 |
'text': text,
|
221 |
'value': value,
|
221 |
'value': value,
|
222 |
'type': type,
|
222 |
'type': type,
|
223 |
'position': position,
|
223 |
'position': position,
|
224 |
'maxlength': maxlength,
|
224 |
'maxlength': maxlength,
|
225 |
'multiline': multiline,
|
225 |
'multiline': multiline,
|
226 |
'range': range,
|
226 |
'range': range,
|
227 |
'options': [],
|
227 |
'options': [],
|
228 |
'answer': type=='multiple' ? [] : ''
|
228 |
'answer': type=='multiple' ? [] : ''
|
229 |
}
|
229 |
}
|
230 |
this.sections[i].questions.push(question);
|
230 |
this.sections[i].sections.push(section);
|
231 |
renderTable = true;
|
231 |
renderTable = true;
|
232 |
break;
|
232 |
break;
|
233 |
}
|
233 |
}
|
234 |
}
|
234 |
}
|
235 |
if (renderTable) {
|
235 |
if (renderTable) {
|
236 |
this.renderSection(slug_section);
|
236 |
this.renderSection(slug_section);
|
237 |
}
|
237 |
}
|
238 |
},
|
238 |
},
|
239 |
/**
|
239 |
/**
|
240 |
* Add element to question array
|
240 |
* Add element to section array
|
241 |
*/
|
241 |
*/
|
242 |
this.editQuestion = function(slug_section, slug_question, text, value, type, maxlength, multiline, range) {
|
242 |
this.editsection = function(slug_section, slug_section, text, value, type, maxlength, multiline, range) {
|
243 |
var renderTable = false;
|
243 |
var renderTable = false;
|
244 |
for (i = 0; i < this.sections.length; i++) {
|
244 |
for (i = 0; i < this.sections.length; i++) {
|
245 |
if (slug_section == this.sections[i].slug_section) {
|
245 |
if (slug_section == this.sections[i].slug_section) {
|
246 |
for (j = 0; j < this.sections[i].questions.length; j++) {
|
246 |
for (j = 0; j < this.sections[i].sections.length; j++) {
|
247 |
if (slug_question == this.sections[i].questions[j].slug_question) {
|
247 |
if (slug_section == this.sections[i].sections[j].slug_section) {
|
248 |
this.sections[i].questions[j].text = text,
|
248 |
this.sections[i].sections[j].text = text,
|
249 |
this.sections[i].questions[j].value = value,
|
249 |
this.sections[i].sections[j].value = value,
|
250 |
this.sections[i].questions[j].type = type;
|
250 |
this.sections[i].sections[j].type = type;
|
251 |
if (type == 'open') {
|
251 |
if (type == 'open') {
|
252 |
this.sections[i].questions[j].maxlength = maxlength;
|
252 |
this.sections[i].sections[j].maxlength = maxlength;
|
253 |
this.sections[i].questions[j].multiline = multiline;
|
253 |
this.sections[i].sections[j].multiline = multiline;
|
254 |
this.sections[i].questions[j].options = [];
|
254 |
this.sections[i].sections[j].options = [];
|
255 |
} else {
|
255 |
} else {
|
256 |
this.sections[i].questions[j].maxlength = 0;
|
256 |
this.sections[i].sections[j].maxlength = 0;
|
257 |
this.sections[i].questions[j].multiline = 0;
|
257 |
this.sections[i].sections[j].multiline = 0;
|
258 |
}
|
258 |
}
|
259 |
if (type == 'rating-range') {
|
259 |
if (type == 'rating-range') {
|
260 |
this.sections[i].questions[j].range = range;
|
260 |
this.sections[i].sections[j].range = range;
|
261 |
} else {
|
261 |
} else {
|
262 |
this.sections[i].questions[j].range = 0;
|
262 |
this.sections[i].sections[j].range = 0;
|
263 |
}
|
263 |
}
|
Línea 264... |
Línea 264... |
264 |
|
264 |
|
265 |
if(type=='multiple'){
|
265 |
if(type=='multiple'){
|
266 |
this.sections[i].questions[j].answer = [];
|
266 |
this.sections[i].sections[j].answer = [];
|
267 |
}else{
|
267 |
}else{
|
268 |
this.sections[i].questions[j].answer = '';
|
268 |
this.sections[i].sections[j].answer = '';
|
Línea 269... |
Línea 269... |
269 |
}
|
269 |
}
|
270 |
|
270 |
|
271 |
renderTable = true;
|
271 |
renderTable = true;
|
Línea 280... |
Línea 280... |
280 |
if (renderTable) {
|
280 |
if (renderTable) {
|
281 |
this.renderSection(slug_section);
|
281 |
this.renderSection(slug_section);
|
282 |
}
|
282 |
}
|
283 |
},
|
283 |
},
|
284 |
/**
|
284 |
/**
|
285 |
* Remove element to question array
|
285 |
* Remove element to section array
|
286 |
*/
|
286 |
*/
|
287 |
this.deleteQuestion = function(slug_section, slug_question) {
|
287 |
this.deletesection = function(slug_section, slug_section) {
|
288 |
var renderTable = false;
|
288 |
var renderTable = false;
|
289 |
for (i = 0; i < this.sections.length; i++) {
|
289 |
for (i = 0; i < this.sections.length; i++) {
|
290 |
if (slug_section == this.sections[i].slug_section) {
|
290 |
if (slug_section == this.sections[i].slug_section) {
|
291 |
for (j = 0; j < this.sections[i].questions.length; j++) {
|
291 |
for (j = 0; j < this.sections[i].sections.length; j++) {
|
292 |
if (slug_question == this.sections[i].questions[j].slug_question) {
|
292 |
if (slug_section == this.sections[i].sections[j].slug_section) {
|
293 |
this.sections[i].questions.splice(j, 1);
|
293 |
this.sections[i].sections.splice(j, 1);
|
294 |
renderTable = true;
|
294 |
renderTable = true;
|
295 |
break;
|
295 |
break;
|
296 |
}
|
296 |
}
|
297 |
}
|
297 |
}
|
298 |
}
|
298 |
}
|
Línea 305... |
Línea 305... |
305 |
}
|
305 |
}
|
306 |
},
|
306 |
},
|
307 |
/**
|
307 |
/**
|
308 |
* Add element to option array
|
308 |
* Add element to option array
|
309 |
*/
|
309 |
*/
|
310 |
this.addOption = function(slug_section, slug_question, text, correct, value) {
|
310 |
this.addOption = function(slug_section, slug_section, text, correct, value) {
|
311 |
var d = new Date();
|
311 |
var d = new Date();
|
312 |
var slug_option = 'option' + d.getTime();
|
312 |
var slug_option = 'option' + d.getTime();
|
313 |
var position = 0;
|
313 |
var position = 0;
|
314 |
var renderTable = false;
|
314 |
var renderTable = false;
|
315 |
for (i = 0; i < this.sections.length; i++) {
|
315 |
for (i = 0; i < this.sections.length; i++) {
|
316 |
if (slug_section == this.sections[i].slug_section) {
|
316 |
if (slug_section == this.sections[i].slug_section) {
|
317 |
for (j = 0; j < this.sections[i].questions.length; j++) {
|
317 |
for (j = 0; j < this.sections[i].sections.length; j++) {
|
318 |
if (slug_question == this.sections[i].questions[j].slug_question) {
|
318 |
if (slug_section == this.sections[i].sections[j].slug_section) {
|
319 |
$.each(this.sections[i].questions[j].options, function(index, option) {
|
319 |
$.each(this.sections[i].sections[j].options, function(index, option) {
|
320 |
if (position < option.position) {
|
320 |
if (position < option.position) {
|
321 |
position = option.position;
|
321 |
position = option.position;
|
322 |
}
|
322 |
}
|
323 |
});
|
323 |
});
|
324 |
position++;
|
324 |
position++;
|
325 |
var option = {
|
325 |
var option = {
|
326 |
'slug_section': slug_section,
|
326 |
'slug_section': slug_section,
|
327 |
'slug_question': slug_question,
|
327 |
'slug_section': slug_section,
|
328 |
'slug_option': slug_option,
|
328 |
'slug_option': slug_option,
|
329 |
'text': text,
|
329 |
'text': text,
|
330 |
'correct': correct,
|
330 |
'correct': correct,
|
331 |
'value': value,
|
331 |
'value': value,
|
332 |
'checked': false
|
332 |
'checked': false
|
333 |
}
|
333 |
}
|
334 |
this.sections[i].questions[j].options.push(option);
|
334 |
this.sections[i].sections[j].options.push(option);
|
335 |
renderTable = true;
|
335 |
renderTable = true;
|
336 |
break;
|
336 |
break;
|
337 |
}
|
337 |
}
|
338 |
if (renderTable) {
|
338 |
if (renderTable) {
|
339 |
break;
|
339 |
break;
|
Línea 346... |
Línea 346... |
346 |
}
|
346 |
}
|
347 |
},
|
347 |
},
|
348 |
/**
|
348 |
/**
|
349 |
* Edit element to option array
|
349 |
* Edit element to option array
|
350 |
*/
|
350 |
*/
|
351 |
this.editOption = function(slug_section, slug_question, option_slug, text, correct, value) {
|
351 |
this.editOption = function(slug_section, slug_section, option_slug, text, correct, value) {
|
352 |
var renderTable = false;
|
352 |
var renderTable = false;
|
353 |
for (i = 0; i < this.sections.length; i++) {
|
353 |
for (i = 0; i < this.sections.length; i++) {
|
354 |
if (slug_section == this.sections[i].slug_section) {
|
354 |
if (slug_section == this.sections[i].slug_section) {
|
355 |
for (j = 0; j < this.sections[i].questions.length; j++) {
|
355 |
for (j = 0; j < this.sections[i].sections.length; j++) {
|
356 |
if (slug_question == this.sections[i].questions[j].slug_question) {
|
356 |
if (slug_section == this.sections[i].sections[j].slug_section) {
|
357 |
for (k = 0; k < this.sections[i].questions[j].options.length; k++) {
|
357 |
for (k = 0; k < this.sections[i].sections[j].options.length; k++) {
|
358 |
if (option_slug == this.sections[i].questions[j].options[k].slug_option) {
|
358 |
if (option_slug == this.sections[i].sections[j].options[k].slug_option) {
|
359 |
this.sections[i].questions[j].options[k].text = text;
|
359 |
this.sections[i].sections[j].options[k].text = text;
|
360 |
this.sections[i].questions[j].options[k].correct = correct;
|
360 |
this.sections[i].sections[j].options[k].correct = correct;
|
361 |
this.sections[i].questions[j].options[k].value = value;
|
361 |
this.sections[i].sections[j].options[k].value = value;
|
362 |
renderTable = true;
|
362 |
renderTable = true;
|
363 |
break;
|
363 |
break;
|
364 |
}
|
364 |
}
|
365 |
}
|
365 |
}
|
366 |
}
|
366 |
}
|
Línea 378... |
Línea 378... |
378 |
}
|
378 |
}
|
379 |
},
|
379 |
},
|
380 |
/**
|
380 |
/**
|
381 |
* Remove element to option array
|
381 |
* Remove element to option array
|
382 |
*/
|
382 |
*/
|
383 |
this.deleteOption = function(slug_section, slug_question, option_slug) {
|
383 |
this.deleteOption = function(slug_section, slug_section, option_slug) {
|
384 |
var renderTable = false;
|
384 |
var renderTable = false;
|
385 |
for (i = 0; i < this.sections.length; i++) {
|
385 |
for (i = 0; i < this.sections.length; i++) {
|
386 |
if (slug_section == this.sections[i].slug_section) {
|
386 |
if (slug_section == this.sections[i].slug_section) {
|
387 |
for (j = 0; j < this.sections[i].questions.length; j++) {
|
387 |
for (j = 0; j < this.sections[i].sections.length; j++) {
|
388 |
if (slug_question == this.sections[i].questions[j].slug_question) {
|
388 |
if (slug_section == this.sections[i].sections[j].slug_section) {
|
389 |
for (k = 0; k < this.sections[i].questions[j].options.length; k++) {
|
389 |
for (k = 0; k < this.sections[i].sections[j].options.length; k++) {
|
390 |
if (option_slug == this.sections[i].questions[j].options[k].slug_option) {
|
390 |
if (option_slug == this.sections[i].sections[j].options[k].slug_option) {
|
391 |
this.sections[i].questions[j].options.splice(k, 1);
|
391 |
this.sections[i].sections[j].options.splice(k, 1);
|
392 |
renderTable = true;
|
392 |
renderTable = true;
|
393 |
break;
|
393 |
break;
|
394 |
}
|
394 |
}
|
395 |
}
|
395 |
}
|
396 |
}
|
396 |
}
|
Línea 705... |
Línea 705... |
705 |
if (objFormGenerator.sections.length == 0) {
|
705 |
if (objFormGenerator.sections.length == 0) {
|
706 |
$.fn.showError('ERROR_SECCTIONS');
|
706 |
$.fn.showError('ERROR_SECCTIONS');
|
707 |
return false;
|
707 |
return false;
|
708 |
} else {
|
708 |
} else {
|
709 |
for (i = 0; i < objFormGenerator.sections.length; i++) {
|
709 |
for (i = 0; i < objFormGenerator.sections.length; i++) {
|
710 |
if (objFormGenerator.sections[i].questions.length == 0) {
|
710 |
if (objFormGenerator.sections[i].sections.length == 0) {
|
711 |
$.fn.showError('ERROR_QUESTIONS'.replace('%s', objFormGenerator.sections[i].name));
|
711 |
$.fn.showError('ERROR_sectionS'.replace('%s', objFormGenerator.sections[i].name));
|
712 |
return false;
|
712 |
return false;
|
713 |
}
|
713 |
}
|
714 |
var valueSection = parseInt(objFormGenerator.sections[i].value);
|
714 |
var valueSection = parseInt(objFormGenerator.sections[i].value);
|
715 |
var totalValueQuestion = 0;
|
715 |
var totalValuesection = 0;
|
716 |
for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
|
716 |
for (j = 0; j < objFormGenerator.sections[i].sections.length; j++) {
|
717 |
valueQuestion = parseInt(objFormGenerator.sections[i].questions[j].value);
|
717 |
valuesection = parseInt(objFormGenerator.sections[i].sections[j].value);
|
718 |
totalValueQuestion = totalValueQuestion + valueQuestion;
|
718 |
totalValuesection = totalValuesection + valuesection;
|
719 |
if (objFormGenerator.sections[i].questions[j].type == 'simple' ||
|
719 |
if (objFormGenerator.sections[i].sections[j].type == 'simple' ||
|
720 |
objFormGenerator.sections[i].questions[j].type == 'multiple' ||
|
720 |
objFormGenerator.sections[i].sections[j].type == 'multiple' ||
|
721 |
objFormGenerator.sections[i].questions[j].type == 'rating-open') {
|
721 |
objFormGenerator.sections[i].sections[j].type == 'rating-open') {
|
722 |
var questionNumber = j + 1;
|
722 |
var sectionNumber = j + 1;
|
723 |
var numberCorrect = 0;
|
723 |
var numberCorrect = 0;
|
724 |
if (objFormGenerator.sections[i].questions[j].options.length == 0) {
|
724 |
if (objFormGenerator.sections[i].sections[j].options.length == 0) {
|
725 |
$.fn.showError('ERROR_OPTIONS'.replace('%s', objFormGenerator.sections[i].name).replace('%n', questionNumber));
|
725 |
$.fn.showError('ERROR_OPTIONS'.replace('%s', objFormGenerator.sections[i].name).replace('%n', sectionNumber));
|
726 |
return false;
|
726 |
return false;
|
727 |
}
|
727 |
}
|
728 |
var totalOption = 0;
|
728 |
var totalOption = 0;
|
729 |
var maxOption = 0;
|
729 |
var maxOption = 0;
|
730 |
for (k = 0; k < objFormGenerator.sections[i].questions[j].options.length; k++) {
|
730 |
for (k = 0; k < objFormGenerator.sections[i].sections[j].options.length; k++) {
|
731 |
if (objFormGenerator.sections[i].questions[j].type == 'simple' || objFormGenerator.sections[i].questions[j].type == 'multiple') {
|
731 |
if (objFormGenerator.sections[i].sections[j].type == 'simple' || objFormGenerator.sections[i].sections[j].type == 'multiple') {
|
732 |
if (objFormGenerator.sections[i].questions[j].options[k].correct == 1) {
|
732 |
if (objFormGenerator.sections[i].sections[j].options[k].correct == 1) {
|
733 |
numberCorrect++;
|
733 |
numberCorrect++;
|
734 |
}
|
734 |
}
|
735 |
}
|
735 |
}
|
736 |
if (objFormGenerator.sections[i].questions[j].type == 'multiple' && objFormGenerator.sections[i].questions[j].options[k].correct == 1) {
|
736 |
if (objFormGenerator.sections[i].sections[j].type == 'multiple' && objFormGenerator.sections[i].sections[j].options[k].correct == 1) {
|
737 |
totalOption = totalOption + parseInt(objFormGenerator.sections[i].questions[j].options[k].value);
|
737 |
totalOption = totalOption + parseInt(objFormGenerator.sections[i].sections[j].options[k].value);
|
738 |
}
|
738 |
}
|
739 |
if (objFormGenerator.sections[i].questions[j].type == 'rating-open') {
|
739 |
if (objFormGenerator.sections[i].sections[j].type == 'rating-open') {
|
740 |
if (parseInt(objFormGenerator.sections[i].questions[j].options[k].value) > maxOption) {
|
740 |
if (parseInt(objFormGenerator.sections[i].sections[j].options[k].value) > maxOption) {
|
741 |
maxOption = parseInt(objFormGenerator.sections[i].questions[j].options[k].value);
|
741 |
maxOption = parseInt(objFormGenerator.sections[i].sections[j].options[k].value);
|
742 |
}
|
742 |
}
|
743 |
}
|
743 |
}
|
744 |
}
|
744 |
}
|
745 |
if (objFormGenerator.sections[i].questions[j].type == 'simple' || objFormGenerator.sections[i].questions[j].type == 'multiple') {
|
745 |
if (objFormGenerator.sections[i].sections[j].type == 'simple' || objFormGenerator.sections[i].sections[j].type == 'multiple') {
|
746 |
if (numberCorrect == 0) {
|
746 |
if (numberCorrect == 0) {
|
747 |
$.fn.showError('ERROR_OPTIONS_CORRECT'.replace('%s', objFormGenerator.sections[i].name).replace('%n', questionNumber));
|
747 |
$.fn.showError('ERROR_OPTIONS_CORRECT'.replace('%s', objFormGenerator.sections[i].name).replace('%n', sectionNumber));
|
748 |
return false;
|
748 |
return false;
|
749 |
}
|
749 |
}
|
750 |
if (
|
750 |
if (
|
751 |
objFormGenerator.sections[i].questions[j].type == 'simple' && numberCorrect > 1) {
|
751 |
objFormGenerator.sections[i].sections[j].type == 'simple' && numberCorrect > 1) {
|
752 |
$.fn.showError('ERROR_OPTIONS_DUPLICATE_CORRECT'.replace('%s', objFormGenerator.sections[i].name).replace('%n', questionNumber));
|
752 |
$.fn.showError('ERROR_OPTIONS_DUPLICATE_CORRECT'.replace('%s', objFormGenerator.sections[i].name).replace('%n', sectionNumber));
|
753 |
return false;
|
753 |
return false;
|
754 |
}
|
754 |
}
|
755 |
if (objFormGenerator.sections[i].questions[j].type == 'multiple' && numberCorrect == 1) {
|
755 |
if (objFormGenerator.sections[i].sections[j].type == 'multiple' && numberCorrect == 1) {
|
756 |
$.fn.showError('ERROR_OPTIONS_ONE_CORRECT'.replace('%s', objFormGenerator.sections[i].name).replace('%n', questionNumber));
|
756 |
$.fn.showError('ERROR_OPTIONS_ONE_CORRECT'.replace('%s', objFormGenerator.sections[i].name).replace('%n', sectionNumber));
|
757 |
return false;
|
757 |
return false;
|
758 |
}
|
758 |
}
|
759 |
}
|
759 |
}
|
760 |
if (objFormGenerator.sections[i].questions[j].type == 'multiple' && totalOption != valueQuestion) {
|
760 |
if (objFormGenerator.sections[i].sections[j].type == 'multiple' && totalOption != valuesection) {
|
761 |
$.fn.showError('ERROR_OPTIONS_SUM_VALUES'.replace('%s', objFormGenerator.sections[i].name).replace('%n', questionNumber));
|
761 |
$.fn.showError('ERROR_OPTIONS_SUM_VALUES'.replace('%s', objFormGenerator.sections[i].name).replace('%n', sectionNumber));
|
762 |
return false;
|
762 |
return false;
|
763 |
}
|
763 |
}
|
764 |
if (objFormGenerator.sections[i].questions[j].type == 'rating-open' && maxOption > valueQuestion) {
|
764 |
if (objFormGenerator.sections[i].sections[j].type == 'rating-open' && maxOption > valuesection) {
|
765 |
$.fn.showError('ERROR_OPTIONS_MAX_OPTION'.replace('%s', objFormGenerator.sections[i].name).replace('%n', questionNumber));
|
765 |
$.fn.showError('ERROR_OPTIONS_MAX_OPTION'.replace('%s', objFormGenerator.sections[i].name).replace('%n', sectionNumber));
|
766 |
return false;
|
766 |
return false;
|
767 |
}
|
767 |
}
|
768 |
}
|
768 |
}
|
769 |
}
|
769 |
}
|
770 |
if (valueSection != totalValueQuestion) {
|
770 |
if (valueSection != totalValuesection) {
|
771 |
$.fn.showError('ERROR_VALUE_SECTIONS'.replace('%s', objFormGenerator.sections[i].name));
|
771 |
$.fn.showError('ERROR_VALUE_SECTIONS'.replace('%s', objFormGenerator.sections[i].name));
|
772 |
return false;
|
772 |
return false;
|
773 |
}
|
773 |
}
|
774 |
}
|
774 |
}
|
775 |
var formId = parseInt($('#form-main #form-id').val());
|
775 |
var formId = parseInt($('#form-main #form-id').val());
|
Línea 818... |
Línea 818... |
818 |
return false;
|
818 |
return false;
|
819 |
}
|
819 |
}
|
820 |
}
|
820 |
}
|
821 |
});
|
821 |
});
|
822 |
/**
|
822 |
/**
|
823 |
* Validate rules form Questions
|
823 |
* Validate rules form sections
|
824 |
*/
|
824 |
*/
|
825 |
var validatorFormQuestion = $("#form-section").validate({
|
825 |
var validatorFormsection = $("#form-section").validate({
|
826 |
ignore: [],
|
826 |
ignore: [],
|
827 |
errorClass: 'help-block',
|
827 |
errorClass: 'help-block',
|
828 |
errorElement: 'span',
|
828 |
errorElement: 'span',
|
829 |
rules: {
|
829 |
rules: {
|
830 |
'section-text': {
|
830 |
'section-text': {
|
Línea 869... |
Línea 869... |
869 |
scrollTop: $(validator.errorList[0].element).offset().top - 100
|
869 |
scrollTop: $(validator.errorList[0].element).offset().top - 100
|
870 |
}, 1000);
|
870 |
}, 1000);
|
871 |
},
|
871 |
},
|
872 |
submitHandler: function(form) {
|
872 |
submitHandler: function(form) {
|
873 |
if ($('#form-section #section-id').val()) {
|
873 |
if ($('#form-section #section-id').val()) {
|
874 |
objFormGenerator.editQuestion(
|
874 |
objFormGenerator.editsection(
|
875 |
$('#form-section #section-section').val(),
|
875 |
$('#form-section #section-section').val(),
|
876 |
$('#form-section #section-id').val(),
|
876 |
$('#form-section #section-id').val(),
|
877 |
$('#form-section #section-text').val(),
|
877 |
$('#form-section #section-text').val(),
|
878 |
$('#form-section #section-value').val(),
|
878 |
$('#form-section #section-value').val(),
|
879 |
$('#form-section #section-type').val(),
|
879 |
$('#form-section #section-type').val(),
|
880 |
$('#form-section #section-max-length').val(),
|
880 |
$('#form-section #section-max-length').val(),
|
881 |
$('#form-section #section-multiline').val(),
|
881 |
$('#form-section #section-multiline').val(),
|
882 |
$('#form-section #section-range').val()
|
882 |
$('#form-section #section-range').val()
|
883 |
);
|
883 |
);
|
884 |
} else {
|
884 |
} else {
|
885 |
objFormGenerator.addQuestion(
|
885 |
objFormGenerator.addsection(
|
886 |
$('#form-section #section-section').val(),
|
886 |
$('#form-section #section-section').val(),
|
887 |
$('#form-section #section-text').val(),
|
887 |
$('#form-section #section-text').val(),
|
888 |
$('#form-section #section-value').val(),
|
888 |
$('#form-section #section-value').val(),
|
889 |
$('#form-section #section-type').val(),
|
889 |
$('#form-section #section-type').val(),
|
890 |
$('#form-section #section-max-length').val(),
|
890 |
$('#form-section #section-max-length').val(),
|
Línea 942... |
Línea 942... |
942 |
},
|
942 |
},
|
943 |
submitHandler: function(form) {
|
943 |
submitHandler: function(form) {
|
944 |
if ($('#form-option #option-slug').val()) {
|
944 |
if ($('#form-option #option-slug').val()) {
|
945 |
objFormGenerator.editOption(
|
945 |
objFormGenerator.editOption(
|
946 |
$('#form-option #option-section').val(),
|
946 |
$('#form-option #option-section').val(),
|
947 |
$('#form-option #option-question').val(),
|
947 |
$('#form-option #option-section').val(),
|
948 |
$('#form-option #option-slug').val(),
|
948 |
$('#form-option #option-slug').val(),
|
949 |
$('#form-option #option-text').val(),
|
949 |
$('#form-option #option-text').val(),
|
950 |
$('#form-option #option-correct').val(),
|
950 |
$('#form-option #option-correct').val(),
|
951 |
$('#form-option #option-value').val()
|
951 |
$('#form-option #option-value').val()
|
952 |
);
|
952 |
);
|
953 |
} else {
|
953 |
} else {
|
954 |
objFormGenerator.addOption(
|
954 |
objFormGenerator.addOption(
|
955 |
$('#form-option #option-section').val(),
|
955 |
$('#form-option #option-section').val(),
|
956 |
$('#form-option #option-question').val(),
|
956 |
$('#form-option #option-section').val(),
|
957 |
$('#form-option #option-text').val(),
|
957 |
$('#form-option #option-text').val(),
|
958 |
$('#form-option #option-correct').val(),
|
958 |
$('#form-option #option-correct').val(),
|
959 |
$('#form-option #option-value').val()
|
959 |
$('#form-option #option-value').val()
|
960 |
);
|
960 |
);
|
961 |
}
|
961 |
}
|
Línea 963... |
Línea 963... |
963 |
$('#modal-option').modal('hide');
|
963 |
$('#modal-option').modal('hide');
|
964 |
return false;
|
964 |
return false;
|
965 |
}
|
965 |
}
|
966 |
});
|
966 |
});
|
967 |
/**
|
967 |
/**
|
968 |
* Clicked add new question
|
968 |
* Clicked add new section
|
969 |
*/
|
969 |
*/
|
970 |
$('body').on('click', 'button.btn-add-section', function(e) {
|
970 |
$('body').on('click', 'button.btn-add-section', function(e) {
|
971 |
validatorFormQuestion.resetForm();
|
- |
|
972 |
$('#form-section #section-id').val('');
|
- |
|
973 |
CKEDITOR.instances['section-text'].setData('');
|
- |
|
974 |
$('#form-section #section-type').val($('#form-section #section-type option:first').val());
|
- |
|
975 |
$('#form-section #section-max-length').val('0');
|
- |
|
976 |
$('#form-section #section-max-length').parent().show();
|
- |
|
977 |
$('#modal-section h4[class="modal-title"]').html('LABEL_ADD LABEL_SECTION');
|
- |
|
978 |
$('#modal-section').modal('show');
|
971 |
$('#modal-section').modal('show');
|
979 |
});
|
972 |
});
|
980 |
/**
|
973 |
/**
|
981 |
* Clicked edit question
|
974 |
* Clicked edit section
|
982 |
*/
|
975 |
*/
|
983 |
$('body').on('click', 'button.btn-edit-section', function(e) {
|
976 |
$('body').on('click', 'button.btn-edit-section', function(e) {
|
984 |
e.preventDefault();
|
977 |
e.preventDefault();
|
985 |
var slug_section = $(this).data('section');
|
978 |
var slug_section = $(this).data('section');
|
986 |
var slug = $(this).data('question');
|
979 |
var slug = $(this).data('section');
|
987 |
var showForm = false;
|
980 |
var showForm = false;
|
988 |
for (i = 0; i < objFormGenerator.sections.length; i++) {
|
- |
|
989 |
if (slug_section == objFormGenerator.sections[i].slug_section) {
|
- |
|
990 |
for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
|
- |
|
991 |
if (slug == objFormGenerator.sections[i].questions[j].slug_question) {
|
- |
|
992 |
validatorFormQuestion.resetForm();
|
- |
|
993 |
$('#form-section #section-section').val(objFormGenerator.sections[i].slug_section);
|
- |
|
994 |
$('#form-section #section-id').val(objFormGenerator.sections[i].questions[j].slug_question);
|
- |
|
995 |
CKEDITOR.instances['section-text'].setData(objFormGenerator.sections[i].questions[j].text);
|
- |
|
996 |
$('#form-section #section-value').val(objFormGenerator.sections[i].questions[j].value);
|
- |
|
997 |
$('#form-section #section-type').val(objFormGenerator.sections[i].questions[j].type);
|
- |
|
998 |
if (objFormGenerator.sections[i].questions[j].type == 'open') {
|
- |
|
999 |
$('#form-section #section-max-length').val(objFormGenerator.sections[i].questions[j].maxlength);
|
- |
|
1000 |
$('#form-section #section-max-length').parent().show();
|
- |
|
1001 |
$('#form-section #section-multiline').val(objFormGenerator.sections[i].questions[j].multiline);
|
- |
|
1002 |
$('#form-section #section-multiline').parent().show();
|
- |
|
1003 |
} else {
|
- |
|
1004 |
$('#form-section #section-max-length').val('0');
|
- |
|
1005 |
$('#form-section #section-max-length').parent().hide();
|
- |
|
1006 |
$('#form-section #section-multiline').val('0');
|
- |
|
1007 |
$('#form-section #section-multiline').parent().hide();
|
- |
|
1008 |
}
|
- |
|
1009 |
if (objFormGenerator.sections[i].questions[j].type == 'rating-range') {
|
- |
|
1010 |
$('#form-section #section-range').val(objFormGenerator.sections[i].questions[j].range);
|
- |
|
1011 |
$('#form-section #section-range').parent().show();
|
- |
|
1012 |
} else {
|
- |
|
1013 |
$('#form-section #section-range').val('10');
|
- |
|
1014 |
$('#form-section #section-range').parent().hide();
|
- |
|
1015 |
}
|
- |
|
1016 |
showForm = true;
|
- |
|
1017 |
break;
|
- |
|
1018 |
}
|
- |
|
1019 |
}
|
- |
|
1020 |
break;
|
- |
|
1021 |
}
|
- |
|
1022 |
}
|
- |
|
1023 |
if (showForm) {
|
- |
|
1024 |
$('#modal-section h4[class="modal-title"]').html('LABEL_EDIT LABEL_SECTION');
|
- |
|
1025 |
$('#modal-section').modal('show');
|
- |
|
1026 |
}
|
981 |
|
1027 |
});
|
982 |
});
|
1028 |
/**
|
983 |
/**
|
1029 |
* Clicked remove question
|
984 |
* Clicked remove section
|
1030 |
*/
|
985 |
*/
|
1031 |
$('body').on('click', 'button.btn-delete-section', function(e) {
|
986 |
$('body').on('click', 'button.btn-delete-section', function(e) {
|
1032 |
e.preventDefault();
|
987 |
e.preventDefault();
|
1033 |
var slug_section = $(this).data('section');
|
988 |
var slug_section = $(this).data('section');
|
1034 |
var slug = $(this).data('question');
|
989 |
var slug = $(this).data('section');
|
1035 |
bootbox.confirm({
|
990 |
bootbox.confirm({
|
1036 |
title: "LABEL_DELETE LABEL_SECTION",
|
991 |
title: "LABEL_DELETE LABEL_SECTION",
|
1037 |
message: "LABEL_SECTION_DELETE",
|
992 |
message: "LABEL_SECTION_DELETE",
|
1038 |
buttons: {
|
993 |
buttons: {
|
1039 |
cancel: {
|
994 |
cancel: {
|
Línea 1043... |
Línea 998... |
1043 |
label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
|
998 |
label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
|
1044 |
}
|
999 |
}
|
1045 |
},
|
1000 |
},
|
1046 |
callback: function(result) {
|
1001 |
callback: function(result) {
|
1047 |
if (result) {
|
1002 |
if (result) {
|
1048 |
objFormGenerator.deleteQuestion(slug_section, slug);
|
1003 |
objFormGenerator.deletesection(slug_section, slug);
|
1049 |
renderSectionData(objFormGenerator.sections);
|
1004 |
renderSectionData(objFormGenerator.sections);
|
1050 |
}
|
1005 |
}
|
1051 |
}
|
1006 |
}
|
1052 |
});
|
1007 |
});
|
1053 |
});
|
1008 |
});
|
Línea 1055... |
Línea 1010... |
1055 |
* Clicked add new Option
|
1010 |
* Clicked add new Option
|
1056 |
*/
|
1011 |
*/
|
1057 |
$('body').on('click', 'button.btn-add-option', function(e) {
|
1012 |
$('body').on('click', 'button.btn-add-option', function(e) {
|
1058 |
e.preventDefault();
|
1013 |
e.preventDefault();
|
1059 |
var slug_section = $(this).data('section');
|
1014 |
var slug_section = $(this).data('section');
|
1060 |
var slug_question = $(this).data('question');
|
1015 |
var slug_section = $(this).data('section');
|
1061 |
var showForm = false;
|
1016 |
var showForm = false;
|
1062 |
for (i = 0; i < objFormGenerator.sections.length; i++) {
|
1017 |
for (i = 0; i < objFormGenerator.sections.length; i++) {
|
1063 |
if (slug_section == objFormGenerator.sections[i].slug_section) {
|
1018 |
if (slug_section == objFormGenerator.sections[i].slug_section) {
|
1064 |
for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
|
1019 |
for (j = 0; j < objFormGenerator.sections[i].sections.length; j++) {
|
1065 |
if (slug_question == objFormGenerator.sections[i].questions[j].slug_question) {
|
1020 |
if (slug_section == objFormGenerator.sections[i].sections[j].slug_section) {
|
1066 |
validatorFormOption.resetForm();
|
1021 |
validatorFormOption.resetForm();
|
1067 |
$('#form-option #option-section').val(slug_section);
|
1022 |
$('#form-option #option-section').val(slug_section);
|
1068 |
$('#form-option #option-question').val(slug_question);
|
1023 |
$('#form-option #option-section').val(slug_section);
|
1069 |
$('#form-option #option-slug').val('');
|
1024 |
$('#form-option #option-slug').val('');
|
1070 |
CKEDITOR.instances['option-text'].setData('', function() {
|
1025 |
CKEDITOR.instances['option-text'].setData('', function() {
|
1071 |
editor.focus();
|
1026 |
editor.focus();
|
1072 |
});
|
1027 |
});
|
1073 |
$('#form-option #option-correct').val('0');
|
1028 |
$('#form-option #option-correct').val('0');
|
1074 |
if (objFormGenerator.sections[i].questions[j].type == 'rating-open') {
|
1029 |
if (objFormGenerator.sections[i].sections[j].type == 'rating-open') {
|
1075 |
$('#form-option #option-correct').parent().hide();
|
1030 |
$('#form-option #option-correct').parent().hide();
|
1076 |
} else {
|
1031 |
} else {
|
1077 |
$('#form-option #option-correct').parent().show();
|
1032 |
$('#form-option #option-correct').parent().show();
|
1078 |
}
|
1033 |
}
|
1079 |
if (objFormGenerator.sections[i].questions[j].type == 'multiple' || objFormGenerator.sections[i].questions[j].type == 'rating-open') {
|
1034 |
if (objFormGenerator.sections[i].sections[j].type == 'multiple' || objFormGenerator.sections[i].sections[j].type == 'rating-open') {
|
1080 |
$('#form-option #option-value').val('0');
|
1035 |
$('#form-option #option-value').val('0');
|
1081 |
$('#form-option #option-value').parent().show();
|
1036 |
$('#form-option #option-value').parent().show();
|
1082 |
} else {
|
1037 |
} else {
|
1083 |
$('#form-option #option-value').val('1');
|
1038 |
$('#form-option #option-value').val('1');
|
1084 |
$('#form-option #option-value').parent().hide();
|
1039 |
$('#form-option #option-value').parent().hide();
|
Línea 1096... |
Línea 1051... |
1096 |
* Clicked edit option
|
1051 |
* Clicked edit option
|
1097 |
*/
|
1052 |
*/
|
1098 |
$('body').on('click', 'button.btn-edit-option', function(e) {
|
1053 |
$('body').on('click', 'button.btn-edit-option', function(e) {
|
1099 |
e.preventDefault();
|
1054 |
e.preventDefault();
|
1100 |
var slug_section = $(this).data('section');
|
1055 |
var slug_section = $(this).data('section');
|
1101 |
var slug_question = $(this).data('question');
|
1056 |
var slug_section = $(this).data('section');
|
1102 |
var slug = $(this).data('slug');
|
1057 |
var slug = $(this).data('slug');
|
1103 |
var showForm = false;
|
1058 |
var showForm = false;
|
1104 |
for (i = 0; i < objFormGenerator.sections.length; i++) {
|
1059 |
for (i = 0; i < objFormGenerator.sections.length; i++) {
|
1105 |
if (slug_section == objFormGenerator.sections[i].slug_section) {
|
1060 |
if (slug_section == objFormGenerator.sections[i].slug_section) {
|
1106 |
for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
|
1061 |
for (j = 0; j < objFormGenerator.sections[i].sections.length; j++) {
|
1107 |
if (slug_question == objFormGenerator.sections[i].questions[j].slug_question) {
|
1062 |
if (slug_section == objFormGenerator.sections[i].sections[j].slug_section) {
|
1108 |
for (k = 0; k < objFormGenerator.sections[i].questions[j].options.length; k++) {
|
1063 |
for (k = 0; k < objFormGenerator.sections[i].sections[j].options.length; k++) {
|
1109 |
if (slug == objFormGenerator.sections[i].questions[j].options[k].slug_option) {
|
1064 |
if (slug == objFormGenerator.sections[i].sections[j].options[k].slug_option) {
|
1110 |
validatorFormOption.resetForm();
|
1065 |
validatorFormOption.resetForm();
|
1111 |
$('#form-option #option-section').val(objFormGenerator.sections[i].slug_section);
|
1066 |
$('#form-option #option-section').val(objFormGenerator.sections[i].slug_section);
|
1112 |
$('#form-option #option-question').val(objFormGenerator.sections[i].questions[j].slug_question);
|
1067 |
$('#form-option #option-section').val(objFormGenerator.sections[i].sections[j].slug_section);
|
1113 |
$('#form-option #option-slug').val(objFormGenerator.sections[i].questions[j].options[k].slug_option);
|
1068 |
$('#form-option #option-slug').val(objFormGenerator.sections[i].sections[j].options[k].slug_option);
|
1114 |
CKEDITOR.instances['option-text'].setData(objFormGenerator.sections[i].questions[j].options[k].text,
|
1069 |
CKEDITOR.instances['option-text'].setData(objFormGenerator.sections[i].sections[j].options[k].text,
|
1115 |
function() {
|
1070 |
function() {
|
1116 |
editor.focus();
|
1071 |
editor.focus();
|
1117 |
});
|
1072 |
});
|
1118 |
$('#form-option #option-correct').val(objFormGenerator.sections[i].questions[j].options[k].correct);
|
1073 |
$('#form-option #option-correct').val(objFormGenerator.sections[i].sections[j].options[k].correct);
|
1119 |
if (objFormGenerator.sections[i].questions[j].type == 'multiple' || objFormGenerator.sections[i].questions[j].type == 'simple') {
|
1074 |
if (objFormGenerator.sections[i].sections[j].type == 'multiple' || objFormGenerator.sections[i].sections[j].type == 'simple') {
|
1120 |
$('#form-option #option-correct').parent().show();
|
1075 |
$('#form-option #option-correct').parent().show();
|
1121 |
} else {
|
1076 |
} else {
|
1122 |
$('#form-option #option-correct').parent().hide();
|
1077 |
$('#form-option #option-correct').parent().hide();
|
1123 |
}
|
1078 |
}
|
1124 |
$('#form-option #option-value').val(objFormGenerator.sections[i].questions[j].options[k].value);
|
1079 |
$('#form-option #option-value').val(objFormGenerator.sections[i].sections[j].options[k].value);
|
1125 |
if (objFormGenerator.sections[i].questions[j].type == 'multiple' || objFormGenerator.sections[i].questions[j].type == 'rating-open') {
|
1080 |
if (objFormGenerator.sections[i].sections[j].type == 'multiple' || objFormGenerator.sections[i].sections[j].type == 'rating-open') {
|
1126 |
$('#form-option #option-value').parent().show();
|
1081 |
$('#form-option #option-value').parent().show();
|
1127 |
} else {
|
1082 |
} else {
|
1128 |
$('#form-option #option-value').parent().hide();
|
1083 |
$('#form-option #option-value').parent().hide();
|
1129 |
}
|
1084 |
}
|
1130 |
showForm = true;
|
1085 |
showForm = true;
|
Línea 1150... |
Línea 1105... |
1150 |
* Clicked remove option
|
1105 |
* Clicked remove option
|
1151 |
*/
|
1106 |
*/
|
1152 |
$('body').on('click', 'button.btn-delete-option', function(e) {
|
1107 |
$('body').on('click', 'button.btn-delete-option', function(e) {
|
1153 |
e.preventDefault();
|
1108 |
e.preventDefault();
|
1154 |
var slug_section = $(this).data('section');
|
1109 |
var slug_section = $(this).data('section');
|
1155 |
var slug_question = $(this).data('question');
|
1110 |
var slug_section = $(this).data('section');
|
1156 |
var slug = $(this).data('slug');
|
1111 |
var slug = $(this).data('slug');
|
1157 |
bootbox.confirm({
|
1112 |
bootbox.confirm({
|
1158 |
title: "LABEL_DELETE LABEL_OPTION",
|
1113 |
title: "LABEL_DELETE LABEL_OPTION",
|
1159 |
message: "LABEL_SECTION_DELETE",
|
1114 |
message: "LABEL_SECTION_DELETE",
|
1160 |
buttons: {
|
1115 |
buttons: {
|
Línea 1165... |
Línea 1120... |
1165 |
label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
|
1120 |
label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
|
1166 |
}
|
1121 |
}
|
1167 |
},
|
1122 |
},
|
1168 |
callback: function(result) {
|
1123 |
callback: function(result) {
|
1169 |
if (result) {
|
1124 |
if (result) {
|
1170 |
objFormGenerator.deleteOption(slug_section, slug_question, slug);
|
1125 |
objFormGenerator.deleteOption(slug_section, slug_section, slug);
|
1171 |
renderSectionData(objFormGenerator.sections);
|
1126 |
renderSectionData(objFormGenerator.sections);
|
1172 |
}
|
1127 |
}
|
1173 |
}
|
1128 |
}
|
1174 |
});
|
1129 |
});
|
1175 |
})
|
1130 |
})
|
Línea 1213... |
Línea 1168... |
1213 |
e.preventDefault();
|
1168 |
e.preventDefault();
|
1214 |
$('#form-main #form-continue').val('0')
|
1169 |
$('#form-main #form-continue').val('0')
|
1215 |
$('#form-main').submit();
|
1170 |
$('#form-main').submit();
|
1216 |
});
|
1171 |
});
|
1217 |
/**
|
1172 |
/**
|
1218 |
* Get Question type
|
1173 |
* Get section type
|
1219 |
*/
|
1174 |
*/
|
1220 |
const getQuestionTypeBySlug = (slug_section, slug_question) => {
|
1175 |
const getsectionTypeBySlug = (slug_section, slug_section) => {
|
1221 |
for (i = 0; i < objFormGenerator.sections.length; i++) {
|
1176 |
for (i = 0; i < objFormGenerator.sections.length; i++) {
|
1222 |
if (slug_section == objFormGenerator.sections[i].slug_section) {
|
1177 |
if (slug_section == objFormGenerator.sections[i].slug_section) {
|
1223 |
for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
|
1178 |
for (j = 0; j < objFormGenerator.sections[i].sections.length; j++) {
|
1224 |
if (slug_question == objFormGenerator.sections[i].questions[j].slug_question) {
|
1179 |
if (slug_section == objFormGenerator.sections[i].sections[j].slug_section) {
|
1225 |
return objFormGenerator.sections[i].questions[j].type;
|
1180 |
return objFormGenerator.sections[i].sections[j].type;
|
1226 |
}
|
1181 |
}
|
1227 |
}
|
1182 |
}
|
1228 |
}
|
1183 |
}
|
1229 |
}
|
1184 |
}
|
1230 |
}
|
1185 |
}
|
Línea 1234... |
Línea 1189... |
1234 |
const removeTags = (str) => str.toString().replace( /(<([^>]+)>)/ig, '')
|
1189 |
const removeTags = (str) => str.toString().replace( /(<([^>]+)>)/ig, '')
|
1235 |
/**
|
1190 |
/**
|
1236 |
* Render Sections data
|
1191 |
* Render Sections data
|
1237 |
*/
|
1192 |
*/
|
1238 |
const renderSectionData = (data) => $("#rows").html($("#sectionTemplate").render(data, {
|
1193 |
const renderSectionData = (data) => $("#rows").html($("#sectionTemplate").render(data, {
|
1239 |
getType: getQuestionTypeBySlug,
|
1194 |
getType: getsectionTypeBySlug,
|
1240 |
removeTags: removeTags
|
1195 |
removeTags: removeTags
|
1241 |
}));
|
1196 |
}));
|
Línea 1242... |
Línea 1197... |
1242 |
|
1197 |
|
Línea 1332... |
Línea 1287... |
1332 |
|
1287 |
|
Línea 1333... |
Línea 1288... |
1333 |
<!-- Create/Edit Form-->
|
1288 |
<!-- Create/Edit Form-->
|
Línea 1334... |
Línea 1289... |
1334 |
|
1289 |
|
1335 |
|
1290 |
|
1336 |
|
1291 |
|
1337 |
<!-- Question Modal -->
|
1292 |
<!-- section Modal -->
|
Línea 1378... |
Línea 1333... |
1378 |
</div>
|
1333 |
</div>
|
1379 |
</form>
|
1334 |
</form>
|
1380 |
</div>
|
1335 |
</div>
|
1381 |
</div>
|
1336 |
</div>
|
Línea 1382... |
Línea 1337... |
1382 |
|
1337 |
|
Línea 1383... |
Línea 1338... |
1383 |
<!-- End Modal Question -->
|
1338 |
<!-- End Modal section -->
|
Línea 1384... |
Línea 1339... |
1384 |
|
1339 |
|
1385 |
<!-- Modal Options -->
|
1340 |
<!-- Modal Options -->
|
1386 |
|
1341 |
|
1387 |
<div id="modal-option" class="modal" tabindex="-1" role="dialog">
|
1342 |
<div id="modal-option" class="modal" tabindex="-1" role="dialog">
|
1388 |
<div class="modal-dialog modal-lg" role="document">
|
1343 |
<div class="modal-dialog modal-lg" role="document">
|
1389 |
<form action="#" name="form-option" id="form-option">
|
1344 |
<form action="#" name="form-option" id="form-option">
|
1390 |
<input type="hidden" name="option-section" id="option-section" value="" />
|
1345 |
<input type="hidden" name="option-section" id="option-section" value="" />
|
1391 |
<input type="hidden" name="option-question" id="option-question" value="" />
|
1346 |
<input type="hidden" name="option-section" id="option-section" value="" />
|
1392 |
<input type="hidden" name="option-slug" id="option-slug" value="" />
|
1347 |
<input type="hidden" name="option-slug" id="option-slug" value="" />
|
1393 |
<div class="modal-content">
|
1348 |
<div class="modal-content">
|
Línea 1447... |
Línea 1402... |
1447 |
<td>{{:value}}</td>
|
1402 |
<td>{{:value}}</td>
|
1448 |
<td></td>
|
1403 |
<td></td>
|
1449 |
<td>
|
1404 |
<td>
|
1450 |
<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>
|
1405 |
<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>
|
1451 |
<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>
|
1406 |
<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>
|
1452 |
<button class="btn btn-default btn-add-question" data-section="{{:slug_section}}" data-toggle="tooltip" data-original-title="LABEL_ADD LABEL_SECTION"><i class="fa fa-plus" aria-hidden="true"></i> LABEL_ADD LABEL_SECTION </button>
|
1407 |
<button class="btn btn-default btn-add-section" data-section="{{:slug_section}}" data-toggle="tooltip" data-original-title="LABEL_ADD LABEL_SECTION"><i class="fa fa-plus" aria-hidden="true"></i> LABEL_ADD LABEL_SECTION </button>
|
1453 |
</td>
|
1408 |
</td>
|
1454 |
</tr>
|
1409 |
</tr>
|
1455 |
{{for questions}}
|
1410 |
{{for sections}}
|
1456 |
<tr class="tr-question">
|
1411 |
<tr class="tr-section">
|
1457 |
<td class="text-left">--LABEL_SECTION</td>
|
1412 |
<td class="text-left">--LABEL_SECTION</td>
|
1458 |
<td class="text-left">
|
1413 |
<td class="text-left">
|
1459 |
{{:~removeTags(text)}}
|
1414 |
{{:~removeTags(text)}}
|
1460 |
</td>
|
1415 |
</td>
|
1461 |
<td><font color="red">{{:value}}</font></td>
|
1416 |
<td><font color="red">{{:value}}</font></td>
|
Línea 1465... |
Línea 1420... |
1465 |
{{if type == 'multiple'}} Multiple {{/if}}
|
1420 |
{{if type == 'multiple'}} Multiple {{/if}}
|
1466 |
{{if type == 'rating-open'}} LABEL_RATING_OPEN {{/if}}
|
1421 |
{{if type == 'rating-open'}} LABEL_RATING_OPEN {{/if}}
|
1467 |
{{if type == 'rating-range'}} LABEL_RATING_RANGE {{/if}}
|
1422 |
{{if type == 'rating-range'}} LABEL_RATING_RANGE {{/if}}
|
1468 |
</td>
|
1423 |
</td>
|
1469 |
<td>
|
1424 |
<td>
|
1470 |
<button class="btn btn-default btn-edit-question" data-section="{{:slug_section}}" data-question="{{:slug_question}}" data-toggle="tooltip" data-original-title="LABEL_EDIT LABEL_SECTION"><i class="fa fa-edit" aria-hidden="true"></i> LABEL_EDIT LABEL_SECTION</button>
|
1425 |
<button class="btn btn-default btn-edit-section" data-section="{{:slug_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>
|
1471 |
<button class="btn btn-default btn-delete-question" data-section="{{:slug_section}}" data-question="{{:slug_question}}" data-toggle="tooltip" data-original-title="LABEL_DELETE LABEL_SECTION"><i class="fa fa-ban" aria-hidden="true"></i> LABEL_DELETE LABEL_SECTION</button>
|
1426 |
<button class="btn btn-default btn-delete-section" data-section="{{:slug_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>
|
Línea 1472... |
Línea 1427... |
1472 |
|
1427 |
|
1473 |
{{if type == 'simple' || type == 'rating-open' || type=='multiple' }}
|
1428 |
{{if type == 'simple' || type == 'rating-open' || type=='multiple' }}
|
1474 |
<button class="btn btn-default btn-add-option" data-section="{{:slug_section}}" data-question="{{:slug_question}}" data-toggle="tooltip" data-original-title="LABEL_ADD LABEL_OPTION"><i class="fa fa-plus" aria-hidden="true"></i> LABEL_ADD LABEL_OPTION</button>
|
1429 |
<button class="btn btn-default btn-add-option" data-section="{{:slug_section}}" data-section="{{:slug_section}}" data-toggle="tooltip" data-original-title="LABEL_ADD LABEL_OPTION"><i class="fa fa-plus" aria-hidden="true"></i> LABEL_ADD LABEL_OPTION</button>
|
Línea 1475... |
Línea 1430... |
1475 |
{{/if}}
|
1430 |
{{/if}}
|
1476 |
|
1431 |
|
1477 |
</td>
|
1432 |
</td>
|
Línea 1482... |
Línea 1437... |
1482 |
<td class="text-left">
|
1437 |
<td class="text-left">
|
1483 |
{{:~removeTags(text)}}
|
1438 |
{{:~removeTags(text)}}
|
1484 |
</td>
|
1439 |
</td>
|
1485 |
<td>
|
1440 |
<td>
|
Línea 1486... |
Línea 1441... |
1486 |
|
1441 |
|
1487 |
{{if ~getType( slug_section, slug_question) == 'multiple' || ~getType( slug_section, slug_question) == 'rating-open' }}
|
1442 |
{{if ~getType( slug_section, slug_section) == 'multiple' || ~getType( slug_section, slug_section) == 'rating-open' }}
|
1488 |
{{:value}}
|
1443 |
{{:value}}
|
1489 |
{{/if}}
|
1444 |
{{/if}}
|
1490 |
</td>
|
1445 |
</td>
|
1491 |
<td class="text-left">
|
1446 |
<td class="text-left">
|
1492 |
{{if ~getType( slug_section, slug_question) != 'rating-open'}}
|
1447 |
{{if ~getType( slug_section, slug_section) != 'rating-open'}}
|
1493 |
{{if correct == 1}}
|
1448 |
{{if correct == 1}}
|
1494 |
<font color="green">LABEL_CORRECT</font>
|
1449 |
<font color="green">LABEL_CORRECT</font>
|
1495 |
{{/if}}
|
1450 |
{{/if}}
|
1496 |
{{if correct == 0}}
|
1451 |
{{if correct == 0}}
|
1497 |
<font color="red">LABEL_FAIL</font>
|
1452 |
<font color="red">LABEL_FAIL</font>
|
1498 |
{{/if}}
|
1453 |
{{/if}}
|
1499 |
{{/if}}
|
1454 |
{{/if}}
|
1500 |
</td>
|
1455 |
</td>
|
1501 |
<td>
|
1456 |
<td>
|
1502 |
<button class="btn btn-default btn-edit-option" data-section="{{:slug_section}}" data-question="{{:slug_question}}" data-slug="{{:slug_option}}" data-toggle="tooltip" data-original-title="LABEL_EDIT LABEL_OPTION"><i class="fa fa-edit" aria-hidden="true"></i> LABEL_EDIT LABEL_OPTION</button>
|
1457 |
<button class="btn btn-default btn-edit-option" data-section="{{:slug_section}}" data-section="{{:slug_section}}" data-slug="{{:slug_option}}" data-toggle="tooltip" data-original-title="LABEL_EDIT LABEL_OPTION"><i class="fa fa-edit" aria-hidden="true"></i> LABEL_EDIT LABEL_OPTION</button>
|
1503 |
<button class="btn btn-default btn-delete-option" data-section="{{:slug_section}}" data-question="{{:slug_question}}" data-slug="{{:slug_option}}" data-toggle="tooltip" data-original-title="LABEL_DELETE LABEL_OPTION"><i class="fa fa-ban" aria-hidden="true"></i> LABEL_DELETE LABEL_OPTION</button>
|
1458 |
<button class="btn btn-default btn-delete-option" data-section="{{:slug_section}}" data-section="{{:slug_section}}" data-slug="{{:slug_option}}" data-toggle="tooltip" data-original-title="LABEL_DELETE LABEL_OPTION"><i class="fa fa-ban" aria-hidden="true"></i> LABEL_DELETE LABEL_OPTION</button>
|
1504 |
</td>
|
1459 |
</td>
|
1505 |
</tr>
|
1460 |
</tr>
|
1506 |
{{/for}}
|
1461 |
{{/for}}
|
1507 |
{{/for}}
|
1462 |
{{/for}}
|