Commit 335f4bd9325fc2e53af55258e26e790389732a58
1 parent
99fd7a45
Implemented Submit Btn Functionality
Showing
3 changed files
with
409 additions
and
34 deletions
400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js
1 | /// <reference path="../../content/data/json/le/LabExercise.js" /> | 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", | ||
3 | -function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location, $document, $sce, $compile, $location) { | 2 | +AIA.controller("LabExercController", ["$scope", "$rootScope", "pages", "$log", '$http', 'DataService', '$filter', '$location', '$document', '$sce', "$compile", "$location", "LabExerciseService", |
3 | +function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location, $document, $sce, $compile, $location, LabExerciseService) { | ||
4 | $scope.$sce = $sce; | 4 | $scope.$sce = $sce; |
5 | $scope.LabExerciseName; | 5 | $scope.LabExerciseName; |
6 | $scope.LabExerciseQuiz = null; | 6 | $scope.LabExerciseQuiz = null; |
@@ -10,13 +10,14 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | @@ -10,13 +10,14 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | ||
10 | $scope.Title = ""; | 10 | $scope.Title = ""; |
11 | $scope.Imagepath = ""; | 11 | $scope.Imagepath = ""; |
12 | $scope.DraggedList = []; | 12 | $scope.DraggedList = []; |
13 | + $scope.UserAttempt = []; | ||
14 | + $scope.UserAnswersForAllQuestions = []; | ||
15 | + $scope.LabExerciseUserData = []; | ||
16 | + $scope.LabExercise = []; | ||
13 | $scope.dragableId = ""; | 17 | $scope.dragableId = ""; |
18 | + $scope.UserAttempt = []; | ||
14 | $scope.blReviewAttempt = false; | 19 | $scope.blReviewAttempt = false; |
15 | $scope.$on('$viewContentLoaded', function (event) { | 20 | $scope.$on('$viewContentLoaded', function (event) { |
16 | - | ||
17 | - if ($rootScope.refreshcheck == null) { | ||
18 | - $location.path('/'); | ||
19 | - } | ||
20 | // code that will be executed ... | 21 | // code that will be executed ... |
21 | // every time this view is loaded | 22 | // every time this view is loaded |
22 | 23 | ||
@@ -31,7 +32,7 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | @@ -31,7 +32,7 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | ||
31 | $rootScope.currentActiveModuleTitle = selectedModuleName; | 32 | $rootScope.currentActiveModuleTitle = selectedModuleName; |
32 | }) | 33 | }) |
33 | 34 | ||
34 | - $scope.showTabButton = false; | 35 | + $scope.showme = false; |
35 | $rootScope.currentActiveModuleTitle = pages[8].name; | 36 | $rootScope.currentActiveModuleTitle = pages[8].name; |
36 | $scope.getLabExerciseModules(); | 37 | $scope.getLabExerciseModules(); |
37 | 38 | ||
@@ -47,7 +48,7 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | @@ -47,7 +48,7 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | ||
47 | 48 | ||
48 | }); | 49 | }); |
49 | 50 | ||
50 | - // $scope.showTabButton = false; | 51 | + // $scope.showme = false; |
51 | $scope.IsVisible = function () { | 52 | $scope.IsVisible = function () { |
52 | // $scope.scroll(); | 53 | // $scope.scroll(); |
53 | 54 | ||
@@ -85,6 +86,7 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | @@ -85,6 +86,7 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | ||
85 | if (title != null) { | 86 | if (title != null) { |
86 | $scope.LabExerciseQuiz = title; | 87 | $scope.LabExerciseQuiz = title; |
87 | $scope.LabExerciseName = title.Topic; | 88 | $scope.LabExerciseName = title.Topic; |
89 | + $scope.LabExerciseUserData = []; | ||
88 | $location.url("/lab-exercises-detail?labexercise=" + (title.Slug || "")); | 90 | $location.url("/lab-exercises-detail?labexercise=" + (title.Slug || "")); |
89 | } | 91 | } |
90 | 92 | ||
@@ -92,19 +94,17 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | @@ -92,19 +94,17 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | ||
92 | 94 | ||
93 | 95 | ||
94 | $scope.GetQuizByTopic = function () { | 96 | $scope.GetQuizByTopic = function () { |
95 | - | ||
96 | - if ($rootScope.refreshcheck == null) { | ||
97 | - $location.path('/'); | ||
98 | - } | ||
99 | var keywords = $location.search(); | 97 | var keywords = $location.search(); |
100 | $scope.LabExerciseName = keywords.labexercise; | 98 | $scope.LabExerciseName = keywords.labexercise; |
101 | $scope.LabExerciseModules = null; | 99 | $scope.LabExerciseModules = null; |
102 | $scope.LabExerciseBoxes = null; | 100 | $scope.LabExerciseBoxes = null; |
101 | + | ||
102 | + | ||
103 | var labExerciseModulePath = '~/../content/data/json/le/' + $scope.LabExerciseName + '.json'; | 103 | var labExerciseModulePath = '~/../content/data/json/le/' + $scope.LabExerciseName + '.json'; |
104 | 104 | ||
105 | DataService.getAnotherJson(labExerciseModulePath).then( | 105 | DataService.getAnotherJson(labExerciseModulePath).then( |
106 | function (result) { | 106 | function (result) { |
107 | - //debugger; | 107 | + $scope.LabExData = result; |
108 | // alert(JSON.stringify(result.LabExercise)); | 108 | // alert(JSON.stringify(result.LabExercise)); |
109 | $.each(result.LabExercise, function (index, value) { | 109 | $.each(result.LabExercise, function (index, value) { |
110 | $scope.LabExerciseName = result.LabExercise[index].Topic; | 110 | $scope.LabExerciseName = result.LabExercise[index].Topic; |
@@ -113,23 +113,28 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | @@ -113,23 +113,28 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | ||
113 | $scope.TotalNumberofQuiz = result.LabExercise[index].NumberofQuestions; | 113 | $scope.TotalNumberofQuiz = result.LabExercise[index].NumberofQuestions; |
114 | $.each(result.LabExercise[index].Questions, function (index1, value1) { | 114 | $.each(result.LabExercise[index].Questions, function (index1, value1) { |
115 | if (result.LabExercise[index].Questions[index1].Number == $scope.quiznumber) { | 115 | if (result.LabExercise[index].Questions[index1].Number == $scope.quiznumber) { |
116 | + $scope.MaxScore = result.LabExercise[index].Questions[index1].Options.length; | ||
116 | if (result.LabExercise[index].Questions[index1].ImagePath == "") { | 117 | if (result.LabExercise[index].Questions[index1].ImagePath == "") { |
117 | $("#imgblock").css("display", "none"); | 118 | $("#imgblock").css("display", "none"); |
119 | + //$("#imgblock").remove(); | ||
118 | $scope.IsVisible = false; | 120 | $scope.IsVisible = false; |
119 | $("#textblock").css("display", "block"); | 121 | $("#textblock").css("display", "block"); |
120 | $scope.LabExerciseModules = result.LabExercise[index].Questions[index1]; | 122 | $scope.LabExerciseModules = result.LabExercise[index].Questions[index1]; |
121 | $scope.deliberatelyTrustDangerousSnippet = function (html) { | 123 | $scope.deliberatelyTrustDangerousSnippet = function (html) { |
122 | - //var htmltag= $compile(html)($scope); | ||
123 | - return $sce.trustAsHtml(html); | 124 | + //var htmltag= $compile(html)($scope); |
125 | + return $sce.trustAsHtml(html); | ||
124 | }; | 126 | }; |
125 | $scope.activityTitle = result.LabExercise[index].Questions[index1].activityTitle; | 127 | $scope.activityTitle = result.LabExercise[index].Questions[index1].activityTitle; |
126 | $scope.Title = result.LabExercise[index].Questions[index1].Title; | 128 | $scope.Title = result.LabExercise[index].Questions[index1].Title; |
129 | + | ||
127 | } | 130 | } |
128 | else { | 131 | else { |
129 | $("#imgblock").css("display", "block"); | 132 | $("#imgblock").css("display", "block"); |
130 | $scope.IsVisible = true; | 133 | $scope.IsVisible = true; |
131 | $("#textblock").css("display", "none"); | 134 | $("#textblock").css("display", "none"); |
135 | + // $("#textblock").remove(); | ||
132 | $scope.LabExerciseModules = result.LabExercise[index].Questions[index1]; | 136 | $scope.LabExerciseModules = result.LabExercise[index].Questions[index1]; |
137 | + console.log($scope.LabExerciseModules); | ||
133 | $scope.activityTitle = result.LabExercise[index].Questions[index1].activityTitle; | 138 | $scope.activityTitle = result.LabExercise[index].Questions[index1].activityTitle; |
134 | $scope.Title = result.LabExercise[index].Questions[index1].Title; | 139 | $scope.Title = result.LabExercise[index].Questions[index1].Title; |
135 | $scope.Imagepath = keywords.labexercise + "/" + result.LabExercise[index].Questions[index1].ImagePath; | 140 | $scope.Imagepath = keywords.labexercise + "/" + result.LabExercise[index].Questions[index1].ImagePath; |
@@ -137,7 +142,7 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | @@ -137,7 +142,7 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | ||
137 | $scope.ShowHideDiv(result.LabExercise[index].Questions[index1].Options[0].textalign); | 142 | $scope.ShowHideDiv(result.LabExercise[index].Questions[index1].Options[0].textalign); |
138 | } | 143 | } |
139 | }); | 144 | }); |
140 | - //$scope.quiznumber++; | 145 | + //$scope.quiznumber++;0 |
141 | 146 | ||
142 | } | 147 | } |
143 | 148 | ||
@@ -149,32 +154,126 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | @@ -149,32 +154,126 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | ||
149 | } | 154 | } |
150 | ) | 155 | ) |
151 | } | 156 | } |
152 | - | 157 | + $scope.isReviewBtnSelected = false; |
153 | $scope.nextQuiz = function () { | 158 | $scope.nextQuiz = function () { |
159 | + | ||
160 | + //need to save all questions till the current question number when user clicks on save | ||
161 | + //if ($scope.dragableId!="") { | ||
162 | + // $scope.UserAnswersForAllQuestions.push({'QuestionNo':$scope.quiznumber,'UserAnswer':$scope.UserAttempt}) | ||
163 | + | ||
164 | + //} | ||
165 | + //else { | ||
166 | + // //need to anattampted question means user ahs not dragged, dropped options so save blank | ||
167 | + // $scope.UserAnswersForAllQuestions.push({ 'QuestionNo': $scope.quiznumber, 'UserAnswer': "" }) | ||
168 | + //} | ||
169 | + if ($scope.quiznumber != $scope.TotalNumberofQuiz) | ||
170 | + { | ||
171 | + $scope.CreateLabExerciseDataToSave(); | ||
172 | + } | ||
173 | + | ||
174 | + //{ | ||
175 | + // $scope.selectedQuestionNo = $scope.quiznumber + 1; | ||
176 | + // $scope.CreateLabExerciseDataToSave(); | ||
177 | + //} | ||
178 | + | ||
179 | + | ||
180 | + $scope.dragableId = ""; | ||
154 | if ($scope.quiznumber == $scope.TotalNumberofQuiz) | 181 | if ($scope.quiznumber == $scope.TotalNumberofQuiz) |
155 | return; | 182 | return; |
156 | else | 183 | else |
157 | - $scope.quiznumber++; | 184 | + $scope.quiznumber++; |
185 | + | ||
186 | + | ||
187 | + if ($scope.quiznumber == $scope.TotalNumberofQuiz) { | ||
188 | + if ($scope.isReviewBtnSelected == true) { | ||
189 | + $("#quizSubmitBtn").css("display", "none"); | ||
190 | + } | ||
191 | + else { | ||
192 | + $("#quizSubmitBtn").css("display", "block"); | ||
193 | + } | ||
194 | + | ||
195 | + } | ||
196 | + else | ||
197 | + { | ||
198 | + $("#quizSubmitBtn").css("display", "none"); | ||
199 | + } | ||
200 | + | ||
158 | $scope.resetQuiz(); | 201 | $scope.resetQuiz(); |
159 | $scope.ShowHideDiv(); | 202 | $scope.ShowHideDiv(); |
203 | + | ||
204 | + | ||
160 | } | 205 | } |
161 | 206 | ||
162 | $scope.prevQuiz = function () { | 207 | $scope.prevQuiz = function () { |
163 | - if ($scope.quiznumber == 1) | ||
164 | - return; | ||
165 | - else | ||
166 | - $scope.quiznumber--; | 208 | + if ($scope.quiznumber != 1) { |
209 | + // $scope.quizQuesNo = $scope.quizQuesNo - 1; | ||
210 | + // $scope.selectedQuestionNo = $scope.quizQuesNo; | ||
211 | + $scope.CreateLabExerciseDataToSave(); | ||
212 | + } | ||
213 | + $scope.dragableId = ""; | ||
214 | + $scope.UserAttempt = []; | ||
215 | + if ($scope.quiznumber == 1) | ||
216 | + return; | ||
217 | + else | ||
218 | + $scope.quiznumber--; | ||
219 | + | ||
220 | + if ($scope.quiznumber == $scope.TotalNumberofQuiz) { | ||
221 | + if ($scope.isReviewBtnSelected == true) { | ||
222 | + $("#quizSubmitBtn").css("display", "none"); | ||
223 | + } | ||
224 | + else { | ||
225 | + $("#quizSubmitBtn").css("display", "block"); | ||
226 | + } | ||
227 | + } | ||
228 | + else { | ||
229 | + $("#quizSubmitBtn").css("display", "none"); | ||
230 | + } | ||
231 | + $scope.resetQuiz(); | ||
232 | + $scope.ShowHideDiv(); | ||
233 | + } | ||
167 | 234 | ||
168 | - $scope.resetQuiz(); | ||
169 | - $scope.ShowHideDiv(); | 235 | + |
236 | + $scope.SubmitAttempt = function () { | ||
237 | + $scope.CreateLabExerciseDataToSave(); | ||
238 | + | ||
239 | + $("#submitResultHtml").css("display", "block"); | ||
240 | + $("#questionHtml").css("display", "none"); | ||
241 | + console.log($scope.usersCorrectQuestData); | ||
242 | + $("#resultLabData").empty(); | ||
243 | + for (var i = 0; i <= $scope.usersCorrectQuestData.length - 1; i++) { | ||
244 | + var labExerciseHtml = $("#resultLabData").append("<tr><td>" + $scope.usersCorrectQuestData[i].QuestionNo + "</td><td>" + $scope.usersCorrectQuestData[i].title + "</td><td>" + $scope.usersCorrectQuestData[i].CorrectStatus + "</td><td><button ng-click='reviewAttemptAnswer(" + $scope.usersCorrectQuestData[i].QuestionNo + ");' id=" + $scope.usersCorrectQuestData[i].QuestionNo + " class='btn btn-danger btn-sm'><i class='fa fa-times'></i> Review</button></td></tr>"); | ||
245 | + $compile(labExerciseHtml)($scope); | ||
246 | + } | ||
170 | } | 247 | } |
171 | 248 | ||
249 | + | ||
250 | + $scope.ReportGen = function () { | ||
251 | + $("#submitResultHtml").css("display", "block"); | ||
252 | + $("#questionHtml").css("display", "none"); | ||
253 | + } | ||
254 | + | ||
255 | + | ||
172 | $scope.handleDragStart = function (e) { | 256 | $scope.handleDragStart = function (e) { |
173 | 257 | ||
174 | - this.style.opacity = '0.8'; | 258 | + this.style.opacity = '0.4'; |
175 | e.dataTransfer.setData('text/plain', this.innerHTML); | 259 | e.dataTransfer.setData('text/plain', this.innerHTML); |
176 | $scope.dragableId = $(this).attr("Id"); | 260 | $scope.dragableId = $(this).attr("Id"); |
177 | 261 | ||
262 | + //if user drag already selected answer from one blankbox to another than it gets id of blank box so need to get answer | ||
263 | + if ($scope.dragableId.indexOf('T') != -1) { | ||
264 | + var optionText = document.getElementById($scope.dragableId).innerHTML; | ||
265 | + var currentQuizData = new jinqJs() | ||
266 | + .from($scope.LabExData.LabExercise[0].Questions) | ||
267 | + .where('Number == ' + $scope.quiznumber) | ||
268 | + .select(); | ||
269 | + var optionData = new jinqJs() | ||
270 | + .from(currentQuizData[0].Options) | ||
271 | + .where('OptionTitle == ' + optionText) | ||
272 | + .select(); | ||
273 | + var option = optionData[0].OptionNumber; | ||
274 | + $scope.dragableId = optionText + '-' + option; | ||
275 | + } | ||
276 | + | ||
178 | }; | 277 | }; |
179 | 278 | ||
180 | $scope.handleDragEnd = function (e) { | 279 | $scope.handleDragEnd = function (e) { |
@@ -188,7 +287,10 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | @@ -188,7 +287,10 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | ||
188 | //alert(x.left + "," + $("#droppable").clientWidth + "," + x.top); | 287 | //alert(x.left + "," + $("#droppable").clientWidth + "," + x.top); |
189 | 288 | ||
190 | var id = $(this).attr("id"); | 289 | var id = $(this).attr("id"); |
290 | + | ||
191 | var keywords = $location.search(); | 291 | var keywords = $location.search(); |
292 | + $scope.labExercideIdentifier = (keywords.labexercise.replace('.json', '')).split('dat_')[1]; | ||
293 | + | ||
192 | var dataText = e.dataTransfer.getData('text/plain'); | 294 | var dataText = e.dataTransfer.getData('text/plain'); |
193 | if (id == "divoptions" || id == "divleft" || id == "divright") { | 295 | if (id == "divoptions" || id == "divleft" || id == "divright") { |
194 | var item = $('#' + $scope.dragableId).html(); | 296 | var item = $('#' + $scope.dragableId).html(); |
@@ -202,11 +304,15 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | @@ -202,11 +304,15 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | ||
202 | $.each(result.LabExercise[index].Questions, function (index1, value1) { | 304 | $.each(result.LabExercise[index].Questions, function (index1, value1) { |
203 | if (result.LabExercise[index].Questions[index1].Number == $scope.quiznumber) { | 305 | if (result.LabExercise[index].Questions[index1].Number == $scope.quiznumber) { |
204 | var Options = result.LabExercise[index].Questions[index1].Options; | 306 | var Options = result.LabExercise[index].Questions[index1].Options; |
307 | + | ||
308 | + | ||
205 | $.each(Options, function (inx, value2) { | 309 | $.each(Options, function (inx, value2) { |
206 | if (Options[inx].OptionTitle == item) { | 310 | if (Options[inx].OptionTitle == item) { |
207 | if ($scope.DraggedList != null) { | 311 | if ($scope.DraggedList != null) { |
208 | $.each($scope.DraggedList, function (inx1, value3) { | 312 | $.each($scope.DraggedList, function (inx1, value3) { |
209 | - | 313 | + $scope.UserAttempt.push({ "BlankBoxName": id.split('-')[1], "OptionName": $scope.dragableId.split('-')[1] }); |
314 | + //var balnkBox=id.split('-')[1]; | ||
315 | + //$scope.UserAttempt.push({balnkBox :+ $scope.dragableId.split('-')[1] }); | ||
210 | if ($scope.DraggedList[inx1].Value == item) { | 316 | if ($scope.DraggedList[inx1].Value == item) { |
211 | $scope.DraggedList.splice(inx1, 1); | 317 | $scope.DraggedList.splice(inx1, 1); |
212 | $('#block-' + Options[inx].OptionNumber).css("display", "block"); | 318 | $('#block-' + Options[inx].OptionNumber).css("display", "block"); |
@@ -248,7 +354,9 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | @@ -248,7 +354,9 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | ||
248 | } | 354 | } |
249 | }); | 355 | }); |
250 | } | 356 | } |
251 | - | 357 | + //var balnkBox = id.split('-')[1]; |
358 | + //$scope.UserAttempt.push({ balnkBox: +$scope.dragableId.split('-')[1] }); | ||
359 | + $scope.UserAttempt.push({ "BlankBoxName": id.split('-')[1], "OptionName": $scope.dragableId.split('-')[1] }); | ||
252 | $scope.DraggedList.push({ "id": id.split('-')[1], "optionName": id.split('-')[1], "Value": dataText, "topcoord": Options[inx].topcoord, "leftcoord": Options[inx].leftcoord }); | 360 | $scope.DraggedList.push({ "id": id.split('-')[1], "optionName": id.split('-')[1], "Value": dataText, "topcoord": Options[inx].topcoord, "leftcoord": Options[inx].leftcoord }); |
253 | //$('#' + $scope.dragableId).remove(); | 361 | //$('#' + $scope.dragableId).remove(); |
254 | $('#' + $scope.dragableId).css("display", "none"); | 362 | $('#' + $scope.dragableId).css("display", "none"); |
@@ -274,6 +382,7 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | @@ -274,6 +382,7 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | ||
274 | //{ | 382 | //{ |
275 | // $("#divoptions").html("<br><br><br><br>") | 383 | // $("#divoptions").html("<br><br><br><br>") |
276 | //} | 384 | //} |
385 | + //alert(JSON.stringify($scope.UserAttempt)); | ||
277 | }; | 386 | }; |
278 | 387 | ||
279 | $scope.handleDragOver = function (e) { | 388 | $scope.handleDragOver = function (e) { |
@@ -284,6 +393,7 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | @@ -284,6 +393,7 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | ||
284 | 393 | ||
285 | $scope.resetQuiz = function () { | 394 | $scope.resetQuiz = function () { |
286 | $scope.DraggedList = []; | 395 | $scope.DraggedList = []; |
396 | + $scope.UserAttempt = []; | ||
287 | $scope.GetQuizByTopic(); | 397 | $scope.GetQuizByTopic(); |
288 | }; | 398 | }; |
289 | 399 | ||
@@ -342,7 +452,211 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | @@ -342,7 +452,211 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | ||
342 | } | 452 | } |
343 | 453 | ||
344 | }; | 454 | }; |
345 | - | 455 | + |
456 | + $scope.SaveAnswer = function () { | ||
457 | + $scope.CreateLabExerciseDataToSave(); | ||
458 | + | ||
459 | + | ||
460 | + //LabExerciseService.saveLabExerciseAttempt("superadmin", $scope.LabExerciseAttemptedData) | ||
461 | + $scope.labExerciseAttempt = []; | ||
462 | + $scope.labExerciseAttempt.push({ 'LabExerciseUserData': $scope.LabExerciseUserData, 'userId': $scope.userId, 'labExerciseIdentifier': $scope.labExerciseIdentifier, 'LastQuestion': $scope.LastQuestion, 'TotalQuestions': $scope.TotalQuestions }); | ||
463 | + LabExerciseService.saveLabExerciseAttempt($scope.labExerciseAttempt) | ||
464 | + .then( | ||
465 | + function (result) { | ||
466 | + alert("Successfully updated"); | ||
467 | + }, | ||
468 | + function (error) { | ||
469 | + console.log(' Error in authentication = ' + error.statusText); | ||
470 | + alert("Error"); | ||
471 | + }); | ||
472 | + }; | ||
473 | + | ||
474 | + $scope.usersCorrectQuestData = []; | ||
475 | + $scope.CreateLabExerciseDataToSave = function () { | ||
476 | + | ||
477 | + $scope.LabExerciseAttemptedData = []; | ||
478 | + $scope.lb = []; | ||
479 | + //get user answers | ||
480 | + $scope.getUserAnswers(); | ||
481 | + | ||
482 | + | ||
483 | + //get correct response | ||
484 | + $scope.getCorrectResponse(); | ||
485 | + | ||
486 | + // $scope.correctResponseForSavingDatabaseArray = $scope.correctResponseForSavingDatabase.split(','); | ||
487 | + | ||
488 | + //get dragItems | ||
489 | + $scope.getDragItems(); | ||
490 | + | ||
491 | + //get score | ||
492 | + $scope.getScore(); | ||
493 | + | ||
494 | + $scope.userId = JSON.parse(localStorage.getItem('loggedInUserDetails')).Id; | ||
495 | + $scope.labExerciseIdentifier = $scope.labExercideIdentifier; | ||
496 | + $scope.LastQuestion = $scope.quiznumber; | ||
497 | + $scope.TotalQuestions = $scope.TotalNumberofQuiz; | ||
498 | + | ||
499 | + $scope.LabExerciseAttemptedData = { | ||
500 | + | ||
501 | + MaxScore: $scope.MaxScore, | ||
502 | + UserAnswer: $scope.commaSeperatedUserAnswers, | ||
503 | + QuestionNo: $scope.quiznumber, | ||
504 | + CorrectAnswer: JSON.stringify($scope.correctResponseForSavingDatabase), | ||
505 | + DragItems: $scope.DragItems, | ||
506 | + Score: $scope.Score, | ||
507 | + title: $scope.activityTitle, | ||
508 | + } | ||
509 | + | ||
510 | + | ||
511 | + if($scope.LabExerciseAttemptedData.MaxScore == $scope.LabExerciseAttemptedData.Score) | ||
512 | + { | ||
513 | + $scope.usersCorrectQuestData.push({ | ||
514 | + MaxScore: $scope.MaxScore, | ||
515 | + UserAnswer: $scope.commaSeperatedUserAnswers, | ||
516 | + QuestionNo: $scope.quiznumber, | ||
517 | + CorrectAnswer: JSON.stringify($scope.correctResponseForSavingDatabase), | ||
518 | + DragItems: $scope.DragItems, | ||
519 | + Score: $scope.Score, | ||
520 | + title: $scope.activityTitle, | ||
521 | + CorrectStatus : 'Correct' | ||
522 | + }); | ||
523 | + } | ||
524 | + else | ||
525 | + { | ||
526 | + $scope.usersCorrectQuestData.push({ | ||
527 | + MaxScore: $scope.MaxScore, | ||
528 | + UserAnswer: $scope.commaSeperatedUserAnswers, | ||
529 | + QuestionNo: $scope.quiznumber, | ||
530 | + CorrectAnswer: JSON.stringify($scope.correctResponseForSavingDatabase), | ||
531 | + DragItems: $scope.DragItems, | ||
532 | + Score: $scope.Score, | ||
533 | + title: $scope.activityTitle, | ||
534 | + CorrectStatus: 'Incorrect' | ||
535 | + }); | ||
536 | + } | ||
537 | + | ||
538 | + var thisQuestiondataInLabExerciseUserData = new jinqJs() | ||
539 | + .from($scope.LabExerciseUserData) | ||
540 | + .where('QuestionNo == ' + $scope.LabExerciseAttemptedData.QuestionNo) | ||
541 | + .select(); | ||
542 | + if (thisQuestiondataInLabExerciseUserData.length > 0) { | ||
543 | + | ||
544 | + angular.forEach($scope.LabExerciseUserData, function (value, key) { | ||
545 | + if (value.QuestionNo == $scope.LabExerciseAttemptedData.QuestionNo) { | ||
546 | + | ||
547 | + } | ||
548 | + else { | ||
549 | + $scope.lb.push(value); | ||
550 | + } | ||
551 | + }) | ||
552 | + $scope.LabExerciseUserData = []; | ||
553 | + | ||
554 | + $scope.lb.push($scope.LabExerciseAttemptedData); | ||
555 | + angular.forEach($scope.lb, function (value1, key1) { | ||
556 | + $scope.LabExerciseUserData.push(value1); | ||
557 | + }) | ||
558 | + } | ||
559 | + else | ||
560 | + $scope.LabExerciseUserData.push($scope.LabExerciseAttemptedData); | ||
561 | + } | ||
562 | + | ||
563 | + $scope.reviewAttemptAnswer = function () { | ||
564 | + $scope.isReviewBtnSelected = true; | ||
565 | + $("#reviewBtn").css("display", "none"); | ||
566 | + $("#resetBtn").css("display", "none"); | ||
567 | + $("#saveBtn").css("display", "none"); | ||
568 | + $("#submitResultHtml").css("display", "none"); | ||
569 | + $("#questionHtml").css("display", "block"); | ||
570 | + $("#reportBtn").css("display", "block"); | ||
571 | + $scope.quiznumber = 1; | ||
572 | + $scope.nextQuiz(); | ||
573 | + } | ||
574 | + | ||
575 | + | ||
576 | + | ||
577 | + $scope.getUserAnswers = function () { | ||
578 | + var userAnswers = []; | ||
579 | + var blockBoxes = $("div[id*='blockbox']"); | ||
580 | + var blockBoxesInTextBlock = $("#textblock").children(); | ||
581 | + | ||
582 | + var blockBoxLength = blockBoxes.length - blockBoxesInTextBlock.length; | ||
583 | + var blockAnswers = $("div[id*='blockans']"); | ||
584 | + for (var i = 0; i < blockAnswers.length; i++) { | ||
585 | + | ||
586 | + var id = (blockAnswers[i].id).split('-')[1]; | ||
587 | + userAnswers[id.replace('T', '')] = blockAnswers[i].innerHTML; | ||
588 | + } | ||
589 | + | ||
590 | + $scope.commaSeperatedUserAnswers = ''; | ||
591 | + for (var i = 1; i <= blockBoxLength; i++) { | ||
592 | + | ||
593 | + var userAns = userAnswers[i]; | ||
594 | + if (userAns != undefined) { | ||
595 | + $scope.commaSeperatedUserAnswers += userAns + ','; | ||
596 | + } | ||
597 | + else { | ||
598 | + $scope.commaSeperatedUserAnswers += '' + ','; | ||
599 | + } | ||
600 | + } | ||
601 | + //remove last comma | ||
602 | + $scope.commaSeperatedUserAnswers = $scope.commaSeperatedUserAnswers.replace(/,$/, ''); | ||
603 | + } | ||
604 | + | ||
605 | + $scope.getCorrectResponse = function () { | ||
606 | + $scope.correctResponse = ''; | ||
607 | + $scope.correctResponseForSavingDatabase = ''; | ||
608 | + var cr = new jinqJs() | ||
609 | + .from($scope.LabExData.LabExercise[0].Questions) | ||
610 | + .where('Number == ' + $scope.quiznumber) | ||
611 | + .select(); | ||
612 | + for (var i = 0; i < cr[0].correctResponse.length; i++) { | ||
613 | + var blankBox = cr[0].correctResponse[i].OptionBox; | ||
614 | + var option = cr[0].correctResponse[i].Answer; | ||
615 | + | ||
616 | + var options = new jinqJs() | ||
617 | + .from(cr[0].Options) | ||
618 | + .where('OptionNumber == ' + option) | ||
619 | + .select(); | ||
620 | + | ||
621 | + //var optionText = options[0].OptionTitle; | ||
622 | + // $scope.correctResponse += blankBox + ' ' + option + ','; | ||
623 | + // $scope.correctResponseForSavingDatabase += parseInt(blankBox.replace('T', '')) - 1 + ':' + optionText + ','; | ||
624 | + } | ||
625 | + | ||
626 | + $scope.correctResponse = $scope.correctResponse.replace(/,$/, ''); | ||
627 | + $scope.correctResonseKeyValue = $scope.correctResponse.split(','); | ||
628 | + | ||
629 | + $scope.correctResponseForSavingDatabase = $scope.correctResponseForSavingDatabase.replace(/,$/, ''); | ||
630 | + } | ||
631 | + | ||
632 | + | ||
633 | + $scope.getDragItems = function () { | ||
634 | + var OptionBoxes = $("div[id*='block-']"); | ||
635 | + $scope.DragItems = ''; | ||
636 | + for (var i = 0; i < OptionBoxes.length; i++) { | ||
637 | + $scope.DragItems += OptionBoxes[i].id.replace('block-', '') + ',' + OptionBoxes[i].innerHTML + ';'; | ||
638 | + } | ||
639 | + $scope.DragItems = $scope.DragItems.replace(/;$/, ''); | ||
640 | + | ||
641 | + } | ||
642 | + | ||
643 | + $scope.getScore = function () { | ||
644 | + | ||
645 | + var abc = $scope.UserAttempt; | ||
646 | + $scope.Score = 0; | ||
647 | + angular.forEach($scope.UserAttempt, function (value, key) { | ||
648 | + | ||
649 | + var userOptedAnswer = value.BlankBoxName + ' ' + value.OptionName; | ||
650 | + for (var i = 0; i < $scope.correctResonseKeyValue.length; i++) { | ||
651 | + if (userOptedAnswer == $scope.correctResonseKeyValue[i]) { | ||
652 | + $scope.Score += 1; | ||
653 | + } | ||
654 | + | ||
655 | + } | ||
656 | + | ||
657 | + | ||
658 | + }) | ||
659 | + } | ||
346 | }] | 660 | }] |
347 | 661 | ||
348 | ); | 662 | ); |
400-SOURCECODE/AIAHTML5.Web/app/views/LabExerc/lab-exercises-detail.html
@@ -17,11 +17,11 @@ | @@ -17,11 +17,11 @@ | ||
17 | 17 | ||
18 | <div class="container-fluid main-full"> | 18 | <div class="container-fluid main-full"> |
19 | <div class="row"> | 19 | <div class="row"> |
20 | - <div class="panel panel-default"> | 20 | + <div class="panel panel-default" id="questionHtml"> |
21 | <div class="panel-heading"> | 21 | <div class="panel-heading"> |
22 | {{activityTitle}}<p style="margin:-20px 474px -1px;" class="text-primary">{{Title}}</p> | 22 | {{activityTitle}}<p style="margin:-20px 474px -1px;" class="text-primary">{{Title}}</p> |
23 | <div class="pull-right" style="margin: -20px 20px;"> | 23 | <div class="pull-right" style="margin: -20px 20px;"> |
24 | - <p>Question <strong>{{quiznumber}}</strong> of {{TotalNumberofQuiz}}</p> | 24 | + <p>Question <strong id="quizNo">{{quiznumber}}</strong> of {{TotalNumberofQuiz}}</p> |
25 | </div> | 25 | </div> |
26 | </div> | 26 | </div> |
27 | <div class="panel-body" style="padding:2px;overflow:scroll"> | 27 | <div class="panel-body" style="padding:2px;overflow:scroll"> |
@@ -64,9 +64,11 @@ | @@ -64,9 +64,11 @@ | ||
64 | </div> | 64 | </div> |
65 | <div class="pull-right"> | 65 | <div class="pull-right"> |
66 | <div class="btn-group pull-left marginR5"> | 66 | <div class="btn-group pull-left marginR5"> |
67 | - <button class="btn btn-sm btn-primary">Save</button> | ||
68 | - <button class="btn btn-sm btn-primary" ng-click="ReviewAttempt()">Review Your Attempt</button> | ||
69 | - <button class="btn btn-sm btn-primary" ng-click="resetQuiz()">Reset</button> | 67 | + <button class="btn btn-sm btn-primary" style="display:none;" ng-click="SubmitAttempt()" id="quizSubmitBtn">Submit</button> |
68 | + <button class="btn btn-sm btn-primary" style="display:none;" id="reportBtn" ng-click="ReportGen()">Report</button> | ||
69 | + <button class="btn btn-sm btn-primary" id="saveBtn">Save</button> | ||
70 | + <button class="btn btn-sm btn-primary" id="reviewBtn" ng-click="ReviewAttempt()">Review Your Attempt</button> | ||
71 | + <button class="btn btn-sm btn-primary" id="resetBtn" ng-click="resetQuiz()">Reset</button> | ||
70 | </div> | 72 | </div> |
71 | <div class="btn-group"> | 73 | <div class="btn-group"> |
72 | <button class="btn btn-sm btn-black" ng-click="prevQuiz()"><i class="fa fa-arrow-left"></i></button> | 74 | <button class="btn btn-sm btn-black" ng-click="prevQuiz()"><i class="fa fa-arrow-left"></i></button> |
@@ -77,6 +79,65 @@ | @@ -77,6 +79,65 @@ | ||
77 | </div> | 79 | </div> |
78 | 80 | ||
79 | </div> | 81 | </div> |
82 | + | ||
83 | + | ||
84 | + <div class="panel panel-default" id="submitResultHtml" style="display:none;"> | ||
85 | + <div class="panel-heading"> | ||
86 | + <div class="row"> | ||
87 | + <div class="col-sm-4 text-left"><strong>Cardiovascula System</strong></div> | ||
88 | + <div class="col-sm-4 text-center">Performace Report</div> | ||
89 | + <div class="col-sm-4 text-right">Score: 0% </div> | ||
90 | + </div> | ||
91 | + </div> | ||
92 | + <div class="panel-body no-padding"> | ||
93 | + <div class="row"> | ||
94 | + <div class="col-sm-12 table-responsive "> | ||
95 | + <table class="table table-hover table-condensed bg-white"> | ||
96 | + <thead> | ||
97 | + <tr class="active"> | ||
98 | + <th class="text-center">Total Question</th> | ||
99 | + <th class="text-center">Correct Answers</th> | ||
100 | + <th class="text-center">Incorrect Answers</th> | ||
101 | + </tr> | ||
102 | + </thead> | ||
103 | + <tbody> | ||
104 | + <tr class="text-center"> | ||
105 | + <td>18</td> | ||
106 | + <td>0</td> | ||
107 | + <td>18</td> | ||
108 | + </tr> | ||
109 | + </tbody> | ||
110 | + </table> | ||
111 | + | ||
112 | + </div> | ||
113 | + <div class="col-sm-12 table-responsive"> | ||
114 | + <table class="table table-hover table-condensed bg-white"> | ||
115 | + <thead> | ||
116 | + <tr class="active"> | ||
117 | + <th>Question</th> | ||
118 | + <th>Activity Title</th> | ||
119 | + <th>Status</th> | ||
120 | + <th>Action</th> | ||
121 | + </tr> | ||
122 | + </thead> | ||
123 | + <tbody id="resultLabData"></tbody> | ||
124 | + </table> | ||
125 | + </div> | ||
126 | + </div> | ||
127 | + </div> | ||
128 | + <div class="panel-footer"> | ||
129 | + <div class="text-center"> | ||
130 | + <button class="btn btn-sm btn-primary"> | ||
131 | |||
132 | + </button> | ||
133 | + | ||
134 | + </div> | ||
135 | + <div class="clearfix"></div> | ||
136 | + </div> | ||
137 | + | ||
138 | + </div> | ||
139 | + | ||
140 | + | ||
80 | </div> | 141 | </div> |
81 | </div> | 142 | </div> |
82 | </div> | 143 | </div> |
400-SOURCECODE/AIAHTML5.Web/index.html
@@ -1447,7 +1447,7 @@ | @@ -1447,7 +1447,7 @@ | ||
1447 | <!--<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.js"></script>--> | 1447 | <!--<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.js"></script>--> |
1448 | <script src="libs/html2canvas.js"></script> | 1448 | <script src="libs/html2canvas.js"></script> |
1449 | <script src="libs/FileSaver.js"></script> | 1449 | <script src="libs/FileSaver.js"></script> |
1450 | - | 1450 | + <script src="app/services/LabExerciseService.js"></script> |
1451 | <!--<script type="text/javascript"> | 1451 | <!--<script type="text/javascript"> |
1452 | $(function () { | 1452 | $(function () { |
1453 | $('#canvas').sketch(); | 1453 | $('#canvas').sketch(); |