Commit ef50da462cfb25879a424703909965406fa40d43
1 parent
b6e51d1c
undefined check
Showing
1 changed file
with
44 additions
and
43 deletions
400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js
... | ... | @@ -1202,7 +1202,7 @@ function ($scope, $rootScope, pages, log, $http, $timeout, DataService, $filter, |
1202 | 1202 | } |
1203 | 1203 | //if this exists in LabExerciseUserData, show the new opted else show from database |
1204 | 1204 | var isFromDB = false; |
1205 | - if (thisQuestiondataInLabExerciseUserData.length > 0) { | |
1205 | + if (thisQuestiondataInLabExerciseUserData!=undefined && thisQuestiondataInLabExerciseUserData.length > 0) { | |
1206 | 1206 | |
1207 | 1207 | |
1208 | 1208 | lastQuestionDetails = thisQuestiondataInLabExerciseUserData; |
... | ... | @@ -1270,56 +1270,57 @@ function ($scope, $rootScope, pages, log, $http, $timeout, DataService, $filter, |
1270 | 1270 | .from($scope.LabExData.LabExercise[0].Questions) |
1271 | 1271 | .where('Number == ' + lastQuestion) |
1272 | 1272 | .select(); |
1273 | - | |
1274 | - angular.forEach($scope.QustionAnsKeyValue, function (value, key) { | |
1275 | - var questionOptionBox = new jinqJs() | |
1276 | - .from(labQuestionData[0].OptionBox) | |
1277 | - .where('BoxName == ' + value.blockbox) | |
1278 | - .select(); | |
1279 | - if (value.text != "") { | |
1280 | - | |
1281 | - var OptionList = new jinqJs() | |
1282 | - .from(labQuestionData[0].Options) | |
1283 | - .where('OptionTitle == ' + value.text) | |
1284 | - .select(); | |
1285 | - | |
1286 | - | |
1287 | - var blockId = 'block-' + OptionList[0].OptionNumber; | |
1288 | - if (OptionList != undefined && OptionList.length > 1 && blockIds.indexOf(blockId) != -1) { | |
1289 | - blockId = 'block-' + OptionList[1].OptionNumber; | |
1290 | - } | |
1291 | - blockIds.push(blockId); | |
1292 | - console.log($scope.draggedIDArray); | |
1293 | - $scope.DraggedList.push({ "DraggedAttr": blockId, "blockID": blockId, "id": value.blockbox, "optionName": value.blockbox, "Value": value.text, "topcoord": questionOptionBox[0].topcoord, "leftcoord": questionOptionBox[0].leftcoord }); | |
1273 | + if ($scope.QustionAnsKeyValue != undefined) { | |
1274 | + angular.forEach($scope.QustionAnsKeyValue, function (value, key) { | |
1275 | + var questionOptionBox = new jinqJs() | |
1276 | + .from(labQuestionData[0].OptionBox) | |
1277 | + .where('BoxName == ' + value.blockbox) | |
1278 | + .select(); | |
1279 | + if (value.text != "") { | |
1280 | + | |
1281 | + var OptionList = new jinqJs() | |
1282 | + .from(labQuestionData[0].Options) | |
1283 | + .where('OptionTitle == ' + value.text) | |
1284 | + .select(); | |
1285 | + | |
1286 | + | |
1287 | + var blockId = 'block-' + OptionList[0].OptionNumber; | |
1288 | + if (OptionList != undefined && OptionList.length > 1 && blockIds.indexOf(blockId) != -1) { | |
1289 | + blockId = 'block-' + OptionList[1].OptionNumber; | |
1290 | + } | |
1291 | + blockIds.push(blockId); | |
1292 | + console.log($scope.draggedIDArray); | |
1293 | + $scope.DraggedList.push({ "DraggedAttr": blockId, "blockID": blockId, "id": value.blockbox, "optionName": value.blockbox, "Value": value.text, "topcoord": questionOptionBox[0].topcoord, "leftcoord": questionOptionBox[0].leftcoord }); | |
1294 | 1294 | |
1295 | 1295 | |
1296 | - // $scope.DraggedList.push({ "id": value.blockbox, "optionName": value.blockbox, "Value": value.text, "topcoord": questionOptionBox[0].topcoord, "leftcoord": questionOptionBox[0].leftcoord }); | |
1296 | + // $scope.DraggedList.push({ "id": value.blockbox, "optionName": value.blockbox, "Value": value.text, "topcoord": questionOptionBox[0].topcoord, "leftcoord": questionOptionBox[0].leftcoord }); | |
1297 | 1297 | |
1298 | - $rootScope.isLoading = false; | |
1299 | - $('#spinner').css('visibility', 'hidden'); | |
1298 | + $rootScope.isLoading = false; | |
1299 | + $('#spinner').css('visibility', 'hidden'); | |
1300 | 1300 | |
1301 | 1301 | |
1302 | - $timeout(function () { | |
1303 | - if ($("#textblock").css("display") == "block") { | |
1304 | - $("#imgdiv").css("position", "static"); | |
1305 | - $("#imgdiv").find("div").each(function () { | |
1306 | - var answerDiv = $(this).attr("id").split("-"); | |
1307 | - if (answerDiv[0] == "blockans") { | |
1308 | - var concatID = answerDiv[0] + "-" + answerDiv[1]; | |
1309 | - $("#" + concatID).css("width", "auto"); | |
1302 | + $timeout(function () { | |
1303 | + if ($("#textblock").css("display") == "block") { | |
1304 | + $("#imgdiv").css("position", "static"); | |
1305 | + $("#imgdiv").find("div").each(function () { | |
1306 | + var answerDiv = $(this).attr("id").split("-"); | |
1307 | + if (answerDiv[0] == "blockans") { | |
1308 | + var concatID = answerDiv[0] + "-" + answerDiv[1]; | |
1309 | + $("#" + concatID).css("width", "auto"); | |
1310 | + } | |
1311 | + }); | |
1312 | + for (var i = 0; i <= $scope.DraggedList.length - 1; i++) { | |
1313 | + $('#blockbox-' + $scope.DraggedList[i].optionName).attr("dropdattr", "blockans-" + $scope.DraggedList[i].optionName + "") | |
1310 | 1314 | } |
1311 | - }); | |
1312 | - for (var i = 0; i <= $scope.DraggedList.length - 1; i++) { | |
1313 | - $('#blockbox-' + $scope.DraggedList[i].optionName).attr("dropdattr", "blockans-"+$scope.DraggedList[i].optionName+"") | |
1314 | 1315 | } |
1315 | - } | |
1316 | - else { | |
1317 | - $("#imgdiv").css("position", "relative"); | |
1318 | - } | |
1319 | - }, 350); | |
1320 | - } | |
1316 | + else { | |
1317 | + $("#imgdiv").css("position", "relative"); | |
1318 | + } | |
1319 | + }, 350); | |
1320 | + } | |
1321 | 1321 | |
1322 | - }) | |
1322 | + }) | |
1323 | + } | |
1323 | 1324 | } |
1324 | 1325 | $rootScope.isLoading = false; |
1325 | 1326 | $('#spinner').css('visibility', 'hidden'); | ... | ... |