From 4147a3d3da645928b54e77b6b60f93b3653702c0 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 26 Feb 2018 19:22:25 +0530 Subject: [PATCH] Commit Changes --- 400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++------------- 400-SOURCECODE/AIAHTML5.Web/app/services/LabExerciseService.js | 29 +++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+), 13 deletions(-) create mode 100644 400-SOURCECODE/AIAHTML5.Web/app/services/LabExerciseService.js diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js index 93b8d4d..a0fffa5 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js @@ -154,7 +154,9 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location } ) } + $scope.isReviewBtnSelected = false; + $rootScope.selectedDivArray = []; $scope.nextQuiz = function () { //need to save all questions till the current question number when user clicks on save @@ -171,12 +173,7 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location $scope.CreateLabExerciseDataToSave(); } - //{ - // $scope.selectedQuestionNo = $scope.quiznumber + 1; - // $scope.CreateLabExerciseDataToSave(); - //} - - + console.log($rootScope.selectedDivArray); $scope.dragableId = ""; if ($scope.quiznumber == $scope.TotalNumberofQuiz) return; @@ -200,11 +197,22 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location $scope.resetQuiz(); $scope.ShowHideDiv(); + } + + + + + + + + + $scope.prevQuiz = function () { + debugger; if ($scope.quiznumber != 1) { // $scope.quizQuesNo = $scope.quizQuesNo - 1; // $scope.selectedQuestionNo = $scope.quizQuesNo; @@ -230,10 +238,21 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location } $scope.resetQuiz(); $scope.ShowHideDiv(); + + for (var i = 0; i <= $rootScope.selectedDivArray.length - 1; i++) { + if ($scope.quiznumber == $rootScope.selectedDivArray[i].questionNo) { + document.getElementById($rootScope.selectedDivArray[i].droppedID).innerHTML = $rootScope.selectedDivArray[i].draggedText; + // $('#'+$rootScope.selectedDivArray[i].droppedID).html($rootScope.selectedDivArray[i].draggedText); + document.getElementById($rootScope.selectedDivArray[i].droppedID).style.display = "none"; + // $('#'+$rootScope.selectedDivArray[i].draggedID).css("display","none!important"); + } + + } } $scope.SubmitAttempt = function () { + debugger; $scope.CreateLabExerciseDataToSave(); $("#submitResultHtml").css("display", "block"); @@ -241,7 +260,7 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location console.log($scope.usersCorrectQuestData); $("#resultLabData").empty(); for (var i = 0; i <= $scope.usersCorrectQuestData.length - 1; i++) { - var labExerciseHtml = $("#resultLabData").append("" + $scope.usersCorrectQuestData[i].QuestionNo + "" + $scope.usersCorrectQuestData[i].title + "" + $scope.usersCorrectQuestData[i].CorrectStatus + ""); + var labExerciseHtml = $("#resultLabData").append("" + $scope.usersCorrectQuestData[i].QuestionNo + "" + $scope.usersCorrectQuestData[i].title + "" + $scope.usersCorrectQuestData[i].CorrectStatus + ""); $compile(labExerciseHtml)($scope); } } @@ -258,6 +277,9 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location this.style.opacity = '0.4'; e.dataTransfer.setData('text/plain', this.innerHTML); $scope.dragableId = $(this).attr("Id"); + // alert($scope.dragableId); + $scope.dragableText = $("#" + $scope.dragableId).text(); + // alert($("#" + $scope.dragableId).text()); //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) { @@ -287,6 +309,18 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location //alert(x.left + "," + $("#droppable").clientWidth + "," + x.top); var id = $(this).attr("id"); + // alert($scope.dragableId); + // $scope.dragableText = $("#" + $scope.dragableId).text(); + + $rootScope.selectedDivArray.push({ + "questionNo": $scope.quiznumber, + "draggedID": $scope.dragableId, + "draggedText": $scope.dragableText, + "droppedID": id + }); + + + console.log($rootScope.selectedDivArray); var keywords = $location.search(); $scope.labExercideIdentifier = (keywords.labexercise.replace('.json', '')).split('dat_')[1]; @@ -383,6 +417,8 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location // $("#divoptions").html("



") //} //alert(JSON.stringify($scope.UserAttempt)); + + }; $scope.handleDragOver = function (e) { @@ -473,7 +509,7 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location $scope.usersCorrectQuestData = []; $scope.CreateLabExerciseDataToSave = function () { - + debugger; $scope.LabExerciseAttemptedData = []; $scope.lb = []; //get user answers @@ -507,8 +543,8 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location title: $scope.activityTitle, } - - if($scope.LabExerciseAttemptedData.MaxScore == $scope.LabExerciseAttemptedData.Score) + alert($scope.LabExerciseAttemptedData.MaxScore + " " + $scope.LabExerciseAttemptedData.Score); + if ($scope.MaxScore == $scope.Score) { $scope.usersCorrectQuestData.push({ MaxScore: $scope.MaxScore, @@ -560,7 +596,7 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location $scope.LabExerciseUserData.push($scope.LabExerciseAttemptedData); } - $scope.reviewAttemptAnswer = function () { + $scope.reviewAttemptAnswer = function (evt) { $scope.isReviewBtnSelected = true; $("#reviewBtn").css("display", "none"); $("#resetBtn").css("display", "none"); @@ -568,8 +604,12 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location $("#submitResultHtml").css("display", "none"); $("#questionHtml").css("display", "block"); $("#reportBtn").css("display", "block"); - $scope.quiznumber = 1; - $scope.nextQuiz(); + $("#quizSubmitBtn").css("display", "none"); + $scope.quiznumber = evt.target.id; + $scope.CreateLabExerciseDataToSave(); + $scope.dragableId = ""; + $scope.resetQuiz(); + $scope.ShowHideDiv(); } diff --git a/400-SOURCECODE/AIAHTML5.Web/app/services/LabExerciseService.js b/400-SOURCECODE/AIAHTML5.Web/app/services/LabExerciseService.js new file mode 100644 index 0000000..f4ffcbe --- /dev/null +++ b/400-SOURCECODE/AIAHTML5.Web/app/services/LabExerciseService.js @@ -0,0 +1,29 @@ +AIA.factory('LabExerciseService', function ($http, $q, $rootScope) { + return { + saveLabExerciseAttempt: function (labExercieObj) { + var deferred = $q.defer(); + $http.post('/API/api/LabExercise', JSON.stringify(labExercieObj), { + headers: { + 'Content-Type': 'application/json' + } + }) + //$http.post('/API/api/LabExercise', JSON.stringify(labExercieObj, userId, labExerciseIdentifier, LastQuestion, TotalQuestions), { + // headers: { + // 'Content-Type': 'application/json' + // } + //}) + .success(function (data, status, headers, config) { + console.log('success') + deferred.resolve(data); + }).error(function (data, status, headers, config) { + console.log('error') + deferred.reject(data); + $rootScope.isVisibleLogin = true; + $rootScope.errorMessage = data; + $("#messageModal").modal('show'); + + }); + return deferred.promise; + }, + } +}) \ No newline at end of file -- libgit2 0.21.4