Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 165 | Rev 167 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 165 Rev 166
Línea 83... Línea 83...
83
				var s = '';
83
				var s = '';
84
				for(i = 0; i < this.sections.length; i++)
84
				for(i = 0; i < this.sections.length; i++)
85
				{
85
				{
86
					if(section_slug !=  this.sections[i].slug_section) {
86
					if(section_slug !=  this.sections[i].slug_section) {
87
						continue;
87
						continue;
88
					}
88
					}				
89
 
-
 
90
					$('span.section-name' + section_slug).html(this.sections[i].name);
-
 
91
 
-
 
92
					let table = 'table-section-question-option' + this.sections[i].slug_section; 
-
 
93
					$('#' + table  + ' tbody').empty();
-
 
94
					
-
 
95
					s = '<tr class="tr-section" data-slug="' + this.sections[i].slug_section + '">';
-
 
96
					s = s  + '<td class="text-left">LABEL_SECTION</td>';
-
 
97
					s = s  + '<td class="text-left">' + this.sections[i].name +  '</td>';
-
 
98
					s = s  + '<td class="text-right">' + this.sections[i].value + '</td>';
-
 
99
					s = s  + '<td>&nbsp</td>';
-
 
100
					s = s  + '<td>';
-
 
101
					s = s  + '<button class="btn btn-default btn-edit-section" data-slug="' + this.sections[i].slug_section + '" data-toggle="tooltip" title="LABEL_EDIT LABEL_SECTION"><i class="fa fa-edit" aria-hidden="true"></i> LABEL_EDIT LABEL_SECTION </button>&nbsp';
-
 
102
					s = s  + '<button class="btn btn-default btn-delete-section" data-slug="' + this.sections[i].slug_section + '" data-toggle="tooltip" title="LABEL_DELETE LABEL_SECTION"><i class="fa fa-ban" aria-hidden="true"></i> LABEL_DELETE LABEL_SECTION </button>&nbsp';
-
 
103
					s = s  + '<button class="btn btn-default btn-add-question" data-slug="' + this.sections[i].slug_section + '" data-toggle="tooltip" title="LABEL_ADD LABEL_QUESTION"><i class="fa fa-plus" aria-hidden="true"></i> LABEL_ADD LABEL_QUESTION </button>&nbsp';
-
 
104
					s = s  + '</td>';
-
 
105
					s = s  + '</tr>';
-
 
106
					$('#' + table + ' tbody').append(s);
-
 
107
					
-
 
Línea 108... Línea 89...
108
					
89
					
109
 
90
 
110
					for(j = 0; j < this.sections[i].questions.length; j++)
91
					for(j = 0; j < this.sections[i].questions.length; j++)
Línea 111... Línea -...
111
					{
-
 
-
 
92
					{
112
						this.sections[i].questions[j].position = j;
93
						this.sections[i].questions[j].position = j;
Línea 113... Línea 94...
113
 
94
 
114
						this.drawQuestion( this.sections[i].slug_section, this.sections[i].questions[j].slug_question, this.sections[i].questions[j].text, this.sections[i].questions[j].value , this.sections[i].questions[j].type);
95
						
Línea 127... Línea 108...
127
								
108
								
128
							
109
							
129
							for(k = 0; k < this.sections[i].questions[j].options.length; k++)
110
							for(k = 0; k < this.sections[i].questions[j].options.length; k++)
130
							{
-
 
131
								this.sections[i].questions[j].options[k].position = j;
-
 
132
								this.drawOption(
-
 
133
									this.sections[i].slug_section, 
-
 
134
									this.sections[i].questions[j].slug_question,  
-
 
135
									this.sections[i].questions[j].type, 
-
 
136
									this.sections[i].questions[j].options[k].slug_option, 
-
 
137
									this.sections[i].questions[j].options[k].text, 
-
 
138
									this.sections[i].questions[j].options[k].type, 
-
 
139
									this.sections[i].questions[j].options[k].correct, 
-
 
140
									this.sections[i].questions[j].options[k].value
111
							{
141
								);
112
								this.sections[i].questions[j].options[k].position = j;
142
							}
113
							}
143
						}
114
						}
Línea 144... Línea 115...
144
					}
115
					}
