Commit 4147a3d3da645928b54e77b6b60f93b3653702c0

Authored by unknown
1 parent 335f4bd9

Commit Changes

400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js
... ... @@ -154,7 +154,9 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location
154 154 }
155 155 )
156 156 }
  157 +
157 158 $scope.isReviewBtnSelected = false;
  159 + $rootScope.selectedDivArray = [];
158 160 $scope.nextQuiz = function () {
159 161  
160 162 //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
171 173 $scope.CreateLabExerciseDataToSave();
172 174 }
173 175  
174   - //{
175   - // $scope.selectedQuestionNo = $scope.quiznumber + 1;
176   - // $scope.CreateLabExerciseDataToSave();
177   - //}
178   -
179   -
  176 + console.log($rootScope.selectedDivArray);
180 177 $scope.dragableId = "";
181 178 if ($scope.quiznumber == $scope.TotalNumberofQuiz)
182 179 return;
... ... @@ -200,11 +197,22 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location
200 197  
201 198 $scope.resetQuiz();
202 199 $scope.ShowHideDiv();
  200 +
203 201  
204 202  
205 203 }
206 204  
  205 +
  206 +
  207 +
  208 +
  209 +
  210 +
  211 +
  212 +
  213 +
207 214 $scope.prevQuiz = function () {
  215 + debugger;
208 216 if ($scope.quiznumber != 1) {
209 217 // $scope.quizQuesNo = $scope.quizQuesNo - 1;
210 218 // $scope.selectedQuestionNo = $scope.quizQuesNo;
... ... @@ -230,10 +238,21 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location
230 238 }
231 239 $scope.resetQuiz();
232 240 $scope.ShowHideDiv();
  241 +
  242 + for (var i = 0; i <= $rootScope.selectedDivArray.length - 1; i++) {
  243 + if ($scope.quiznumber == $rootScope.selectedDivArray[i].questionNo) {
  244 + document.getElementById($rootScope.selectedDivArray[i].droppedID).innerHTML = $rootScope.selectedDivArray[i].draggedText;
  245 + // $('#'+$rootScope.selectedDivArray[i].droppedID).html($rootScope.selectedDivArray[i].draggedText);
  246 + document.getElementById($rootScope.selectedDivArray[i].droppedID).style.display = "none";
  247 + // $('#'+$rootScope.selectedDivArray[i].draggedID).css("display","none!important");
  248 + }
  249 +
  250 + }
233 251 }
234 252  
235 253  
236 254 $scope.SubmitAttempt = function () {
  255 + debugger;
237 256 $scope.CreateLabExerciseDataToSave();
238 257  
239 258 $("#submitResultHtml").css("display", "block");
... ... @@ -241,7 +260,7 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location
241 260 console.log($scope.usersCorrectQuestData);
242 261 $("#resultLabData").empty();
243 262 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>");
  263 + 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($event);' id=" + $scope.usersCorrectQuestData[i].QuestionNo + " class='btn btn-danger btn-sm'><i class='fa fa-times'></i> Review</button></td></tr>");
245 264 $compile(labExerciseHtml)($scope);
246 265 }
247 266 }
... ... @@ -258,6 +277,9 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location
258 277 this.style.opacity = '0.4';
259 278 e.dataTransfer.setData('text/plain', this.innerHTML);
260 279 $scope.dragableId = $(this).attr("Id");
  280 + // alert($scope.dragableId);
  281 + $scope.dragableText = $("#" + $scope.dragableId).text();
  282 + // alert($("#" + $scope.dragableId).text());
