diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js index c22a45f..a87f1b5 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js @@ -450,11 +450,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 +507,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 +537,38 @@ 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]); - } + debugger; + + 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"); + // alert('removed from dropbox= '+'blockans-' + $scope.b.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.a.split('-')[1]).css("background-color", "transparent !important"); + + //} + + //else + //{ + // 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.b.split('-')[1]).css("background-color", "transparent !important"); + // // alert('removed from dropbox= '+'blockans-' + $scope.b.split('-')[1]); + // } + //} }); } } @@ -579,9 +613,13 @@ function ($scope, $rootScope, pages, log, $http, $timeout, DataService, $filter, continue; } - + debugger; + //if ($scope.DraggedList[i].Value == dataText) { - if ($scope.DraggedList[i].id == id.split('-')[1]) { + // if ($scope.DraggedList[i].id == id.split('-')[1]) + + if ($scope.DraggedList[i].DraggedAttr == $scope.draggableAttribute) + { $scope.DraggedList.splice(i, 1); } } @@ -589,10 +627,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 +816,8 @@ function ($scope, $rootScope, pages, log, $http, $timeout, DataService, $filter, $("#messageModal").modal('show'); } ) + + }; $scope.usersCorrectQuestData = []; @@ -1059,20 +1118,18 @@ function ($scope, $rootScope, pages, log, $http, $timeout, DataService, $filter, 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]) { + debugger; + alert((blocks[j].innerHTML).toString()); $('#' + blocks[j].id).css("display", "none"); break; }; - } - } } @@ -1101,13 +1158,14 @@ function ($scope, $rootScope, pages, log, $http, $timeout, DataService, $filter, .where('OptionTitle == ' + value.text) .select(); - + debugger; 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 @@
{{optionbox.Answervalue}}
-
{{ans.Value}}
+
{{ans.Value}}