145
				}
116
				}
146
				
-
 
147
				$('[data-toggle="tooltip"]').tooltip();
-
 
148
			},
-
 
149
			this.drawSection = function(section_slug, section_name, section_value)
-
 
150
			{
-
 
151
				let table = 'table-section-question-option' + section_slug; 
-
 
152
				let collapse = 'collapse-' + section_slug;
-
 
153
 
-
 
154
				s = '<div class="panel panel-default" id="panel' + section_slug + '">';
-
 
155
				s = s + '	<div class="panel-heading">';
-
 
156
				s = s + '		<h4 class="panel-title">';
-
 
157
				s = s + '			<a class="accordion-toggle collapsed" data-toggle="collapse" data-parent="#accordion" href="#' + collapse + '"><span class="section-name' + section_slug + '">' + section_name + '</span></a>';
-
 
158
				s = s + '		</h4>';
-
 
159
				s = s + '	</div>';
-
 
160
				s = s + '	<div id="' + collapse + '" class="panel-collapse collapse">';
-
 
161
				s = s + '		<div class="panel-body">';
-
 
162
				s = s + '			<div class="table-responsive">';
-
 
163
				s = s + '				<table class="table table-bordered" id="' + table + '">';
-
 
164
				s = s + '					<thead>';
-
 
165
				s = s + '						<tr>';
-
 
166
				s = s + '							<th>LABEL_ELEMENT</th>';
-
 
167
				s = s + '							<th>LABEL_TEXT</th>';
-
 
168
				s = s + '							<th>LABEL_VALUE</th>';
-
 
169
				s = s + '							<th>LABEL_TYPE</th>';
-
 
170
				s = s + '							<th>LABEL_ACTIONS</th>';
-
 
171
				s = s + '						</tr>';
-
 
172
				s = s + '					</thead>';
-
 
173
				s = s + '					<tbody>';
-
 
174
				s = s + '					</tbody>';					
-
 
175
				s = s + '				</table>';
-
 
176
				s = s + '			</div>';
-
 
177
				s = s + '		</div>';
-
 
178
				s = s + '	</div>';
-
 
179
				s = s + '</div>';
-
 
180
 
-
 
181
				$('#accordion').append(s);
-
 
182
 
-
 
183
 
-
 
184
				s = '<tr class="tr-section" data-slug="' + section_slug + '">';
-
 
185
				s = s  + '<td class="text-left">LABEL_SECTION</td>';
-
 
186
				s = s  + '<td class="text-left">' + section_name +  '</td>';
-
 
187
				s = s  + '<td class="text-right">' + section_value + '</td>';
-
 
188
				s = s  + '<td>&nbsp</td>';
-
 
189
				s = s  + '<td>';
-
 
190
				s = s  + '<button class="btn btn-default btn-edit-section" data-slug="' + section_slug + '" data-toggle="tooltip" title="LABEL_EDIT LABEL_SECTION"><i class="fa fa-edit" aria-hidden="true"></i> LABEL_EDIT LABEL_SECTION </button>&nbsp';
-
 
191
				s = s  + '<button class="btn btn-default btn-delete-section" data-slug="' + section_slug + '" data-toggle="tooltip" title="LABEL_DELETE LABEL_SECTION"><i class="fa fa-ban" aria-hidden="true"></i> LABEL_DELETE LABEL_SECTION </button>&nbsp';
-
 
192
				s = s  + '<button class="btn btn-default btn-add-question" data-slug="' + section_slug + '" data-toggle="tooltip" title="LABEL_ADD LABEL_QUESTION"><i class="fa fa-plus" aria-hidden="true"></i> LABEL_ADD LABEL_QUESTION </button>&nbsp';
-
 
193
				s = s  + '</td>';
-
 
194
				s = s  + '</tr>';
-
 
195
				$('#' + table + ' tbody').append(s);
-
 
196
			},
-
 
197
 
-
 
198
			this.drawQuestion = function(section_slug, question_slug, question_text, question_value, question_type)
-
 
