Commit 4070b2c33a9f3e39a0fb82c090e7397fda11a92f
1 parent
a22aeb20
Dropping Issue resolved.
Showing
1 changed file
with
165 additions
and
68 deletions
400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js
... | ... | @@ -451,17 +451,23 @@ function ($scope, $rootScope, pages, log, $http, $timeout, DataService, $filter, |
451 | 451 | |
452 | 452 | console.log($scope.dragableId); |
453 | 453 | $scope.dragableText = $("#" + $scope.dragableId).text(); |
454 | - | |
454 | + | |
455 | 455 | if ($scope.dragableId.split('-')[0] != 'block') { |
456 | 456 | $scope.draggableAttribute = $("#" + $scope.dragableId).attr("draggedattr"); |
457 | 457 | // $("#" + $scope.dragableId).removeAttr("draggedattr"); |
458 | 458 | } |
459 | 459 | else |
460 | 460 | { |
461 | - | |
462 | 461 | $scope.draggableAttribute = ''; |
463 | 462 | } |
464 | 463 | |
464 | + if ($("#textblock").css("display") == "block") { | |
465 | + $scope.droppableAttribute = $("#blockbox-" + $scope.dragableId.split('-')[1]).attr("dropdattr"); | |
466 | + console.log(" $scope.droppableAttribute " + $scope.droppableAttribute + "id" + "#blockbox" + $scope.dragableId.split('-')[1]); | |
467 | + } | |
468 | + | |
469 | + | |
470 | + | |
465 | 471 | //if user drag already selected answer from one blankbox to another than it gets id of blank box so need to get answer |
466 | 472 | if ($scope.dragableId.indexOf('T') != -1) { |
467 | 473 | var optionText = document.getElementById($scope.dragableId).innerHTML; |
... | ... | @@ -516,7 +522,7 @@ function ($scope, $rootScope, pages, log, $http, $timeout, DataService, $filter, |
516 | 522 | else { |
517 | 523 | var dataText = e.dataTransfer.getData('text/plain'); |
518 | 524 | } |
519 | - | |
525 | + | |
520 | 526 | if (id == "divoptions" || id == "divleft" || id == "divright") { |
521 | 527 | |
522 | 528 | $scope.item = $('#' + $scope.dragableId).html(); |
... | ... | @@ -535,12 +541,15 @@ function ($scope, $rootScope, pages, log, $http, $timeout, DataService, $filter, |
535 | 541 | if ($scope.DraggedList != null) { |
536 | 542 | $.each($scope.DraggedList, function (inx1, value3) { |
537 | 543 | $scope.UserAttempt.push({ "BlankBoxName": id.split('-')[1], "OptionName": $scope.dragableId.split('-')[1] }); |
538 | - if ($scope.DraggedList[inx1].DraggedAttr == $scope.draggableAttribute) { | |
539 | - // $scope.b = $scope.DraggedList[inx1].blockID; | |
540 | - $scope.DraggedList.splice(inx1, 1); | |
541 | - $('#' + $scope.draggableAttribute).css({ "display": "block", "color": "#000000!important" }); | |
542 | - $('#blockans-' + $scope.a.split('-')[1]).css("background-color", "transparent !important"); | |
544 | + if ($scope.DraggedList[inx1].DraggedAttr == $scope.draggableAttribute) { | |
545 | + // $scope.b = $scope.DraggedList[inx1].blockID; | |
546 | + $scope.DraggedList.splice(inx1, 1); | |
547 | + $('#' + $scope.draggableAttribute).css({ "display": "block", "color": "#000000!important" }); | |
548 | + $('#blockans-' + $scope.a.split('-')[1]).css("background-color", "transparent !important"); | |
549 | + if ($("#textblock").css("display") == "block") { | |
550 | + $('#blockbox-' + $scope.dragableId.split('-')[1]).removeAttr("dropdattr"); | |
543 | 551 | } |
552 | + } | |
544 | 553 | |
545 | 554 | }); |
546 | 555 | } |
... | ... | @@ -551,7 +560,6 @@ function ($scope, $rootScope, pages, log, $http, $timeout, DataService, $filter, |
551 | 560 | } |
552 | 561 | |
553 | 562 | }); |
554 | - | |
555 | 563 | }, |
556 | 564 | function (error) { |
557 | 565 | console.log(error.statusText) |
... | ... | @@ -559,76 +567,162 @@ function ($scope, $rootScope, pages, log, $http, $timeout, DataService, $filter, |
559 | 567 | ) |
560 | 568 | } |
561 | 569 | else { |
562 | - $(this).each(function (key, value) { | |
563 | - | |
564 | - var droppedID = $(this).attr("id").split("-"); | |
565 | - if (droppedID[0] == 'blockbox') { | |
566 | - var labExerciseModulePath = '~/../content/data/json/le/' + keywords.labexercise + '.json'; | |
567 | - DataService.getAnotherJson(labExerciseModulePath).then( | |
568 | - function (result) { | |
569 | - $.each(result.LabExercise, function (index, value) { | |
570 | - if (result.LabExercise[index].Slug == keywords.labexercise) { | |
571 | - $.each(result.LabExercise[index].Questions, function (index1, value1) { | |
572 | - if (result.LabExercise[index].Questions[index1].Number == $scope.quiznumber) { | |
573 | - var Options = result.LabExercise[index].Questions[index1].OptionBox; | |
574 | - $.each(Options, function (inx, value2) { | |
575 | - if (Options[inx].BoxName == id.split('-')[1]) { | |
576 | - if ($scope.DraggedList != null) { | |
577 | - for (var i = 0; i <= $scope.DraggedList.length - 1; i++) { | |
578 | - if ($scope.DraggedList[i].Value == undefined) { | |
579 | - i = 0; | |
580 | - continue; | |
570 | + if ($("#textblock").css("display") == "block") { | |
571 | + if ($("#"+id).attr("dropdattr") == undefined) { | |
572 | + $(this).each(function (key, value) { | |
573 | + var droppedID = $(this).attr("id").split("-"); | |
574 | + if (droppedID[0] == 'blockbox') { | |
575 | + var labExerciseModulePath = '~/../content/data/json/le/' + keywords.labexercise + '.json'; | |
576 | + DataService.getAnotherJson(labExerciseModulePath).then( | |
577 | + function (result) { | |
578 | + $.each(result.LabExercise, function (index, value) { | |
579 | + if (result.LabExercise[index].Slug == keywords.labexercise) { | |
580 | + $.each(result.LabExercise[index].Questions, function (index1, value1) { | |
581 | + if (result.LabExercise[index].Questions[index1].Number == $scope.quiznumber) { | |
582 | + var Options = result.LabExercise[index].Questions[index1].OptionBox; | |
583 | + $.each(Options, function (inx, value2) { | |
584 | + if (Options[inx].BoxName == id.split('-')[1]) { | |
585 | + if ($scope.DraggedList != null) { | |
586 | + for (var i = 0; i <= $scope.DraggedList.length - 1; i++) { | |
587 | + if ($scope.DraggedList[i].Value == undefined) { | |
588 | + i = 0; | |
589 | + continue; | |
590 | + } | |
591 | + if ($scope.DraggedList[i].DraggedAttr == $scope.draggableAttribute) { | |
592 | + $scope.DraggedList.splice(i, 1); | |
593 | + } | |
594 | + } | |
581 | 595 | } |
582 | - if ($scope.DraggedList[i].DraggedAttr == $scope.draggableAttribute) | |
583 | - { | |
584 | - $scope.DraggedList.splice(i, 1); | |
596 | + // $scope.UserAttempt.push({ "BlankBoxName": id.split('-')[1], "OptionName": $scope.dragableId.split('-')[1] }); | |
597 | + //$scope.UserAttempt.push({ balnkBox: +$scope.dragableId.split('-')[1] }); | |
598 | + $scope.UserAttempt.push({ "BlankBoxName": id.split('-')[1], "OptionName": $scope.dragableId.split('-')[1] }); | |
599 | + if ($scope.dragableId.split('-')[0] == 'block') { | |
600 | + $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 }); | |
585 | 601 | } |
586 | - } | |
587 | - } | |
588 | - // $scope.UserAttempt.push({ "BlankBoxName": id.split('-')[1], "OptionName": $scope.dragableId.split('-')[1] }); | |
589 | - //$scope.UserAttempt.push({ balnkBox: +$scope.dragableId.split('-')[1] }); | |
590 | - $scope.UserAttempt.push({ "BlankBoxName": id.split('-')[1], "OptionName": $scope.dragableId.split('-')[1] }); | |
591 | - if ($scope.dragableId.split('-')[0] == 'block') { | |
592 | - $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 }); | |
593 | - } | |
594 | - else | |
595 | - { | |
596 | - $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 }); | |
597 | - } | |
598 | - $('#' + $scope.dragableId).css("display", "none"); | |
599 | - $('#blockans-' + Options[inx].OptionNumber).css("background-color", "transparent !important"); | |
600 | - if ($scope.dragableId.split('-')[0] == 'block') { | |
601 | - $timeout(function () { | |
602 | - $('#blockans-' + id.split('-')[1]).attr("draggedAttr", $scope.dragableId); | |
603 | - }, 350); | |
604 | - } | |
605 | - else | |
606 | - { | |
607 | - $timeout(function () { | |
608 | - $('#blockans-' + id.split('-')[1]).attr("draggedAttr", $scope.draggableAttribute); | |
609 | - }, 350); | |
610 | - } | |
611 | - console.log($scope.DraggedList); | |
612 | - $scope.a = $scope.dragableId; | |
602 | + else { | |
603 | + $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 }); | |
604 | + } | |
605 | + $('#' + $scope.dragableId).css("display", "none"); | |
606 | + $('#blockans-' + Options[inx].OptionNumber).css("background-color", "transparent !important"); | |
607 | + if ($scope.dragableId.split('-')[0] == 'block') { | |
608 | + $timeout(function () { | |
609 | + $('#blockans-' + id.split('-')[1]).attr("draggedAttr", $scope.dragableId); | |
610 | + }, 350); | |
611 | + } | |
612 | + else { | |
613 | + $timeout(function () { | |
614 | + $('#blockans-' + id.split('-')[1]).attr("draggedAttr", $scope.draggableAttribute); | |
615 | + }, 350); | |
616 | + } | |
617 | + | |
618 | + | |
619 | + $('#blockbox-' + id.split('-')[1]).attr("dropdAttr", 'blockans-' + id.split('-')[1]); | |
620 | + // "blockbox" + $scope.droppableAttribute.split('-')[1]; | |
621 | + // alert($scope.droppableAttribute); | |
622 | + | |
623 | + if ($scope.droppableAttribute != undefined) | |
624 | + { | |
625 | + $('#blockbox-' + $scope.droppableAttribute.split('-')[1]).removeAttr("dropdattr"); | |
626 | + } | |
627 | + | |
628 | + console.log($scope.DraggedList); | |
629 | + $scope.a = $scope.dragableId; | |
613 | 630 | |
631 | + } | |
632 | + }); | |
614 | 633 | } |
615 | 634 | }); |
616 | 635 | } |
636 | + | |
617 | 637 | }); |
618 | - } | |
619 | 638 | |
620 | - }); | |
621 | 639 | |
622 | - | |
623 | 640 | |
624 | - }, | |
625 | - function (error) { | |
626 | - console.log(error.statusText) | |
627 | - } | |
628 | - ) | |
641 | + }, | |
642 | + function (error) { | |
643 | + console.log(error.statusText) | |
644 | + } | |
645 | + ) | |
646 | + } | |
647 | + }); | |
629 | 648 | } |
630 | - }); | |
649 | + else | |
650 | + { | |
651 | + | |
652 | + | |
653 | + } | |
654 | + } | |
655 | + else { | |
656 | + $(this).each(function (key, value) { | |
657 | + | |
658 | + var droppedID = $(this).attr("id").split("-"); | |
659 | + if (droppedID[0] == 'blockbox') { | |
660 | + var labExerciseModulePath = '~/../content/data/json/le/' + keywords.labexercise + '.json'; | |
661 | + DataService.getAnotherJson(labExerciseModulePath).then( | |
662 | + function (result) { | |
663 | + $.each(result.LabExercise, function (index, value) { | |
664 | + if (result.LabExercise[index].Slug == keywords.labexercise) { | |
665 | + $.each(result.LabExercise[index].Questions, function (index1, value1) { | |
666 | + if (result.LabExercise[index].Questions[index1].Number == $scope.quiznumber) { | |
667 | + var Options = result.LabExercise[index].Questions[index1].OptionBox; | |
668 | + $.each(Options, function (inx, value2) { | |
669 | + if (Options[inx].BoxName == id.split('-')[1]) { | |
670 | + if ($scope.DraggedList != null) { | |
671 | + for (var i = 0; i <= $scope.DraggedList.length - 1; i++) { | |
672 | + if ($scope.DraggedList[i].Value == undefined) { | |
673 | + i = 0; | |
674 | + continue; | |
675 | + } | |
676 | + if ($scope.DraggedList[i].DraggedAttr == $scope.draggableAttribute) { | |
677 | + $scope.DraggedList.splice(i, 1); | |
678 | + } | |
679 | + } | |
680 | + } | |
681 | + // $scope.UserAttempt.push({ "BlankBoxName": id.split('-')[1], "OptionName": $scope.dragableId.split('-')[1] }); | |
682 | + //$scope.UserAttempt.push({ balnkBox: +$scope.dragableId.split('-')[1] }); | |
683 | + $scope.UserAttempt.push({ "BlankBoxName": id.split('-')[1], "OptionName": $scope.dragableId.split('-')[1] }); | |
684 | + if ($scope.dragableId.split('-')[0] == 'block') { | |
685 | + $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 }); | |
686 | + } | |
687 | + else { | |
688 | + $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 }); | |
689 | + } | |
690 | + $('#' + $scope.dragableId).css("display", "none"); | |
691 | + $('#blockans-' + Options[inx].OptionNumber).css("background-color", "transparent !important"); | |
692 | + if ($scope.dragableId.split('-')[0] == 'block') { | |
693 | + $timeout(function () { | |
694 | + $('#blockans-' + id.split('-')[1]).attr("draggedAttr", $scope.dragableId); | |
695 | + }, 350); | |
696 | + } | |
697 | + else { | |
698 | + $timeout(function () { | |
699 | + $('#blockans-' + id.split('-')[1]).attr("draggedAttr", $scope.draggableAttribute); | |
700 | + }, 350); | |
701 | + } | |
702 | + | |
703 | + | |
704 | + $('#blockbox-' + id.split('-')[1]).attr("dropdAttr", 'blockans-' + id.split('-')[1]); | |
705 | + console.log($scope.DraggedList); | |
706 | + $scope.a = $scope.dragableId; | |
707 | + | |
708 | + } | |
709 | + }); | |
710 | + } | |
711 | + }); | |
712 | + } | |
713 | + | |
714 | + }); | |
715 | + | |
716 | + | |
631 | 717 | |
718 | + }, | |
719 | + function (error) { | |
720 | + console.log(error.statusText) | |
721 | + } | |
722 | + ) | |
723 | + } | |
724 | + }); | |
725 | + } | |
632 | 726 | } |
633 | 727 | $scope.$apply(); |
634 | 728 | |
... | ... | @@ -1041,7 +1135,7 @@ function ($scope, $rootScope, pages, log, $http, $timeout, DataService, $filter, |
1041 | 1135 | } |
1042 | 1136 | |
1043 | 1137 | $scope.ShowSavedLabExercise = function () { |
1044 | - | |
1138 | + | |
1045 | 1139 | //from database |
1046 | 1140 | var lastQuestion = $scope.quiznumber; |
1047 | 1141 | var lastQuestionDetails; |
... | ... | @@ -1162,6 +1256,9 @@ function ($scope, $rootScope, pages, log, $http, $timeout, DataService, $filter, |
1162 | 1256 | $("#" + concatID).css("width", "auto"); |
1163 | 1257 | } |
1164 | 1258 | }); |
1259 | + for (var i = 0; i <= $scope.DraggedList.length - 1; i++) { | |
1260 | + $('#blockbox-' + $scope.DraggedList[i].optionName).attr("dropdattr", "blockans-"+$scope.DraggedList[i].optionName+"") | |
1261 | + } | |
1165 | 1262 | } |
1166 | 1263 | else { |
1167 | 1264 | $("#imgdiv").css("position", "relative"); | ... | ... |