diff --git a/400-SOURCECODE/AIAHTML5.API/Web.config b/400-SOURCECODE/AIAHTML5.API/Web.config index b173e51..490d784 100644 --- a/400-SOURCECODE/AIAHTML5.API/Web.config +++ b/400-SOURCECODE/AIAHTML5.API/Web.config @@ -69,15 +69,15 @@ - + - + - + diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js index 305437b..b1bdeeb 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js @@ -109,6 +109,7 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, if (labResult != undefined && labResult.lastQuestion>0 && labResult != AIAConstants.SAVED_LAB_EXERCISE_NOT_FOUND) { $scope.SavedLabExercise = labResult; $scope.quiznumber = $scope.SavedLabExercise.lastQuestion; + $scope.initialQuestioNo = $scope.SavedLabExercise.lastQuestion; $scope.GetQuizByTopic(); } else { @@ -312,25 +313,55 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, $scope.SubmitAttempt = function () { - + $scope.CreateLabExerciseDataToSave(); $("#submitResultHtml").css("display", "block"); $("#questionHtml").css("display", "none"); console.log($scope.usersCorrectQuestData); $("#resultLabData").empty(); - for (var i = 0; i <= $scope.usersCorrectQuestData.length - 1; i++) { - if ($scope.usersCorrectQuestData[i].CorrectStatus == "Correct") { - var labExerciseHtml = $("#resultLabData").append("" + $scope.usersCorrectQuestData[i].QuestionNo + "" + $scope.usersCorrectQuestData[i].title + "" + $scope.usersCorrectQuestData[i].CorrectStatus + ""); - $compile(labExerciseHtml)($scope); + + $scope.usersCorrectQuestData.sort(function (obj1, obj2) { + // Ascending: first age less than the previous + return obj1.QuestionNo - obj2.QuestionNo; + }); + + + for (var j = $scope.TotalNumberofQuiz; j >= 1; j--) { + for (var i = 0; i <= $scope.usersCorrectQuestData.length - 1; i++) { + if (j == $scope.usersCorrectQuestData[i].QuestionNo) + { + if ($scope.usersCorrectQuestData[i].CorrectStatus == "Correct") { + var labExerciseHtml = $("#resultLabData").append("" + $scope.usersCorrectQuestData[i].QuestionNo + "" + $scope.usersCorrectQuestData[i].title + "" + $scope.usersCorrectQuestData[i].CorrectStatus + ""); + $compile(labExerciseHtml)($scope); + } + else { + var labExerciseHtml = $("#resultLabData").append("" + $scope.usersCorrectQuestData[i].QuestionNo + "" + $scope.usersCorrectQuestData[i].title + "" + $scope.usersCorrectQuestData[i].CorrectStatus + ""); + $compile(labExerciseHtml)($scope); + } + break; + } + else + { + var labExerciseHtml_1 = $("#resultLabData").prepend("" + j + " Incorrect"); + $compile(labExerciseHtml_1)($scope); + break; + } + } + } + + + $scope.inCorrectAnswer = 0; + $scope.CorrectAnswer = 0; + $("#resultLabData tr td:nth-child(3)").each(function () { + if ($(this).text() == "Incorrect") { + $scope.inCorrectAnswer = $scope.inCorrectAnswer + 1; } else { - var labExerciseHtml = $("#resultLabData").append("" + $scope.usersCorrectQuestData[i].QuestionNo + "" + $scope.usersCorrectQuestData[i].title + "" + $scope.usersCorrectQuestData[i].CorrectStatus + ""); - $compile(labExerciseHtml)($scope); + $scope.CorrectAnswer = $scope.CorrectAnswer + 1; } - - } + }); } @@ -585,6 +616,7 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, //LabExerciseService.saveLabExerciseAttempt("superadmin", $scope.LabExerciseAttemptedData) $scope.labExerciseAttempt = []; $scope.labExerciseAttempt.push({ 'LabExerciseUserData': $scope.LabExerciseUserData, 'userId': $scope.userId, 'labExerciseIdentifier': $scope.labExerciseIdentifier, 'LastQuestion': $scope.LastQuestion, 'TotalQuestions': $scope.TotalQuestions }); + $scope.initialQuestioNo = $scope.LastQuestion; LabExerciseService.saveLabExerciseAttempt($scope.labExerciseAttempt) .then( function (result) { @@ -611,7 +643,7 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, $scope.usersCorrectQuestData = []; $scope.CreateLabExerciseDataToSave = function () { - + $scope.LabExerciseAttemptedData = []; $scope.lb = []; //get user answers @@ -645,36 +677,8 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, title: $scope.activityTitle } - console.log($scope.LabExerciseAttemptedData); - if ($scope.MaxScore == $scope.Score) - { - $scope.usersCorrectQuestData.push({ - MaxScore: $scope.MaxScore, - UserAnswer: $scope.commaSeperatedUserAnswers, - QuestionNo: $scope.quiznumber, - CorrectAnswer: JSON.stringify($scope.correctResponseForSavingDatabase), - DragItems: $scope.DragItems, - Score: $scope.Score, - title: $scope.activityTitle, - CorrectStatus: 'Correct' - - }); - } - else - { - $scope.usersCorrectQuestData.push({ - MaxScore: $scope.MaxScore, - UserAnswer: $scope.commaSeperatedUserAnswers, - QuestionNo: $scope.quiznumber, - CorrectAnswer: JSON.stringify($scope.correctResponseForSavingDatabase), - DragItems: $scope.DragItems, - Score: $scope.Score, - title: $scope.activityTitle, - CorrectStatus: 'Incorrect' - - }); - } + var thisQuestiondataInLabExerciseUserData = new jinqJs() .from($scope.LabExerciseUserData) @@ -698,7 +702,71 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, }) } else - $scope.LabExerciseUserData.push($scope.LabExerciseAttemptedData); + $scope.LabExerciseUserData.push($scope.LabExerciseAttemptedData); + + $scope.usersCorrectQuestData = []; + //alert($scope.LabExerciseUserData); + if ($scope.LabExerciseUserData.length > 0) { + + for(var i=0;i<=$scope.LabExerciseUserData.length-1;i++) + { + + if ($scope.LabExerciseUserData[i].MaxScore == $scope.LabExerciseUserData[i].Score) { + $scope.usersCorrectQuestData.push({ + MaxScore: $scope.LabExerciseUserData[i].MaxScore, + UserAnswer: $scope.LabExerciseUserData[i].UserAnswer, + QuestionNo: $scope.LabExerciseUserData[i].QuestionNo, + CorrectAnswer: JSON.stringify($scope.LabExerciseUserData[i].CorrectAnswer), + DragItems: $scope.LabExerciseUserData[i].DragItems, + Score: $scope.LabExerciseUserData[i].Score, + title: $scope.LabExerciseUserData[i].title, + CorrectStatus: 'Correct' + }); + } + else { + $scope.usersCorrectQuestData.push({ + MaxScore: $scope.LabExerciseUserData[i].MaxScore, + UserAnswer: $scope.LabExerciseUserData[i].UserAnswer, + QuestionNo: $scope.LabExerciseUserData[i].QuestionNo, + CorrectAnswer: JSON.stringify($scope.LabExerciseUserData[i].CorrectAnswer), + DragItems: $scope.LabExerciseUserData[i].DragItems, + Score: $scope.LabExerciseUserData[i].Score, + title: $scope.LabExerciseUserData[i].title, + CorrectStatus: 'Incorrect' + }); + } + } + + } + else { + if ($scope.MaxScore == $scope.Score) { + $scope.usersCorrectQuestData.push({ + MaxScore: $scope.MaxScore, + UserAnswer: $scope.commaSeperatedUserAnswers, + QuestionNo: $scope.quiznumber, + CorrectAnswer: JSON.stringify($scope.correctResponseForSavingDatabase), + DragItems: $scope.DragItems, + Score: $scope.Score, + title: $scope.activityTitle, + CorrectStatus: 'Correct' + }); + } + else { + $scope.usersCorrectQuestData.push({ + MaxScore: $scope.MaxScore, + UserAnswer: $scope.commaSeperatedUserAnswers, + QuestionNo: $scope.quiznumber, + CorrectAnswer: JSON.stringify($scope.correctResponseForSavingDatabase), + DragItems: $scope.DragItems, + Score: $scope.Score, + title: $scope.activityTitle, + CorrectStatus: 'Incorrect' + }); + } + } + + // console.log($scope.usersCorrectQuestData); + // console.log($scope.LabExerciseUserData); } $scope.reviewAttemptAnswer = function (evt) { $scope.isReviewBtnSelected = true; @@ -710,10 +778,10 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, $("#reportBtn").css("display", "block"); $("#quizSubmitBtn").css("display", "none"); $scope.quiznumber = evt.target.id; - $scope.CreateLabExerciseDataToSave(); + // $scope.CreateLabExerciseDataToSave(); $scope.dragableId = ""; - // $scope.resetQuiz(); - $scope.GetQuizByTopic(); + $scope.resetQuiz(); + // $scope.GetQuizByTopic(); //$scope.ShowHideDiv(); } @@ -836,7 +904,6 @@ function ($scope, $rootScope, pages, log, $http,$timeout, DataService, $filter, $scope.ShowSavedLabExercise = function () { //from database - var lastQuestion = $scope.quiznumber; var lastQuestionDetails; var lastQuestionAnswers; diff --git a/400-SOURCECODE/AIAHTML5.Web/app/views/LabExerc/lab-exercises-detail.html b/400-SOURCECODE/AIAHTML5.Web/app/views/LabExerc/lab-exercises-detail.html index eafa835..a90adbd 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/views/LabExerc/lab-exercises-detail.html +++ b/400-SOURCECODE/AIAHTML5.Web/app/views/LabExerc/lab-exercises-detail.html @@ -102,9 +102,9 @@ - 18 - 0 - 18 + {{TotalNumberofQuiz}} + {{CorrectAnswer}} + {{inCorrectAnswer}}