199
			{
-
 
200
				
-
 
201
				
-
 
202
				s = '<tr class="tr-question" data-slug="' + question_slug + '">';
-
 
203
				s = s  + '<td class="text-left">--LABEL_QUESTION</td>';
-
 
204
				s = s  + '<td class="text-left">' + question_text +  '</td>';
-
 
205
				s = s  + '<td class="text-right"><font color="red">' + question_value + '</font></td>';
-
 
206
				s = s  + '<td>' + question_type.substr(0,1).toUpperCase() + question_type.substr(1) +  '</td>';
-
 
207
				s = s  + '<td>';
-
 
208
				s = s  + '<button class="btn btn-default btn-edit-question" data-section="' + section_slug + '" data-slug="' + question_slug + '" data-toggle="tooltip" title="LABEL_EDIT LABEL_QUESTION"><i class="fa fa-edit" aria-hidden="true"></i> LABEL_EDIT LABEL_QUESTION</button>&nbsp';
-
 
209
				s = s  + '<button class="btn btn-default btn-delete-question" data-section="' + section_slug + '" data-slug="' + question_slug + '" data-toggle="tooltip" title="LABEL_DELETE LABEL_QUESTION"><i class="fa fa-ban" aria-hidden="true"></i> LABEL_DELETE LABEL_QUESTION</button>&nbsp';
-
 
210
				if(question_type == 'simple' || question_type == 'multiple' || question_type == 'rating-open') {
-
 
211
					s = s  + '<button class="btn btn-default btn-add-option" data-section="' + section_slug + '" data-slug="' + question_slug + '" data-toggle="tooltip" title="LABEL_ADD LABEL_OPTION"><i class="fa fa-plus" aria-hidden="true"></i> LABEL_ADD LABEL_OPTION</button>&nbsp';
-
 
212
				}
-
 
213
				
-
 
214
				s = s  + '</td>';
-
 
215
 
-
 
216
				let table = 'table-section-question-option' + section_slug; 
-
 
217
				$('#' + table + ' tbody').append(s);
-
 
218
			},
-
 
219
 
-
 
220
			this.drawOption = function(section_slug, question_slug,  question_type, option_slug, option_text, option_type, option_correct, option_value)
-
 
221
			{
-
 
222
				
-
 
223
				
-
 
224
				s = '<tr class="tr-option" data-slug="' + option_slug + '">';
-
 
225
				s = s  + '<td class="text-left">---LABEL_OPTION</td>';
-
 
226
				s = s  + '<td class="text-left">' + option_text +  '</td>';
-
 
227
				if(question_type == 'multiple' || question_type == 'rating-open') {
-
 
228
 
-
 
229
					if(question_type == 'multiple') {
-
 
230
						if(option_correct == 1) {
-
 
231
							s = s  + '<td class="text-right">' + option_value + '</td>';
-
 
232
						} else {
-
 
233
							s = s  + '<td>&nbsp</td>';
-
 
234
						}
-
 
235
					} else {
-
 
236
						s = s  + '<td class="text-right">' + option_value + '</td>';
-
 
237
					}	
-
 
238
				} else {
-
 
239
					s = s  + '<td>&nbsp</td>';
-
 
240
				}
-
 
241
 
-
 
242
				if(question_type == 'simple' || question_type == 'multiple') {
-
 
243
					if(option_correct == 1) {
-
 
244
						s = s  + '<td class="text-left"><font color="green">LABEL_CORRECT</font></td>';
-
 
245
					} else {
-
 
246
						s = s  + '<td class="text-left"><font color="red">LABEL_FAIL</font></td>';
-
 
247
						
-
 
248
					}
-
 
249
				} else {
-
 
250
					s = s  + '<td>&nbsp</td>';
-
 
251
				}
-
 
252
				
-
 
253
				
-
 
254
				s = s  + '<td>';
-
 
255
				s = s  + '<button class="btn btn-default btn-edit-option" data-section="' + section_slug + '" data-question="' + question_slug + '" data-slug="' + option_slug + '" data-toggle="tooltip" title="LABEL_EDIT LABEL_OPTION"><i class="fa fa-edit" aria-hidden="true"></i></button>&nbsp';
117
				
256
				s = s  + '<button class="btn btn-default btn-delete-option" data-section="' + section_slug + '" data-question="' + question_slug + '" data-slug="' + option_slug + '" data-toggle="tooltip" title="LABEL_DELETE LABEL_OPTION"><i class="fa fa-ban" aria-hidden="true"></i></button>&nbsp';
-
 
257
				s = s  + '</td>';
-
 
258
 
118
				$('[data-toggle="tooltip"]').tooltip();
259
				let table = 'table-section-question-option' + section_slug; 
-
 
Línea 260... Línea 119...
260
				$('#' + table + ' tbody').append(s);
119
			},
