Commit 9cec3e391b102b09785c66668ca451485b40f2f6
1 parent
f63480a5
showing saved labexercise data for the last question saved in database
Showing
1 changed file
with
77 additions
and
59 deletions
400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js
1 | 1 | /// <reference path="../../content/data/json/le/LabExercise.js" /> |
2 | -AIA.controller("LabExercController", ["$scope", "$rootScope", "pages", "$log", '$http', 'DataService', '$filter', '$location', '$document', '$sce', "$compile", "$location", "LabExerciseService","AIAConstants", | |
3 | -function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location, $document, $sce, $compile, $location, LabExerciseService,AIAConstants) { | |
2 | +AIA.controller("LabExercController", ["$scope", "$rootScope", "pages", "$log", '$http','$timeout', 'DataService', '$filter', '$location', '$document', '$sce', "$compile", "$location", "LabExerciseService","AIAConstants", | |
3 | +function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, $location, $document, $sce, $compile, $location, LabExerciseService,AIAConstants) { | |
4 | 4 | $scope.$sce = $sce; |
5 | 5 | $scope.LabExerciseName; |
6 | 6 | $scope.LabExerciseQuiz = null; |
... | ... | @@ -98,61 +98,88 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location |
98 | 98 | $scope.LabExerciseName = keywords.labexercise; |
99 | 99 | $scope.LabExerciseModules = null; |
100 | 100 | $scope.LabExerciseBoxes = null; |
101 | - | |
101 | + | |
102 | 102 | //alert($scope.LabExerciseName) |
103 | 103 | var labExerciseModulePath = '~/../content/data/json/le/' + $scope.LabExerciseName + '.json'; |
104 | 104 | |
105 | 105 | DataService.getAnotherJson(labExerciseModulePath).then( |
106 | 106 | function (result) { |
107 | 107 | $scope.LabExData = result; |
108 | - // alert(JSON.stringify(result.LabExercise)); | |
109 | - $.each(result.LabExercise, function (index, value) { | |
110 | - $scope.LabExerciseName = result.LabExercise[index].Topic; | |
111 | - if (result.LabExercise[index].Slug == keywords.labexercise) { | |
112 | 108 | |
113 | - $scope.TotalNumberofQuiz = result.LabExercise[index].NumberofQuestions; | |
114 | - $.each(result.LabExercise[index].Questions, function (index1, value1) { | |
115 | - if (result.LabExercise[index].Questions[index1].Number == $scope.quiznumber) { | |
116 | - $scope.MaxScore = result.LabExercise[index].Questions[index1].Options.length; | |
117 | - if (result.LabExercise[index].Questions[index1].ImagePath == "") { | |
118 | - $("#imgblock").css("display", "none"); | |
119 | - //$("#imgblock").remove(); | |
120 | - $scope.IsVisible = false; | |
121 | - $("#textblock").css("display", "block"); | |
122 | - $scope.LabExerciseModules = result.LabExercise[index].Questions[index1]; | |
123 | - $scope.deliberatelyTrustDangerousSnippet = function (html) { | |
124 | - //var htmltag= $compile(html)($scope); | |
125 | - return $sce.trustAsHtml(html); | |
126 | - }; | |
127 | - $scope.activityTitle = result.LabExercise[index].Questions[index1].activityTitle; | |
128 | - $scope.Title = result.LabExercise[index].Questions[index1].Title; | |
129 | - } | |
130 | - else { | |
131 | - $("#imgblock").css("display", "block"); | |
132 | - $scope.IsVisible = true; | |
133 | - $("#textblock").css("display", "none"); | |
134 | - // $("#textblock").remove(); | |
135 | - $scope.LabExerciseModules = result.LabExercise[index].Questions[index1]; | |
136 | - $scope.activityTitle = result.LabExercise[index].Questions[index1].activityTitle; | |
137 | - $scope.Title = result.LabExercise[index].Questions[index1].Title; | |
138 | - $scope.Imagepath = keywords.labexercise + "/" + result.LabExercise[index].Questions[index1].ImagePath; | |
139 | - } | |
140 | - $scope.ShowHideDiv(result.LabExercise[index].Questions[index1].Options[0].textalign); | |
109 | + //get saved labExercis | |
110 | + var keywords = $location.search(); | |
111 | + $scope.labExercideIdentifier = (keywords.labexercise.replace('.json', '')).split('dat_')[1]; | |
112 | + var labExerciseInfo = { | |
113 | + userId: JSON.parse(localStorage.getItem('loggedInUserDetails')).Id, | |
114 | + identifier: $scope.labExercideIdentifier, | |
115 | + }; | |
141 | 116 | |
142 | - $scope.GetSavedLabExerciseFromDatabase(); | |
143 | - } | |
144 | - }); | |
145 | - //$scope.quiznumber++; | |
146 | - | |
147 | - } | |
117 | + LabExerciseService.GetLabExercise(labExerciseInfo) | |
118 | + .then( | |
148 | 119 | |
149 | - }); | |
150 | - //$scope.ShowHideDiv(); | |
151 | - }, | |
120 | + function (labResult) { | |
121 | + if (labResult != undefined && labResult != AIAConstants.SAVED_LAB_EXERCISE_NOT_FOUND) { | |
122 | + $scope.SavedLabExercise = labResult; | |
123 | + $scope.quiznumber = $scope.SavedLabExercise.lastQuestion; | |
124 | + | |
125 | + //layout the original question data | |
126 | + | |
127 | + $.each(result.LabExercise, function (index, value) { | |
128 | + $scope.LabExerciseName = result.LabExercise[index].Topic; | |
129 | + if (result.LabExercise[index].Slug == keywords.labexercise) { | |
130 | + | |
131 | + $scope.TotalNumberofQuiz = result.LabExercise[index].NumberofQuestions; | |
132 | + $.each(result.LabExercise[index].Questions, function (index1, value1) { | |
133 | + if (result.LabExercise[index].Questions[index1].Number == $scope.quiznumber) { | |
134 | + $scope.MaxScore = result.LabExercise[index].Questions[index1].Options.length; | |
135 | + if (result.LabExercise[index].Questions[index1].ImagePath == "") { | |
136 | + $("#imgblock").css("display", "none"); | |
137 | + //$("#imgblock").remove(); | |
138 | + $scope.IsVisible = false; | |
139 | + $("#textblock").css("display", "block"); | |
140 | + $scope.LabExerciseModules = result.LabExercise[index].Questions[index1]; | |
141 | + $scope.deliberatelyTrustDangerousSnippet = function (html) { | |
142 | + //var htmltag= $compile(html)($scope); | |
143 | + return $sce.trustAsHtml(html); | |
144 | + }; | |
145 | + $scope.activityTitle = result.LabExercise[index].Questions[index1].activityTitle; | |
146 | + $scope.Title = result.LabExercise[index].Questions[index1].Title; | |
147 | + } | |
148 | + else { | |
149 | + $("#imgblock").css("display", "block"); | |
150 | + $scope.IsVisible = true; | |
151 | + $("#textblock").css("display", "none"); | |
152 | + // $("#textblock").remove(); | |
153 | + $scope.LabExerciseModules = result.LabExercise[index].Questions[index1]; | |
154 | + $scope.activityTitle = result.LabExercise[index].Questions[index1].activityTitle; | |
155 | + $scope.Title = result.LabExercise[index].Questions[index1].Title; | |
156 | + $scope.Imagepath = keywords.labexercise + "/" + result.LabExercise[index].Questions[index1].ImagePath; | |
157 | + } | |
158 | + $scope.ShowHideDiv(result.LabExercise[index].Questions[index1].Options[0].textalign); | |
159 | + | |
160 | + //show saved data | |
161 | + | |
162 | + } | |
163 | + }); | |
164 | + $timeout(function () | |
165 | + { | |
166 | + $scope.ShowSavedLabExercise(); | |
167 | + },100); | |
168 | + | |
169 | + // $scope.ShowSavedLabExercise(); | |
170 | + //$scope.quiznumber++; | |
171 | + | |
172 | + } | |
173 | + | |
174 | + }); | |
175 | + } | |
176 | + //$scope.ShowHideDiv(); | |
177 | + }, | |
152 | 178 | function (error) { |
153 | 179 | console.log(error.statusText) |
154 | 180 | } |
155 | 181 | ) |
182 | + }) | |
156 | 183 | } |
157 | 184 | |
158 | 185 | $scope.nextQuiz = function () { |
... | ... | @@ -230,8 +257,7 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location |
230 | 257 | |
231 | 258 | var dataText = e.dataTransfer.getData('text/plain'); |
232 | 259 | if (id == "divoptions" || id == "divleft" || id == "divright") { |
233 | - alert('if') | |
234 | - | |
260 | + | |
235 | 261 | var item = $('#' + $scope.dragableId).html(); |
236 | 262 | var rindex = $scope.DraggedList.indexOf(item); |
237 | 263 | var labExerciseModulePath = '~/../content/data/json/le/' + keywords.labexercise + '.json'; |
... | ... | @@ -274,7 +300,7 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location |
274 | 300 | ) |
275 | 301 | } |
276 | 302 | else { |
277 | - alert('else') | |
303 | + | |
278 | 304 | var labExerciseModulePath = '~/../content/data/json/le/' + keywords.labexercise + '.json'; |
279 | 305 | DataService.getAnotherJson(labExerciseModulePath).then( |
280 | 306 | function (result) { |
... | ... | @@ -293,14 +319,11 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location |
293 | 319 | } |
294 | 320 | }); |
295 | 321 | } |
296 | - //var balnkBox = id.split('-')[1]; | |
297 | - //$scope.UserAttempt.push({ balnkBox: +$scope.dragableId.split('-')[1] }); | |
298 | 322 | $scope.UserAttempt.push({ "BlankBoxName": id.split('-')[1], "OptionName": $scope.dragableId.split('-')[1] }); |
299 | 323 | $scope.DraggedList.push({ "id": id.split('-')[1], "optionName": id.split('-')[1], "Value": dataText, "topcoord": Options[inx].topcoord, "leftcoord": Options[inx].leftcoord }); |
300 | - //$('#' + $scope.dragableId).remove(); | |
301 | 324 | $('#' + $scope.dragableId).css("display", "none"); |
302 | 325 | $('#blockans-' + Options[inx].OptionNumber).css("background-color", "transparent !important"); |
303 | - //$('#' + id).remove(); | |
326 | + | |
304 | 327 | } |
305 | 328 | }); |
306 | 329 | } |
... | ... | @@ -316,12 +339,7 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location |
316 | 339 | ) |
317 | 340 | } |
318 | 341 | $scope.$apply(); |
319 | - //alert($("#divoptions").css("display") + "," + $("#divoptions").html()); | |
320 | - //if ($("#divoptions").css("display") == "block" && $("#divoptions").html()=="") | |
321 | - //{ | |
322 | - // $("#divoptions").html("<br><br><br><br>") | |
323 | - //} | |
324 | - //alert(JSON.stringify($scope.UserAttempt)); | |
342 | + | |
325 | 343 | }; |
326 | 344 | |
327 | 345 | $scope.handleDragOver = function (e) { |
... | ... | @@ -586,7 +604,7 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location |
586 | 604 | |
587 | 605 | $scope.ShowSavedLabExercise = function () { |
588 | 606 | |
589 | - var lastQuestion = 1;//$scope.SavedLabExercise.lastQuestion; | |
607 | + var lastQuestion = $scope.SavedLabExercise.lastQuestion; | |
590 | 608 | var lastQuestionDetails = new jinqJs() |
591 | 609 | .from($scope.SavedLabExercise.labExercise) |
592 | 610 | .where('QuestionNo == ' + lastQuestion) |
... | ... | @@ -605,7 +623,7 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location |
605 | 623 | if ((blocks[j].innerHTML).toString() == lastQuestionAnswers[i]) { |
606 | 624 | $('#' + blocks[j].id).css("display", "none"); |
607 | 625 | }; |
608 | - // userAnswers[id.replace('T', '')] = blockAnswers[i].innerHTML; | |
626 | + | |
609 | 627 | } |
610 | 628 | |
611 | 629 | } | ... | ... |