Commit 74140fb67047d0cb3016f14f2c0909607caac3b6

Authored by Nikita Kulshreshtha
1 parent 315946b3

fixed issue when 2 options are same than one disappear while dropping

400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js
@@ -495,7 +495,8 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, @@ -495,7 +495,8 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter,
495 $scope.b = $scope.DraggedList[inx1].blockID; 495 $scope.b = $scope.DraggedList[inx1].blockID;
496 $scope.DraggedList.splice(inx1, 1); 496 $scope.DraggedList.splice(inx1, 1);
497 $('#' + $scope.b).css({ "display": "block", "color": "#000000!important" }); 497 $('#' + $scope.b).css({ "display": "block", "color": "#000000!important" });
498 - $('#blockans-' + $scope.b.split('-')[1]).css("background-color","transparent !important"); 498 + $('#blockans-' + $scope.b.split('-')[1]).css("background-color", "transparent !important");
  499 + // alert('removed from dropbox= '+'blockans-' + $scope.b.split('-')[1]);
499 } 500 }
500 }); 501 });
501 } 502 }
@@ -741,8 +742,8 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, @@ -741,8 +742,8 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter,
741 CorrectAnswer: JSON.stringify($scope.correctResponseForSavingDatabase), 742 CorrectAnswer: JSON.stringify($scope.correctResponseForSavingDatabase),
742 DragItems: $scope.DragItems, 743 DragItems: $scope.DragItems,
743 Score: $scope.Score, 744 Score: $scope.Score,
744 - title: $scope.activityTitle  
745 - 745 + title: $scope.activityTitle,
  746 + DragList: $scope.DraggedList
746 } 747 }
747 748
748 749
@@ -974,6 +975,7 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, @@ -974,6 +975,7 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter,
974 var lastQuestion = $scope.quiznumber; 975 var lastQuestion = $scope.quiznumber;
975 var lastQuestionDetails; 976 var lastQuestionDetails;
976 var lastQuestionAnswers; 977 var lastQuestionAnswers;
  978 + var blockIds = [];
977 979
978 //if user opted this question, it will have entry in LabExerciseUserData 980 //if user opted this question, it will have entry in LabExerciseUserData
979 var thisQuestiondataInLabExerciseUserData = new jinqJs() 981 var thisQuestiondataInLabExerciseUserData = new jinqJs()
@@ -983,6 +985,7 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, @@ -983,6 +985,7 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter,
983 985
984 986
985 //if this exists in LabExerciseUserData, show the new opted else show from database 987 //if this exists in LabExerciseUserData, show the new opted else show from database
  988 + var isFromDB = false;
986 if (thisQuestiondataInLabExerciseUserData.length > 0){ 989 if (thisQuestiondataInLabExerciseUserData.length > 0){
987 990
988 991
@@ -992,7 +995,7 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, @@ -992,7 +995,7 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter,
992 } 995 }
993 996
994 else{ 997 else{
995 - 998 + isFromDB = true;
996 lastQuestionDetails = new jinqJs() 999 lastQuestionDetails = new jinqJs()
997 .from($scope.SavedLabExercise.labExercise) 1000 .from($scope.SavedLabExercise.labExercise)
998 .where('QuestionNo == ' + lastQuestion) 1001 .where('QuestionNo == ' + lastQuestion)
@@ -1006,20 +1009,29 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, @@ -1006,20 +1009,29 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter,
1006 var num = i + 1; 1009 var num = i + 1;
1007 $scope.QustionAnsKeyValue.push({ blockbox: 'T' + num, text: lastQuestionAnswers[i] }); 1010 $scope.QustionAnsKeyValue.push({ blockbox: 'T' + num, text: lastQuestionAnswers[i] });
1008 1011
1009 - if (lastQuestionAnswers[i] != "") {  
1010 - var blocks = $("div[id*='block-']");  
1011 - for (var j = 0; j < blocks.length; j++) { 1012 + if (isFromDB) {
1012 1013
1013 - if ((blocks[j].innerHTML).toString() == lastQuestionAnswers[i]) {  
1014 - $('#' + blocks[j].id).css("display", "none");  
1015 - }; 1014 + if (lastQuestionAnswers[i] != "") {
  1015 + var blocks = $("div[id*='block-']");
  1016 + for (var j = 0; j < blocks.length; j++) {
1016 1017
1017 - } 1018 + if ((blocks[j].innerHTML).toString() == lastQuestionAnswers[i]) {
  1019 + $('#' + blocks[j].id).css("display", "none");
  1020 + };
1018 1021
  1022 + }
  1023 +
  1024 + }
1019 } 1025 }
1020 - }  
1021 1026
  1027 + else {
  1028 + var dragList = lastQuestionDetails[0].DragList;
  1029 + angular.forEach(dragList, function (v, k) {
  1030 + $('#' + v.blockID).css("display", "none");
  1031 + })
  1032 + }
1022 1033
  1034 + }
