diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js index 6d81b4a..96abcc6 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js @@ -65,14 +65,12 @@ function ($scope, $rootScope, pages, log, $http, $timeout, DataService, $filter, //to get all lab exercise modules from json files $scope.getLabExerciseModules = function () { - //debugger; + $scope.LabExerciseModules1 = null; var labExerciseModulePath = '~/../content/data/json/le/labexercise.json'; DataService.getAnotherJson(labExerciseModulePath).then( function (result) { - //debugger; - //alert(JSON.stringify(result)); $scope.LabExerciseModules1 = result; }, function (error) { @@ -450,11 +448,20 @@ function ($scope, $rootScope, pages, log, $http, $timeout, DataService, $filter, $scope.dragableId = $(this).attr("Id"); $scope.a = $scope.dragableId; - + console.log($scope.dragableId); $scope.dragableText = $("#" + $scope.dragableId).text(); - // alert($("#" + $scope.dragableId).text()); - + + if ($scope.dragableId.split('-')[0] != 'block') { + $scope.draggableAttribute = $("#" + $scope.dragableId).attr("draggedattr"); + $("#" + $scope.dragableId).removeAttr("draggedattr"); + } + else + { + + $scope.draggableAttribute = ''; + } + //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) { var optionText = document.getElementById($scope.dragableId).innerHTML; @@ -498,8 +505,8 @@ function ($scope, $rootScope, pages, log, $http, $timeout, DataService, $filter, var x = $("#droppable").offset(); var id = $(this).attr("id"); - - + + var keywords = $location.search(); if ($.browser.msie) { @@ -528,13 +535,13 @@ function ($scope, $rootScope, pages, log, $http, $timeout, DataService, $filter, if ($scope.DraggedList != null) { $.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.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]); - } + if ($scope.DraggedList[inx1].DraggedAttr == $scope.draggableAttribute) { + // $scope.b = $scope.DraggedList[inx1].blockID; + $scope.DraggedList.splice(inx1, 1); + $('#' + $scope.draggableAttribute).css({ "display": "block", "color": "#000000!important" }); + $('#blockans-' + $scope.a.split('-')[1]).css("background-color", "transparent !important"); + } + }); } } @@ -567,21 +574,13 @@ function ($scope, $rootScope, pages, log, $http, $timeout, DataService, $filter, $.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]) { + if ($scope.DraggedList[i].DraggedAttr == $scope.draggableAttribute) + { $scope.DraggedList.splice(i, 1); } } @@ -589,10 +588,29 @@ function ($scope, $rootScope, pages, log, $http, $timeout, DataService, $filter, // $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 }); + if ($scope.dragableId.split('-')[0] == 'block') { + $scope.DraggedList.push({ "DraggedAttr": $scope.dragableId, "blockID": $scope.dragableId, "id": id.split('-')[1], "optionName": id.split('-')[1], "Value": dataText, "topcoord": Options[inx].topcoord, "leftcoord": Options[inx].leftcoord }); + } + else + { + $scope.DraggedList.push({ "DraggedAttr": $scope.draggableAttribute, "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"); + if ($scope.dragableId.split('-')[0] == 'block') { + $timeout(function () { + $('#blockans-' + id.split('-')[1]).attr("draggedAttr", $scope.dragableId); + }, 350); + } + else + { + $timeout(function () { + $('#blockans-' + id.split('-')[1]).attr("draggedAttr", $scope.draggableAttribute); + }, 350); + } + console.log($scope.DraggedList); $scope.a = $scope.dragableId; + } }); } @@ -759,6 +777,8 @@ function ($scope, $rootScope, pages, log, $http, $timeout, DataService, $filter, $("#messageModal").modal('show'); } ) + + }; $scope.usersCorrectQuestData = []; @@ -1071,21 +1091,33 @@ function ($scope, $rootScope, pages, log, $http, $timeout, DataService, $filter, $('#' + blocks[j].id).css("display", "none"); break; } - + }; - + } } } - else { - var dragList = lastQuestionDetails[0].DragList; - angular.forEach(dragList, function (v, k) { - $('#' + v.blockID).css("display", "none"); - }) - } + } + if (lastQuestionDetails != undefined && lastQuestionDetails.length > 0 && !isFromDB) { + var dragList = lastQuestionDetails[0].DragList; + var blocks = $("div[id*='block-']"); + angular.forEach(dragList, function (v, k) { + + for (var j = 0; j < blocks.length; j++) { + + if ((blocks[j].innerHTML).toString() == v.Value) { + if ($('#' + blocks[j].id).css('display').toLowerCase() == 'block') { + $('#' + blocks[j].id).css("display", "none"); + break; + } + + }; + } + //$('#' + v.blockID).css("display", "none"); + }) } var labQuestionData = new jinqJs() .from($scope.LabExData.LabExercise[0].Questions) @@ -1104,13 +1136,14 @@ function ($scope, $rootScope, pages, log, $http, $timeout, DataService, $filter, .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 }); + 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 }); diff --git a/400-SOURCECODE/AIAHTML5.Web/app/views/LabExerc/lab-exercises-detail.html b/400-SOURCECODE/AIAHTML5.Web/app/views/LabExerc/lab-exercises-detail.html index 709b3b2..47d7366 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/views/LabExerc/lab-exercises-detail.html +++ b/400-SOURCECODE/AIAHTML5.Web/app/views/LabExerc/lab-exercises-detail.html @@ -52,7 +52,7 @@
-