261 283  
262 284 //if user drag already selected answer from one blankbox to another than it gets id of blank box so need to get answer
263 285 if ($scope.dragableId.indexOf('T') != -1) {
... ... @@ -287,6 +309,18 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location
287 309 //alert(x.left + "," + $("#droppable").clientWidth + "," + x.top);
288 310  
289 311 var id = $(this).attr("id");
  312 + // alert($scope.dragableId);
  313 + // $scope.dragableText = $("#" + $scope.dragableId).text();
  314 +
  315 + $rootScope.selectedDivArray.push({
  316 + "questionNo": $scope.quiznumber,
  317 + "draggedID": $scope.dragableId,
  318 + "draggedText": $scope.dragableText,
  319 + "droppedID": id
  320 + });
  321 +
  322 +
  323 + console.log($rootScope.selectedDivArray);
290 324  
291 325 var keywords = $location.search();
292 326 $scope.labExercideIdentifier = (keywords.labexercise.replace('.json', '')).split('dat_')[1];
... ... @@ -383,6 +417,8 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location
383 417 // $("#divoptions").html("<br><br><br><br>")
384 418 //}
385 419 //alert(JSON.stringify($scope.UserAttempt));
  420 +
  421 +
386 422 };
387 423  
388 424 $scope.handleDragOver = function (e) {
... ... @@ -473,7 +509,7 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location
473 509  
474 510 $scope.usersCorrectQuestData = [];
475 511 $scope.CreateLabExerciseDataToSave = function () {
476   -
  512 + debugger;
477 513 $scope.LabExerciseAttemptedData = [];
478 514 $scope.lb = [];
479 515 //get user answers
... ... @@ -507,8 +543,8 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location
507 543 title: $scope.activityTitle,
508 544 }
509 545  
510   -
511   - if($scope.LabExerciseAttemptedData.MaxScore == $scope.LabExerciseAttemptedData.Score)
  546 + alert($scope.LabExerciseAttemptedData.MaxScore + " " + $scope.LabExerciseAttemptedData.Score);
  547 + if ($scope.MaxScore == $scope.Score)
512 548 {
513 549 $scope.usersCorrectQuestData.push({
514 550 MaxScore: $scope.MaxScore,
... ... @@ -560,7 +596,7 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location
560 596 $scope.LabExerciseUserData.push($scope.LabExerciseAttemptedData);
561 597 }
562 598  
563   - $scope.reviewAttemptAnswer = function () {
  599 + $scope.reviewAttemptAnswer = function (evt) {
564 600 $scope.isReviewBtnSelected = true;
565 601 $("#reviewBtn").css("display", "none");
566 602 $("#resetBtn").css("display", "none");
... ... @@ -568,8 +604,12 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location
568 604 $("#submitResultHtml").css("display", "none");
569 605 $("#questionHtml").css("display", "block");
570 606 $("#reportBtn").css("display", "block");
571   - $scope.quiznumber = 1;
572   - $scope.nextQuiz();
  607 + $("#quizSubmitBtn").css("display", "none");
  608 + $scope.quiznumber = evt.target.id;
  609 + $scope.CreateLabExerciseDataToSave();
  610 + $scope.dragableId = "";
  611 + $scope.resetQuiz();
  612 + $scope.ShowHideDiv();
573 613 }
574 614  
575 615  
... ...
400-SOURCECODE/AIAHTML5.Web/app/services/LabExerciseService.js 0 → 100644
  1 +AIA.factory('LabExerciseService', function ($http, $q, $rootScope) {
  2 + return {
  3 + saveLabExerciseAttempt: function (labExercieObj) {
  4 + var deferred = $q.defer();
  5 + $http.post('/API/api/LabExercise', JSON.stringify(labExercieObj), {
  6 + headers: {
  7 + 'Content-Type': 'application/json'
  8 + }
  9 + })
  10 + //$http.post('/API/api/LabExercise', JSON.stringify(labExercieObj, userId, labExerciseIdentifier, LastQuestion, TotalQuestions), {
  11 + // headers: {
  12 + // 'Content-Type': 'application/json'
  13 + // }
  14 + //})
  15 + .success(function (data, status, headers, config) {
  16 + console.log('success')
  17 + deferred.resolve(data);
  18 + }).error(function (data, status, headers, config) {
  19 + console.log('error')
  20 + deferred.reject(data);
  21 + $rootScope.isVisibleLogin = true;
  22 + $rootScope.errorMessage = data;
  23 + $("#messageModal").modal('show');
  24 +
  25 + });
  26 + return deferred.promise;
  27 + },
  28 + }
  29 +})
0 30 \ No newline at end of file
... ...