diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js index 832db53..586558f 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js @@ -1202,7 +1202,7 @@ function ($scope, $rootScope, pages, log, $http, $timeout, DataService, $filter, } //if this exists in LabExerciseUserData, show the new opted else show from database var isFromDB = false; - if (thisQuestiondataInLabExerciseUserData.length > 0) { + if (thisQuestiondataInLabExerciseUserData!=undefined && thisQuestiondataInLabExerciseUserData.length > 0) { lastQuestionDetails = thisQuestiondataInLabExerciseUserData; @@ -1270,56 +1270,57 @@ function ($scope, $rootScope, pages, log, $http, $timeout, DataService, $filter, .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); - console.log($scope.draggedIDArray); - $scope.DraggedList.push({ "DraggedAttr": blockId, "blockID": blockId, "id": value.blockbox, "optionName": value.blockbox, "Value": value.text, "topcoord": questionOptionBox[0].topcoord, "leftcoord": questionOptionBox[0].leftcoord }); + if ($scope.QustionAnsKeyValue != undefined) { + 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); + console.log($scope.draggedIDArray); + $scope.DraggedList.push({ "DraggedAttr": blockId, "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 }); + // $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'); - $timeout(function () { - if ($("#textblock").css("display") == "block") { - $("#imgdiv").css("position", "static"); - $("#imgdiv").find("div").each(function () { - var answerDiv = $(this).attr("id").split("-"); - if (answerDiv[0] == "blockans") { - var concatID = answerDiv[0] + "-" + answerDiv[1]; - $("#" + concatID).css("width", "auto"); + $timeout(function () { + if ($("#textblock").css("display") == "block") { + $("#imgdiv").css("position", "static"); + $("#imgdiv").find("div").each(function () { + var answerDiv = $(this).attr("id").split("-"); + if (answerDiv[0] == "blockans") { + var concatID = answerDiv[0] + "-" + answerDiv[1]; + $("#" + concatID).css("width", "auto"); + } + }); + for (var i = 0; i <= $scope.DraggedList.length - 1; i++) { + $('#blockbox-' + $scope.DraggedList[i].optionName).attr("dropdattr", "blockans-" + $scope.DraggedList[i].optionName + "") } - }); - for (var i = 0; i <= $scope.DraggedList.length - 1; i++) { - $('#blockbox-' + $scope.DraggedList[i].optionName).attr("dropdattr", "blockans-"+$scope.DraggedList[i].optionName+"") } - } - else { - $("#imgdiv").css("position", "relative"); - } - }, 350); - } + else { + $("#imgdiv").css("position", "relative"); + } + }, 350); + } - }) + }) + } } $rootScope.isLoading = false; $('#spinner').css('visibility', 'hidden');