Commit 207f03317e73951a23e5b79fff212078ed8fdb0b
1 parent
0663ce5c
Submit Functionality
Showing
1 changed file
with
79 additions
and
31 deletions
400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js
@@ -109,6 +109,7 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, | @@ -109,6 +109,7 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, | ||
109 | if (labResult != undefined && labResult.lastQuestion>0 && labResult != AIAConstants.SAVED_LAB_EXERCISE_NOT_FOUND) { | 109 | if (labResult != undefined && labResult.lastQuestion>0 && labResult != AIAConstants.SAVED_LAB_EXERCISE_NOT_FOUND) { |
110 | $scope.SavedLabExercise = labResult; | 110 | $scope.SavedLabExercise = labResult; |
111 | $scope.quiznumber = $scope.SavedLabExercise.lastQuestion; | 111 | $scope.quiznumber = $scope.SavedLabExercise.lastQuestion; |
112 | + $scope.initialQuestioNo = $scope.SavedLabExercise.lastQuestion; | ||
112 | $scope.GetQuizByTopic(); | 113 | $scope.GetQuizByTopic(); |
113 | } | 114 | } |
114 | else { | 115 | else { |
@@ -310,7 +311,7 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, | @@ -310,7 +311,7 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, | ||
310 | 311 | ||
311 | 312 | ||
312 | $scope.SubmitAttempt = function () { | 313 | $scope.SubmitAttempt = function () { |
313 | - | 314 | + |
314 | $scope.CreateLabExerciseDataToSave(); | 315 | $scope.CreateLabExerciseDataToSave(); |
315 | 316 | ||
316 | $("#submitResultHtml").css("display", "block"); | 317 | $("#submitResultHtml").css("display", "block"); |
@@ -321,6 +322,14 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, | @@ -321,6 +322,14 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, | ||
321 | 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>"); | 322 | 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>"); |
322 | $compile(labExerciseHtml)($scope); | 323 | $compile(labExerciseHtml)($scope); |
323 | } | 324 | } |
325 | + if ($scope.initialQuestioNo > 0) { | ||
326 | + for (var i = $scope.initialQuestioNo - 1; i > 0; i--) { | ||
327 | + var labExerciseHtml_1 = $("#resultLabData").prepend("<tr><td>" + i + "</td><td> </td><td>Incorrect</td><td><button ng-click='reviewAttemptAnswer($event);' id=" + i + " class='btn btn-danger btn-sm'><i class='fa fa-times'></i> Review</button></td></tr>"); | ||
328 | + $compile(labExerciseHtml_1)($scope); | ||
329 | + } | ||
330 | + } | ||
331 | + | ||
332 | + | ||
324 | } | 333 | } |
325 | 334 | ||
326 | 335 | ||
@@ -575,6 +584,7 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, | @@ -575,6 +584,7 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, | ||
575 | //LabExerciseService.saveLabExerciseAttempt("superadmin", $scope.LabExerciseAttemptedData) | 584 | //LabExerciseService.saveLabExerciseAttempt("superadmin", $scope.LabExerciseAttemptedData) |
576 | $scope.labExerciseAttempt = []; | 585 | $scope.labExerciseAttempt = []; |
577 | $scope.labExerciseAttempt.push({ 'LabExerciseUserData': $scope.LabExerciseUserData, 'userId': $scope.userId, 'labExerciseIdentifier': $scope.labExerciseIdentifier, 'LastQuestion': $scope.LastQuestion, 'TotalQuestions': $scope.TotalQuestions }); | 586 | $scope.labExerciseAttempt.push({ 'LabExerciseUserData': $scope.LabExerciseUserData, 'userId': $scope.userId, 'labExerciseIdentifier': $scope.labExerciseIdentifier, 'LastQuestion': $scope.LastQuestion, 'TotalQuestions': $scope.TotalQuestions }); |
587 | + $scope.initialQuestioNo = $scope.LastQuestion; | ||
578 | LabExerciseService.saveLabExerciseAttempt($scope.labExerciseAttempt) | 588 | LabExerciseService.saveLabExerciseAttempt($scope.labExerciseAttempt) |
579 | .then( | 589 | .then( |
580 | function (result) { | 590 | function (result) { |
@@ -635,33 +645,8 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, | @@ -635,33 +645,8 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, | ||
635 | title: $scope.activityTitle | 645 | title: $scope.activityTitle |
636 | 646 | ||
637 | } | 647 | } |
638 | - alert("$scope.MaxScore=" + $scope.MaxScore + ", " + "$scope.Score=" + $scope.Score); | ||
639 | - if ($scope.MaxScore == $scope.Score) | ||
640 | - { | ||
641 | - $scope.usersCorrectQuestData.push({ | ||
642 | - MaxScore: $scope.MaxScore, | ||
643 | - UserAnswer: $scope.commaSeperatedUserAnswers, | ||
644 | - QuestionNo: $scope.quiznumber, | ||
645 | - CorrectAnswer: JSON.stringify($scope.correctResponseForSavingDatabase), | ||
646 | - DragItems: $scope.DragItems, | ||
647 | - Score: $scope.Score, | ||
648 | - title: $scope.activityTitle, | ||
649 | - CorrectStatus : 'Correct' | ||
650 | - }); | ||
651 | - } | ||
652 | - else | ||
653 | - { | ||
654 | - $scope.usersCorrectQuestData.push({ | ||
655 | - MaxScore: $scope.MaxScore, | ||
656 | - UserAnswer: $scope.commaSeperatedUserAnswers, | ||
657 | - QuestionNo: $scope.quiznumber, | ||
658 | - CorrectAnswer: JSON.stringify($scope.correctResponseForSavingDatabase), | ||
659 | - DragItems: $scope.DragItems, | ||
660 | - Score: $scope.Score, | ||
661 | - title: $scope.activityTitle, | ||
662 | - CorrectStatus: 'Incorrect' | ||
663 | - }); | ||
664 | - } | 648 | + |
649 | + | ||
665 | 650 | ||
666 | var thisQuestiondataInLabExerciseUserData = new jinqJs() | 651 | var thisQuestiondataInLabExerciseUserData = new jinqJs() |
667 | .from($scope.LabExerciseUserData) | 652 | .from($scope.LabExerciseUserData) |
@@ -685,7 +670,70 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, | @@ -685,7 +670,70 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, | ||
685 | }) | 670 | }) |
686 | } | 671 | } |
687 | else | 672 | else |
688 | - $scope.LabExerciseUserData.push($scope.LabExerciseAttemptedData); | 673 | + $scope.LabExerciseUserData.push($scope.LabExerciseAttemptedData); |
674 | + | ||
675 | + $scope.usersCorrectQuestData = []; | ||
676 | + if ($scope.LabExerciseUserData.length > 0) { | ||
677 | + | ||
678 | + for(var i=0;i<=$scope.LabExerciseUserData.length-1;i++) | ||
679 | + { | ||
680 | + | ||
681 | + if ($scope.LabExerciseUserData[i].MaxScore == $scope.LabExerciseUserData[i].Score) { | ||
682 | + $scope.usersCorrectQuestData.push({ | ||
683 | + MaxScore: $scope.LabExerciseUserData[i].MaxScore, | ||
684 | + UserAnswer: $scope.LabExerciseUserData[i].UserAnswer, | ||
685 | + QuestionNo: $scope.LabExerciseUserData[i].QuestionNo, | ||
686 | + CorrectAnswer: JSON.stringify($scope.LabExerciseUserData[i].CorrectAnswer), | ||
687 | + DragItems: $scope.LabExerciseUserData[i].DragItems, | ||
688 | + Score: $scope.LabExerciseUserData[i].Score, | ||
689 | + title: $scope.LabExerciseUserData[i].title, | ||
690 | + CorrectStatus: 'Correct' | ||
691 | + }); | ||
692 | + } | ||
693 | + else { | ||
694 | + $scope.usersCorrectQuestData.push({ | ||
695 | + MaxScore: $scope.LabExerciseUserData[i].MaxScore, | ||
696 | + UserAnswer: $scope.LabExerciseUserData[i].UserAnswer, | ||
697 | + QuestionNo: $scope.LabExerciseUserData[i].QuestionNo, | ||
698 | + CorrectAnswer: JSON.stringify($scope.LabExerciseUserData[i].CorrectAnswer), | ||
699 | + DragItems: $scope.LabExerciseUserData[i].DragItems, | ||
700 | + Score: $scope.LabExerciseUserData[i].Score, | ||
701 | + title: $scope.LabExerciseUserData[i].title, | ||
702 | + CorrectStatus: 'Incorrect' | ||
703 | + }); | ||
704 | + } | ||
705 | + } | ||
706 | + | ||
707 | + } | ||
708 | + else { | ||
709 | + if ($scope.MaxScore == $scope.Score) { | ||
710 | + $scope.usersCorrectQuestData.push({ | ||
711 | + MaxScore: $scope.MaxScore, | ||
712 | + UserAnswer: $scope.commaSeperatedUserAnswers, | ||
713 | + QuestionNo: $scope.quiznumber, | ||
714 | + CorrectAnswer: JSON.stringify($scope.correctResponseForSavingDatabase), | ||
715 | + DragItems: $scope.DragItems, | ||
716 | + Score: $scope.Score, | ||
717 | + title: $scope.activityTitle, | ||
718 | + CorrectStatus: 'Correct' | ||
719 | + }); | ||
720 | + } | ||
721 | + else { | ||
722 | + $scope.usersCorrectQuestData.push({ | ||
723 | + MaxScore: $scope.MaxScore, | ||
724 | + UserAnswer: $scope.commaSeperatedUserAnswers, | ||
725 | + QuestionNo: $scope.quiznumber, | ||
726 | + CorrectAnswer: JSON.stringify($scope.correctResponseForSavingDatabase), | ||
727 | + DragItems: $scope.DragItems, | ||
728 | + Score: $scope.Score, | ||
729 | + title: $scope.activityTitle, | ||
730 | + CorrectStatus: 'Incorrect' | ||
731 | + }); | ||
732 | + } | ||
733 | + } | ||
734 | + | ||
735 | + // console.log($scope.usersCorrectQuestData); | ||
736 | + // console.log($scope.LabExerciseUserData); | ||
689 | } | 737 | } |
690 | $scope.reviewAttemptAnswer = function (evt) { | 738 | $scope.reviewAttemptAnswer = function (evt) { |
691 | $scope.isReviewBtnSelected = true; | 739 | $scope.isReviewBtnSelected = true; |
@@ -867,12 +915,12 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, | @@ -867,12 +915,12 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, | ||
867 | } | 915 | } |
868 | } | 916 | } |
869 | 917 | ||
870 | - | 918 | + |
871 | var labQuestionData = new jinqJs() | 919 | var labQuestionData = new jinqJs() |
872 | .from($scope.LabExData.LabExercise[0].Questions) | 920 | .from($scope.LabExData.LabExercise[0].Questions) |
873 | .where('Number == ' + lastQuestion) | 921 | .where('Number == ' + lastQuestion) |
874 | .select(); | 922 | .select(); |
875 | - | 923 | + |
876 | angular.forEach($scope.QustionAnsKeyValue, function (value, key) { | 924 | angular.forEach($scope.QustionAnsKeyValue, function (value, key) { |
877 | var questionOptionBox = new jinqJs() | 925 | var questionOptionBox = new jinqJs() |
878 | .from(labQuestionData[0].OptionBox) | 926 | .from(labQuestionData[0].OptionBox) |