Commit 9b618102965509a8f8b24b4f2b51838bc007183e
1 parent
0ae97439
issue was in duplicate text options in save
Showing
1 changed file
with
253 additions
and
261 deletions
400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js
1 | 1 | /// <reference path="../../content/data/json/le/LabExercise.js" /> |
2 | -AIA.controller("LabExercController", ["$scope", "$rootScope", "pages", "$log", '$http','$timeout', 'DataService', '$filter', '$location', '$document', '$sce', "$compile", "$location", "LabExerciseService","AIAConstants", | |
3 | -function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, $location, $document, $sce, $compile, $location, LabExerciseService,AIAConstants) { | |
2 | +AIA.controller("LabExercController", ["$scope", "$rootScope", "pages", "$log", '$http', '$timeout', 'DataService', '$filter', '$location', '$document', '$sce', "$compile", "$location", "LabExerciseService", "AIAConstants", | |
3 | +function ($scope, $rootScope, pages, log, $http, $timeout, DataService, $filter, $location, $document, $sce, $compile, $location, LabExerciseService, AIAConstants) { | |
4 | 4 | $scope.$sce = $sce; |
5 | 5 | $scope.LabExerciseName; |
6 | 6 | $scope.LabExerciseQuiz = null; |
... | ... | @@ -106,7 +106,7 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, |
106 | 106 | .then( |
107 | 107 | |
108 | 108 | function (labResult) { |
109 | - if (labResult != undefined && labResult.lastQuestion>0 && labResult != AIAConstants.SAVED_LAB_EXERCISE_NOT_FOUND) { | |
109 | + if (labResult != undefined && labResult.lastQuestion > 0 && labResult != AIAConstants.SAVED_LAB_EXERCISE_NOT_FOUND) { | |
110 | 110 | $scope.SavedLabExercise = labResult; |
111 | 111 | $scope.quiznumber = $scope.SavedLabExercise.lastQuestion; |
112 | 112 | $scope.initialQuestioNo = $scope.SavedLabExercise.lastQuestion; |
... | ... | @@ -116,14 +116,14 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, |
116 | 116 | $scope.GetQuizByTopic(); |
117 | 117 | } |
118 | 118 | }, |
119 | - function(error){ | |
119 | + function (error) { | |
120 | 120 | console.log('error in getting save ddata'); |
121 | 121 | } |
122 | 122 | ) |
123 | 123 | } |
124 | 124 | |
125 | 125 | $scope.GetQuizByTopic = function () { |
126 | - | |
126 | + | |
127 | 127 | $rootScope.isLoading = true; |
128 | 128 | $('#spinner').css('visibility', 'visible'); |
129 | 129 | |
... | ... | @@ -141,10 +141,10 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, |
141 | 141 | |
142 | 142 | var keywords = $location.search(); |
143 | 143 | $scope.labExercideIdentifier = (keywords.labexercise.replace('.json', '')).split('dat_')[1]; |
144 | - | |
145 | - | |
144 | + | |
145 | + | |
146 | 146 | $.each(result.LabExercise, function (index, value) { |
147 | - | |
147 | + | |
148 | 148 | $scope.LabExerciseName = result.LabExercise[index].Topic; |
149 | 149 | if (result.LabExercise[index].Slug == keywords.labexercise) { |
150 | 150 | |
... | ... | @@ -176,17 +176,16 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, |
176 | 176 | $scope.Imagepath = keywords.labexercise + "/" + result.LabExercise[index].Questions[index1].ImagePath; |
177 | 177 | } |
178 | 178 | //$scope.ShowHideDiv(result.LabExercise[index].Questions[index1].Options[0].textalign); |
179 | - | |
179 | + | |
180 | 180 | $scope.ShowHideDiv("bottom"); |
181 | 181 | |
182 | 182 | } |
183 | 183 | }); |
184 | - $timeout(function () | |
185 | - { | |
184 | + $timeout(function () { | |
186 | 185 | if ($scope.SavedLabExercise != undefined && $scope.SavedLabExercise.lastQuestion > 0) { |
187 | 186 | if ($scope.isResetClicked != true) { |
188 | 187 | $scope.ShowSavedLabExercise(); |
189 | - | |
188 | + | |
190 | 189 | } |
191 | 190 | else { |
192 | 191 | $rootScope.isLoading = false; |
... | ... | @@ -198,9 +197,9 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, |
198 | 197 | $rootScope.isLoading = false; |
199 | 198 | $('#spinner').css('visibility', 'hidden'); |
200 | 199 | } |
201 | - },100); | |
202 | - | |
203 | - | |
200 | + }, 100); | |
201 | + | |
202 | + | |
204 | 203 | } |
205 | 204 | |
206 | 205 | }); |
... | ... | @@ -211,12 +210,12 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, |
211 | 210 | console.log(error.statusText) |
212 | 211 | } |
213 | 212 | ) |
214 | - | |
213 | + | |
215 | 214 | } |
216 | 215 | |
217 | 216 | |
218 | 217 | $scope.isReviewBtnSelected = false; |
219 | - // $rootScope.selectedDivArray = []; | |
218 | + // $rootScope.selectedDivArray = []; | |
220 | 219 | $scope.nextQuiz = function () { |
221 | 220 | //need to save all questions till the current question number when user clicks on save |
222 | 221 | //if ($scope.dragableId!="") { |
... | ... | @@ -230,22 +229,21 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, |
230 | 229 | $scope.isNextOrPreviousClicked = true; |
231 | 230 | $scope.dragableId = ""; |
232 | 231 | |
233 | - | |
234 | 232 | |
235 | - if ($scope.quiznumber != $scope.TotalNumberofQuiz) | |
236 | - { | |
233 | + | |
234 | + if ($scope.quiznumber != $scope.TotalNumberofQuiz) { | |
237 | 235 | $scope.CreateLabExerciseDataToSave(); |
238 | 236 | } |
239 | 237 | |
240 | - | |
238 | + | |
241 | 239 | if ($scope.quiznumber == $scope.TotalNumberofQuiz) |
242 | 240 | return; |
243 | 241 | else |
244 | 242 | $scope.quiznumber++; |
245 | - | |
246 | - // console.log($rootScope.selectedDivArray); | |
247 | - | |
248 | - | |
243 | + | |
244 | + // console.log($rootScope.selectedDivArray); | |
245 | + | |
246 | + | |
249 | 247 | |
250 | 248 | if ($scope.quiznumber == $scope.TotalNumberofQuiz) { |
251 | 249 | if ($scope.isReviewBtnSelected == true) { |
... | ... | @@ -254,18 +252,17 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, |
254 | 252 | else { |
255 | 253 | $("#quizSubmitBtn").css("display", "block"); |
256 | 254 | } |
257 | - | |
255 | + | |
258 | 256 | } |
259 | - else | |
260 | - { | |
257 | + else { | |
261 | 258 | $("#quizSubmitBtn").css("display", "none"); |
262 | 259 | } |
263 | 260 | |
264 | 261 | $scope.resetQuiz(); |
265 | 262 | $scope.ShowHideDiv(); |
266 | - | |
267 | - | |
268 | - | |
263 | + | |
264 | + | |
265 | + | |
269 | 266 | } |
270 | 267 | |
271 | 268 | |
... | ... | @@ -278,50 +275,50 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, |
278 | 275 | |
279 | 276 | |
280 | 277 | $scope.prevQuiz = function () { |
281 | - | |
278 | + | |
282 | 279 | if ($scope.quiznumber != 1) { |
283 | - // $scope.quizQuesNo = $scope.quizQuesNo - 1; | |
284 | - // $scope.selectedQuestionNo = $scope.quizQuesNo; | |
280 | + // $scope.quizQuesNo = $scope.quizQuesNo - 1; | |
281 | + // $scope.selectedQuestionNo = $scope.quizQuesNo; | |
285 | 282 | $scope.CreateLabExerciseDataToSave(); |
286 | 283 | } |
287 | - $scope.dragableId = ""; | |
288 | - $scope.UserAttempt = []; | |
289 | - if ($scope.quiznumber == 1) | |
290 | - return; | |
291 | - else | |
292 | - $scope.quiznumber--; | |
284 | + $scope.dragableId = ""; | |
285 | + $scope.UserAttempt = []; | |
286 | + if ($scope.quiznumber == 1) | |
287 | + return; | |
288 | + else | |
289 | + $scope.quiznumber--; | |
293 | 290 | |
294 | - if ($scope.quiznumber == $scope.TotalNumberofQuiz) { | |
295 | - if ($scope.isReviewBtnSelected == true) { | |
296 | - $("#quizSubmitBtn").css("display", "none"); | |
297 | - } | |
298 | - else { | |
299 | - $("#quizSubmitBtn").css("display", "block"); | |
300 | - } | |
291 | + if ($scope.quiznumber == $scope.TotalNumberofQuiz) { | |
292 | + if ($scope.isReviewBtnSelected == true) { | |
293 | + $("#quizSubmitBtn").css("display", "none"); | |
301 | 294 | } |
302 | 295 | else { |
303 | - $("#quizSubmitBtn").css("display", "none"); | |
296 | + $("#quizSubmitBtn").css("display", "block"); | |
304 | 297 | } |
305 | - $scope.resetQuiz(); | |
306 | - $scope.ShowHideDiv(); | |
307 | - | |
298 | + } | |
299 | + else { | |
300 | + $("#quizSubmitBtn").css("display", "none"); | |
301 | + } | |
302 | + $scope.resetQuiz(); | |
303 | + $scope.ShowHideDiv(); | |
308 | 304 | |
309 | 305 | |
310 | - //for (var i = 0; i <= $rootScope.selectedDivArray.length - 1; i++) { | |
311 | - // if ($scope.quiznumber == $rootScope.selectedDivArray[i].questionNo) { | |
312 | - // alert($rootScope.selectedDivArray[i].draggedText); | |
313 | - // document.getElementById($rootScope.selectedDivArray[i].droppedID).innerHTML = $rootScope.selectedDivArray[i].draggedText; | |
314 | - // // $('#'+$rootScope.selectedDivArray[i].droppedID).html($rootScope.selectedDivArray[i].draggedText); | |
315 | - // document.getElementById($rootScope.selectedDivArray[i].droppedID).style.display = "none"; | |
316 | - // // $('#'+$rootScope.selectedDivArray[i].draggedID).css("display","none!important"); | |
317 | - // } | |
318 | 306 | |
319 | - //} | |
307 | + //for (var i = 0; i <= $rootScope.selectedDivArray.length - 1; i++) { | |
308 | + // if ($scope.quiznumber == $rootScope.selectedDivArray[i].questionNo) { | |
309 | + // alert($rootScope.selectedDivArray[i].draggedText); | |
310 | + // document.getElementById($rootScope.selectedDivArray[i].droppedID).innerHTML = $rootScope.selectedDivArray[i].draggedText; | |
311 | + // // $('#'+$rootScope.selectedDivArray[i].droppedID).html($rootScope.selectedDivArray[i].draggedText); | |
312 | + // document.getElementById($rootScope.selectedDivArray[i].droppedID).style.display = "none"; | |
313 | + // // $('#'+$rootScope.selectedDivArray[i].draggedID).css("display","none!important"); | |
314 | + // } | |
315 | + | |
316 | + //} | |
320 | 317 | } |
321 | 318 | |
322 | - | |
319 | + | |
323 | 320 | $scope.SubmitAttempt = function () { |
324 | - | |
321 | + | |
325 | 322 | $scope.CreateLabExerciseDataToSave(); |
326 | 323 | |
327 | 324 | $("#submitResultHtml").css("display", "block"); |
... | ... | @@ -329,11 +326,10 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, |
329 | 326 | console.log($scope.usersCorrectQuestData); |
330 | 327 | $("#resultLabData").empty(); |
331 | 328 | var sortedQuestionHtml = ''; |
332 | - | |
329 | + | |
333 | 330 | for (var j = $scope.TotalNumberofQuiz; j >= 1; j--) { |
334 | 331 | for (var i = 0; i <= $scope.usersCorrectQuestData.length - 1; i++) { |
335 | - if (j == $scope.usersCorrectQuestData[i].QuestionNo) | |
336 | - { | |
332 | + if (j == $scope.usersCorrectQuestData[i].QuestionNo) { | |
337 | 333 | if ($scope.usersCorrectQuestData[i].CorrectStatus == "Correct") { |
338 | 334 | var labExerciseHtml = $("#resultLabData").append("<tr><td>" + $scope.usersCorrectQuestData[i].QuestionNo + "</td><td>" + $scope.usersCorrectQuestData[i].title + "</td><td>" + $scope.usersCorrectQuestData[i].CorrectStatus + "</td><td><button ng-click='reviewAttemptAnswer($event);' id=" + $scope.usersCorrectQuestData[i].QuestionNo + " class='btn btn-sm' style='background-color:#007ab3;border-color:#007ab3;color:#ffffff;'><i class='fa fa-times'></i> Review</button></td></tr>"); |
339 | 335 | $compile(labExerciseHtml)($scope); |
... | ... | @@ -349,22 +345,20 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, |
349 | 345 | $scope.isValueExist = false; |
350 | 346 | } |
351 | 347 | } |
352 | - if ($scope.isValueExist == false) | |
353 | - { | |
354 | - var labExerciseHtml_1 = $("#resultLabData").prepend("<tr><td>" + j + "</td><td> </td><td>Incorrect</td><td><button ng-click='reviewAttemptAnswer($event);' id=" + j + " class='btn btn-danger btn-sm'><i class='fa fa-times'></i> Review</button></td></tr>"); | |
355 | - $compile(labExerciseHtml_1)($scope); | |
356 | - } | |
348 | + if ($scope.isValueExist == false) { | |
349 | + var labExerciseHtml_1 = $("#resultLabData").prepend("<tr><td>" + j + "</td><td> </td><td>Incorrect</td><td><button ng-click='reviewAttemptAnswer($event);' id=" + j + " class='btn btn-danger btn-sm'><i class='fa fa-times'></i> Review</button></td></tr>"); | |
350 | + $compile(labExerciseHtml_1)($scope); | |
351 | + } | |
357 | 352 | } |
358 | - | |
359 | - for (var j = 1;j <= $scope.TotalNumberofQuiz;j++) { | |
353 | + | |
354 | + for (var j = 1; j <= $scope.TotalNumberofQuiz; j++) { | |
360 | 355 | $("#resultLabData tr td:nth-child(1)").each(function () { |
361 | 356 | if (j == $(this).text()) { |
362 | 357 | $q = $(this).parent(); |
363 | 358 | if ($q.find("td:nth-child(3)").text() == "Correct") { |
364 | 359 | sortedQuestionHtml += '<tr><td>' + $q.find("td:nth-child(1)").text() + '</td><td>' + $q.find("td:nth-child(2)").text() + '</td><td>' + $q.find("td:nth-child(3)").text() + '</td><td><button ng-click="reviewAttemptAnswer($event);" id=' + $q.find("td:nth-child(1)").text() + ' class="btn btn-sm" style="background-color:#007ab3;border-color:#007ab3;color:#ffffff;"><i class="fa fa-times"></i> Review</button></td></tr>'; |
365 | 360 | } |
366 | - else | |
367 | - { | |
361 | + else { | |
368 | 362 | sortedQuestionHtml += '<tr><td>' + $q.find("td:nth-child(1)").text() + '</td><td>' + $q.find("td:nth-child(2)").text() + '</td><td>' + $q.find("td:nth-child(3)").text() + '</td><td><button ng-click="reviewAttemptAnswer($event);" id=' + $q.find("td:nth-child(1)").text() + ' class="btn btn-sm" style="background-color:#d9534f;border-color:#d9534f;color:#ffffff;"><i class="fa fa-times"></i> Review</button></td></tr>'; |
369 | 363 | } |
370 | 364 | } |
... | ... | @@ -381,15 +375,14 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, |
381 | 375 | if ($(this).text() == "Incorrect") { |
382 | 376 | $scope.inCorrectAnswer = $scope.inCorrectAnswer + 1; |
383 | 377 | } |
384 | - else | |
385 | - { | |
378 | + else { | |
386 | 379 | $scope.CorrectAnswer = $scope.CorrectAnswer + 1; |
387 | 380 | } |
388 | 381 | }); |
389 | 382 | |
390 | 383 | $scope.scoreResult = (parseInt($scope.CorrectAnswer) / parseInt($scope.inCorrectAnswer)) * 100; |
391 | 384 | $scope.scoreResult = Math.round($scope.scoreResult); |
392 | - | |
385 | + | |
393 | 386 | } |
394 | 387 | |
395 | 388 | |
... | ... | @@ -400,23 +393,22 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, |
400 | 393 | |
401 | 394 | |
402 | 395 | $scope.handleDragStart = function (e) { |
403 | - | |
396 | + | |
404 | 397 | this.style.opacity = '0.4'; |
405 | - | |
398 | + | |
406 | 399 | if ($.browser.msie) { |
407 | 400 | localStorage.setItem("text", this.innerHTML); |
408 | 401 | } |
409 | - else | |
410 | - { | |
402 | + else { | |
411 | 403 | e.dataTransfer.setData('text/plain', this.innerHTML); |
412 | 404 | } |
413 | - | |
405 | + | |
414 | 406 | $scope.dragableId = $(this).attr("Id"); |
415 | 407 | $scope.a = $scope.dragableId; |
416 | - | |
408 | + | |
417 | 409 | console.log($scope.dragableId); |
418 | 410 | $scope.dragableText = $("#" + $scope.dragableId).text(); |
419 | - // alert($("#" + $scope.dragableId).text()); | |
411 | + // alert($("#" + $scope.dragableId).text()); | |
420 | 412 | |
421 | 413 | //if user drag already selected answer from one blankbox to another than it gets id of blank box so need to get answer |
422 | 414 | if ($scope.dragableId.indexOf('T') != -1) { |
... | ... | @@ -430,7 +422,7 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, |
430 | 422 | .where('OptionTitle == ' + optionText) |
431 | 423 | .select(); |
432 | 424 | var option = optionData[0].OptionNumber; |
433 | - // $scope.dragableId = optionText + '-' + option; | |
425 | + // $scope.dragableId = optionText + '-' + option; | |
434 | 426 | } |
435 | 427 | |
436 | 428 | //if user drag already selected answer from one blankbox to another than it gets id of blank box so need to get answer |
... | ... | @@ -455,16 +447,16 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, |
455 | 447 | }; |
456 | 448 | |
457 | 449 | $scope.handleDrop = function (e) { |
458 | - | |
450 | + | |
459 | 451 | e.preventDefault(); |
460 | 452 | e.stopPropagation(); |
461 | 453 | var x = $("#droppable").offset(); |
462 | 454 | |
463 | 455 | var id = $(this).attr("id"); |
464 | - | |
456 | + | |
465 | 457 | |
466 | 458 | var keywords = $location.search(); |
467 | - | |
459 | + | |
468 | 460 | if ($.browser.msie) { |
469 | 461 | dataText = localStorage.getItem("text"); |
470 | 462 | localStorage.setItem("text", ''); |
... | ... | @@ -472,9 +464,9 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, |
472 | 464 | else { |
473 | 465 | var dataText = e.dataTransfer.getData('text/plain'); |
474 | 466 | } |
475 | - | |
467 | + | |
476 | 468 | if (id == "divoptions" || id == "divleft" || id == "divright") { |
477 | - | |
469 | + | |
478 | 470 | $scope.item = $('#' + $scope.dragableId).html(); |
479 | 471 | var rindex = $scope.DraggedList.indexOf($scope.item); |
480 | 472 | console.log($scope.DraggedList); |
... | ... | @@ -492,11 +484,11 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, |
492 | 484 | $.each($scope.DraggedList, function (inx1, value3) { |
493 | 485 | $scope.UserAttempt.push({ "BlankBoxName": id.split('-')[1], "OptionName": $scope.dragableId.split('-')[1] }); |
494 | 486 | if ($scope.DraggedList[inx1].id == $scope.a.split('-')[1]) { |
495 | - $scope.b = $scope.DraggedList[inx1].blockID; | |
487 | + $scope.b = $scope.DraggedList[inx1].blockID; | |
496 | 488 | $scope.DraggedList.splice(inx1, 1); |
497 | 489 | $('#' + $scope.b).css({ "display": "block", "color": "#000000!important" }); |
498 | 490 | $('#blockans-' + $scope.b.split('-')[1]).css("background-color", "transparent !important"); |
499 | - // alert('removed from dropbox= '+'blockans-' + $scope.b.split('-')[1]); | |
491 | + // alert('removed from dropbox= '+'blockans-' + $scope.b.split('-')[1]); | |
500 | 492 | } |
501 | 493 | }); |
502 | 494 | } |
... | ... | @@ -516,68 +508,68 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, |
516 | 508 | } |
517 | 509 | else { |
518 | 510 | $(this).each(function (key, value) { |
519 | - | |
520 | - var droppedID = $(this).attr("id").split("-"); | |
521 | - if (droppedID[0] == 'blockbox') { | |
522 | - var labExerciseModulePath = '~/../content/data/json/le/' + keywords.labexercise + '.json'; | |
523 | - DataService.getAnotherJson(labExerciseModulePath).then( | |
524 | - function (result) { | |
525 | - $.each(result.LabExercise, function (index, value) { | |
526 | - if (result.LabExercise[index].Slug == keywords.labexercise) { | |
527 | - $.each(result.LabExercise[index].Questions, function (index1, value1) { | |
528 | - if (result.LabExercise[index].Questions[index1].Number == $scope.quiznumber) { | |
529 | - var Options = result.LabExercise[index].Questions[index1].OptionBox; | |
530 | - $.each(Options, function (inx, value2) { | |
531 | - if (Options[inx].BoxName == id.split('-')[1]) { | |
532 | - if ($scope.DraggedList != null) { | |
533 | - //$.each($scope.DraggedList, function (inx1, value3) { | |
534 | - // if ($scope.DraggedList[inx1].Value == dataText) { | |
535 | - // $scope.DraggedList.splice(inx1, 1); | |
536 | - // } | |
537 | - //}); | |
538 | - for (var i = 0; i <= $scope.DraggedList.length - 1; i++) { | |
539 | - | |
540 | - if ($scope.DraggedList[i].Value == undefined) { | |
541 | - i = 0; | |
542 | - continue; | |
543 | - } | |
544 | 511 | |
545 | - | |
546 | - //if ($scope.DraggedList[i].Value == dataText) { | |
547 | - if ($scope.DraggedList[i].id == id.split('-')[1]) { | |
548 | - $scope.DraggedList.splice(i, 1); | |
512 | + var droppedID = $(this).attr("id").split("-"); | |
513 | + if (droppedID[0] == 'blockbox') { | |
514 | + var labExerciseModulePath = '~/../content/data/json/le/' + keywords.labexercise + '.json'; | |
515 | + DataService.getAnotherJson(labExerciseModulePath).then( | |
516 | + function (result) { | |
517 | + $.each(result.LabExercise, function (index, value) { | |
518 | + if (result.LabExercise[index].Slug == keywords.labexercise) { | |
519 | + $.each(result.LabExercise[index].Questions, function (index1, value1) { | |
520 | + if (result.LabExercise[index].Questions[index1].Number == $scope.quiznumber) { | |
521 | + var Options = result.LabExercise[index].Questions[index1].OptionBox; | |
522 | + $.each(Options, function (inx, value2) { | |
523 | + if (Options[inx].BoxName == id.split('-')[1]) { | |
524 | + if ($scope.DraggedList != null) { | |
525 | + //$.each($scope.DraggedList, function (inx1, value3) { | |
526 | + // if ($scope.DraggedList[inx1].Value == dataText) { | |
527 | + // $scope.DraggedList.splice(inx1, 1); | |
528 | + // } | |
529 | + //}); | |
530 | + for (var i = 0; i <= $scope.DraggedList.length - 1; i++) { | |
531 | + | |
532 | + if ($scope.DraggedList[i].Value == undefined) { | |
533 | + i = 0; | |
534 | + continue; | |
535 | + } | |
536 | + | |
537 | + | |
538 | + //if ($scope.DraggedList[i].Value == dataText) { | |
539 | + if ($scope.DraggedList[i].id == id.split('-')[1]) { | |
540 | + $scope.DraggedList.splice(i, 1); | |
541 | + } | |
549 | 542 | } |
550 | 543 | } |
544 | + // $scope.UserAttempt.push({ "BlankBoxName": id.split('-')[1], "OptionName": $scope.dragableId.split('-')[1] }); | |
545 | + //$scope.UserAttempt.push({ balnkBox: +$scope.dragableId.split('-')[1] }); | |
546 | + $scope.UserAttempt.push({ "BlankBoxName": id.split('-')[1], "OptionName": $scope.dragableId.split('-')[1] }); | |
547 | + $scope.DraggedList.push({ "blockID": $scope.dragableId, "id": id.split('-')[1], "optionName": id.split('-')[1], "Value": dataText, "topcoord": Options[inx].topcoord, "leftcoord": Options[inx].leftcoord }); | |
548 | + $('#' + $scope.dragableId).css("display", "none"); | |
549 | + $('#blockans-' + Options[inx].OptionNumber).css("background-color", "transparent !important"); | |
550 | + $scope.a = $scope.dragableId; | |
551 | 551 | } |
552 | - // $scope.UserAttempt.push({ "BlankBoxName": id.split('-')[1], "OptionName": $scope.dragableId.split('-')[1] }); | |
553 | - //$scope.UserAttempt.push({ balnkBox: +$scope.dragableId.split('-')[1] }); | |
554 | - $scope.UserAttempt.push({ "BlankBoxName": id.split('-')[1], "OptionName": $scope.dragableId.split('-')[1] }); | |
555 | - $scope.DraggedList.push({ "blockID": $scope.dragableId, "id": id.split('-')[1], "optionName": id.split('-')[1], "Value": dataText, "topcoord": Options[inx].topcoord, "leftcoord": Options[inx].leftcoord }); | |
556 | - $('#' + $scope.dragableId).css("display", "none"); | |
557 | - $('#blockans-' + Options[inx].OptionNumber).css("background-color", "transparent !important"); | |
558 | - $scope.a = $scope.dragableId; | |
559 | - } | |
560 | - }); | |
561 | - } | |
562 | - }); | |
563 | - } | |
552 | + }); | |
553 | + } | |
554 | + }); | |
555 | + } | |
564 | 556 | |
565 | - }); | |
566 | - | |
567 | - | |
568 | - }, | |
569 | - function (error) { | |
570 | - console.log(error.statusText) | |
557 | + }); | |
558 | + | |
559 | + | |
560 | + }, | |
561 | + function (error) { | |
562 | + console.log(error.statusText) | |
563 | + } | |
564 | + ) | |
571 | 565 | } |
572 | - ) | |
573 | - } | |
574 | - }); | |
575 | - | |
566 | + }); | |
567 | + | |
576 | 568 | } |
577 | 569 | $scope.$apply(); |
578 | - | |
570 | + | |
579 | 571 | //alert(JSON.stringify($scope.UserAttempt)); |
580 | - | |
572 | + | |
581 | 573 | |
582 | 574 | }; |
583 | 575 | |
... | ... | @@ -587,16 +579,16 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, |
587 | 579 | $("#questionHtml").css("display", "none"); |
588 | 580 | $("#LabExPageHeading").css("display", "none"); |
589 | 581 | $("#LabExMinimizedId").css("display", "block"); |
590 | - | |
582 | + | |
591 | 583 | |
592 | 584 | } |
593 | 585 | $scope.maxLabExPanel = function () { |
594 | 586 | $("#questionHtml").css("display", "block"); |
595 | 587 | $("#LabExPageHeading").css("display", "block"); |
596 | 588 | $("#LabExMinimizedId").css("display", "none"); |
597 | - | |
598 | 589 | |
599 | - } | |
590 | + | |
591 | + } | |
600 | 592 | $scope.handleDragOver = function (e) { |
601 | 593 | e.preventDefault(); // Necessary. Allows us to drop. |
602 | 594 | e.dataTransfer.dropEffect = 'move'; // See the section on the DataTransfer object. |
... | ... | @@ -610,7 +602,7 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, |
610 | 602 | } |
611 | 603 | |
612 | 604 | $scope.resetQuiz = function () { |
613 | - | |
605 | + | |
614 | 606 | $scope.DraggedList = []; |
615 | 607 | $scope.UserAttempt = []; |
616 | 608 | $scope.GetQuizByTopic(); |
... | ... | @@ -679,8 +671,8 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, |
679 | 671 | $('#spinner').css('visibility', 'hidden'); |
680 | 672 | |
681 | 673 | $scope.CreateLabExerciseDataToSave(); |
682 | - | |
683 | - | |
674 | + | |
675 | + | |
684 | 676 | //LabExerciseService.saveLabExerciseAttempt("superadmin", $scope.LabExerciseAttemptedData) |
685 | 677 | $scope.labExerciseAttempt = []; |
686 | 678 | $scope.labExerciseAttempt.push({ 'LabExerciseUserData': $scope.LabExerciseUserData, 'userId': $scope.userId, 'labExerciseIdentifier': $scope.labExerciseIdentifier, 'LastQuestion': $scope.LastQuestion, 'TotalQuestions': $scope.TotalQuestions }); |
... | ... | @@ -711,7 +703,7 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, |
711 | 703 | |
712 | 704 | $scope.usersCorrectQuestData = []; |
713 | 705 | $scope.CreateLabExerciseDataToSave = function () { |
714 | - | |
706 | + | |
715 | 707 | $scope.LabExerciseAttemptedData = []; |
716 | 708 | $scope.lb = []; |
717 | 709 | //get user answers |
... | ... | @@ -745,14 +737,14 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, |
745 | 737 | title: $scope.activityTitle, |
746 | 738 | DragList: $scope.DraggedList |
747 | 739 | } |
748 | - | |
740 | + | |
749 | 741 | |
750 | 742 | |
751 | 743 | var thisQuestiondataInLabExerciseUserData = new jinqJs() |
752 | 744 | .from($scope.LabExerciseUserData) |
753 | 745 | .where('QuestionNo == ' + $scope.LabExerciseAttemptedData.QuestionNo) |
754 | 746 | .select(); |
755 | - if (thisQuestiondataInLabExerciseUserData.length>0) { | |
747 | + if (thisQuestiondataInLabExerciseUserData.length > 0) { | |
756 | 748 | |
757 | 749 | angular.forEach($scope.LabExerciseUserData, function (value, key) { |
758 | 750 | if (value.QuestionNo == $scope.LabExerciseAttemptedData.QuestionNo) { |
... | ... | @@ -765,20 +757,19 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, |
765 | 757 | $scope.LabExerciseUserData = []; |
766 | 758 | |
767 | 759 | $scope.lb.push($scope.LabExerciseAttemptedData); |
768 | - angular.forEach($scope.lb,function(value1,key1){ | |
769 | - $scope.LabExerciseUserData.push(value1); | |
760 | + angular.forEach($scope.lb, function (value1, key1) { | |
761 | + $scope.LabExerciseUserData.push(value1); | |
770 | 762 | }) |
771 | 763 | } |
772 | - else | |
764 | + else | |
773 | 765 | $scope.LabExerciseUserData.push($scope.LabExerciseAttemptedData); |
774 | - | |
766 | + | |
775 | 767 | $scope.usersCorrectQuestData = []; |
776 | - //alert($scope.LabExerciseUserData); | |
768 | + //alert($scope.LabExerciseUserData); | |
777 | 769 | if ($scope.LabExerciseUserData.length > 0) { |
778 | 770 | |
779 | - for(var i=0;i<=$scope.LabExerciseUserData.length-1;i++) | |
780 | - { | |
781 | - | |
771 | + for (var i = 0; i <= $scope.LabExerciseUserData.length - 1; i++) { | |
772 | + | |
782 | 773 | if ($scope.LabExerciseUserData[i].MaxScore == $scope.LabExerciseUserData[i].Score) { |
783 | 774 | $scope.usersCorrectQuestData.push({ |
784 | 775 | MaxScore: $scope.LabExerciseUserData[i].MaxScore, |
... | ... | @@ -833,8 +824,8 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, |
833 | 824 | } |
834 | 825 | } |
835 | 826 | |
836 | - // console.log($scope.usersCorrectQuestData); | |
837 | - // console.log($scope.LabExerciseUserData); | |
827 | + // console.log($scope.usersCorrectQuestData); | |
828 | + // console.log($scope.LabExerciseUserData); | |
838 | 829 | } |
839 | 830 | $scope.reviewAttemptAnswer = function (evt) { |
840 | 831 | $scope.isReviewBtnSelected = true; |
... | ... | @@ -846,10 +837,10 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, |
846 | 837 | $("#reportBtn").css("display", "block"); |
847 | 838 | $("#quizSubmitBtn").css("display", "none"); |
848 | 839 | $scope.quiznumber = evt.target.id; |
849 | - // $scope.CreateLabExerciseDataToSave(); | |
840 | + // $scope.CreateLabExerciseDataToSave(); | |
850 | 841 | $scope.dragableId = ""; |
851 | - $scope.resetQuiz(); | |
852 | - // $scope.GetQuizByTopic(); | |
842 | + $scope.resetQuiz(); | |
843 | + // $scope.GetQuizByTopic(); | |
853 | 844 | //$scope.ShowHideDiv(); |
854 | 845 | } |
855 | 846 | |
... | ... | @@ -867,7 +858,7 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, |
867 | 858 | userAnswers[id.replace('T', '')] = blockAnswers[i].innerHTML; |
868 | 859 | } |
869 | 860 | |
870 | - $scope.commaSeperatedUserAnswers = ''; | |
861 | + $scope.commaSeperatedUserAnswers = ''; | |
871 | 862 | for (var i = 1; i <= blockBoxLength; i++) { |
872 | 863 | |
873 | 864 | var userAns = userAnswers[i]; |
... | ... | @@ -898,7 +889,7 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, |
898 | 889 | option = multipleanswer[0]; |
899 | 890 | } |
900 | 891 | else |
901 | - option = cr[0].correctResponse[i].Answer; | |
892 | + option = cr[0].correctResponse[i].Answer; | |
902 | 893 | |
903 | 894 | var options = new jinqJs() |
904 | 895 | .from(cr[0].Options) |
... | ... | @@ -933,7 +924,7 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, |
933 | 924 | angular.forEach($scope.UserAttempt, function (value, key) { |
934 | 925 | |
935 | 926 | var userOptedAnswer = value.BlankBoxName + ' ' + value.OptionName; |
936 | - for(var i=0;i<$scope.correctResonseKeyValue.length;i++) { | |
927 | + for (var i = 0; i < $scope.correctResonseKeyValue.length; i++) { | |
937 | 928 | if (userOptedAnswer == $scope.correctResonseKeyValue[i]) { |
938 | 929 | $scope.Score += 1; |
939 | 930 | } |
... | ... | @@ -950,7 +941,7 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, |
950 | 941 | userId: 1, |
951 | 942 | identifier: 'di' |
952 | 943 | }; |
953 | - | |
944 | + | |
954 | 945 | LabExerciseService.GetLabExercise(labExerciseInfo) |
955 | 946 | .then( |
956 | 947 | |
... | ... | @@ -961,7 +952,7 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, |
961 | 952 | $scope.ShowSavedLabExercise(); |
962 | 953 | } |
963 | 954 | }, |
964 | - function(error){ | |
955 | + function (error) { | |
965 | 956 | console.log(' Error in getting LabExercise = ' + error.statusText); |
966 | 957 | $rootScope.errorMessage = AdminConstants.ERROR_IN_FECTHING_DETAILS; |
967 | 958 | $("#messageModal").modal('show'); |
... | ... | @@ -972,10 +963,10 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, |
972 | 963 | $scope.ShowSavedLabExercise = function () { |
973 | 964 | |
974 | 965 | //from database |
975 | - var lastQuestion = $scope.quiznumber; | |
976 | - var lastQuestionDetails; | |
977 | - var lastQuestionAnswers; | |
978 | - var blockIds = []; | |
966 | + var lastQuestion = $scope.quiznumber; | |
967 | + var lastQuestionDetails; | |
968 | + var lastQuestionAnswers; | |
969 | + var blockIds = []; | |
979 | 970 | |
980 | 971 | //if user opted this question, it will have entry in LabExerciseUserData |
981 | 972 | var thisQuestiondataInLabExerciseUserData = new jinqJs() |
... | ... | @@ -983,91 +974,92 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, |
983 | 974 | .where('QuestionNo == ' + $scope.quiznumber) |
984 | 975 | .select(); |
985 | 976 | |
986 | - | |
977 | + | |
987 | 978 | //if this exists in LabExerciseUserData, show the new opted else show from database |
988 | 979 | var isFromDB = false; |
989 | - if (thisQuestiondataInLabExerciseUserData.length > 0){ | |
990 | - | |
991 | - | |
992 | - lastQuestionDetails = thisQuestiondataInLabExerciseUserData; | |
993 | - if (lastQuestionDetails != undefined && lastQuestionDetails.length > 0) | |
994 | - lastQuestionAnswers = lastQuestionDetails[0].UserAnswer.split(','); | |
995 | - } | |
996 | - | |
997 | - else{ | |
998 | - isFromDB = true; | |
999 | - lastQuestionDetails = new jinqJs() | |
1000 | - .from($scope.SavedLabExercise.labExercise) | |
1001 | - .where('QuestionNo == ' + lastQuestion) | |
980 | + if (thisQuestiondataInLabExerciseUserData.length > 0) { | |
981 | + | |
982 | + | |
983 | + lastQuestionDetails = thisQuestiondataInLabExerciseUserData; | |
984 | + if (lastQuestionDetails != undefined && lastQuestionDetails.length > 0) | |
985 | + lastQuestionAnswers = lastQuestionDetails[0].UserAnswer.split(','); | |
986 | + } | |
987 | + | |
988 | + else { | |
989 | + isFromDB = true; | |
990 | + lastQuestionDetails = new jinqJs() | |
991 | + .from($scope.SavedLabExercise.labExercise) | |
992 | + .where('QuestionNo == ' + lastQuestion) | |
993 | + .select(); | |
994 | + if (lastQuestionDetails != undefined && lastQuestionDetails.length > 0) | |
995 | + lastQuestionAnswers = lastQuestionDetails[0].UserAnswers.split(','); | |
996 | + } | |
997 | + if (lastQuestionDetails != undefined && lastQuestionDetails.length > 0) { | |
998 | + $scope.QustionAnsKeyValue = []; | |
999 | + for (var i = 0; i < lastQuestionAnswers.length; i++) { | |
1000 | + var num = i + 1; | |
1001 | + $scope.QustionAnsKeyValue.push({ blockbox: 'T' + num, text: lastQuestionAnswers[i] }); | |
1002 | + | |
1003 | + if (isFromDB) { | |
1004 | + | |
1005 | + if (lastQuestionAnswers[i] != "") { | |
1006 | + var blocks = $("div[id*='block-']"); | |
1007 | + for (var j = 0; j < blocks.length; j++) { | |
1008 | + | |
1009 | + if ((blocks[j].innerHTML).toString() == lastQuestionAnswers[i]) { | |
1010 | + $('#' + blocks[j].id).css("display", "none"); | |
1011 | + break; | |
1012 | + }; | |
1013 | + | |
1014 | + } | |
1015 | + | |
1016 | + } | |
1017 | + } | |
1018 | + | |
1019 | + else { | |
1020 | + var dragList = lastQuestionDetails[0].DragList; | |
1021 | + angular.forEach(dragList, function (v, k) { | |
1022 | + $('#' + v.blockID).css("display", "none"); | |
1023 | + }) | |
1024 | + } | |
1025 | + | |
1026 | + } | |
1027 | + var labQuestionData = new jinqJs() | |
1028 | + .from($scope.LabExData.LabExercise[0].Questions) | |
1029 | + .where('Number == ' + lastQuestion) | |
1030 | + .select(); | |
1031 | + | |
1032 | + angular.forEach($scope.QustionAnsKeyValue, function (value, key) { | |
1033 | + var questionOptionBox = new jinqJs() | |
1034 | + .from(labQuestionData[0].OptionBox) | |
1035 | + .where('BoxName == ' + value.blockbox) | |
1036 | + .select(); | |
1037 | + if (value.text != "") { | |
1038 | + | |
1039 | + var OptionList = new jinqJs() | |
1040 | + .from(labQuestionData[0].Options) | |
1041 | + .where('OptionTitle == ' + value.text) | |
1002 | 1042 | .select(); |
1003 | - if (lastQuestionDetails != undefined && lastQuestionDetails.length>0) | |
1004 | - lastQuestionAnswers = lastQuestionDetails[0].UserAnswers.split(','); | |
1005 | - } | |
1006 | - if (lastQuestionDetails != undefined && lastQuestionDetails.length > 0) { | |
1007 | - $scope.QustionAnsKeyValue = []; | |
1008 | - for (var i = 0; i < lastQuestionAnswers.length; i++) { | |
1009 | - var num = i + 1; | |
1010 | - $scope.QustionAnsKeyValue.push({ blockbox: 'T' + num, text: lastQuestionAnswers[i] }); | |
1011 | - | |
1012 | - if (isFromDB) { | |
1013 | - | |
1014 | - if (lastQuestionAnswers[i] != "") { | |
1015 | - var blocks = $("div[id*='block-']"); | |
1016 | - for (var j = 0; j < blocks.length; j++) { | |
1017 | - | |
1018 | - if ((blocks[j].innerHTML).toString() == lastQuestionAnswers[i]) { | |
1019 | - $('#' + blocks[j].id).css("display", "none"); | |
1020 | - }; | |
1021 | - | |
1022 | - } | |
1023 | - | |
1024 | - } | |
1025 | - } | |
1026 | - | |
1027 | - else { | |
1028 | - var dragList = lastQuestionDetails[0].DragList; | |
1029 | - angular.forEach(dragList, function (v, k) { | |
1030 | - $('#' + v.blockID).css("display", "none"); | |
1031 | - }) | |
1032 | - } | |
1033 | - | |
1034 | - } | |
1035 | - var labQuestionData = new jinqJs() | |
1036 | - .from($scope.LabExData.LabExercise[0].Questions) | |
1037 | - .where('Number == ' + lastQuestion) | |
1038 | - .select(); | |
1039 | - | |
1040 | - angular.forEach($scope.QustionAnsKeyValue, function (value, key) { | |
1041 | - var questionOptionBox = new jinqJs() | |
1042 | - .from(labQuestionData[0].OptionBox) | |
1043 | - .where('BoxName == ' + value.blockbox) | |
1044 | - .select(); | |
1045 | - if (value.text != "") { | |
1046 | - | |
1047 | - var OptionList = new jinqJs() | |
1048 | - .from(labQuestionData[0].Options) | |
1049 | - .where('OptionTitle == ' + value.text) | |
1050 | - .select(); | |
1051 | - | |
1052 | - | |
1053 | - var blockId = 'block-' + OptionList[0].OptionNumber; | |
1054 | - if (OptionList != undefined && OptionList.length > 1 && blockIds.indexOf(blockId) != -1) { | |
1055 | - blockId = 'block-' + OptionList[1].OptionNumber; | |
1056 | - } | |
1057 | - blockIds.push(blockId); | |
1058 | - $scope.DraggedList.push({ "blockID": blockId, "id": value.blockbox, "optionName": value.blockbox, "Value": value.text, "topcoord": questionOptionBox[0].topcoord, "leftcoord": questionOptionBox[0].leftcoord }); | |
1059 | - | |
1060 | - | |
1061 | - // $scope.DraggedList.push({ "id": value.blockbox, "optionName": value.blockbox, "Value": value.text, "topcoord": questionOptionBox[0].topcoord, "leftcoord": questionOptionBox[0].leftcoord }); | |
1062 | - | |
1063 | - $rootScope.isLoading = false; | |
1064 | - $('#spinner').css('visibility', 'hidden'); | |
1065 | - } | |
1066 | - | |
1067 | - }) | |
1068 | - } | |
1069 | - $rootScope.isLoading = false; | |
1070 | - $('#spinner').css('visibility', 'hidden'); | |
1043 | + | |
1044 | + | |
1045 | + var blockId = 'block-' + OptionList[0].OptionNumber; | |
1046 | + if (OptionList != undefined && OptionList.length > 1 && blockIds.indexOf(blockId) != -1) { | |
1047 | + blockId = 'block-' + OptionList[1].OptionNumber; | |
1048 | + } | |
1049 | + blockIds.push(blockId); | |
1050 | + $scope.DraggedList.push({ "blockID": blockId, "id": value.blockbox, "optionName": value.blockbox, "Value": value.text, "topcoord": questionOptionBox[0].topcoord, "leftcoord": questionOptionBox[0].leftcoord }); | |
1051 | + | |
1052 | + | |
1053 | + // $scope.DraggedList.push({ "id": value.blockbox, "optionName": value.blockbox, "Value": value.text, "topcoord": questionOptionBox[0].topcoord, "leftcoord": questionOptionBox[0].leftcoord }); | |
1054 | + | |
1055 | + $rootScope.isLoading = false; | |
1056 | + $('#spinner').css('visibility', 'hidden'); | |
1057 | + } | |
1058 | + | |
1059 | + }) | |
1060 | + } | |
1061 | + $rootScope.isLoading = false; | |
1062 | + $('#spinner').css('visibility', 'hidden'); | |
1071 | 1063 | |
1072 | 1064 | if (lastQuestion == $scope.TotalNumberofQuiz) { |
1073 | 1065 | if ($scope.isReviewBtnSelected == true) { |
... | ... | @@ -1084,8 +1076,8 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, |
1084 | 1076 | |
1085 | 1077 | } |
1086 | 1078 | |
1087 | - | |
1088 | - | |
1079 | + | |
1080 | + | |
1089 | 1081 | }] |
1090 | 1082 | |
1091 | 1083 | ); |
... | ... | @@ -1106,7 +1098,7 @@ AIA.directive('droppable', function () { |
1106 | 1098 | element[0].addEventListener('drop', $scope.handleDrop, false); |
1107 | 1099 | element[0].addEventListener('dragover', $scope.handleDragOver, false); |
1108 | 1100 | |
1109 | - | |
1101 | + | |
1110 | 1102 | } |
1111 | 1103 | } |
1112 | 1104 | }); | ... | ... |