261
 
120
			
262
			},
121
			
Línea 278... Línea 137...
278
				var s = '';
137
				var s = '';
279
				for(i = 0; i < this.sections.length; i++)
138
				for(i = 0; i < this.sections.length; i++)
280
				{
139
				{
281
					this.sections[i].position = i;
140
					this.sections[i].position = i;
Línea 282... Línea -...
282
 
-
 
283
 
-
 
284
					this.drawSection(this.sections[i].slug_section, this.sections[i].name, this.sections[i].value);
-
 
285
					
-
 
286
					
141
 
287
					this.sections[i].questions.sort(function(a, b) {
142
					this.sections[i].questions.sort(function(a, b) {
288
						if (a.position > b.position) {
143
						if (a.position > b.position) {
289
								return 1;
144
								return 1;
290
						}
145
						}
Línea 297... Línea 152...
297
					
152
					
298
					for(j = 0; j < this.sections[i].questions.length; j++)
153
					for(j = 0; j < this.sections[i].questions.length; j++)
299
					{
154
					{
Línea 300... Línea -...
300
						this.sections[i].questions[j].position = j;
-
 
-
 
155
						this.sections[i].questions[j].position = j;
301
 
156
 
Línea 302... Línea 157...
302
						this.drawQuestion( this.sections[i].slug_section, this.sections[i].questions[j].slug_question, this.sections[i].questions[j].text, this.sections[i].questions[j].value , this.sections[i].questions[j].type);
157
					
303
						if(this.sections[i].questions[j].type == 'simple' || this.sections[i].questions[j].type == 'multiple'|| this.sections[i].questions[j].type == 'rating-open') {
158
						if(this.sections[i].questions[j].type == 'simple' || this.sections[i].questions[j].type == 'multiple'|| this.sections[i].questions[j].type == 'rating-open') {
Línea 315... Línea 170...
315
								
170
								
316
							
171
							
317
							for(k = 0; k < this.sections[i].questions[j].options.length; k++)
172
							for(k = 0; k < this.sections[i].questions[j].options.length; k++)
318
							{
-
 
319
								this.sections[i].questions[j].options[k].position = j;
-
 
320
								this.drawOption(
-
 
321
									this.sections[i].slug_section, 
-
 
322
									this.sections[i].questions[j].slug_question,  
-
 
323
									this.sections[i].questions[j].type, 
-
 
324
									this.sections[i].questions[j].options[k].slug_option, 
-
 
325
									this.sections[i].questions[j].options[k].text, 
-
 
326
									this.sections[i].questions[j].options[k].type, 
-
 
327
									this.sections[i].questions[j].options[k].correct, 
-
 
328
									this.sections[i].questions[j].options[k].value
173
							{
329
								);
174
								this.sections[i].questions[j].options[k].position = j;
Línea 330... Línea 175...
330
							}
175
							}
Línea 361... Línea 206...
361
					'position' 	: position,
206
					'position' 	: position,
362
					'questions' : [],
207
					'questions' : [],
363
				}
208
				}
Línea 364... Línea 209...
364
 
209
 
365
				this.sections.push(section);
-
 
366
				this.drawSection(slug, name, text);
210
				this.sections.push(section);
367
			},
211
			},
368
			this.editSection = function (slug, name, text, value)
212
			this.editSection = function (slug, name, text, value)
369
			{
213
			{
370
				var renderTable = false;
214
				var renderTable = false;