From 9b618102965509a8f8b24b4f2b51838bc007183e Mon Sep 17 00:00:00 2001 From: nikita Date: Thu, 15 Mar 2018 11:42:55 +0530 Subject: [PATCH] issue was in duplicate text options in save --- 400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js | 514 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 1 file changed, 253 insertions(+), 261 deletions(-) diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js index e77ec03..c88276f 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js @@ -1,6 +1,6 @@ /// -AIA.controller("LabExercController", ["$scope", "$rootScope", "pages", "$log", '$http','$timeout', 'DataService', '$filter', '$location', '$document', '$sce', "$compile", "$location", "LabExerciseService","AIAConstants", -function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, $location, $document, $sce, $compile, $location, LabExerciseService,AIAConstants) { +AIA.controller("LabExercController", ["$scope", "$rootScope", "pages", "$log", '$http', '$timeout', 'DataService', '$filter', '$location', '$document', '$sce', "$compile", "$location", "LabExerciseService", "AIAConstants", +function ($scope, $rootScope, pages, log, $http, $timeout, DataService, $filter, $location, $document, $sce, $compile, $location, LabExerciseService, AIAConstants) { $scope.$sce = $sce; $scope.LabExerciseName; $scope.LabExerciseQuiz = null; @@ -106,7 +106,7 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, .then( function (labResult) { - if (labResult != undefined && labResult.lastQuestion>0 && labResult != AIAConstants.SAVED_LAB_EXERCISE_NOT_FOUND) { + if (labResult != undefined && labResult.lastQuestion > 0 && labResult != AIAConstants.SAVED_LAB_EXERCISE_NOT_FOUND) { $scope.SavedLabExercise = labResult; $scope.quiznumber = $scope.SavedLabExercise.lastQuestion; $scope.initialQuestioNo = $scope.SavedLabExercise.lastQuestion; @@ -116,14 +116,14 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, $scope.GetQuizByTopic(); } }, - function(error){ + function (error) { console.log('error in getting save ddata'); } ) } $scope.GetQuizByTopic = function () { - + $rootScope.isLoading = true; $('#spinner').css('visibility', 'visible'); @@ -141,10 +141,10 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, var keywords = $location.search(); $scope.labExercideIdentifier = (keywords.labexercise.replace('.json', '')).split('dat_')[1]; - - + + $.each(result.LabExercise, function (index, value) { - + $scope.LabExerciseName = result.LabExercise[index].Topic; if (result.LabExercise[index].Slug == keywords.labexercise) { @@ -176,17 +176,16 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, $scope.Imagepath = keywords.labexercise + "/" + result.LabExercise[index].Questions[index1].ImagePath; } //$scope.ShowHideDiv(result.LabExercise[index].Questions[index1].Options[0].textalign); - + $scope.ShowHideDiv("bottom"); } }); - $timeout(function () - { + $timeout(function () { if ($scope.SavedLabExercise != undefined && $scope.SavedLabExercise.lastQuestion > 0) { if ($scope.isResetClicked != true) { $scope.ShowSavedLabExercise(); - + } else { $rootScope.isLoading = false; @@ -198,9 +197,9 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, $rootScope.isLoading = false; $('#spinner').css('visibility', 'hidden'); } - },100); - - + }, 100); + + } }); @@ -211,12 +210,12 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, console.log(error.statusText) } ) - + } $scope.isReviewBtnSelected = false; - // $rootScope.selectedDivArray = []; + // $rootScope.selectedDivArray = []; $scope.nextQuiz = function () { //need to save all questions till the current question number when user clicks on save //if ($scope.dragableId!="") { @@ -230,22 +229,21 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, $scope.isNextOrPreviousClicked = true; $scope.dragableId = ""; - - if ($scope.quiznumber != $scope.TotalNumberofQuiz) - { + + if ($scope.quiznumber != $scope.TotalNumberofQuiz) { $scope.CreateLabExerciseDataToSave(); } - + if ($scope.quiznumber == $scope.TotalNumberofQuiz) return; else $scope.quiznumber++; - - // console.log($rootScope.selectedDivArray); - - + + // console.log($rootScope.selectedDivArray); + + if ($scope.quiznumber == $scope.TotalNumberofQuiz) { if ($scope.isReviewBtnSelected == true) { @@ -254,18 +252,17 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, else { $("#quizSubmitBtn").css("display", "block"); } - + } - else - { + else { $("#quizSubmitBtn").css("display", "none"); } $scope.resetQuiz(); $scope.ShowHideDiv(); - - - + + + } @@ -278,50 +275,50 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, $scope.prevQuiz = function () { - + if ($scope.quiznumber != 1) { - // $scope.quizQuesNo = $scope.quizQuesNo - 1; - // $scope.selectedQuestionNo = $scope.quizQuesNo; + // $scope.quizQuesNo = $scope.quizQuesNo - 1; + // $scope.selectedQuestionNo = $scope.quizQuesNo; $scope.CreateLabExerciseDataToSave(); } - $scope.dragableId = ""; - $scope.UserAttempt = []; - if ($scope.quiznumber == 1) - return; - else - $scope.quiznumber--; + $scope.dragableId = ""; + $scope.UserAttempt = []; + if ($scope.quiznumber == 1) + return; + else + $scope.quiznumber--; - if ($scope.quiznumber == $scope.TotalNumberofQuiz) { - if ($scope.isReviewBtnSelected == true) { - $("#quizSubmitBtn").css("display", "none"); - } - else { - $("#quizSubmitBtn").css("display", "block"); - } + if ($scope.quiznumber == $scope.TotalNumberofQuiz) { + if ($scope.isReviewBtnSelected == true) { + $("#quizSubmitBtn").css("display", "none"); } else { - $("#quizSubmitBtn").css("display", "none"); + $("#quizSubmitBtn").css("display", "block"); } - $scope.resetQuiz(); - $scope.ShowHideDiv(); - + } + else { + $("#quizSubmitBtn").css("display", "none"); + } + $scope.resetQuiz(); + $scope.ShowHideDiv(); - //for (var i = 0; i <= $rootScope.selectedDivArray.length - 1; i++) { - // if ($scope.quiznumber == $rootScope.selectedDivArray[i].questionNo) { - // alert($rootScope.selectedDivArray[i].draggedText); - // document.getElementById($rootScope.selectedDivArray[i].droppedID).innerHTML = $rootScope.selectedDivArray[i].draggedText; - // // $('#'+$rootScope.selectedDivArray[i].droppedID).html($rootScope.selectedDivArray[i].draggedText); - // document.getElementById($rootScope.selectedDivArray[i].droppedID).style.display = "none"; - // // $('#'+$rootScope.selectedDivArray[i].draggedID).css("display","none!important"); - // } - //} + //for (var i = 0; i <= $rootScope.selectedDivArray.length - 1; i++) { + // if ($scope.quiznumber == $rootScope.selectedDivArray[i].questionNo) { + // alert($rootScope.selectedDivArray[i].draggedText); + // document.getElementById($rootScope.selectedDivArray[i].droppedID).innerHTML = $rootScope.selectedDivArray[i].draggedText; + // // $('#'+$rootScope.selectedDivArray[i].droppedID).html($rootScope.selectedDivArray[i].draggedText); + // document.getElementById($rootScope.selectedDivArray[i].droppedID).style.display = "none"; + // // $('#'+$rootScope.selectedDivArray[i].draggedID).css("display","none!important"); + // } + + //} } - + $scope.SubmitAttempt = function () { - + $scope.CreateLabExerciseDataToSave(); $("#submitResultHtml").css("display", "block"); @@ -329,11 +326,10 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, console.log($scope.usersCorrectQuestData); $("#resultLabData").empty(); var sortedQuestionHtml = ''; - + for (var j = $scope.TotalNumberofQuiz; j >= 1; j--) { for (var i = 0; i <= $scope.usersCorrectQuestData.length - 1; i++) { - if (j == $scope.usersCorrectQuestData[i].QuestionNo) - { + if (j == $scope.usersCorrectQuestData[i].QuestionNo) { if ($scope.usersCorrectQuestData[i].CorrectStatus == "Correct") { var labExerciseHtml = $("#resultLabData").append("" + $scope.usersCorrectQuestData[i].QuestionNo + "" + $scope.usersCorrectQuestData[i].title + "" + $scope.usersCorrectQuestData[i].CorrectStatus + ""); $compile(labExerciseHtml)($scope); @@ -349,22 +345,20 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, $scope.isValueExist = false; } } - if ($scope.isValueExist == false) - { - var labExerciseHtml_1 = $("#resultLabData").prepend("" + j + " Incorrect"); - $compile(labExerciseHtml_1)($scope); - } + if ($scope.isValueExist == false) { + var labExerciseHtml_1 = $("#resultLabData").prepend("" + j + " Incorrect"); + $compile(labExerciseHtml_1)($scope); + } } - - for (var j = 1;j <= $scope.TotalNumberofQuiz;j++) { + + for (var j = 1; j <= $scope.TotalNumberofQuiz; j++) { $("#resultLabData tr td:nth-child(1)").each(function () { if (j == $(this).text()) { $q = $(this).parent(); if ($q.find("td:nth-child(3)").text() == "Correct") { sortedQuestionHtml += '' + $q.find("td:nth-child(1)").text() + '' + $q.find("td:nth-child(2)").text() + '' + $q.find("td:nth-child(3)").text() + ''; } - else - { + else { sortedQuestionHtml += '' + $q.find("td:nth-child(1)").text() + '' + $q.find("td:nth-child(2)").text() + '' + $q.find("td:nth-child(3)").text() + ''; } } @@ -381,15 +375,14 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, if ($(this).text() == "Incorrect") { $scope.inCorrectAnswer = $scope.inCorrectAnswer + 1; } - else - { + else { $scope.CorrectAnswer = $scope.CorrectAnswer + 1; } }); $scope.scoreResult = (parseInt($scope.CorrectAnswer) / parseInt($scope.inCorrectAnswer)) * 100; $scope.scoreResult = Math.round($scope.scoreResult); - + } @@ -400,23 +393,22 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, $scope.handleDragStart = function (e) { - + this.style.opacity = '0.4'; - + if ($.browser.msie) { localStorage.setItem("text", this.innerHTML); } - else - { + else { e.dataTransfer.setData('text/plain', this.innerHTML); } - + $scope.dragableId = $(this).attr("Id"); $scope.a = $scope.dragableId; - + console.log($scope.dragableId); $scope.dragableText = $("#" + $scope.dragableId).text(); - // alert($("#" + $scope.dragableId).text()); + // alert($("#" + $scope.dragableId).text()); //if user drag already selected answer from one blankbox to another than it gets id of blank box so need to get answer if ($scope.dragableId.indexOf('T') != -1) { @@ -430,7 +422,7 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, .where('OptionTitle == ' + optionText) .select(); var option = optionData[0].OptionNumber; - // $scope.dragableId = optionText + '-' + option; + // $scope.dragableId = optionText + '-' + option; } //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, }; $scope.handleDrop = function (e) { - + e.preventDefault(); e.stopPropagation(); var x = $("#droppable").offset(); var id = $(this).attr("id"); - + var keywords = $location.search(); - + if ($.browser.msie) { dataText = localStorage.getItem("text"); localStorage.setItem("text", ''); @@ -472,9 +464,9 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, else { var dataText = e.dataTransfer.getData('text/plain'); } - + if (id == "divoptions" || id == "divleft" || id == "divright") { - + $scope.item = $('#' + $scope.dragableId).html(); var rindex = $scope.DraggedList.indexOf($scope.item); console.log($scope.DraggedList); @@ -492,11 +484,11 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, $.each($scope.DraggedList, function (inx1, value3) { $scope.UserAttempt.push({ "BlankBoxName": id.split('-')[1], "OptionName": $scope.dragableId.split('-')[1] }); if ($scope.DraggedList[inx1].id == $scope.a.split('-')[1]) { - $scope.b = $scope.DraggedList[inx1].blockID; + $scope.b = $scope.DraggedList[inx1].blockID; $scope.DraggedList.splice(inx1, 1); $('#' + $scope.b).css({ "display": "block", "color": "#000000!important" }); $('#blockans-' + $scope.b.split('-')[1]).css("background-color", "transparent !important"); - // alert('removed from dropbox= '+'blockans-' + $scope.b.split('-')[1]); + // alert('removed from dropbox= '+'blockans-' + $scope.b.split('-')[1]); } }); } @@ -516,68 +508,68 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, } else { $(this).each(function (key, value) { - - var droppedID = $(this).attr("id").split("-"); - if (droppedID[0] == 'blockbox') { - var labExerciseModulePath = '~/../content/data/json/le/' + keywords.labexercise + '.json'; - DataService.getAnotherJson(labExerciseModulePath).then( - function (result) { - $.each(result.LabExercise, function (index, value) { - if (result.LabExercise[index].Slug == keywords.labexercise) { - $.each(result.LabExercise[index].Questions, function (index1, value1) { - if (result.LabExercise[index].Questions[index1].Number == $scope.quiznumber) { - var Options = result.LabExercise[index].Questions[index1].OptionBox; - $.each(Options, function (inx, value2) { - if (Options[inx].BoxName == id.split('-')[1]) { - if ($scope.DraggedList != null) { - //$.each($scope.DraggedList, function (inx1, value3) { - // if ($scope.DraggedList[inx1].Value == dataText) { - // $scope.DraggedList.splice(inx1, 1); - // } - //}); - for (var i = 0; i <= $scope.DraggedList.length - 1; i++) { - - if ($scope.DraggedList[i].Value == undefined) { - i = 0; - continue; - } - - //if ($scope.DraggedList[i].Value == dataText) { - if ($scope.DraggedList[i].id == id.split('-')[1]) { - $scope.DraggedList.splice(i, 1); + var droppedID = $(this).attr("id").split("-"); + if (droppedID[0] == 'blockbox') { + var labExerciseModulePath = '~/../content/data/json/le/' + keywords.labexercise + '.json'; + DataService.getAnotherJson(labExerciseModulePath).then( + function (result) { + $.each(result.LabExercise, function (index, value) { + if (result.LabExercise[index].Slug == keywords.labexercise) { + $.each(result.LabExercise[index].Questions, function (index1, value1) { + if (result.LabExercise[index].Questions[index1].Number == $scope.quiznumber) { + var Options = result.LabExercise[index].Questions[index1].OptionBox; + $.each(Options, function (inx, value2) { + if (Options[inx].BoxName == id.split('-')[1]) { + if ($scope.DraggedList != null) { + //$.each($scope.DraggedList, function (inx1, value3) { + // if ($scope.DraggedList[inx1].Value == dataText) { + // $scope.DraggedList.splice(inx1, 1); + // } + //}); + for (var i = 0; i <= $scope.DraggedList.length - 1; i++) { + + if ($scope.DraggedList[i].Value == undefined) { + i = 0; + continue; + } + + + //if ($scope.DraggedList[i].Value == dataText) { + if ($scope.DraggedList[i].id == id.split('-')[1]) { + $scope.DraggedList.splice(i, 1); + } } } + // $scope.UserAttempt.push({ "BlankBoxName": id.split('-')[1], "OptionName": $scope.dragableId.split('-')[1] }); + //$scope.UserAttempt.push({ balnkBox: +$scope.dragableId.split('-')[1] }); + $scope.UserAttempt.push({ "BlankBoxName": id.split('-')[1], "OptionName": $scope.dragableId.split('-')[1] }); + $scope.DraggedList.push({ "blockID": $scope.dragableId, "id": id.split('-')[1], "optionName": id.split('-')[1], "Value": dataText, "topcoord": Options[inx].topcoord, "leftcoord": Options[inx].leftcoord }); + $('#' + $scope.dragableId).css("display", "none"); + $('#blockans-' + Options[inx].OptionNumber).css("background-color", "transparent !important"); + $scope.a = $scope.dragableId; } - // $scope.UserAttempt.push({ "BlankBoxName": id.split('-')[1], "OptionName": $scope.dragableId.split('-')[1] }); - //$scope.UserAttempt.push({ balnkBox: +$scope.dragableId.split('-')[1] }); - $scope.UserAttempt.push({ "BlankBoxName": id.split('-')[1], "OptionName": $scope.dragableId.split('-')[1] }); - $scope.DraggedList.push({ "blockID": $scope.dragableId, "id": id.split('-')[1], "optionName": id.split('-')[1], "Value": dataText, "topcoord": Options[inx].topcoord, "leftcoord": Options[inx].leftcoord }); - $('#' + $scope.dragableId).css("display", "none"); - $('#blockans-' + Options[inx].OptionNumber).css("background-color", "transparent !important"); - $scope.a = $scope.dragableId; - } - }); - } - }); - } + }); + } + }); + } - }); - - - }, - function (error) { - console.log(error.statusText) + }); + + + }, + function (error) { + console.log(error.statusText) + } + ) } - ) - } - }); - + }); + } $scope.$apply(); - + //alert(JSON.stringify($scope.UserAttempt)); - + }; @@ -587,16 +579,16 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, $("#questionHtml").css("display", "none"); $("#LabExPageHeading").css("display", "none"); $("#LabExMinimizedId").css("display", "block"); - + } $scope.maxLabExPanel = function () { $("#questionHtml").css("display", "block"); $("#LabExPageHeading").css("display", "block"); $("#LabExMinimizedId").css("display", "none"); - - } + + } $scope.handleDragOver = function (e) { e.preventDefault(); // Necessary. Allows us to drop. e.dataTransfer.dropEffect = 'move'; // See the section on the DataTransfer object. @@ -610,7 +602,7 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, } $scope.resetQuiz = function () { - + $scope.DraggedList = []; $scope.UserAttempt = []; $scope.GetQuizByTopic(); @@ -679,8 +671,8 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, $('#spinner').css('visibility', 'hidden'); $scope.CreateLabExerciseDataToSave(); - - + + //LabExerciseService.saveLabExerciseAttempt("superadmin", $scope.LabExerciseAttemptedData) $scope.labExerciseAttempt = []; $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, $scope.usersCorrectQuestData = []; $scope.CreateLabExerciseDataToSave = function () { - + $scope.LabExerciseAttemptedData = []; $scope.lb = []; //get user answers @@ -745,14 +737,14 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, title: $scope.activityTitle, DragList: $scope.DraggedList } - + var thisQuestiondataInLabExerciseUserData = new jinqJs() .from($scope.LabExerciseUserData) .where('QuestionNo == ' + $scope.LabExerciseAttemptedData.QuestionNo) .select(); - if (thisQuestiondataInLabExerciseUserData.length>0) { + if (thisQuestiondataInLabExerciseUserData.length > 0) { angular.forEach($scope.LabExerciseUserData, function (value, key) { if (value.QuestionNo == $scope.LabExerciseAttemptedData.QuestionNo) { @@ -765,20 +757,19 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, $scope.LabExerciseUserData = []; $scope.lb.push($scope.LabExerciseAttemptedData); - angular.forEach($scope.lb,function(value1,key1){ - $scope.LabExerciseUserData.push(value1); + angular.forEach($scope.lb, function (value1, key1) { + $scope.LabExerciseUserData.push(value1); }) } - else + else $scope.LabExerciseUserData.push($scope.LabExerciseAttemptedData); - + $scope.usersCorrectQuestData = []; - //alert($scope.LabExerciseUserData); + //alert($scope.LabExerciseUserData); if ($scope.LabExerciseUserData.length > 0) { - for(var i=0;i<=$scope.LabExerciseUserData.length-1;i++) - { - + for (var i = 0; i <= $scope.LabExerciseUserData.length - 1; i++) { + if ($scope.LabExerciseUserData[i].MaxScore == $scope.LabExerciseUserData[i].Score) { $scope.usersCorrectQuestData.push({ MaxScore: $scope.LabExerciseUserData[i].MaxScore, @@ -833,8 +824,8 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, } } - // console.log($scope.usersCorrectQuestData); - // console.log($scope.LabExerciseUserData); + // console.log($scope.usersCorrectQuestData); + // console.log($scope.LabExerciseUserData); } $scope.reviewAttemptAnswer = function (evt) { $scope.isReviewBtnSelected = true; @@ -846,10 +837,10 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, $("#reportBtn").css("display", "block"); $("#quizSubmitBtn").css("display", "none"); $scope.quiznumber = evt.target.id; - // $scope.CreateLabExerciseDataToSave(); + // $scope.CreateLabExerciseDataToSave(); $scope.dragableId = ""; - $scope.resetQuiz(); - // $scope.GetQuizByTopic(); + $scope.resetQuiz(); + // $scope.GetQuizByTopic(); //$scope.ShowHideDiv(); } @@ -867,7 +858,7 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, userAnswers[id.replace('T', '')] = blockAnswers[i].innerHTML; } - $scope.commaSeperatedUserAnswers = ''; + $scope.commaSeperatedUserAnswers = ''; for (var i = 1; i <= blockBoxLength; i++) { var userAns = userAnswers[i]; @@ -898,7 +889,7 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, option = multipleanswer[0]; } else - option = cr[0].correctResponse[i].Answer; + option = cr[0].correctResponse[i].Answer; var options = new jinqJs() .from(cr[0].Options) @@ -933,7 +924,7 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, angular.forEach($scope.UserAttempt, function (value, key) { var userOptedAnswer = value.BlankBoxName + ' ' + value.OptionName; - for(var i=0;i<$scope.correctResonseKeyValue.length;i++) { + for (var i = 0; i < $scope.correctResonseKeyValue.length; i++) { if (userOptedAnswer == $scope.correctResonseKeyValue[i]) { $scope.Score += 1; } @@ -950,7 +941,7 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, userId: 1, identifier: 'di' }; - + LabExerciseService.GetLabExercise(labExerciseInfo) .then( @@ -961,7 +952,7 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, $scope.ShowSavedLabExercise(); } }, - function(error){ + function (error) { console.log(' Error in getting LabExercise = ' + error.statusText); $rootScope.errorMessage = AdminConstants.ERROR_IN_FECTHING_DETAILS; $("#messageModal").modal('show'); @@ -972,10 +963,10 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, $scope.ShowSavedLabExercise = function () { //from database - var lastQuestion = $scope.quiznumber; - var lastQuestionDetails; - var lastQuestionAnswers; - var blockIds = []; + var lastQuestion = $scope.quiznumber; + var lastQuestionDetails; + var lastQuestionAnswers; + var blockIds = []; //if user opted this question, it will have entry in LabExerciseUserData var thisQuestiondataInLabExerciseUserData = new jinqJs() @@ -983,91 +974,92 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, .where('QuestionNo == ' + $scope.quiznumber) .select(); - + //if this exists in LabExerciseUserData, show the new opted else show from database var isFromDB = false; - if (thisQuestiondataInLabExerciseUserData.length > 0){ - - - lastQuestionDetails = thisQuestiondataInLabExerciseUserData; - if (lastQuestionDetails != undefined && lastQuestionDetails.length > 0) - lastQuestionAnswers = lastQuestionDetails[0].UserAnswer.split(','); - } - - else{ - isFromDB = true; - lastQuestionDetails = new jinqJs() - .from($scope.SavedLabExercise.labExercise) - .where('QuestionNo == ' + lastQuestion) + if (thisQuestiondataInLabExerciseUserData.length > 0) { + + + lastQuestionDetails = thisQuestiondataInLabExerciseUserData; + if (lastQuestionDetails != undefined && lastQuestionDetails.length > 0) + lastQuestionAnswers = lastQuestionDetails[0].UserAnswer.split(','); + } + + else { + isFromDB = true; + lastQuestionDetails = new jinqJs() + .from($scope.SavedLabExercise.labExercise) + .where('QuestionNo == ' + lastQuestion) + .select(); + if (lastQuestionDetails != undefined && lastQuestionDetails.length > 0) + lastQuestionAnswers = lastQuestionDetails[0].UserAnswers.split(','); + } + if (lastQuestionDetails != undefined && lastQuestionDetails.length > 0) { + $scope.QustionAnsKeyValue = []; + for (var i = 0; i < lastQuestionAnswers.length; i++) { + var num = i + 1; + $scope.QustionAnsKeyValue.push({ blockbox: 'T' + num, text: lastQuestionAnswers[i] }); + + if (isFromDB) { + + if (lastQuestionAnswers[i] != "") { + var blocks = $("div[id*='block-']"); + for (var j = 0; j < blocks.length; j++) { + + if ((blocks[j].innerHTML).toString() == lastQuestionAnswers[i]) { + $('#' + blocks[j].id).css("display", "none"); + break; + }; + + } + + } + } + + else { + var dragList = lastQuestionDetails[0].DragList; + angular.forEach(dragList, function (v, k) { + $('#' + v.blockID).css("display", "none"); + }) + } + + } + var labQuestionData = new jinqJs() + .from($scope.LabExData.LabExercise[0].Questions) + .where('Number == ' + lastQuestion) + .select(); + + angular.forEach($scope.QustionAnsKeyValue, function (value, key) { + var questionOptionBox = new jinqJs() + .from(labQuestionData[0].OptionBox) + .where('BoxName == ' + value.blockbox) + .select(); + if (value.text != "") { + + var OptionList = new jinqJs() + .from(labQuestionData[0].Options) + .where('OptionTitle == ' + value.text) .select(); - if (lastQuestionDetails != undefined && lastQuestionDetails.length>0) - lastQuestionAnswers = lastQuestionDetails[0].UserAnswers.split(','); - } - if (lastQuestionDetails != undefined && lastQuestionDetails.length > 0) { - $scope.QustionAnsKeyValue = []; - for (var i = 0; i < lastQuestionAnswers.length; i++) { - var num = i + 1; - $scope.QustionAnsKeyValue.push({ blockbox: 'T' + num, text: lastQuestionAnswers[i] }); - - if (isFromDB) { - - if (lastQuestionAnswers[i] != "") { - var blocks = $("div[id*='block-']"); - for (var j = 0; j < blocks.length; j++) { - - if ((blocks[j].innerHTML).toString() == lastQuestionAnswers[i]) { - $('#' + blocks[j].id).css("display", "none"); - }; - - } - - } - } - - else { - var dragList = lastQuestionDetails[0].DragList; - angular.forEach(dragList, function (v, k) { - $('#' + v.blockID).css("display", "none"); - }) - } - - } - var labQuestionData = new jinqJs() - .from($scope.LabExData.LabExercise[0].Questions) - .where('Number == ' + lastQuestion) - .select(); - - angular.forEach($scope.QustionAnsKeyValue, function (value, key) { - var questionOptionBox = new jinqJs() - .from(labQuestionData[0].OptionBox) - .where('BoxName == ' + value.blockbox) - .select(); - if (value.text != "") { - - var OptionList = new jinqJs() - .from(labQuestionData[0].Options) - .where('OptionTitle == ' + value.text) - .select(); - - - var blockId = 'block-' + OptionList[0].OptionNumber; - if (OptionList != undefined && OptionList.length > 1 && blockIds.indexOf(blockId) != -1) { - blockId = 'block-' + OptionList[1].OptionNumber; - } - blockIds.push(blockId); - $scope.DraggedList.push({ "blockID": blockId, "id": value.blockbox, "optionName": value.blockbox, "Value": value.text, "topcoord": questionOptionBox[0].topcoord, "leftcoord": questionOptionBox[0].leftcoord }); - - - // $scope.DraggedList.push({ "id": value.blockbox, "optionName": value.blockbox, "Value": value.text, "topcoord": questionOptionBox[0].topcoord, "leftcoord": questionOptionBox[0].leftcoord }); - - $rootScope.isLoading = false; - $('#spinner').css('visibility', 'hidden'); - } - - }) - } - $rootScope.isLoading = false; - $('#spinner').css('visibility', 'hidden'); + + + var blockId = 'block-' + OptionList[0].OptionNumber; + if (OptionList != undefined && OptionList.length > 1 && blockIds.indexOf(blockId) != -1) { + blockId = 'block-' + OptionList[1].OptionNumber; + } + blockIds.push(blockId); + $scope.DraggedList.push({ "blockID": blockId, "id": value.blockbox, "optionName": value.blockbox, "Value": value.text, "topcoord": questionOptionBox[0].topcoord, "leftcoord": questionOptionBox[0].leftcoord }); + + + // $scope.DraggedList.push({ "id": value.blockbox, "optionName": value.blockbox, "Value": value.text, "topcoord": questionOptionBox[0].topcoord, "leftcoord": questionOptionBox[0].leftcoord }); + + $rootScope.isLoading = false; + $('#spinner').css('visibility', 'hidden'); + } + + }) + } + $rootScope.isLoading = false; + $('#spinner').css('visibility', 'hidden'); if (lastQuestion == $scope.TotalNumberofQuiz) { if ($scope.isReviewBtnSelected == true) { @@ -1084,8 +1076,8 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, } - - + + }] ); @@ -1106,7 +1098,7 @@ AIA.directive('droppable', function () { element[0].addEventListener('drop', $scope.handleDrop, false); element[0].addEventListener('dragover', $scope.handleDragOver, false); - + } } }); -- libgit2 0.21.4