1023 var labQuestionData = new jinqJs() 1035 var labQuestionData = new jinqJs()
1024 .from($scope.LabExData.LabExercise[0].Questions) 1036 .from($scope.LabExData.LabExercise[0].Questions)
1025 .where('Number == ' + lastQuestion) 1037 .where('Number == ' + lastQuestion)
@@ -1036,8 +1048,13 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, @@ -1036,8 +1048,13 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter,
1036 .from(labQuestionData[0].Options) 1048 .from(labQuestionData[0].Options)
1037 .where('OptionTitle == ' + value.text) 1049 .where('OptionTitle == ' + value.text)
1038 .select(); 1050 .select();
1039 - 1051 +
  1052 +
1040 var blockId = 'block-' + OptionList[0].OptionNumber; 1053 var blockId = 'block-' + OptionList[0].OptionNumber;
  1054 + if (OptionList != undefined && OptionList.length > 1 && blockIds.indexOf(blockId) != -1) {
  1055 + blockId = 'block-' + OptionList[1].OptionNumber;
  1056 + }
  1057 + blockIds.push(blockId);
1041 $scope.DraggedList.push({ "blockID": blockId, "id": value.blockbox, "optionName": value.blockbox, "Value": value.text, "topcoord": questionOptionBox[0].topcoord, "leftcoord": questionOptionBox[0].leftcoord }); 1058 $scope.DraggedList.push({ "blockID": blockId, "id": value.blockbox, "optionName": value.blockbox, "Value": value.text, "topcoord": questionOptionBox[0].topcoord, "leftcoord": questionOptionBox[0].leftcoord });
1042 1059
1043 1060
400-SOURCECODE/AIAHTML5.Web/app/views/LabExerc/lab-exercises-detail.html
@@ -52,7 +52,7 @@ @@ -52,7 +52,7 @@
52 </div> 52 </div>
53 53
54 <div ng-show="IsVisible" ng-repeat="optionbox in LabExerciseModules.OptionBox" droppable="true" class="droppable ui-droppable options" id="blockbox-{{optionbox.BoxName}}" ng-style="{'top':{{optionbox.topcoord}}, 'left':{{optionbox.leftcoord}},'position': 'absolute', 'width': '155px', 'height':'30px', 'border':'0px solid #333', 'background': '#E8E8E8' }">{{optionbox.Answervalue}}</div> 54 <div ng-show="IsVisible" ng-repeat="optionbox in LabExerciseModules.OptionBox" droppable="true" class="droppable ui-droppable options" id="blockbox-{{optionbox.BoxName}}" ng-style="{'top':{{optionbox.topcoord}}, 'left':{{optionbox.leftcoord}},'position': 'absolute', 'width': '155px', 'height':'30px', 'border':'0px solid #333', 'background': '#E8E8E8' }">{{optionbox.Answervalue}}</div>
55 - <div draggable="true" ng-repeat="ans in DraggedList" droppable="true" class="droppable ui-droppable answerdroppable" id="blockans-{{ans.id}}" ng-style="{'top':{{ans.topcoord}}, 'left':{{ans.leftcoord}},'position': 'absolute', 'width': '158px', 'height':'30px', 'border':'0px solid #333', 'background': 'transparent','font-size': '12px','border-color':'#FF0000','padding-top':'5px'}">{{ans.Value}}</div> 55 + <div draggable="true" ng-repeat="ans in DraggedList" droppable="true" class="droppable ui-droppable answerdroppable" id="blockans-{{ans.id}}" ng-style="{'top':{{ans.topcoord}}, 'left':{{ans.leftcoord}},'position': 'absolute', 'width': '158px', 'height':'30px', 'border':'0px solid #333', 'background': 'transparent','font-size': '12px','border-color':'#FF0000','padding-top':'4px','line-height':'1'}">{{ans.Value}}</div>
56 </div> 56 </div>
57 57
58 <div class="col-sm-12" style=" margin-top: 20px; min-height:100px;" id="divoptions" droppable="true"> 58 <div class="col-sm-12" style=" margin-top: 20px; min-height:100px;" id="divoptions" droppable="true">